From 9b414faea2d8df2e2d14c2e576f7197ce310914a Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 27 May 2019 14:28:24 +1000 Subject: [PATCH] test: allow for a LITEST_JOBS environment variable valgrind struggles with too many parallel jobs, too easy to hit timeouts. Let's reduce this for the valgrind runs. Meson doesn't let us pass arguments through depending on the setup, so let's make this an environment value. Signed-off-by: Peter Hutterer --- meson.build | 3 +++ test/litest.c | 11 ++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 0c088d16..f9ddadd8 100644 --- a/meson.build +++ b/meson.build @@ -889,6 +889,8 @@ if get_option('tests') valgrind = find_program('valgrind', required : false) if valgrind.found() + valgrind_env = environment() + valgrind_env.set('LITEST_JOBS', '4') valgrind_suppressions_file = join_paths(dir_src_test, 'valgrind.suppressions') add_test_setup('valgrind', exe_wrapper : [ valgrind, @@ -896,6 +898,7 @@ if get_option('tests') '--gen-suppressions=all', '--error-exitcode=3', '--suppressions=' + valgrind_suppressions_file ], + env : valgrind_env, timeout_multiplier : 100) else message('valgrind not found, disabling valgrind test suite') diff --git a/test/litest.c b/test/litest.c index 8504061c..0fab117b 100644 --- a/test/litest.c +++ b/test/litest.c @@ -3962,6 +3962,7 @@ litest_parse_argv(int argc, char **argv) JOBS_CUSTOM } want_jobs = JOBS_DEFAULT; char *builddir; + char *jobs_env; /* If we are not running from the builddir, we assume we're running * against the system as installed */ @@ -3973,6 +3974,13 @@ litest_parse_argv(int argc, char **argv) if (in_debugger) want_jobs = JOBS_SINGLE; + if ((jobs_env = getenv("LITEST_JOBS"))) { + if (!safe_atoi(jobs_env, &jobs)) { + fprintf(stderr, "LITEST_JOBS environment variable must be positive integer\n"); + exit(EXIT_FAILURE); + } + } + while(1) { int c; int option_index = 0; @@ -3997,7 +4005,8 @@ litest_parse_argv(int argc, char **argv) " --verbose\n" " Enable verbose output\n" " --jobs 8\n" - " Number of parallel test suites to run (default: 8)\n" + " Number of parallel test suites to run (default: 8).\n" + " This overrides the LITEST_JOBS environment variable.\n" " --list\n" " List all tests\n" "\n"