summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2022-06-30 00:45:08 -0400
committerKent Overstreet <kent.overstreet@gmail.com>2022-06-30 00:47:17 -0400
commit9ec8fbadfb399a4d734935cf5f1915b5d33e95c1 (patch)
tree800d60f2595a8e59629f6e95f06b56641fd1068b
parent40a012d64d8a651a4190d2d5186ca5270a9e98d8 (diff)
qemu-wrapper: Handle tests with / in their name
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
-rw-r--r--lib/qemu-wrapper.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/lib/qemu-wrapper.c b/lib/qemu-wrapper.c
index 9d4b99e..deda943 100644
--- a/lib/qemu-wrapper.c
+++ b/lib/qemu-wrapper.c
@@ -39,7 +39,7 @@ static char *mprintf(const char *fmt, ...)
static pid_t child;
static int childfd;
-static const char *testname;
+static char *testname;
static void alarm_handler(int sig)
{
@@ -106,15 +106,20 @@ static const char *str_starts_with(const char *str, const char *prefix)
return str + len;
}
-static const char *test_starts(const char *line)
+static char *test_starts(const char *line)
{
- return str_starts_with(line, "========= TEST ");
-}
+ const char *testname = str_starts_with(line, "========= TEST ");
+ char *ret, *p;
-static bool test_ends(char *line)
-{
- return str_starts_with(line, "========= PASSED ") ||
- str_starts_with(line, "========= FAILED ");
+ if (!testname)
+ return NULL;
+
+ ret = strdup(testname);
+
+ while ((p = strchr(ret, '/')))
+ *p = '.';
+
+ return ret;
}
static FILE *popen_with_pid(char *argv[], pid_t *child)
@@ -173,6 +178,12 @@ static char *output_line(const char *line, struct timespec start)
return mprintf("%.5lu %s\n", elapsed, line);
}
+static bool test_ends(char *line)
+{
+ return str_starts_with(line, "========= PASSED ") ||
+ str_starts_with(line, "========= FAILED ");
+}
+
int main(int argc, char *argv[])
{
bool exit_on_success = false;
@@ -249,6 +260,7 @@ again:
if (test_logfile && testname) {
fclose(test_logfile);
test_logfile = NULL;
+ free(testname);
testname = NULL;
}
@@ -262,8 +274,11 @@ again:
test_logfile = NULL;
}
- if (testname)
+ if (testname) {
test_logfile = log_open(logdir, basename, testname);
+ free(testname);
+ testname = NULL;
+ }
if (exit_on_failure && str_starts_with(line, "TEST FAILED"))
break;