summaryrefslogtreecommitdiff
path: root/infrastructure/buildenv-testmain-template.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'infrastructure/buildenv-testmain-template.cpp')
-rw-r--r--infrastructure/buildenv-testmain-template.cpp92
1 files changed, 87 insertions, 5 deletions
diff --git a/infrastructure/buildenv-testmain-template.cpp b/infrastructure/buildenv-testmain-template.cpp
index 62d2334b..4de30e2e 100644
--- a/infrastructure/buildenv-testmain-template.cpp
+++ b/infrastructure/buildenv-testmain-template.cpp
@@ -2,6 +2,9 @@
// AUTOMATICALLY GENERATED FILE
// do not edit
//
+// Note that infrastructure/buildenv-testmain-template.cpp is NOT
+// auto-generated, but test/*/_main.cpp are generated from it.
+//
// --------------------------------------------------------------------------
@@ -23,6 +26,11 @@
#include <stdarg.h>
#include <fcntl.h>
#include <errno.h>
+#include <string>
+
+#ifdef HAVE_GETOPT_H
+ #include <getopt.h>
+#endif
#ifdef WIN32
#include "emu.h"
@@ -32,6 +40,10 @@
#include <string>
+#include "Logging.h"
+#include "Test.h"
+#include "Timer.h"
+
#include "MemLeakFindOn.h"
int test(int argc, const char *argv[]);
@@ -45,13 +57,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
@@ -77,7 +90,8 @@ bool checkfilesleftopen()
{
if(filedes_open_at_beginning == -1)
{
- // Not used correctly, pretend that there were things left open so this gets invesitgated
+ // Not used correctly, pretend that there were things
+ // left open so this gets investigated
return true;
}
@@ -90,11 +104,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);
@@ -114,16 +189,23 @@ int main(int argc, const char *argv[])
TEST_THAT(WSAStartup(0x0101, &info) != SOCKET_ERROR)
#endif
}
+
try
{
- int returncode = test(argc, argv);
+ #ifdef BOX_MEMORY_LEAK_TESTING
+ memleakfinder_init();
+ #endif
+
+ Timers::Init();
+ int returncode = test(argc, (const char **)argv);
+ Timers::Cleanup();
// check for memory leaks, if enabled
#ifdef BOX_MEMORY_LEAK_TESTING
if(memleakfinder_numleaks() != 0)
{
failures++;
- printf("FAILURE: Memory leaks detected\n");
+ printf("FAILURE: Memory leaks detected in test code\n");
printf("==== MEMORY LEAKS =================================\n");
memleakfinder_reportleaks();
printf("===================================================\n");