summaryrefslogtreecommitdiffstats
path: root/tools/regression
diff options
context:
space:
mode:
authorjmmv <jmmv@FreeBSD.org>2014-03-19 12:51:40 +0000
committerjmmv <jmmv@FreeBSD.org>2014-03-19 12:51:40 +0000
commit72c4c55b8dc505b695206d0ce122aa1363610966 (patch)
tree9bd34dcd021f4555c538f480129caf0e4844acb2 /tools/regression
parent6347abb8452f9f60737489ce782cf23fcd90354c (diff)
downloadFreeBSD-src-72c4c55b8dc505b695206d0ce122aa1363610966.zip
FreeBSD-src-72c4c55b8dc505b695206d0ce122aa1363610966.tar.gz
Make the priv test program exit with non-zero if any failures are detected.
And, mind you, this already returns a failure :-/
Diffstat (limited to 'tools/regression')
-rw-r--r--tools/regression/priv/main.c41
1 files changed, 33 insertions, 8 deletions
diff --git a/tools/regression/priv/main.c b/tools/regression/priv/main.c
index e594c44..c8318fa 100644
--- a/tools/regression/priv/main.c
+++ b/tools/regression/priv/main.c
@@ -53,6 +53,16 @@
#include "main.h"
/*
+ * If true, some test or preparatory step failed along the execution of this
+ * program.
+ *
+ * Intuitively, we would define a counter instead of a boolean. However,
+ * we fork to run the subtests and keeping proper track of the number of
+ * failed tests would be tricky and not provide any real value.
+ */
+static int something_failed = 0;
+
+/*
* Registration table of privilege tests. Each test registers a name, a test
* function, and a cleanup function to run after the test has completed,
* regardless of success/failure.
@@ -358,13 +368,18 @@ expect(const char *test, int error, int expected_error, int expected_errno)
{
if (error == 0) {
- if (expected_error != 0)
+ if (expected_error != 0) {
+ something_failed = 1;
warnx("%s: returned 0", test);
+ }
} else {
- if (expected_error == 0)
+ if (expected_error == 0) {
+ something_failed = 1;
warn("%s: returned (%d, %d)", test, error, errno);
- else if (expected_errno != errno)
+ } else if (expected_errno != errno) {
+ something_failed = 1;
warn("%s: returned (%d, %d)", test, error, errno);
+ }
}
}
@@ -488,14 +503,24 @@ run(struct test *test, int asroot, int injail)
run_child(test, asroot, injail);
fflush(stdout);
fflush(stderr);
- exit(0);
+ exit(something_failed ? EXIT_FAILURE : EXIT_SUCCESS);
} else {
while (1) {
- pid = waitpid(childpid, NULL, 0);
- if (pid == -1)
+ int status;
+ pid = waitpid(childpid, &status, 0);
+ if (pid == -1) {
+ something_failed = 1;
warn("test: waitpid %s", test->t_name);
- if (pid == childpid)
+ }
+ if (pid == childpid) {
+ if (WIFEXITED(status) &&
+ WEXITSTATUS(status) == EXIT_SUCCESS) {
+ /* All good in the subprocess! */
+ } else {
+ something_failed = 1;
+ }
break;
+ }
}
}
fflush(stdout);
@@ -530,5 +555,5 @@ main(int argc, char *argv[])
run(&tests[i], 1, 0);
run(&tests[i], 1, 1);
}
- return (0);
+ return (something_failed ? EXIT_FAILURE : EXIT_SUCCESS);
}
OpenPOWER on IntegriCloud