[Box Backup-commit] COMMIT r1553 - box/chris/merge/infrastructure
boxbackup-dev at fluffy.co.uk
boxbackup-dev at fluffy.co.uk
Sun Apr 22 15:32:29 BST 2007
Author: chris
Date: 2007-04-22 15:32:28 +0100 (Sun, 22 Apr 2007)
New Revision: 1553
Modified:
box/chris/merge/infrastructure/buildenv-testmain-template.cpp
Log:
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)
Modified: box/chris/merge/infrastructure/buildenv-testmain-template.cpp
===================================================================
--- box/chris/merge/infrastructure/buildenv-testmain-template.cpp 2007-04-22 14:25:08 UTC (rev 1552)
+++ box/chris/merge/infrastructure/buildenv-testmain-template.cpp 2007-04-22 14:32:28 UTC (rev 1553)
@@ -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 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 @@
#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 @@
TEST_THAT(WSAStartup(0x0101, &info) != SOCKET_ERROR)
#endif
}
+
try
{
#ifdef BOX_MEMORY_LEAK_TESTING
@@ -127,7 +195,7 @@
#endif
Timers::Init();
- int returncode = test(argc, argv);
+ int returncode = test(argc, (const char **)argv);
Timers::Cleanup();
// check for memory leaks, if enabled
More information about the Boxbackup-commit
mailing list