X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libtest%2Fmain.cc;h=588512d1a5ef78652f4299ca2be02be30cb0206d;hb=20ac79fc8f8999f39b4fb33e55d4a205ce0c9a10;hp=03a40fc8aeea4d6b39540845c01189d05728f91b;hpb=00a8f6f7d315dc3fce0b0e5a1987c8663488ae1c;p=awesomized%2Flibmemcached diff --git a/libtest/main.cc b/libtest/main.cc index 03a40fc8..588512d1 100644 --- a/libtest/main.cc +++ b/libtest/main.cc @@ -34,7 +34,7 @@ * */ -#include +#include "libtest/yatlcon.h" #include #include @@ -132,7 +132,7 @@ int main(int argc, char *argv[]) { { "version", no_argument, NULL, OPT_LIBYATL_VERSION }, { "quiet", no_argument, NULL, OPT_LIBYATL_QUIET }, - { "repeat", no_argument, NULL, OPT_LIBYATL_REPEAT }, + { "repeat", required_argument, NULL, OPT_LIBYATL_REPEAT }, { "collection", required_argument, NULL, OPT_LIBYATL_MATCH_COLLECTION }, { "wildcard", required_argument, NULL, OPT_LIBYATL_MATCH_WILDCARD }, { "massive", no_argument, NULL, OPT_LIBYATL_MASSIVE }, @@ -220,22 +220,24 @@ int main(int argc, char *argv[]) is_massive(opt_massive); } - char buffer[1024]; + libtest::vchar_t tmp_directory; + tmp_directory.resize(1024); if (getenv("LIBTEST_TMP")) { - snprintf(buffer, sizeof(buffer), "%s", getenv("LIBTEST_TMP")); + snprintf(&tmp_directory[0], tmp_directory.size(), "%s", getenv("LIBTEST_TMP")); } else { - snprintf(buffer, sizeof(buffer), "%s", LIBTEST_TEMP); + snprintf(&tmp_directory[0], tmp_directory.size(), "%s", LIBTEST_TEMP); } - if (chdir(buffer) == -1) + if (chdir(&tmp_directory[0]) == -1) { - char getcwd_buffer[1024]; - char *dir= getcwd(getcwd_buffer, sizeof(getcwd_buffer)); + libtest::vchar_t getcwd_buffer; + getcwd_buffer.resize(1024); + char *dir= getcwd(&getcwd_buffer[0], getcwd_buffer.size()); - Error << "Unable to chdir() from " << dir << " to " << buffer << " errno:" << strerror(errno); + Error << "Unable to chdir() from " << dir << " to " << &tmp_directory[0] << " errno:" << strerror(errno); return EXIT_FAILURE; } @@ -282,6 +284,7 @@ int main(int argc, char *argv[]) std::auto_ptr frame(new libtest::Framework(signal, binary_name, collection_to_run, wildcard)); // Run create(), bail on error. + try { switch (frame->create()) { @@ -292,10 +295,14 @@ int main(int argc, char *argv[]) return EXIT_SKIP; case TEST_FAILURE: - std::cerr << "frame->create()" << std::endl; + std::cerr << "Could not call frame->create()" << std::endl; return EXIT_FAILURE; } } + catch (libtest::__skipped e) + { + return EXIT_SKIP; + } frame->exec(); @@ -329,10 +336,7 @@ int main(int argc, char *argv[]) std::ofstream xml_file; std::string file_name; - if (getenv("LIBTEST_TEMP")) - { - file_name.append(getenv("LIBTEST_TEMP")); - } + file_name.append(&tmp_directory[0]); file_name.append(frame->name()); file_name.append(".xml"); xml_file.open(file_name.c_str(), std::ios::trunc); @@ -341,14 +345,18 @@ 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::fatal& e) + catch (libtest::__skipped e) { - std::cerr << "FATAL:" << e.what() << std::endl; + return EXIT_SKIP; + } + catch (libtest::__failure e) + { + libtest::stream::make_cout(e.file(), e.line(), e.func()) << e.what(); exit_code= EXIT_FAILURE; } - catch (libtest::start& e) + catch (libtest::fatal& e) { - std::cerr << "Failure to start:" << e.what() << std::endl; + std::cerr << "FATAL:" << e.what() << std::endl; exit_code= EXIT_FAILURE; } catch (libtest::disconnected& e)