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>
43 char list[] = "--list-subtests";
44 char *argv_list[] = { test, list };
45 char *argv_run[] = { test };
47 static int do_fork(void)
51 switch (pid = fork()) {
58 igt_skip_on_simulation();
63 igt_subtest_init(2, argv_list);
65 igt_subtest_init(1, argv_run);
69 igt_skip_on_simulation();
72 igt_skip_on_simulation();
74 igt_skip_on_simulation();
83 while (waitpid(pid, &status, 0) == -1 &&
87 assert(WIFEXITED(status));
89 return WEXITSTATUS(status);
93 int main(int argc, char **argv)
97 assert(setenv("INTEL_SIMULATION", "1", 1) == 0);
98 assert(do_fork() == IGT_EXIT_SKIP);
100 assert(setenv("INTEL_SIMULATION", "0", 1) == 0);
101 assert(do_fork() == IGT_EXIT_SUCCESS);
103 /* subtests, list mode */
105 list_subtests = true;
108 assert(setenv("INTEL_SIMULATION", "1", 1) == 0);
109 assert(do_fork() == IGT_EXIT_SUCCESS);
111 assert(setenv("INTEL_SIMULATION", "0", 1) == 0);
112 assert(do_fork() == IGT_EXIT_SUCCESS);
115 assert(setenv("INTEL_SIMULATION", "1", 1) == 0);
116 assert(do_fork() == IGT_EXIT_SUCCESS);
118 assert(setenv("INTEL_SIMULATION", "0", 1) == 0);
119 assert(do_fork() == IGT_EXIT_SUCCESS);
123 assert(setenv("INTEL_SIMULATION", "1", 1) == 0);
124 assert(do_fork() == IGT_EXIT_SUCCESS);
126 assert(setenv("INTEL_SIMULATION", "0", 1) == 0);
127 assert(do_fork() == IGT_EXIT_SUCCESS);
129 /* subtest, run mode */
131 list_subtests = false;
134 assert(setenv("INTEL_SIMULATION", "1", 1) == 0);
135 assert(do_fork() == IGT_EXIT_SKIP);
137 assert(setenv("INTEL_SIMULATION", "0", 1) == 0);
138 assert(do_fork() == IGT_EXIT_SUCCESS);
141 assert(setenv("INTEL_SIMULATION", "1", 1) == 0);
142 assert(do_fork() == IGT_EXIT_SKIP);
144 assert(setenv("INTEL_SIMULATION", "0", 1) == 0);
145 assert(do_fork() == IGT_EXIT_SUCCESS);
149 assert(setenv("INTEL_SIMULATION", "1", 1) == 0);
150 assert(do_fork() == IGT_EXIT_SKIP);
152 assert(setenv("INTEL_SIMULATION", "0", 1) == 0);
153 assert(do_fork() == IGT_EXIT_SUCCESS);