summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.c99
1 files changed, 71 insertions, 28 deletions
diff --git a/main.c b/main.c
index 8c6de36..bca639f 100644
--- a/main.c
+++ b/main.c
@@ -32,42 +32,85 @@ void test_uchar_h(void);
void test_wchar_h(void);
void test_wctype_h(void);
+static struct {
+ char *name;
+ void (*fn)(void);
+ int run;
+} tests[] = {
+ { "assert", test_assert_h, 0 },
+ { "complex", test_complex_h, 1 },
+ { "ctype", test_ctype_h, 1 },
+ { "errno", test_errno_h, 1 },
+ { "fenv", test_fenv_h, 1 },
+ { "float", test_float_h, 1 },
+ { "inttypes", test_inttypes_h, 1 },
+ { "iso646", test_iso646_h, 1 },
+ { "limits", test_limits_h, 1 },
+ { "locale", test_locale_h, 1 },
+ { "math", test_math_h, 1 },
+ { "setjmp", test_setjmp_h, 0 },
+ { "signal", test_signal_h, 1 },
+ { "stdalign", test_stdalign_h, 1 },
+ { "stdarg", test_stdarg_h, 1 },
+ { "stdatomic", test_stdatomic_h, 1 },
+ { "stdbool", test_stdbool_h, 1 },
+ { "stddef", test_stddef_h, 1 },
+ { "stdint", test_stdint_h, 1 },
+ { "stdio", test_stdio_h, 1 },
+ { "stdlib", test_stdlib_h, 1 },
+ { "stdnoreturn",test_stdnoreturn_h, 1 },
+ { "string", test_string_h, 1 },
+ { "tgmath", test_tgmath_h, 1 },
+ { "threads", test_threads_h, 1 },
+ { "time", test_time_h, 1 },
+ { "uchar", test_uchar_h, 1 },
+ { "wchar", test_wchar_h, 1 },
+ { "wctype", test_wctype_h, 1 },
+};
+
+void usage(const char *argv0)
+{
+ printf("Usage: %s [-v] [test...]\n", argv0);
+}
+
int main(int argc, char *argv[])
{
+ int torun = 1;
+ int i, j;
+
+ for (i = 1; i < argc; i++) {
+ int ok = 0;
+
+ if (!strcmp("-v", argv[i])) {
+ verbose = 1;
+ ok = 1;
+ }
+
+ for (j = 0; j < sizeof(tests) / sizeof(tests[0]); j++) {
+ if (!strcmp(tests[j].name, argv[i])) {
+ torun = 2;
+ tests[j].run = 2;
+ ok = 1;
+ }
+ }
+
+ if (!ok) {
+ usage(argv[0]);
+ return 1;
+ }
+ }
+
if (argc == 2) {
if (!strcmp(argv[1], "assert")) {
test_assert_h();
}
}
- test_complex_h();
- test_ctype_h();
- test_errno_h();
- test_fenv_h();
- test_float_h();
- test_inttypes_h();
- test_iso646_h();
- test_limits_h();
- test_locale_h();
- test_math_h();
- /* test_setjmp_h(); */
- test_signal_h();
- test_stdalign_h();
- test_stdarg_h();
- test_stdatomic_h();
- test_stdbool_h();
- test_stddef_h();
- test_stdint_h();
- test_stdio_h();
- test_stdlib_h();
- test_stdnoreturn_h();
- test_string_h();
- test_tgmath_h();
- test_threads_h();
- test_time_h();
- test_uchar_h();
- test_wchar_h();
- test_wctype_h();
+ for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) {
+ if (tests[i].run == torun) {
+ tests[i].fn();
+ }
+ }
printf("Total: %u passed, %u failed\n", total_passed, total_failed);
return 0;