scripts/run_tests.sh: define $MAKE variable

... so that we don't have to remember to add -j everytime.  Also switch
to a better way of getting the number of processors.
This commit is contained in:
Eric Biggers 2020-10-18 14:21:26 -07:00
parent de4f3f4bb7
commit fb3bbaad0b

View File

@ -18,7 +18,8 @@ if [ -z "${TESTDATA:-}" ]; then
| head -c 1000000 > "$TESTDATA" | head -c 1000000 > "$TESTDATA"
fi fi
NPROC=$(grep -c processor /proc/cpuinfo) MAKE="make -j$(getconf _NPROCESSORS_ONLN)"
VALGRIND="valgrind --quiet --error-exitcode=100 --leak-check=full --errors-for-leak-kinds=all" VALGRIND="valgrind --quiet --error-exitcode=100 --leak-check=full --errors-for-leak-kinds=all"
SANITIZE_CFLAGS="-fsanitize=undefined -fno-sanitize-recover=undefined,integer" SANITIZE_CFLAGS="-fsanitize=undefined -fno-sanitize-recover=undefined,integer"
@ -39,8 +40,7 @@ native_build_and_test() {
# Build libdeflate, including the test programs. Set the special test # Build libdeflate, including the test programs. Set the special test
# support flag to get support for LIBDEFLATE_DISABLE_CPU_FEATURES. # support flag to get support for LIBDEFLATE_DISABLE_CPU_FEATURES.
make "$@" TEST_SUPPORT__DO_NOT_USE=1 \ $MAKE "$@" TEST_SUPPORT__DO_NOT_USE=1 all test_programs > /dev/null
-j$NPROC all test_programs > /dev/null
# When not using -march=native, run the tests multiple times with # When not using -march=native, run the tests multiple times with
# different combinations of CPU features disabled. This is needed to # different combinations of CPU features disabled. This is needed to
@ -138,7 +138,7 @@ freestanding_tests() {
gzip_tests() { gzip_tests() {
local gzip gunzip local gzip gunzip
run_cmd make -j$NPROC gzip gunzip run_cmd $MAKE gzip gunzip
for gzip in "$PWD/gzip" /bin/gzip; do for gzip in "$PWD/gzip" /bin/gzip; do
for gunzip in "$PWD/gunzip" /bin/gunzip; do for gunzip in "$PWD/gunzip" /bin/gunzip; do
log "Running gzip program tests with GZIP=$gzip," \ log "Running gzip program tests with GZIP=$gzip," \
@ -153,7 +153,7 @@ gzip_tests() {
TESTDATA="$TESTDATA" ./scripts/gzip_tests.sh TESTDATA="$TESTDATA" ./scripts/gzip_tests.sh
log "Running gzip program tests with undefined behavior sanitizer" log "Running gzip program tests with undefined behavior sanitizer"
run_cmd make -j$NPROC CC=clang CFLAGS="$SANITIZE_CFLAGS" gzip gunzip run_cmd $MAKE CC=clang CFLAGS="$SANITIZE_CFLAGS" gzip gunzip
GZIP="$PWD/gzip" GUNZIP="$PWD/gunzip" \ GZIP="$PWD/gzip" GUNZIP="$PWD/gunzip" \
TESTDATA="$TESTDATA" ./scripts/gzip_tests.sh TESTDATA="$TESTDATA" ./scripts/gzip_tests.sh
} }