2 * Copyright © 2014 Intel Corporation
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:
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
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
24 * Daniel Vetter <daniel.vetter@ffwll.ch>
30 #include <sys/types.h>
38 * We need to hide assert from the cocci igt test refactor spatch.
40 * IMPORTANT: Test infrastructure tests are the only valid places where using
43 #define internal_assert assert
51 char list[] = "--list-subtests";
52 char *argv_list[] = { test, list };
53 char *argv_run[] = { test };
55 static int do_fork(void)
59 switch (pid = fork()) {
64 igt_simple_init(1, argv_run);
66 igt_skip_on_simulation();
71 igt_subtest_init(2, argv_list);
73 igt_subtest_init(1, argv_run);
77 igt_skip_on_simulation();
80 igt_skip_on_simulation();
82 igt_skip_on_simulation();
91 while (waitpid(pid, &status, 0) == -1 &&
95 internal_assert(WIFEXITED(status));
97 return WEXITSTATUS(status);
101 int main(int argc, char **argv)
105 internal_assert(setenv("INTEL_SIMULATION", "1", 1) == 0);
106 internal_assert(do_fork() == IGT_EXIT_SKIP);
108 internal_assert(setenv("INTEL_SIMULATION", "0", 1) == 0);
109 internal_assert(do_fork() == IGT_EXIT_SUCCESS);
111 /* subtests, list mode */
113 list_subtests = true;
116 internal_assert(setenv("INTEL_SIMULATION", "1", 1) == 0);
117 internal_assert(do_fork() == IGT_EXIT_SUCCESS);
119 internal_assert(setenv("INTEL_SIMULATION", "0", 1) == 0);
120 internal_assert(do_fork() == IGT_EXIT_SUCCESS);
123 internal_assert(setenv("INTEL_SIMULATION", "1", 1) == 0);
124 internal_assert(do_fork() == IGT_EXIT_SUCCESS);
126 internal_assert(setenv("INTEL_SIMULATION", "0", 1) == 0);
127 internal_assert(do_fork() == IGT_EXIT_SUCCESS);
131 internal_assert(setenv("INTEL_SIMULATION", "1", 1) == 0);
132 internal_assert(do_fork() == IGT_EXIT_SUCCESS);
134 internal_assert(setenv("INTEL_SIMULATION", "0", 1) == 0);
135 internal_assert(do_fork() == IGT_EXIT_SUCCESS);
137 /* subtest, run mode */
139 list_subtests = false;
142 internal_assert(setenv("INTEL_SIMULATION", "1", 1) == 0);
143 internal_assert(do_fork() == IGT_EXIT_SKIP);
145 internal_assert(setenv("INTEL_SIMULATION", "0", 1) == 0);
146 internal_assert(do_fork() == IGT_EXIT_SUCCESS);
149 internal_assert(setenv("INTEL_SIMULATION", "1", 1) == 0);
150 internal_assert(do_fork() == IGT_EXIT_SKIP);
152 internal_assert(setenv("INTEL_SIMULATION", "0", 1) == 0);
153 internal_assert(do_fork() == IGT_EXIT_SUCCESS);
157 internal_assert(setenv("INTEL_SIMULATION", "1", 1) == 0);
158 internal_assert(do_fork() == IGT_EXIT_SKIP);
160 internal_assert(setenv("INTEL_SIMULATION", "0", 1) == 0);
161 internal_assert(do_fork() == IGT_EXIT_SUCCESS);