2 * Copyright © 2012 Intel Corporation
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that copyright
7 * notice and this permission notice appear in supporting documentation, and
8 * that the name of the copyright holders not be used in advertising or
9 * publicity pertaining to distribution of the software without specific,
10 * written prior permission. The copyright holders make no representations
11 * about the suitability of this software for any purpose. It is provided "as
12 * is" without express or implied warranty.
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
26 #include <sys/types.h>
31 #include "weston-test-runner.h"
33 extern const struct weston_test __start_test_section, __stop_test_section;
35 static const struct weston_test *
36 find_test(const char *name)
38 const struct weston_test *t;
40 for (t = &__start_test_section; t < &__stop_test_section; t++)
41 if (strcmp(t->name, name) == 0)
48 run_test(const struct weston_test *t)
54 int main(int argc, char *argv[])
56 const struct weston_test *t;
62 t = find_test(argv[1]);
64 fprintf(stderr, "unknown test: \"%s\"\n", argv[1]);
72 for (t = &__start_test_section; t < &__stop_test_section; t++) {
79 run_test(t); /* never returns */
81 if (waitid(P_ALL, 0, &info, WEXITED)) {
82 fprintf(stderr, "waitid failed: %m\n");
86 fprintf(stderr, "test \"%s\":\t", t->name);
87 switch (info.si_code) {
89 fprintf(stderr, "exit status %d", info.si_status);
90 if (info.si_status == EXIT_SUCCESS)
95 fprintf(stderr, "signal %d", info.si_status);
104 fprintf(stderr, ", pass.\n");
106 fprintf(stderr, ", fail.\n");
109 total = &__stop_test_section - &__start_test_section;
110 fprintf(stderr, "%d tests, %d pass, %d fail\n",
111 total, pass, total - pass);
113 return pass == total ? EXIT_SUCCESS : EXIT_FAILURE;