summaryrefslogtreecommitdiff
path: root/runner/executor.c
diff options
context:
space:
mode:
authorPetri Latvala <petri.latvala@intel.com>2020-02-17 16:50:42 +0200
committerPetri Latvala <petri.latvala@intel.com>2020-02-19 12:34:36 +0200
commitdfba090e720ed4e043158887f1ba6a76059491e8 (patch)
treed87228d0d72dafb197db0f42bcc3845de9cea9c7 /runner/executor.c
parent4dce5cf1f39192656e113260e062e7f6782a4b46 (diff)
runner: Introduce per-test timeouts
A new config option, --per-test-timeout, sets a time a single test cannot exceed without getting itself killed. The time resets when starting a subtest or a dynamic subtest, so an execution with --per-test-timeout=20 can indeed go over 20 seconds a long as it launches a dynamic subtest within that time. As a bonus, verbose log level from runner now also prints dynamic subtest begin/result. Signed-off-by: Petri Latvala <petri.latvala@intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'runner/executor.c')
-rw-r--r--runner/executor.c34
1 files changed, 31 insertions, 3 deletions
diff --git a/runner/executor.c b/runner/executor.c
index 33610c9e..72e45b65 100644
--- a/runner/executor.c
+++ b/runner/executor.c
@@ -676,6 +676,7 @@ static const char *need_to_timeout(struct settings *settings,
int killed,
unsigned long taints,
double time_since_activity,
+ double time_since_subtest,
double time_since_kill)
{
if (killed) {
@@ -712,10 +713,16 @@ static const char *need_to_timeout(struct settings *settings,
is_tainted(taints))
return "Killing the test because the kernel is tainted.\n";
+ if (settings->per_test_timeout != 0 &&
+ time_since_subtest > settings->per_test_timeout) {
+ show_kernel_task_state();
+ return "Per-test timeout exceeded. Killing the current test with SIGQUIT.\n";
+ }
+
if (settings->inactivity_timeout != 0 &&
time_since_activity > settings->inactivity_timeout) {
show_kernel_task_state();
- return "Timeout. Killing the current test with SIGQUIT.\n";
+ return "Inactivity timeout exceeded. Killing the current test with SIGQUIT.\n";
}
return NULL;
@@ -759,12 +766,12 @@ static int monitor_output(pid_t child,
const int interval_length = 1;
int wd_timeout;
int killed = 0; /* 0 if not killed, signal number otherwise */
- struct timespec time_beg, time_now, time_last_activity, time_killed;
+ struct timespec time_beg, time_now, time_last_activity, time_last_subtest, time_killed;
unsigned long taints = 0;
bool aborting = false;
igt_gettime(&time_beg);
- time_last_activity = time_killed = time_beg;
+ time_last_activity = time_last_subtest = time_killed = time_beg;
if (errfd > nfds)
nfds = errfd;
@@ -823,6 +830,7 @@ static int monitor_output(pid_t child,
timeout_reason = need_to_timeout(settings, killed, tainted(&taints),
igt_time_elapsed(&time_last_activity, &time_now),
+ igt_time_elapsed(&time_last_subtest, &time_now),
igt_time_elapsed(&time_killed, &time_now));
if (timeout_reason) {
@@ -893,6 +901,8 @@ static int monitor_output(pid_t child,
linelen - strlen(STARTING_SUBTEST));
current_subtest[linelen - strlen(STARTING_SUBTEST)] = '\0';
+ time_last_subtest = time_now;
+
if (settings->log_level >= LOG_LEVEL_VERBOSE) {
fwrite(outbuf, 1, linelen, stdout);
}
@@ -921,6 +931,24 @@ static int monitor_output(pid_t child,
}
}
}
+ if (linelen > strlen(STARTING_DYNAMIC_SUBTEST) &&
+ !memcmp(outbuf, STARTING_DYNAMIC_SUBTEST, strlen(STARTING_DYNAMIC_SUBTEST))) {
+ time_last_subtest = time_now;
+
+ if (settings->log_level >= LOG_LEVEL_VERBOSE) {
+ fwrite(outbuf, 1, linelen, stdout);
+ }
+ }
+ if (linelen > strlen(DYNAMIC_SUBTEST_RESULT) &&
+ !memcmp(outbuf, DYNAMIC_SUBTEST_RESULT, strlen(DYNAMIC_SUBTEST_RESULT))) {
+ char *delim = memchr(outbuf, ':', linelen);
+
+ if (delim != NULL) {
+ if (settings->log_level >= LOG_LEVEL_VERBOSE) {
+ fwrite(outbuf, 1, linelen, stdout);
+ }
+ }
+ }
memmove(outbuf, newline + 1, outbufsize - linelen);
outbufsize -= linelen;