turns printfs back on
[freebsd-src/fkvm-freebsd.git] / tools / regression / posixshm / test.c
blob8583a0dbbac6a74bc90db1e45ff3b7c4f7733bbf
1 /*-
2 * Copyright (c) 2008 Yahoo!, Inc.
3 * All rights reserved.
4 * Written by: John Baldwin <jhb@FreeBSD.org>
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. Neither the name of the author nor the names of any co-contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
31 #include <sys/cdefs.h>
32 __FBSDID("$FreeBSD$");
34 #include <stdarg.h>
35 #include <stdio.h>
37 #include "test.h"
39 static int test_index;
40 static struct regression_test *test;
41 static int test_acknowleged;
43 SET_DECLARE(regression_tests_set, struct regression_test);
46 * Outputs a test summary of the following:
48 * <status> <test #> [name] [# <fmt> [fmt args]]
50 static void
51 vprint_status(const char *status, const char *fmt, va_list ap)
54 printf("%s %d", status, test_index);
55 if (test->rt_name)
56 printf(" - %s", test->rt_name);
57 if (fmt) {
58 printf(" # ");
59 vprintf(fmt, ap);
61 printf("\n");
62 test_acknowleged = 1;
65 static void
66 print_status(const char *status, const char *fmt, ...)
68 va_list ap;
70 va_start(ap, fmt);
71 vprint_status(status, fmt, ap);
72 va_end(ap);
75 void
76 pass(void)
79 print_status("ok", NULL);
82 void
83 fail(void)
86 print_status("not ok", NULL);
89 void
90 fail_err(const char *fmt, ...)
92 va_list ap;
94 va_start(ap, fmt);
95 vprint_status("not ok", fmt, ap);
96 va_end(ap);
99 void
100 skip(const char *reason)
103 print_status("ok", "skip %s", reason);
106 void
107 todo(const char *reason)
110 print_status("not ok", "TODO %s", reason);
113 void
114 run_tests(void)
116 struct regression_test **testp;
118 printf("1..%td\n", SET_COUNT(regression_tests_set));
119 test_index = 1;
120 SET_FOREACH(testp, regression_tests_set) {
121 test_acknowleged = 0;
122 test = *testp;
123 test->rt_function();
124 if (!test_acknowleged)
125 print_status("not ok", "unknown status");
126 test_index++;