From 0f37283dae83f576f04c114ce673f54ddd8a740f Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Sat, 8 Feb 2020 13:12:45 +0100 Subject: [PATCH] test: add UV_TIMEOUT_MULTIPLIER environment var MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add an environment variable that lets people running the test suite specify a timeout multiplier. Useful when running the tests on slow machines. Fixes: https://github.com/libuv/libuv/issues/2678 PR-URL: https://github.com/libuv/libuv/pull/2679 Reviewed-By: Richard Lau Reviewed-By: Colin Ihrig Reviewed-By: Saúl Ibarra Corretgé Reviewed-By: Santiago Gimeno --- README.md | 7 +++++++ test/runner.c | 19 ++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c040b4c1..9c785da8 100644 --- a/README.md +++ b/README.md @@ -347,6 +347,13 @@ $ make -C out $ ./out/Debug/run-tests ``` +Some tests are timing sensitive. Relaxing test timeouts may be necessary +on slow or overloaded machines: + +```bash +$ env UV_TEST_TIMEOUT_MULTIPLIER=2 ./out/Debug/run-tests # 10s instead of 5s +``` + #### Run one test The list of all tests is in `test/test-list.h`. diff --git a/test/runner.c b/test/runner.c index a0f5df89..bb50b43b 100644 --- a/test/runner.c +++ b/test/runner.c @@ -20,6 +20,7 @@ */ #include +#include #include #include "runner.h" @@ -167,6 +168,7 @@ int run_test(const char* test, process_info_t processes[1024]; process_info_t *main_proc; task_entry_t* task; + int timeout_multiplier; int process_count; int result; int status; @@ -249,7 +251,22 @@ int run_test(const char* test, goto out; } - result = process_wait(main_proc, 1, task->timeout); + timeout_multiplier = 1; +#ifndef _WIN32 + do { + const char* var; + + var = getenv("UV_TEST_TIMEOUT_MULTIPLIER"); + if (var == NULL) + break; + + timeout_multiplier = atoi(var); + if (timeout_multiplier <= 0) + timeout_multiplier = 1; + } while (0); +#endif + + result = process_wait(main_proc, 1, task->timeout * timeout_multiplier); if (result == -1) { FATAL("process_wait failed"); } else if (result == -2) {