summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2022-07-06 17:43:15 -0400
committerKent Overstreet <kent.overstreet@gmail.com>2022-07-07 23:52:08 -0400
commit75abe03bfcaedd96a2d60e07fb6b06c0a46dcc2e (patch)
treeae72ced1ffb3b110cf4a86437a8b5d9d27c972bb
parent588cd716b625e7645f3bce0a3758dc16ed5de934 (diff)
qemu-wrapper is now responsible for writing test status
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
-rw-r--r--ci/_test-git-branch.sh1
-rw-r--r--lib/qemu-wrapper.c43
2 files changed, 29 insertions, 15 deletions
diff --git a/ci/_test-git-branch.sh b/ci/_test-git-branch.sh
index d4efd3e..979940f 100644
--- a/ci/_test-git-branch.sh
+++ b/ci/_test-git-branch.sh
@@ -70,7 +70,6 @@ while true; do
fi
for log in $(find ktest-out/out -name log); do
- tail -n1 "$log" > $(dirname "$log")/status
brotli --rm -9 "$log"
done
diff --git a/lib/qemu-wrapper.c b/lib/qemu-wrapper.c
index 12af309..08d3726 100644
--- a/lib/qemu-wrapper.c
+++ b/lib/qemu-wrapper.c
@@ -82,17 +82,23 @@ static void usage(void)
" -h Display this help and exit\n");
}
-static char *log_path(const char *testname)
+static FILE *test_file_open(const char *fname)
{
- return !testname
- ? mprintf("%s/%s", logdir, test_basename)
- : mprintf("%s/%s.%s/log", logdir, test_basename, testname);
+ char *path = mprintf("%s/%s.%s/%s", logdir, test_basename,
+ current_test, fname);
+
+ FILE *f = fopen(path, "w");
+ if (!f)
+ die("error opening %s: %m", path);
+
+ free(path);
+ setlinebuf(f);
+ return f;
}
-static FILE *log_open(const char *testname)
+static FILE *log_open()
{
- char *path = log_path(testname);
-
+ char *path = mprintf("%s/%s", logdir, test_basename);
FILE *f = fopen(path, "w");
if (!f)
die("error opening %s: %m", path);
@@ -189,22 +195,29 @@ static void update_watchdog(const char *line)
}
}
+static void write_test_status(const char *status)
+{
+ FILE *f = test_file_open("status");
+
+ fputs(status, f);
+ fclose(f);
+}
+
static void test_start(char *new_test, struct timespec now)
{
free(current_test);
current_test = new_test;
current_test_start = now;
- current_test_log = log_open(new_test);
+ current_test_log = test_file_open("log");
+
+ write_test_status("TEST FAILED");
}
static void test_end(struct timespec now)
{
- char *duration_path = mprintf("%s/%s.%s/duration",
- logdir, test_basename, current_test);
- FILE *duration = fopen(duration_path, "w");
+ FILE *duration = test_file_open("duration");
fprintf(duration, "%li", now.tv_sec - current_test_start.tv_sec);
fclose(duration);
- free(duration_path);
fclose(current_test_log);
current_test_log = NULL;
@@ -260,7 +273,7 @@ int main(int argc, char *argv[])
FILE *childf = popen_with_pid(argv + optind, &child);
- FILE *logfile = log_open(NULL);
+ FILE *logfile = log_open();
size_t n = 0;
ssize_t len;
@@ -296,8 +309,10 @@ again:
fputs(output, logfile);
fputs(output, stdout);
- if (current_test_log && test_is_ending(line))
+ if (current_test_log && test_is_ending(line)) {
+ write_test_status(line);
test_end(now);
+ }
if (exit_on_failure && str_starts_with(line, "TEST FAILED"))
break;