X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libtest%2Ftest.cc;h=11222b2c08d11c9d362aff1a9e2c52ed7282be6f;hb=e62187d9544abeffaa8552742da6c154fb77cf7c;hp=cafc48d4e45cfa9f2b41963ce73d3da0d15dab9b;hpb=062e78da580009318a84372a7e117ab2a38869cb;p=awesomized%2Flibmemcached diff --git a/libtest/test.cc b/libtest/test.cc index cafc48d4..11222b2c 100644 --- a/libtest/test.cc +++ b/libtest/test.cc @@ -76,7 +76,9 @@ static long int timedif(struct timeval a, struct timeval b) int main(int argc, char *argv[]) { - bool opt_repeat= false; + bool opt_massive= false; + unsigned long int opt_repeat= 1; // Run all tests once + bool opt_quiet= false; std::string collection_to_run; // Options parsing @@ -84,14 +86,19 @@ int main(int argc, char *argv[]) enum long_option_t { OPT_LIBYATL_VERSION, OPT_LIBYATL_MATCH_COLLECTION, + OPT_LIBYATL_MASSIVE, + OPT_LIBYATL_QUIET, OPT_LIBYATL_REPEAT }; static struct option long_options[]= { - {"repeat", no_argument, NULL, OPT_LIBYATL_REPEAT}, - {"collection", required_argument, NULL, OPT_LIBYATL_MATCH_COLLECTION}, - {0, 0, 0, 0} + { "version", no_argument, NULL, OPT_LIBYATL_VERSION }, + { "quiet", no_argument, NULL, OPT_LIBYATL_QUIET }, + { "repeat", no_argument, NULL, OPT_LIBYATL_REPEAT }, + { "collection", required_argument, NULL, OPT_LIBYATL_MATCH_COLLECTION }, + { "massive", no_argument, NULL, OPT_LIBYATL_MASSIVE }, + { 0, 0, 0, 0 } }; int option_index= 0; @@ -108,14 +115,22 @@ int main(int argc, char *argv[]) case OPT_LIBYATL_VERSION: break; + case OPT_LIBYATL_QUIET: + opt_quiet= true; + break; + case OPT_LIBYATL_REPEAT: - opt_repeat= true; + opt_repeat= strtoul(optarg, (char **) NULL, 10); break; case OPT_LIBYATL_MATCH_COLLECTION: collection_to_run= optarg; break; + case OPT_LIBYATL_MASSIVE: + opt_massive= true; + break; + case '?': /* getopt_long already printed an error message. */ Error << "unknown option to getopt_long()"; @@ -129,11 +144,26 @@ int main(int argc, char *argv[]) srandom((unsigned int)time(NULL)); - if (getenv("LIBTEST_QUIET") and strcmp(getenv("LIBTEST_QUIET"), "0") == 0) + if (bool(getenv("YATL_REPEAT")) and (strtoul(getenv("YATL_REPEAT"), (char **) NULL, 10) > 1)) { - close(STDOUT_FILENO); + opt_repeat= strtoul(getenv("YATL_REPEAT"), (char **) NULL, 10); + } + + if ((bool(getenv("YATL_QUIET")) and (strcmp(getenv("YATL_QUIET"), "0") == 0)) or opt_quiet) + { + opt_quiet= true; } else if (getenv("JENKINS_URL")) + { + if (bool(getenv("YATL_QUIET")) and (strcmp(getenv("YATL_QUIET"), "1") == 0)) + { } + else + { + opt_quiet= true; + } + } + + if (opt_quiet) { close(STDOUT_FILENO); } @@ -173,7 +203,7 @@ int main(int argc, char *argv[]) fatal_assert(sigignore(SIGPIPE) == 0); libtest::SignalThread signal; - if (not signal.setup()) + if (signal.setup() == false) { Error << "Failed to setup signals"; return EXIT_FAILURE; @@ -254,7 +284,7 @@ int main(int argc, char *argv[]) goto cleanup; default: - throw fatal_message("invalid return code"); + fatal_message("invalid return code"); } Out << "Collection: " << next->name; @@ -326,6 +356,11 @@ int main(int argc, char *argv[]) } } + catch (libtest::fatal &e) + { + Error << "Fatal exception was thrown: " << e.what(); + return_code= TEST_FAILURE; + } catch (std::exception &e) { Error << "Exception was thrown: " << e.what(); @@ -359,7 +394,7 @@ int main(int argc, char *argv[]) break; default: - throw fatal_message("invalid return code"); + fatal_message("invalid return code"); } if (test_failed(world.on_error(return_code, creators_ptr))) @@ -420,7 +455,7 @@ cleanup: stats_print(&stats); Outn(); // Generate a blank to break up the messages if make check/test has been run - } while (exit_code == EXIT_SUCCESS and opt_repeat); + } while (exit_code == EXIT_SUCCESS and --opt_repeat); } catch (libtest::fatal& e) {