summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2015-05-04 18:56:29 +0000
committerChris Wilson <chris+github@qwirx.com>2015-05-04 18:56:29 +0000
commitd39fdbcd444ee62ca6118b9bdf8314bc206fbb08 (patch)
tree897c2df00e30b0a66f35c05e75817c349be4c155
parent16bfb3c7f6335d988ebf907ac823418a592f58e3 (diff)
Fix system exit codes from tests, so we can use them in the shell.
I needed reliable exit codes to run the tests in a loop to catch an intermittent failure.
-rwxr-xr-xinfrastructure/makebuildenv.pl.in3
-rw-r--r--test/backupstore/testbackupstore.cpp11
-rw-r--r--test/bbackupd/testbbackupd.cpp2
3 files changed, 12 insertions, 4 deletions
diff --git a/infrastructure/makebuildenv.pl.in b/infrastructure/makebuildenv.pl.in
index fef9d348..0042c7a6 100755
--- a/infrastructure/makebuildenv.pl.in
+++ b/infrastructure/makebuildenv.pl.in
@@ -465,7 +465,7 @@ __E
close FL;
}
- print TESTFILE "$runcmd\n";
+ print TESTFILE "$runcmd\nexit_status=\$?\n";
if (-d "$module/testfiles")
{
@@ -474,6 +474,7 @@ kill_daemons
__E
}
+ print TESTFILE "exit \$exit_status\n";
close TESTFILE;
}
diff --git a/test/backupstore/testbackupstore.cpp b/test/backupstore/testbackupstore.cpp
index 9c548400..2ee1bcdc 100644
--- a/test/backupstore/testbackupstore.cpp
+++ b/test/backupstore/testbackupstore.cpp
@@ -239,8 +239,12 @@ void CheckEntries(BackupStoreDirectory &rDir, int16_t FlagsMustBeSet, int16_t Fl
TEST_THAT(DIR_NUM == SkipEntries(e, FlagsMustBeSet, FlagsNotToBeSet));
}
+int num_tests_selected = 0;
+
//! Simplifies calling setUp() with the current function name in each test.
-#define SETUP() if (!setUp(__FUNCTION__)) return true; // skip this test
+#define SETUP() \
+ if (!setUp(__FUNCTION__)) return true; \
+ num_tests_selected++;
//! Checks account for errors and shuts down daemons at end of every test.
bool teardown_test_backupstore()
@@ -3111,6 +3115,9 @@ int test(int argc, const char *argv[])
TEST_THAT(test_multiple_uploads());
TEST_THAT(test_housekeeping_deletes_files());
- return (failures == 0);
+ TEST_LINE(num_tests_selected > 0, "No tests matched the patterns "
+ "specified on the command line");
+
+ return (failures == 0 && num_tests_selected > 0) ? 0 : 1;
}
diff --git a/test/bbackupd/testbbackupd.cpp b/test/bbackupd/testbbackupd.cpp
index 3f1c5640..e5df9d32 100644
--- a/test/bbackupd/testbbackupd.cpp
+++ b/test/bbackupd/testbbackupd.cpp
@@ -4295,5 +4295,5 @@ int test(int argc, const char *argv[])
"specified on the command line");
TEST_THAT(kill_running_daemons());
- return (failures == 0 && num_tests_selected > 0);
+ return (failures == 0 && num_tests_selected > 0) ? 0 : 1;
}