https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=0ce068434ec359324ff1e27f0c7bd5df8ae4e813
commit 0ce068434ec359324ff1e27f0c7bd5df8ae4e813
Author: Martin Cermak <mc...@re...>
Date: Mon May 5 14:23:16 2025 +0200
Run the LTP syscall tests in parallel
- Run the LTP syscall tests in parallel to save time.
- Allow for running only selected tests using TESTS env var.
Diff:
---
auxprogs/Makefile.am | 6 ++++++
auxprogs/ltp-tester.sh | 58 +++++++++++++++++++++++++++++++++++++-------------
2 files changed, 49 insertions(+), 15 deletions(-)
diff --git a/auxprogs/Makefile.am b/auxprogs/Makefile.am
index 9cec4f222b..3a2d0d1762 100644
--- a/auxprogs/Makefile.am
+++ b/auxprogs/Makefile.am
@@ -231,7 +231,13 @@ gsl-check: $(GSL_BUILD_DIR)/gsl-build
diff -u $(abs_top_srcdir)/auxprogs/gsl-1.6.out.x86.exp \
$(GSL_BUILD_DIR)/valgrind-gsl.out
+# Extract -jNUM from MAKEFLAGS.
+# Note that any spaces between -j and NUM have already been removed.
+# Also there will be only one (the last) -jNUM left in MAKEFLAGS.
+PARALLEL_JOBS=$(subst -j,,$(filter -j%,$(MAKEFLAGS)))
+
ltp-check: $(LTP_SRC_DIR)
+ PARALLEL_JOBS=$(PARALLEL_JOBS) \
LTP_SRC_DIR=$(LTP_SRC_DIR) \
VALGRIND=$(abs_top_builddir)/vg-in-place \
$(abs_top_srcdir)/auxprogs/ltp-tester.sh
diff --git a/auxprogs/ltp-tester.sh b/auxprogs/ltp-tester.sh
index 000cfaa7f3..e31f8a6b12 100755
--- a/auxprogs/ltp-tester.sh
+++ b/auxprogs/ltp-tester.sh
@@ -13,31 +13,30 @@ LOGDIR=${LOGDIR:-$LTP_SRC_DIR/valgrind-ltp-logs}
SUMMARY_LOG="$LOGDIR/summary.log"
DIFFCMD="diff -u"
VALGRIND="${VALGRIND:-$LTP_SRC_DIR/../../../vg-in-place}"
+# For parallel testing, consider IO intensive jobs, take nproc into account
+PARALLEL_JOBS=${PARALLEL_JOBS:-$(nproc)}
+# TESTS env var may be specified to restrict testing to selected test cases
# Initialize LOGDIR
-mkdir -p $LOGDIR; rm -rf $LOGDIR/*
+mkdir -p $LOGDIR; rm -rf ${LOGDIR:?}/*
myLog ()
{
msg="$1"
echo "$msg"
- echo -e "FAIL: $msg" >> $SUMMARY_LOG
+ echo -e "FAIL: $msg" >> summary
}
-cd $LTP_SRC_DIR
-
-mapfile -t files < <(find testcases/kernel/syscalls -executable -and -type f \
- | sort | grep -v -f $ORIG_PWD/ltp-excludes.txt)
-c=${#files[@]}; i=0
-
-for test in "${files[@]}"; do
- dir=$(dirname $test)
- exe=$(basename $test)
+doTest ()
+{
+ t=$1
+ nr=$2
+ dir=$(dirname $t)
+ exe=$(basename $t)
l="$LOGDIR/$exe"
mkdir -p $l
- i=$((++i))
+ echo "[$nr/$c] Testing $exe ..." | tee -a $l/summary
pushd $dir >/dev/null
- echo "[$i/$c] Testing $exe ..." | tee -a $SUMMARY_LOG
PATH="$ORIG_PATH:$PWD"
./$exe >$l/log1std 2>$l/log1err ||:
$VALGRIND -q --tool=none --log-file=$l/log2 ./$exe >$l/log2std 2>$l/log2err ||:
@@ -60,7 +59,7 @@ for test in "${files[@]}"; do
myLog "${exe}: unempty log2:\n$(cat log2)"
fi
- if grep -f $ORIG_PWD/ltp-error-patterns.txt * > error-patterns-found.txt; then
+ if grep -f $ORIG_PWD/ltp-error-patterns.txt log* > error-patterns-found.txt; then
myLog "${exe}: error string found:\n$(cat error-patterns-found.txt)"
fi
@@ -73,7 +72,36 @@ for test in "${files[@]}"; do
fi
popd >/dev/null
popd >/dev/null
+}
+
+cd $LTP_SRC_DIR
+
+if [ -n "$TESTS" ]; then
+ echo "Running individual syscall tests specified in the TESTS env var ..."
+ mapfile -t files < <(find testcases/kernel/syscalls -executable -and -type f \
+ | sort | grep -f <(echo $TESTS | tr ' ' '\n' | sed 's/.*/\/\0$/'))
+else
+ echo "Running whole the LTP syscall testsuite ..."
+ mapfile -t files < <(find testcases/kernel/syscalls -executable -and -type f \
+ | sort | grep -v -f $ORIG_PWD/ltp-excludes.txt)
+fi
+
+c=${#files[@]}; i=0
+
+# Run tests in parallel
+for test in "${files[@]}"; do
+ while test "$(jobs -l | wc -l)" -gt $PARALLEL_JOBS; do sleep 0.1; done
+ i=$((++i))
+ doTest $test $i &
done
-echo "TESTING FINISHED, logs in $LOGDIR"
+wait
+# Reconstruct $SUMMARY_LOG
+for test in "${files[@]}"; do
+ exe=$(basename $test)
+ l="$LOGDIR/$exe"
+ cat $l/summary >> $SUMMARY_LOG
+done
+
+echo "TESTING FINISHED, logs in $LOGDIR"
|