int main(int argc, char **argv) { suite_fn suites[] = { #define SUITE(name) &suite_ ## name, #include "test/suites.h" #undef SUITE NULL }; static const struct option options[] = { {"help", no_argument, NULL, 'h'}, {"verbose", no_argument, NULL, 'v'}, {NULL, 0, NULL, 0} }; int verbose = 0; int c; char *testdir, *dir_before; int result; #ifdef _WIN32 putenv("CCACHE_DETECT_SHEBANG=1"); #endif while ((c = getopt_long(argc, argv, "hv", options, NULL)) != -1) { switch (c) { case 'h': fprintf(stdout, USAGE_TEXT); return 0; case 'v': verbose = 1; break; default: fprintf(stderr, USAGE_TEXT); return 1; } } if (getenv("RUN_FROM_BUILD_FARM")) { verbose = 1; } testdir = format("testdir.%d", (int)getpid()); cct_create_fresh_dir(testdir); dir_before = gnu_getcwd(); cct_chdir(testdir); result = cct_run(suites, verbose); if (result == 0) { cct_chdir(dir_before); cct_wipe(testdir); } free(testdir); free(dir_before); return result; }
void cct_suite_end() { cct_chdir(dir_before_suite); free(dir_before_suite); dir_before_suite = NULL; }
void cct_test_end() { if (dir_before_test) { cct_chdir(dir_before_test); free(dir_before_test); dir_before_test = NULL; } }
void cct_suite_begin(const char *name) { ++total_suites; if (verbose) { printf("=== SUITE: %s ===\n", name); } dir_before_suite = gnu_getcwd(); create_dir(name); cct_chdir(name); current_suite = name; }
void cct_test_begin(const char *name) { ++total_tests; if (verbose) { printf("--- TEST: %s ---\n", name); } dir_before_test = gnu_getcwd(); create_dir(name); cct_chdir(name); current_test = name; putenv("CCACHE_CONFIG_PATH=/dev/null"); cc_reset(); }