aboutsummaryrefslogtreecommitdiff
path: root/support/support_test_main.c
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2016-12-28 13:37:18 +0100
committerFlorian Weimer <fweimer@redhat.com>2016-12-28 13:37:18 +0100
commit5f0b84379024787bae24ad20e81d26ab2f082389 (patch)
tree41c4fdcd00da543528b49cfd4c3e5a9489ba7f85 /support/support_test_main.c
parent9c30df69c485ba93cdb4428c9bea6da371fb16ef (diff)
downloadglibc-5f0b84379024787bae24ad20e81d26ab2f082389.tar
glibc-5f0b84379024787bae24ad20e81d26ab2f082389.tar.gz
glibc-5f0b84379024787bae24ad20e81d26ab2f082389.tar.bz2
glibc-5f0b84379024787bae24ad20e81d26ab2f082389.zip
support: Add support for delayed test failure reporting
The new functions support_record_failure records a test failure, but does not terminate the process. The macros TEST_VERIFY and TEST_VERIFY_EXIT check that a condition is true.
Diffstat (limited to 'support/support_test_main.c')
-rw-r--r--support/support_test_main.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/support/support_test_main.c b/support/support_test_main.c
index 0582230aec..8d31e2f138 100644
--- a/support/support_test_main.c
+++ b/support/support_test_main.c
@@ -17,6 +17,7 @@
<http://www.gnu.org/licenses/>. */
#include <support/test-driver.h>
+#include <support/check.h>
#include <support/temp_file-internal.h>
#include <assert.h>
@@ -164,6 +165,17 @@ static bool test_main_called;
const char *test_dir = NULL;
+
+/* If test failure reporting has been linked in, it may contribute
+ additional test failures. */
+static int
+adjust_exit_status (int status)
+{
+ if (support_report_failure != NULL)
+ return support_report_failure (status);
+ return status;
+}
+
int
support_test_main (int argc, char **argv, const struct test_config *config)
{
@@ -300,7 +312,7 @@ support_test_main (int argc, char **argv, const struct test_config *config)
/* If we are not expected to fork run the function immediately. */
if (direct)
- return run_test_function (argc, argv, config);
+ return adjust_exit_status (run_test_function (argc, argv, config));
/* Set up the test environment:
- prevent core dumps
@@ -363,8 +375,8 @@ support_test_main (int argc, char **argv, const struct test_config *config)
if (config->expected_status == 0)
{
if (config->expected_signal == 0)
- /* Simply exit with the return value of the test. */
- return WEXITSTATUS (status);
+ /* Exit with the return value of the test. */
+ return adjust_exit_status (WEXITSTATUS (status));
else
{
printf ("Expected signal '%s' from child, got none\n",
@@ -382,7 +394,7 @@ support_test_main (int argc, char **argv, const struct test_config *config)
exit (1);
}
}
- return 0;
+ return adjust_exit_status (0);
}
/* Process was killed by timer or other signal. */
else
@@ -401,6 +413,6 @@ support_test_main (int argc, char **argv, const struct test_config *config)
exit (1);
}
- return 0;
+ return adjust_exit_status (0);
}
}