From 4c19425fa69cfb4f7de5225d676a26ef0b442e28 Mon Sep 17 00:00:00 2001 From: Paul Moore Date: Thu, 7 Jan 2021 21:22:18 -0500 Subject: tests: add support for the LIBSECCOMP_TSTCFG_JOBS env variable The LIBSECCOMP_TSTCFG_JOBS environment variable allows the caller to specify the number of test jobs through the environment as opposed to the command line. This is primarily useful for running the tests through scripts or via the 'make check' command. The LIBSECCOMP_TSTCFG_JOBS environment variable value behaves the same as the '-j ' command line argument. Reviewed-by: Tom Hromatka Signed-off-by: Paul Moore --- tests/regression | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/regression b/tests/regression index 4f3f2ac..25043af 100755 --- a/tests/regression +++ b/tests/regression @@ -96,6 +96,7 @@ libseccomp regression test automation script optional arguments: -h show this help message and exit -j JOBS run up to JOBS test jobs in parallel + can also be set via LIBSECCOMP_TSTCFG_JOBS env variable -m MODE specified the test mode [c (default), python] can also be set via LIBSECCOMP_TSTCFG_MODE_LIST env variable -a specifies all tests are to be run @@ -1075,11 +1076,7 @@ while getopts "ab:gj:l:m:s:t:T:vh" opt; do batch_count=$(($batch_count+1)) ;; j) - if [[ $OPTARG -lt 1 ]]; then - jobs=$(cat /proc/cpuinfo | grep "^processor" | wc -l) - else - jobs=$OPTARG - fi + jobs=$OPTARG ;; l) logfile="$OPTARG" @@ -1121,6 +1118,12 @@ done # use mode list from environment if provided [[ -z $mode_list && -n $LIBSECCOMP_TSTCFG_MODE_LIST ]] && mode_list=$LIBSECCOMP_TSTCFG_MODE_LIST +# use job count from environment if provided and do some sanity checking +[[ -n $LIBSECCOMP_TSTCFG_JOBS ]] && jobs=$LIBSECCOMP_TSTCFG_JOBS +if [[ $jobs -lt 1 ]]; then + jobs=$(cat /proc/cpuinfo | grep "^processor" | wc -l) +fi + # determine the mode test automatically if [[ -z $mode_list ]]; then # always perform the native c tests -- cgit v1.2.1