void cct_create_fresh_dir(const char *path) { cct_wipe(path); if (mkdir(path, 0777) != 0) { fprintf(stderr, "mkdir: %s: %s", path, strerror(errno));; abort(); } }
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; }