diff --git a/test/runner-unix.c b/test/runner-unix.c index c7cf9a139..1a54a1adb 100644 --- a/test/runner-unix.c +++ b/test/runner-unix.c @@ -55,8 +55,13 @@ void platform_init(int argc, char **argv) { /* Invoke "argv[0] test-name [test-part]". Store process info in *p. */ /* Make sure that all stdio output of the processes is buffered up. */ -int process_start(char* name, char* part, process_info_t* p) { - FILE* stdout_file = tmpfile(); +int process_start(char* name, char* part, process_info_t* p, int is_helper) { + FILE* stdout_file; + const char* arg; + char* args[16]; + int n; + + stdout_file = tmpfile(); if (!stdout_file) { perror("tmpfile"); return -1; @@ -74,11 +79,28 @@ int process_start(char* name, char* part, process_info_t* p) { if (pid == 0) { /* child */ + arg = getenv("UV_USE_VALGRIND"); + n = 0; + + /* Disable valgrind for helpers, it complains about helpers leaking memory. + * They're killed after the test and as such never get a chance to clean up. + */ + if (is_helper == 0 && arg != NULL && atoi(arg) != 0) { + args[n++] = "valgrind"; + args[n++] = "--quiet"; + args[n++] = "--leak-check=full"; + args[n++] = "--show-reachable=yes"; + args[n++] = "--error-exitcode=125"; + } + + args[n++] = executable_path; + args[n++] = name; + args[n++] = part; + args[n++] = NULL; + dup2(fileno(stdout_file), STDOUT_FILENO); dup2(fileno(stdout_file), STDERR_FILENO); - - char* args[] = { executable_path, name, part, NULL }; - execvp(executable_path, args); + execvp(args[0], args); perror("execvp()"); _exit(127); } diff --git a/test/runner-win.c b/test/runner-win.c index 2f44ff33a..c304a04a1 100644 --- a/test/runner-win.c +++ b/test/runner-win.c @@ -57,7 +57,7 @@ void platform_init(int argc, char **argv) { } -int process_start(char *name, char *part, process_info_t *p) { +int process_start(char *name, char *part, process_info_t *p, int is_helper) { HANDLE file = INVALID_HANDLE_VALUE; HANDLE nul = INVALID_HANDLE_VALUE; WCHAR path[MAX_PATH], filename[MAX_PATH]; diff --git a/test/runner.c b/test/runner.c index b34acc843..55d2a37ed 100644 --- a/test/runner.c +++ b/test/runner.c @@ -147,7 +147,8 @@ int run_test(const char* test, int timeout, int benchmark_output) { if (process_start(task->task_name, task->process_name, - &processes[process_count]) == -1) { + &processes[process_count], + 1 /* is_helper */) == -1) { snprintf(errmsg, sizeof errmsg, "Process `%s` failed to start.", @@ -173,7 +174,8 @@ int run_test(const char* test, int timeout, int benchmark_output) { if (process_start(task->task_name, task->process_name, - &processes[process_count]) == -1) { + &processes[process_count], + 0 /* !is_helper */) == -1) { snprintf(errmsg, sizeof errmsg, "Process `%s` failed to start.", diff --git a/test/runner.h b/test/runner.h index 5cee695ed..0358d7e25 100644 --- a/test/runner.h +++ b/test/runner.h @@ -127,7 +127,7 @@ void platform_init(); /* Invoke "argv[0] test-name [test-part]". Store process info in *p. */ /* Make sure that all stdio output of the processes is buffered up. */ -int process_start(char *name, char* part, process_info_t *p); +int process_start(char *name, char* part, process_info_t *p, int is_helper); /* Wait for all `n` processes in `vec` to terminate. */ /* Time out after `timeout` msec, or never if timeout == -1 */