blob: 5fbd3104ddf125bdd22e8f38e051581b29cf450a [file] [log] [blame]
Daniel Vetter8f718b12013-10-31 17:05:28 +01001/*
2 * Copyright © 2013 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 *
23 * Authors:
24 *
25 */
26
Thomas Wood804e11f2015-08-17 17:57:43 +010027#include "igt.h"
Daniel Vetter8f718b12013-10-31 17:05:28 +010028
Paulo Zanoni46a17912015-05-26 11:11:52 -030029IGT_TEST_DESCRIPTION("Template test.");
30
Daniel Vetter8f718b12013-10-31 17:05:28 +010031/*
32 * Note that test function (and code called by them) should generally not return
33 * a variable indicating success/failure. Instead use the igt_require/igt_assert
34 * macros to skip out of the entire subtest.
35 *
36 * Also, helper functions should only return a status code if the callers have a
37 * real need to differentiate. If the only thing they do is call igt_assert or a
38 * similar macro then it'll result in simpler code when the check is moved
39 * completely into the helper.
40 */
41static void test_A(int fd)
42{
43}
44
45static void test_B(int fd)
46{
47}
48
49/*
50 * Variables which are written to in igt_fixtures/subtest blocks need to be
51 * allocated outside of the relevant function scope, otherwise gcc will wreak
52 * havoc (since these magic blocks use setjmp/longjmp internally).
53 *
54 * Common practice is to put variables used in the main test function into
55 * global scope, but only right above the main function itself (to avoid leaking
56 * it into other functions).
57 */
58
59int drm_fd;
60
61igt_main
62{
63 igt_fixture {
Micah Fedkec81d2932015-07-22 21:54:02 +000064 drm_fd = drm_open_driver(DRIVER_INTEL);
Daniel Vetter8f718b12013-10-31 17:05:28 +010065 igt_require(drm_fd >= 0);
66
67 /* Set up other interesting stuff shared by all tests. */
68 }
69
70 igt_subtest("A")
71 test_A(drm_fd);
72 igt_subtest("B")
73 test_B(drm_fd);
74 /*
75 * Note that subtest names can be programatically generated. See the
76 * various uses of igt_subtest_f for a few neat ideas.
77 */
78
79 igt_fixture {
80 close(drm_fd);
81 }
82}