X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libtest%2Fmain.cc;h=2ceeac92cf0bdba962a035e4e240a38e4409ab79;hb=b036e172e5839d530bce7c3831a8eaf36d68eca7;hp=588512d1a5ef78652f4299ca2be02be30cb0206d;hpb=381d409b224ca3b4510e770a98bc960084cdf2c4;p=awesomized%2Flibmemcached diff --git a/libtest/main.cc b/libtest/main.cc index 588512d1..2ceeac92 100644 --- a/libtest/main.cc +++ b/libtest/main.cc @@ -158,7 +158,13 @@ int main(int argc, char *argv[]) break; case OPT_LIBYATL_REPEAT: + errno= 0; opt_repeat= strtoul(optarg, (char **) NULL, 10); + if (errno != 0) + { + Error << "unknown value passed to --repeat: `" << optarg << "`"; + exit(EXIT_FAILURE); + } break; case OPT_LIBYATL_MATCH_COLLECTION: @@ -186,9 +192,16 @@ int main(int argc, char *argv[]) srandom((unsigned int)time(NULL)); - if (bool(getenv("YATL_REPEAT")) and (strtoul(getenv("YATL_REPEAT"), (char **) NULL, 10) > 1)) + errno= 0; + if (bool(getenv("YATL_REPEAT"))) { + errno= 0; opt_repeat= strtoul(getenv("YATL_REPEAT"), (char **) NULL, 10); + if (errno != 0) + { + Error << "ENV YATL_REPEAT passed an invalid value: `" << getenv("YATL_REPEAT") << "`"; + exit(EXIT_FAILURE); + } } if ((bool(getenv("YATL_QUIET")) and (strcmp(getenv("YATL_QUIET"), "0") == 0)) or opt_quiet) @@ -299,7 +312,7 @@ int main(int argc, char *argv[]) return EXIT_FAILURE; } } - catch (libtest::__skipped e) + catch (const libtest::__skipped& e) { return EXIT_SKIP; } @@ -345,33 +358,33 @@ int main(int argc, char *argv[]) Outn(); // Generate a blank to break up the messages if make check/test has been run } while (exit_code == EXIT_SUCCESS and --opt_repeat); } - catch (libtest::__skipped e) + catch (const libtest::__skipped& e) { return EXIT_SKIP; } - catch (libtest::__failure e) + catch (const libtest::__failure& e) { libtest::stream::make_cout(e.file(), e.line(), e.func()) << e.what(); exit_code= EXIT_FAILURE; } - catch (libtest::fatal& e) + catch (const libtest::fatal& e) { std::cerr << "FATAL:" << e.what() << std::endl; exit_code= EXIT_FAILURE; } - catch (libtest::disconnected& e) + catch (const libtest::disconnected& e) { std::cerr << "Unhandled disconnection occurred:" << e.what() << std::endl; exit_code= EXIT_FAILURE; } - catch (std::exception& e) + catch (const std::exception& e) { std::cerr << "std::exception:" << e.what() << std::endl; exit_code= EXIT_FAILURE; } - catch (char const*) + catch (char const* s) { - std::cerr << "Exception:" << std::endl; + std::cerr << "Exception:" << s << std::endl; exit_code= EXIT_FAILURE; } catch (...)