From 40e6f7a06355cba0305e987ca6536b212e0718cf Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 16 Feb 2014 23:54:15 +0000 Subject: tests: make tests to run parallel Unarguably this change makes test output to be more messy, but when I compare run time tells with clear numbers parallel is quicker. For me the quickness is important factor. Running test suite always after a change is preferrably quick, and if something is indicated to be broken it is ok to spend time in drilling down what happen. $ time ./tests/run.sh --parallel=5 [...] real 1m48.037s Same without parallelization. $ time ./tests/run.sh real 3m16.687s The default is changed to be parallel, where job count is same as number of CPUs. [kzak@redhat.com: - propagate --parallel into function.sh - don't use extra title for non-parallel execution - disable by default] Signed-off-by: Sami Kerola Signed-off-by: Karel Zak --- tests/functions.sh | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) (limited to 'tests/functions.sh') diff --git a/tests/functions.sh b/tests/functions.sh index c802136e2..5e2292d9b 100644 --- a/tests/functions.sh +++ b/tests/functions.sh @@ -31,8 +31,17 @@ function ts_canonicalize { fi } +function ts_report { + if [ "$TS_PARALLEL" == "yes" ]; then + echo "$TS_TITLE $1" + else + echo "$1" + fi + +} + function ts_skip_subtest { - echo " IGNORE ($1)" + ts_report " IGNORE ($1)" } function ts_skip { @@ -51,9 +60,9 @@ function ts_skip_nonroot { function ts_failed_subtest { if [ x"$1" == x"" ]; then - echo " FAILED ($TS_NS)" + ts_report " FAILED ($TS_NS)" else - echo " FAILED ($1)" + ts_report " FAILED ($1)" fi } @@ -64,9 +73,9 @@ function ts_failed { function ts_ok_subtest { if [ x"$1" == x"" ]; then - echo " OK" + ts_report " OK" else - echo " OK ($1)" + ts_report " OK ($1)" fi } @@ -162,6 +171,7 @@ function ts_init_env { ts_init_core_env TS_VERBOSE=$(ts_has_option "verbose" "$*") + TS_PARALLEL=$(ts_has_option "parallel" "$*") BLKID_FILE="$TS_OUTDIR/${TS_TESTNAME}.blkidtab" @@ -209,7 +219,12 @@ function ts_init_subtest { [ $TS_NSUBTESTS -eq 0 ] && echo TS_NSUBTESTS=$(( $TS_NSUBTESTS + 1 )) - printf "%16s: %-27s ..." "" "$TS_SUBNAME" + if [ "$TS_PARALLEL" == "yes" ]; then + TS_TITLE=$(printf "%13s: %-30s ...\n%16s: %-27s ..." "$TS_COMPONENT" "$TS_DESC" "" "$TS_SUBNAME") + else + TS_TITLE=$(printf "%16s: %-27s ..." "" "$TS_SUBNAME") + echo -n "$TS_TITLE" + fi } function ts_init { @@ -223,7 +238,12 @@ function ts_init { ts_init_env "$*" - printf "%13s: %-30s ..." "$TS_COMPONENT" "$TS_DESC" + if [ "$TS_PARALLEL" == "yes" ]; then + TS_TITLE=$(printf "%13s: %-30s ..." "$TS_COMPONENT" "$TS_DESC") + else + TS_TITLE=$(printf "%13s: %-30s ..." "$TS_COMPONENT" "$TS_DESC") + echo -n "$TS_TITLE" + fi [ "$is_fake" == "yes" ] && ts_skip "fake mode" [ "$TS_OPTIONAL" == "yes" -a "$is_force" != "yes" ] && ts_skip "optional" -- cgit v1.2.3-55-g7522