X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libtest%2Fmain.cc;h=6bffa84cf86688a6be22fa55fcd47153375287f4;hb=462de46ceddc9846bbefe91dca9915c5c538308d;hp=453d29668afdfb45d7f2cdd5f07182dcb6535d28;hpb=6278f4fcc2b81952d7420c081961dd83935c8c85;p=awesomized%2Flibmemcached diff --git a/libtest/main.cc b/libtest/main.cc index 453d2966..6bffa84c 100644 --- a/libtest/main.cc +++ b/libtest/main.cc @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -58,7 +59,7 @@ using namespace libtest; -static void stats_print(Framework *frame) +static void stats_print(libtest::Framework *frame) { if (frame->failed() == 0 and frame->success() == 0) { @@ -87,6 +88,23 @@ int main(int argc, char *argv[]) bool opt_quiet= false; std::string collection_to_run; std::string wildcard; + std::string binary_name; + + const char *just_filename= rindex(argv[0], '/'); + if (just_filename) + { + just_filename++; + } + else + { + just_filename= argv[0]; + } + + if (just_filename[0] == 'l' and just_filename[1] == 't' and just_filename[2] == '-') + { + just_filename+= 3; + } + binary_name.append(just_filename); /* Valgrind does not currently work reliably, or sometimes at all, on OSX @@ -202,22 +220,22 @@ int main(int argc, char *argv[]) is_massive(opt_massive); } - char buffer[1024]; + char tmp_directory[1024]; if (getenv("LIBTEST_TMP")) { - snprintf(buffer, sizeof(buffer), "%s", getenv("LIBTEST_TMP")); + snprintf(tmp_directory, sizeof(tmp_directory), "%s", getenv("LIBTEST_TMP")); } else { - snprintf(buffer, sizeof(buffer), "%s", LIBTEST_TEMP); + snprintf(tmp_directory, sizeof(tmp_directory), "%s", LIBTEST_TEMP); } - if (chdir(buffer) == -1) + if (chdir(tmp_directory) == -1) { char getcwd_buffer[1024]; char *dir= getcwd(getcwd_buffer, sizeof(getcwd_buffer)); - Error << "Unable to chdir() from " << dir << " to " << buffer << " errno:" << strerror(errno); + Error << "Unable to chdir() from " << dir << " to " << tmp_directory << " errno:" << strerror(errno); return EXIT_FAILURE; } @@ -261,7 +279,7 @@ int main(int argc, char *argv[]) return EXIT_FAILURE; } - std::auto_ptr frame(new Framework(signal, collection_to_run, wildcard)); + std::auto_ptr frame(new libtest::Framework(signal, binary_name, collection_to_run, wildcard)); // Run create(), bail on error. { @@ -303,11 +321,20 @@ int main(int argc, char *argv[]) } else if (frame->success() and (frame->failed() == 0)) { + Out; Out << "All tests completed successfully."; } stats_print(frame.get()); + std::ofstream xml_file; + std::string file_name; + file_name.append(tmp_directory); + file_name.append(frame->name()); + file_name.append(".xml"); + xml_file.open(file_name.c_str(), std::ios::trunc); + libtest::Formatter::xml(*frame, xml_file); + Outn(); // Generate a blank to break up the messages if make check/test has been run } while (exit_code == EXIT_SUCCESS and --opt_repeat); } @@ -316,6 +343,11 @@ int main(int argc, char *argv[]) std::cerr << "FATAL:" << e.what() << std::endl; exit_code= EXIT_FAILURE; } + catch (libtest::start& e) + { + std::cerr << "Failure to start:" << e.what() << std::endl; + exit_code= EXIT_FAILURE; + } catch (libtest::disconnected& e) { std::cerr << "Unhandled disconnection occurred:" << e.what() << std::endl;