1 // Copyright (C) 2010-2017 Codership Oy <info@codership.com> 2 3 #include <cstdlib> 4 #include <cstdio> 5 #include <string> 6 7 extern "C" { 8 #include <galerautils.h> 9 } 10 11 #include "gcache_tests.hpp" 12 13 #define LOG_FILE "gcache_tests.log" 14 main(int argc,char * argv[])15int main(int argc, char* argv[]) 16 { 17 bool no_fork = (argc >= 2 && std::string(argv[1]) == "nofork"); 18 FILE* log_file = 0; 19 20 if (!no_fork) 21 { 22 log_file = fopen (LOG_FILE, "w"); 23 if (!log_file) return EXIT_FAILURE; 24 gu_conf_set_log_file (log_file); 25 } 26 27 gu_conf_debug_on(); 28 29 int failed = 0; 30 31 for (int i = 0; suites[i] != 0; ++i) 32 { 33 SRunner* sr = srunner_create(suites[i]()); 34 35 if (no_fork) srunner_set_fork_status(sr, CK_NOFORK); 36 37 srunner_run_all(sr, CK_NORMAL); 38 failed += srunner_ntests_failed(sr); 39 srunner_free(sr); 40 } 41 42 if (log_file != 0) fclose(log_file); 43 printf ("Total tests failed: %d\n", failed); 44 45 if (0 == failed && 0 != log_file) ::unlink(LOG_FILE); 46 47 return failed == 0 ? EXIT_SUCCESS : EXIT_FAILURE; 48 } 49