diff options
author | Chris Wilson <chris+github@qwirx.com> | 2007-04-22 14:32:28 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2007-04-22 14:32:28 +0000 |
commit | b5da77c8bcc6e86bc4735308ac88ffde18a0a96f (patch) | |
tree | 1fa889762ff879534f0f5674ae9a0631d2e6ee03 | |
parent | 35e9013d1a108a186908ef1e6ee3f26f9407c5f1 (diff) |
Add --bbackupd-args and --bbstored-args options, which may be used to pass
additional command-line parameters to bbackupd and bbstored in some tests.
Add -t and -T options, which add tags and timestamps to log messages using
the logging framework inside the tests themselves.
Now you can do things like:
./t -Tt test \
--bbackupd-args="-VTkt bbackupd" \
--bbstored-args="-VTkt bbstored"
and you will get output from the test itself, the bbackupd and bbstored
daemons, all interleaved, timestamped and tagged on the console.
This is very useful for debugging synchronisation problems, where
interleaved output from bbackupd and bbstored in the system logs is not
enough, because you want to see exactly how they interact with the test,
or you don't have access to the system logs.
(refs #3)
-rw-r--r-- | infrastructure/buildenv-testmain-template.cpp | 74 |
1 files changed, 71 insertions, 3 deletions
diff --git a/infrastructure/buildenv-testmain-template.cpp b/infrastructure/buildenv-testmain-template.cpp index bffd46d1..711257ea 100644 --- a/infrastructure/buildenv-testmain-template.cpp +++ b/infrastructure/buildenv-testmain-template.cpp @@ -28,12 +28,17 @@ #include <errno.h> #include <string> +#ifdef HAVE_GETOPT_H + #include <getopt.h> +#endif + #ifdef WIN32 #include "emu.h" #else #include <syslog.h> #endif +#include "Logging.h" #include "Test.h" #include "Timer.h" @@ -50,13 +55,14 @@ int test(int argc, const char *argv[]); int failures = 0; int first_fail_line; std::string first_fail_file; +std::string bbackupd_args, bbstored_args, bbackupquery_args; int filedes_open_at_beginning = -1; #ifdef WIN32 // any way to check for open file descriptors on Win32? -inline int count_filedes() { return 0; } +inline int count_filedes() { return 0; } inline bool checkfilesleftopen() { return false; } #else // !WIN32 @@ -96,11 +102,72 @@ bool checkfilesleftopen() #endif -int main(int argc, const char *argv[]) +int main(int argc, char * const * argv) { // Start memory leak testing MEMLEAKFINDER_START +#ifdef HAVE_GETOPT_H + struct option longopts[] = + { + { "bbackupd-args", required_argument, NULL, 'c' }, + { "bbstored-args", required_argument, NULL, 's' }, + { NULL, 0, NULL, 0 } + }; + + int ch; + + while ((ch = getopt_long(argc, argv, "c:s:t:T", longopts, NULL)) + != -1) + { + switch(ch) + { + case 'c': + { + bbackupd_args += " "; + bbackupd_args += optarg; + } + break; + + case 's': + { + bbstored_args += " "; + bbstored_args += optarg; + } + break; + + case 't': + { + Console::SetTag(optarg); + } + break; + + case 'T': + { + Console::SetShowTime(true); + } + break; + + case '?': + { + fprintf(stderr, "Unknown option: %s\n", + optarg); + exit(2); + } + + default: + { + fprintf(stderr, "Unknown option code '%c'\n", + ch); + exit(2); + } + } + } + + argc -= optind - 1; + argv += optind - 1; +#endif // HAVE_GETOPT_H + // If there is more than one argument, then the test is doing something advanced, so leave it alone bool fulltestmode = (argc == 1); @@ -120,6 +187,7 @@ int main(int argc, const char *argv[]) TEST_THAT(WSAStartup(0x0101, &info) != SOCKET_ERROR) #endif } + try { #ifdef BOX_MEMORY_LEAK_TESTING @@ -127,7 +195,7 @@ int main(int argc, const char *argv[]) #endif Timers::Init(); - int returncode = test(argc, argv); + int returncode = test(argc, (const char **)argv); Timers::Cleanup(); // check for memory leaks, if enabled |