1
0
mirror of https://github.com/libuv/libuv synced 2025-03-28 21:13:16 +00:00

test: add UV_TIMEOUT_MULTIPLIER environment var

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 <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
This commit is contained in:
Ben Noordhuis 2020-02-08 13:12:45 +01:00 committed by cjihrig
parent 92808aeab5
commit 0f37283dae
No known key found for this signature in database
GPG Key ID: 7434390BDBE9B9C5
2 changed files with 25 additions and 1 deletions

View File

@ -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`.

View File

@ -20,6 +20,7 @@
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#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) {