From: Joel Rosdahl Date: Sat, 14 Aug 2010 09:36:58 +0000 (+0200) Subject: testfw: Let the compiler catch bad test case names X-Git-Tag: v3.1~82 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=df0b495cfc41a78abaef840f2c5341d59ea5cd03;p=thirdparty%2Fccache.git testfw: Let the compiler catch bad test case names --- diff --git a/test/framework.c b/test/framework.c index 22e985319..f3fae2762 100644 --- a/test/framework.c +++ b/test/framework.c @@ -59,22 +59,6 @@ plural_s(unsigned n) return n == 1 ? "" : "s"; } -static void -verify_test_suite_name(const char *name) -{ - const char *p = name; - while (*p) { - if ((*p < '0' || *p > '9') - && (*p < 'A' || *p > 'Z') - && *p != '_' - && (*p < 'a' || *p > 'z')) { - fprintf(stderr, "Bad character ('%c') in suite/test name: %s\n", *p, name); - exit(1); - } - ++p; - } -} - int cct_run(suite_fn *suites, int verbose_output) { @@ -111,7 +95,6 @@ cct_run(suite_fn *suites, int verbose_output) void cct_suite_begin(const char *name) { - verify_test_suite_name(name); ++total_suites; if (verbose) { printf("=== SUITE: %s ===\n", name); @@ -135,7 +118,6 @@ cct_test_begin(const char *name) { extern char *cache_logfile; - verify_test_suite_name(name); ++total_tests; if (verbose) { printf("--- TEST: %s ---\n", name); diff --git a/test/framework.h b/test/framework.h index 90afdaa90..e78b47b4a 100644 --- a/test/framework.h +++ b/test/framework.h @@ -38,6 +38,8 @@ } \ ++_test_counter; \ if (_test_counter >= _start_point) { \ + static int _verify_test_name##name = 0; \ + (void)_verify_test_name##name; \ cct_test_begin(#name); #define TEST_SUITE_END \