summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2022-07-01 20:08:24 -0400
committerKent Overstreet <kent.overstreet@gmail.com>2022-07-01 20:26:13 -0400
commit8c750e10b226a44587950a3e1e2c426436741e30 (patch)
tree67fb185a963a5e6c803eafd9b5a06b29e8583ac1
parentea2f5854a8e8bc520820face57d965436f4d8554 (diff)
qemu-wrapper: Print timeout on test timeout
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
-rw-r--r--lib/qemu-wrapper.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/qemu-wrapper.c b/lib/qemu-wrapper.c
index 1783cf6..c58c855 100644
--- a/lib/qemu-wrapper.c
+++ b/lib/qemu-wrapper.c
@@ -40,11 +40,12 @@ static char *mprintf(const char *fmt, ...)
static pid_t child;
static int childfd;
static char *testname;
+static unsigned long timeout;
static void alarm_handler(int sig)
{
- char *msg = mprintf("========= FAILED TIMEOUT %s\n",
- testname ?: "(no test)");
+ char *msg = mprintf("========= FAILED TIMEOUT %s in %lus\n",
+ testname ?: "(no test)", timeout);
if (write(childfd, msg, strlen(msg)) != strlen(msg))
die("write error in alarm handler");
@@ -162,8 +163,10 @@ static FILE *popen_with_pid(char *argv[], pid_t *child)
static void update_watchdog(const char *line)
{
const char *new_watchdog = str_starts_with(line, "WATCHDOG ");
- if (new_watchdog)
- alarm(atoi(new_watchdog));
+ if (new_watchdog) {
+ timeout = atol(new_watchdog);
+ alarm(timeout);
+ }
}
static char *output_line(const char *line, struct timespec start)
@@ -181,14 +184,14 @@ static char *output_line(const char *line, struct timespec start)
static bool test_ends(char *line)
{
return str_starts_with(line, "========= PASSED ") ||
- str_starts_with(line, "========= FAILED ");
+ str_starts_with(line, "========= FAILED ") ||
+ str_starts_with(line, "========= NOTRUN");
}
int main(int argc, char *argv[])
{
bool exit_on_success = false;
bool exit_on_failure = false;
- unsigned long timeout = 0;
int opt, ret = EXIT_FAILURE;
struct timespec start;
char *logdir = NULL;