mirror of
https://github.com/cuberite/libdeflate.git
synced 2025-09-13 06:15:51 -04:00
run_tests.sh: portability improvements
Support running the run_tests.sh script on more types of systems.
This commit is contained in:
parent
aadf6d8198
commit
8067f44e8c
@ -144,7 +144,7 @@ gunzip -kfd file.gz
|
|||||||
|
|
||||||
|
|
||||||
begin_test 'Compression levels'
|
begin_test 'Compression levels'
|
||||||
if [ "$GZIP" = /usr/bin/gzip ]; then
|
if [ "$GZIP" = /bin/gzip ]; then
|
||||||
assert_error '\<invalid option\>' gzip -10
|
assert_error '\<invalid option\>' gzip -10
|
||||||
max_level=9
|
max_level=9
|
||||||
else
|
else
|
||||||
|
@ -94,6 +94,27 @@ test_group_included() {
|
|||||||
(( included ))
|
(( included ))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
have_valgrind() {
|
||||||
|
if ! type -P valgrind > /dev/null; then
|
||||||
|
log_skip "valgrind not found; can't run tests with valgrind"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
have_ubsan() {
|
||||||
|
if ! type -P clang > /dev/null; then
|
||||||
|
log_skip "clang not found; can't run tests with UBSAN"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
have_python() {
|
||||||
|
if ! type -P python3 > /dev/null; then
|
||||||
|
log_skip "Python not found"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
native_build_and_test() {
|
native_build_and_test() {
|
||||||
@ -104,15 +125,21 @@ native_build_and_test() {
|
|||||||
|
|
||||||
native_tests() {
|
native_tests() {
|
||||||
test_group_included native || return 0
|
test_group_included native || return 0
|
||||||
local compiler cflags compilers=(gcc)
|
local compiler compilers_to_try=(gcc)
|
||||||
|
local cflags cflags_to_try=("")
|
||||||
shopt -s nullglob
|
shopt -s nullglob
|
||||||
compilers+=(/usr/bin/gcc-[0-9]*)
|
compilers_to_try+=(/usr/bin/gcc-[0-9]*)
|
||||||
compilers+=(/usr/bin/clang-[0-9]*)
|
compilers_to_try+=(/usr/bin/clang-[0-9]*)
|
||||||
compilers+=(/opt/gcc*/bin/gcc)
|
compilers_to_try+=(/opt/gcc*/bin/gcc)
|
||||||
compilers+=(/opt/clang*/bin/clang)
|
compilers_to_try+=(/opt/clang*/bin/clang)
|
||||||
shopt -u nullglob
|
shopt -u nullglob
|
||||||
for compiler in ${compilers[@]}; do
|
|
||||||
for cflags in "" "-march=native" "-m32"; do
|
if [ "$(uname -m)" = "x86_64" ]; then
|
||||||
|
cflags_to_try+=("-march=native")
|
||||||
|
cflags_to_try+=("-m32")
|
||||||
|
fi
|
||||||
|
for compiler in ${compilers_to_try[@]}; do
|
||||||
|
for cflags in "${cflags_to_try[@]}"; do
|
||||||
if [ "$compiler" = "/usr/bin/gcc-4.8" -a \
|
if [ "$compiler" = "/usr/bin/gcc-4.8" -a \
|
||||||
"$cflags" = "-m32" ]; then
|
"$cflags" = "-m32" ]; then
|
||||||
continue
|
continue
|
||||||
@ -124,11 +151,15 @@ native_tests() {
|
|||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
log "Running tests with Valgrind"
|
if have_valgrind; then
|
||||||
WRAPPER="$VALGRIND" native_build_and_test
|
log "Running tests with Valgrind"
|
||||||
|
WRAPPER="$VALGRIND" native_build_and_test
|
||||||
|
fi
|
||||||
|
|
||||||
log "Running tests with undefined behavior sanitizer"
|
if have_ubsan; then
|
||||||
WRAPPER= native_build_and_test CC=clang CFLAGS="$SANITIZE_CFLAGS"
|
log "Running tests with undefined behavior sanitizer"
|
||||||
|
WRAPPER= native_build_and_test CC=clang CFLAGS="$SANITIZE_CFLAGS"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
@ -183,6 +214,10 @@ android_tests() {
|
|||||||
|
|
||||||
mips_tests() {
|
mips_tests() {
|
||||||
test_group_included mips || return 0
|
test_group_included mips || return 0
|
||||||
|
if [ "$(hostname)" != "zzz" ] || [ "$(uname -m)" != "x86_64" ]; then
|
||||||
|
log_skip "MIPS tests are not supported on this host"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
if ! ping -c 1 dd-wrt > /dev/null; then
|
if ! ping -c 1 dd-wrt > /dev/null; then
|
||||||
log_skip "Can't run MIPS tests: dd-wrt system not available"
|
log_skip "Can't run MIPS tests: dd-wrt system not available"
|
||||||
return 0
|
return 0
|
||||||
@ -229,8 +264,8 @@ gzip_tests() {
|
|||||||
|
|
||||||
local gzip gunzip
|
local gzip gunzip
|
||||||
run_cmd make -j$NPROC gzip gunzip
|
run_cmd make -j$NPROC gzip gunzip
|
||||||
for gzip in "$PWD/gzip" /usr/bin/gzip; do
|
for gzip in "$PWD/gzip" /bin/gzip; do
|
||||||
for gunzip in "$PWD/gunzip" /usr/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," \
|
||||||
"GUNZIP=$gunzip"
|
"GUNZIP=$gunzip"
|
||||||
GZIP="$gzip" GUNZIP="$gunzip" SMOKEDATA="$SMOKEDATA" \
|
GZIP="$gzip" GUNZIP="$gunzip" SMOKEDATA="$SMOKEDATA" \
|
||||||
@ -238,14 +273,18 @@ gzip_tests() {
|
|||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
log "Running gzip program tests with Valgrind"
|
if have_valgrind; then
|
||||||
GZIP="$VALGRIND $PWD/gzip" GUNZIP="$VALGRIND $PWD/gunzip" \
|
log "Running gzip program tests with Valgrind"
|
||||||
SMOKEDATA="$SMOKEDATA" ./tools/gzip_tests.sh
|
GZIP="$VALGRIND $PWD/gzip" GUNZIP="$VALGRIND $PWD/gunzip" \
|
||||||
|
SMOKEDATA="$SMOKEDATA" ./tools/gzip_tests.sh
|
||||||
|
fi
|
||||||
|
|
||||||
log "Running gzip program tests with undefined behavior sanitizer"
|
if have_ubsan; then
|
||||||
run_cmd make -j$NPROC CC=clang CFLAGS="$SANITIZE_CFLAGS" gzip gunzip
|
log "Running gzip program tests with undefined behavior sanitizer"
|
||||||
GZIP="$PWD/gzip" GUNZIP="$PWD/gunzip" \
|
run_cmd make -j$NPROC CC=clang CFLAGS="$SANITIZE_CFLAGS" gzip gunzip
|
||||||
SMOKEDATA="$SMOKEDATA" ./tools/gzip_tests.sh
|
GZIP="$PWD/gzip" GUNZIP="$PWD/gunzip" \
|
||||||
|
SMOKEDATA="$SMOKEDATA" ./tools/gzip_tests.sh
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
@ -265,17 +304,19 @@ edge_case_tests() {
|
|||||||
# Note: on random data, this situation is extremely unlikely if the
|
# Note: on random data, this situation is extremely unlikely if the
|
||||||
# compressor uses all matches it finds, since random data will on
|
# compressor uses all matches it finds, since random data will on
|
||||||
# average have a 3-byte match every (256**3)/32768 = 512 bytes.
|
# average have a 3-byte match every (256**3)/32768 = 512 bytes.
|
||||||
python3 > "$TMPFILE" << EOF
|
if have_python; then
|
||||||
|
python3 > "$TMPFILE" << EOF
|
||||||
import sys
|
import sys
|
||||||
for i in range(2):
|
for i in range(2):
|
||||||
for stride in range(1,251):
|
for stride in range(1,251):
|
||||||
b = bytes(stride*multiple % 251 for multiple in range(251))
|
b = bytes(stride*multiple % 251 for multiple in range(251))
|
||||||
sys.stdout.buffer.write(b)
|
sys.stdout.buffer.write(b)
|
||||||
EOF
|
EOF
|
||||||
run_cmd make -j$NPROC benchmark
|
run_cmd make -j$NPROC benchmark
|
||||||
run_cmd ./benchmark -3 "$TMPFILE"
|
run_cmd ./benchmark -3 "$TMPFILE"
|
||||||
run_cmd ./benchmark -6 "$TMPFILE"
|
run_cmd ./benchmark -6 "$TMPFILE"
|
||||||
run_cmd ./benchmark -12 "$TMPFILE"
|
run_cmd ./benchmark -12 "$TMPFILE"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
Loading…
x
Reference in New Issue
Block a user