From patchwork Thu Oct 31 16:17:47 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 3121161 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id AA105BEEB2 for ; Thu, 31 Oct 2013 16:18:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 666932045B for ; Thu, 31 Oct 2013 16:18:10 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 810A42047C for ; Thu, 31 Oct 2013 16:18:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 430D4EFE13; Thu, 31 Oct 2013 09:18:07 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-ea0-f171.google.com (mail-ea0-f171.google.com [209.85.215.171]) by gabe.freedesktop.org (Postfix) with ESMTP id 60D6AEE887 for ; Thu, 31 Oct 2013 09:17:59 -0700 (PDT) Received: by mail-ea0-f171.google.com with SMTP id h10so1520415eak.30 for ; Thu, 31 Oct 2013 09:17:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=G41rR8ZZe4ldDcFU9pb9WyMn38evgpQYztFyBT0AOXE=; b=kDzsj57nRcxfcn/uvxeLUBdNDWGslHBagGX3ydtYV1J4DdMotnG4TNKuC0Eq5ISoPV 9kOVuGJT6n9zIASsfZcTCwpx1bUMeFSXz8gU4kir6K0odi1eNcYGpq/4BXZ5amh//Fen vHecfwrHYUPBiRuTBjVsdGKJNm/849Ua6Vl88= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=G41rR8ZZe4ldDcFU9pb9WyMn38evgpQYztFyBT0AOXE=; b=kM/FB7jyY33v5X6qedR2ZRwICGV2w02PuNrHAQtMo9wDN3zRBFcbE6Y6cPilEvyB1T X7kB6/viXKO44mHLaiGNbm1h9oriR4J9IEbNnn0SLHcDVj3VVBxjejerrUlrtLwswPhL IFCmY76tCZQ922g54e0UViHXt1PS922cIOQT/S21etCB3ls7UVPAP8QuKqB088DOyfrp qsuoxMlgGv3IYQg8wu9XJbo5HgTnZBMRADwcBS9iiJFLRzMgCUXHLTgP8+sQ4uWjz9mF WyNagIi6iAOW5vrEukGtvLQiUK/SwFqAep6hWOcVxUYP98GrwayrLlY8IatNBCrMO4gO /mWA== X-Gm-Message-State: ALoCoQmMoLAXXSLqt59fr5EKqwtowWv6ILbQX4eKvYiwlz/nzBj0VPdf0R1sQn+XuIv13qXC81uM X-Received: by 10.14.6.134 with SMTP id 6mr4096428een.66.1383236278306; Thu, 31 Oct 2013 09:17:58 -0700 (PDT) Received: from gina.ffwll.local (178-83-130-250.dynamic.hispeed.ch. [178.83.130.250]) by mx.google.com with ESMTPSA id m54sm10364945eex.2.2013.10.31.09.17.56 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 Oct 2013 09:17:57 -0700 (PDT) From: Daniel Vetter To: Intel Graphics Development Date: Thu, 31 Oct 2013 17:17:47 +0100 Message-Id: <1383236268-21925-2-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 1.8.4.rc3 In-Reply-To: <1383236268-21925-1-git-send-email-daniel.vetter@ffwll.ch> References: <1383231150-13133-1-git-send-email-daniel.vetter@ffwll.ch> <1383236268-21925-1-git-send-email-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Cc: Daniel Vetter Subject: [Intel-gfx] [PATCH 2/3] tests: Add a test template X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Requested by Paulo. Signed-off-by: Daniel Vetter --- tests/.gitignore | 1 + tests/Makefile.am | 1 + tests/template.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+) create mode 100644 tests/template.c diff --git a/tests/.gitignore b/tests/.gitignore index 4a04c0d..294123c 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -109,4 +109,5 @@ prime_self_import prime_udl sysfs_rc6_residency sysfs_rps +template testdisplay diff --git a/tests/Makefile.am b/tests/Makefile.am index 4ba1d43..7e3ca08 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -59,6 +59,7 @@ TESTS_progs_M = \ $(NOUVEAU_TESTS_M) \ pc8 \ prime_self_import \ + template \ $(NULL) TESTS_progs = \ diff --git a/tests/template.c b/tests/template.c new file mode 100644 index 0000000..24fd850 --- /dev/null +++ b/tests/template.c @@ -0,0 +1,80 @@ +/* + * Copyright © 2013 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + * Authors: + * + */ + +#include "drmtest.h" + +/* + * Note that test function (and code called by them) should generally not return + * a variable indicating success/failure. Instead use the igt_require/igt_assert + * macros to skip out of the entire subtest. + * + * Also, helper functions should only return a status code if the callers have a + * real need to differentiate. If the only thing they do is call igt_assert or a + * similar macro then it'll result in simpler code when the check is moved + * completely into the helper. + */ +static void test_A(int fd) +{ +} + +static void test_B(int fd) +{ +} + +/* + * Variables which are written to in igt_fixtures/subtest blocks need to be + * allocated outside of the relevant function scope, otherwise gcc will wreak + * havoc (since these magic blocks use setjmp/longjmp internally). + * + * Common practice is to put variables used in the main test function into + * global scope, but only right above the main function itself (to avoid leaking + * it into other functions). + */ + +int drm_fd; + +igt_main +{ + igt_fixture { + drm_fd = drm_open_any(); + igt_require(drm_fd >= 0); + + /* Set up other interesting stuff shared by all tests. */ + } + + igt_subtest("A") + test_A(drm_fd); + igt_subtest("B") + test_B(drm_fd); + /* + * Note that subtest names can be programatically generated. See the + * various uses of igt_subtest_f for a few neat ideas. + */ + + igt_fixture { + close(drm_fd); + } +}