2017-09-05 22:29:50 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# Extended tests: Run a few more options other than make check
|
|
|
|
|
|
|
|
set -xe #exit on fail
|
|
|
|
|
|
|
|
# Defaults
|
|
|
|
cpus=1
|
|
|
|
S=$RANDOM
|
|
|
|
MAKE=make
|
|
|
|
READLINK=readlink
|
|
|
|
test_level=check
|
|
|
|
build_opt=''
|
|
|
|
msg=''
|
|
|
|
|
|
|
|
# Override defaults if exist
|
|
|
|
command -V gmake >/dev/null 2>&1 && MAKE=gmake
|
|
|
|
command -V greadlink >/dev/null 2>&1 && READLINK=greadlink
|
|
|
|
[ -n "$CC" ] && build_opt+="CC=$CC "
|
|
|
|
[ -n "$AS" ] && build_opt+="AS=$AS "
|
|
|
|
|
|
|
|
out="$PWD"
|
|
|
|
src=$($READLINK -f $(dirname $0))/..
|
2018-08-14 22:31:27 +02:00
|
|
|
source $src/tools/test_tools.sh
|
2017-09-05 22:29:50 +02:00
|
|
|
cd "$src"
|
|
|
|
|
|
|
|
# Run on mult cpus
|
|
|
|
if command -V lscpu >/dev/null 2>&1; then
|
|
|
|
cpus=`lscpu -p | tail -1 | cut -d, -f 2`
|
|
|
|
cpus=$(($cpus + 1))
|
|
|
|
elif command -V sysctl; then
|
|
|
|
if sysctl -n hw.ncpu >/dev/null 2>&1; then
|
|
|
|
cpus=$(sysctl -n hw.ncpu)
|
|
|
|
cpus=$(($cpus + 1))
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
echo "Using $cpus cpu threads"
|
|
|
|
|
|
|
|
if [ -z "$S" ]; then
|
|
|
|
S=`tr -cd 0-9 </dev/urandom | head -c 4 | sed -e 's/^0*/1/g'`
|
|
|
|
[ "$S" -gt 0 ] 2> /dev/null || S="123"
|
|
|
|
fi
|
|
|
|
msg+="Running with TEST_SEED=$S".$'\n'
|
|
|
|
|
|
|
|
# Fix Darwin issues
|
|
|
|
if uname | grep -q 'Darwin' 2>&1; then
|
|
|
|
export SED=`which sed`
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Check for test libs to add
|
|
|
|
if command -V ldconfig >/dev/null 2>&1; then
|
|
|
|
if ldconfig -p | grep -q libz.so; then
|
|
|
|
test_level=test
|
|
|
|
msg+=$'With extra tests\n'
|
|
|
|
fi
|
|
|
|
if ldconfig -p | grep -q libefence.so; then
|
|
|
|
build_opt+="LDFLAGS+='-lefence' "
|
|
|
|
msg+=$'With efence\n'
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Std makefile build test
|
|
|
|
$MAKE -f Makefile.unx clean
|
2018-08-14 22:31:27 +02:00
|
|
|
test_start "extended_build_test"
|
2017-09-05 22:29:50 +02:00
|
|
|
time $MAKE -f Makefile.unx -j $cpus $build_opt
|
2018-09-04 19:59:30 +02:00
|
|
|
test_end "extended_build_test" $?
|
2017-09-05 22:29:50 +02:00
|
|
|
msg+=$'Std makefile build: Pass\n'
|
|
|
|
|
|
|
|
# Check for gnu executable stack set
|
|
|
|
if command -V readelf >/dev/null 2>&1; then
|
2018-08-14 22:31:27 +02:00
|
|
|
test_start "stack_nx_check"
|
2017-09-05 22:29:50 +02:00
|
|
|
if readelf -W -l bin/libisal.so | grep 'GNU_STACK' | grep -q 'RWE'; then
|
|
|
|
echo $0: Stack NX check bin/libisal.so: Fail
|
2018-09-04 19:59:30 +02:00
|
|
|
test_end "stack_nx_check" 1
|
2017-09-05 22:29:50 +02:00
|
|
|
exit 1
|
|
|
|
else
|
2018-09-04 19:59:30 +02:00
|
|
|
test_end "stack_nx_check" 0
|
2017-09-05 22:29:50 +02:00
|
|
|
msg+=$'Stack NX check bin/lib/libisal.so: Pass\n'
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
msg+=$'Stack NX check not supported: Skip\n'
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Std makefile build perf tests
|
2018-08-14 22:31:27 +02:00
|
|
|
test_start "extended_perf_test"
|
2017-09-05 22:29:50 +02:00
|
|
|
time $MAKE -f Makefile.unx -j $cpus perfs
|
2018-09-04 19:59:30 +02:00
|
|
|
test_end "extended_perf_test" $?
|
2017-09-05 22:29:50 +02:00
|
|
|
msg+=$'Std makefile build perf: Pass\n'
|
|
|
|
|
|
|
|
# Std makefile run tests
|
2018-08-14 22:31:27 +02:00
|
|
|
test_start "extended_makefile_tests"
|
2017-12-12 00:14:06 +01:00
|
|
|
time $MAKE -f Makefile.unx -j $cpus $build_opt D="TEST_SEED=$S" $test_level
|
2018-09-04 19:59:30 +02:00
|
|
|
test_end "extended_makefile_tests" $?
|
2017-09-05 22:29:50 +02:00
|
|
|
msg+=$'Std makefile tests: Pass\n'
|
|
|
|
|
|
|
|
# Std makefile build other
|
2018-08-14 22:31:27 +02:00
|
|
|
test_start "extended_other_tests"
|
2017-12-12 00:14:06 +01:00
|
|
|
time $MAKE -f Makefile.unx -j $cpus $build_opt D="TEST_SEED=$S" other
|
2018-09-04 19:59:30 +02:00
|
|
|
test_end "extended_other_tests" $?
|
2017-09-05 22:29:50 +02:00
|
|
|
msg+=$'Other tests build: Pass\n'
|
|
|
|
|
|
|
|
# Try to pick a random src file
|
|
|
|
if command -V shuf >/dev/null 2>&1; then
|
|
|
|
in_file=$(find $src -type f -size +0 -name \*.c -o -name \*.asm -print 2>/dev/null | shuf | head -1 );
|
|
|
|
else
|
|
|
|
in_file=configure.ac
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo Other tests using $in_file
|
2018-08-14 22:31:27 +02:00
|
|
|
test_start "igzip_file_perf"
|
2017-09-05 22:29:50 +02:00
|
|
|
./igzip_file_perf $in_file
|
2018-09-04 19:59:30 +02:00
|
|
|
test_end "igzip_file_perf" $?
|
2018-08-14 22:31:27 +02:00
|
|
|
test_start "igzip_hist_perf"
|
2017-09-05 22:29:50 +02:00
|
|
|
./igzip_hist_perf $in_file
|
2018-09-04 19:59:30 +02:00
|
|
|
test_end "igzip_hist_perf" $?
|
2018-08-14 22:31:27 +02:00
|
|
|
test_start "igzip_semi_dyn_file_perf"
|
2017-09-05 22:29:50 +02:00
|
|
|
./igzip_semi_dyn_file_perf $in_file
|
2018-09-04 19:59:30 +02:00
|
|
|
test_end "igzip_semi_dyn_file_perf" $?
|
2018-08-14 22:31:27 +02:00
|
|
|
test_start "igzip_fuzz_inflate"
|
2017-09-05 22:29:50 +02:00
|
|
|
./igzip_fuzz_inflate $in_file
|
2018-09-04 19:59:30 +02:00
|
|
|
test_end "igzip_fuzz_inflate" $?
|
2017-09-05 22:29:50 +02:00
|
|
|
msg+=$'Other tests run: Pass\n'
|
|
|
|
|
|
|
|
if command -V shuf >/dev/null 2>&1; then
|
|
|
|
in_files=$(find $src -type f -size +0 -print 2>/dev/null | shuf | head -10 );
|
2018-08-14 22:31:27 +02:00
|
|
|
test_start "igzip_rand_test"
|
2017-09-05 22:29:50 +02:00
|
|
|
./igzip_rand_test $in_files
|
2018-09-04 19:59:30 +02:00
|
|
|
test_end "igzip_rand_test" $?
|
2018-08-14 22:31:27 +02:00
|
|
|
test_start "igzip_inflate_test"
|
2017-09-05 22:29:50 +02:00
|
|
|
./igzip_inflate_test $in_files
|
2018-09-04 19:59:30 +02:00
|
|
|
test_end "igzip_inflate_test" $?
|
2017-09-05 22:29:50 +02:00
|
|
|
msg+=$'Compression file tests: Pass\n'
|
|
|
|
else
|
|
|
|
msg+=$'Compression file test: Skip\n'
|
|
|
|
fi
|
|
|
|
|
|
|
|
time $MAKE -f Makefile.unx -j $cpus $build_opt ex
|
|
|
|
msg+=$'Examples build: Pass\n'
|
|
|
|
|
2018-08-14 22:31:27 +02:00
|
|
|
test_start "ec_simple_example"
|
2018-03-29 19:35:24 +02:00
|
|
|
./ec_simple_example -r $S
|
2018-09-04 19:59:30 +02:00
|
|
|
test_end "ec_simple_example" $?
|
2018-08-14 22:31:27 +02:00
|
|
|
test_start "crc_simple_test"
|
2017-09-05 22:29:50 +02:00
|
|
|
./crc_simple_test
|
2018-09-04 19:59:30 +02:00
|
|
|
test_end "crc_simple_test" $?
|
2018-08-14 22:31:27 +02:00
|
|
|
test_start "crc64_example"
|
2017-09-05 22:29:50 +02:00
|
|
|
./crc64_example
|
2018-09-04 19:59:30 +02:00
|
|
|
test_end "crc64_example" $?
|
2018-08-14 22:31:27 +02:00
|
|
|
test_start "xor_example"
|
2017-09-05 22:29:50 +02:00
|
|
|
./xor_example
|
2018-09-04 19:59:30 +02:00
|
|
|
test_end "xor_example" $?
|
2018-08-14 22:31:27 +02:00
|
|
|
test_start "igzip_example"
|
2017-09-05 22:29:50 +02:00
|
|
|
./igzip_example ${in_file} ${in_file}.cmp
|
2018-09-04 19:59:30 +02:00
|
|
|
test_end "igzip_example" $?
|
2017-09-05 22:29:50 +02:00
|
|
|
rm -rf ${in_file}.cmp
|
|
|
|
msg+=$'Examples run: Pass\n'
|
|
|
|
|
|
|
|
# Test custom hufftables
|
2018-08-14 22:31:27 +02:00
|
|
|
test_start "generate_custom_hufftables"
|
2017-09-05 22:29:50 +02:00
|
|
|
./generate_custom_hufftables $in_file
|
2020-10-20 18:55:24 +02:00
|
|
|
$MAKE -f Makefile.unx clean
|
2018-08-07 19:34:16 +02:00
|
|
|
$MAKE -f Makefile.unx -j $cpus D="NO_STATIC_INFLATE_H" checks
|
2017-09-05 22:29:50 +02:00
|
|
|
./igzip_rand_test $in_file
|
|
|
|
rm -rf hufftables_c.c
|
2018-09-04 19:59:30 +02:00
|
|
|
test_end "generate_custom_hufftables" $?
|
2018-08-07 19:34:16 +02:00
|
|
|
|
2017-09-05 22:29:50 +02:00
|
|
|
msg+=$'Custom hufftable build: Pass\n'
|
|
|
|
|
2023-11-16 21:23:06 +01:00
|
|
|
# Test NO_NT_LDST
|
|
|
|
test_start "no_nt_ldst"
|
|
|
|
$MAKE -f Makefile.unx clean
|
|
|
|
$MAKE -f Makefile.unx -j $cpus D="NO_NT_LDST" checks
|
|
|
|
test_end "no_nt_ldst" $?
|
|
|
|
|
|
|
|
# Test EC_ALIGNED_ADDR
|
|
|
|
test_start "ec_aligned_address"
|
|
|
|
$MAKE -f Makefile.unx clean
|
|
|
|
$MAKE -f Makefile.unx -j $cpus D="EC_ALIGNED_ADDR" checks
|
|
|
|
test_end "ec_aligned_address" $?
|
|
|
|
|
|
|
|
# Test EC_ALIGNED_ADDR & NO_NT_LDST
|
|
|
|
test_start "ec_aligned_addres_no_nt_ldsts"
|
|
|
|
$MAKE -f Makefile.unx clean
|
|
|
|
$MAKE -f Makefile.unx -j $cpus D="EC_ALIGNED_ADDR NO_NT_LDST" checks
|
|
|
|
test_end "ec_aligned_address_no_nt_ldst" $?
|
|
|
|
|
2017-09-05 22:29:50 +02:00
|
|
|
$MAKE -f Makefile.unx clean
|
|
|
|
|
2020-08-26 20:41:03 +02:00
|
|
|
test_start "nmake_file_consistency"
|
2020-08-27 20:16:30 +02:00
|
|
|
$MAKE -f Makefile.unx host_cpu="x86_64" test_nmake_file
|
2020-08-26 20:41:03 +02:00
|
|
|
test_end "nmake_file_consistency" $?
|
|
|
|
msg+=$'Nmake file consistency: Pass\n'
|
|
|
|
|
2017-09-05 22:29:50 +02:00
|
|
|
# noarch build
|
2018-08-14 22:31:27 +02:00
|
|
|
test_start "noarch_build"
|
2017-09-05 22:29:50 +02:00
|
|
|
time $MAKE -f Makefile.unx -j $cpus arch=noarch $build_opt
|
2018-09-04 19:59:30 +02:00
|
|
|
test_end "noarch_build" $?
|
2018-08-14 22:31:27 +02:00
|
|
|
test_start "noarch_build_random"
|
2017-12-12 00:14:06 +01:00
|
|
|
time $MAKE -f Makefile.unx -j $cpus arch=noarch $build_opt D="TEST_SEED=$S" check
|
2018-09-04 19:59:30 +02:00
|
|
|
test_end "noarch_build_random" $?
|
2017-09-05 22:29:50 +02:00
|
|
|
$MAKE -f Makefile.unx arch=noarch clean
|
|
|
|
msg+=$'Noarch build: Pass\n'
|
|
|
|
|
2023-11-30 10:29:07 +01:00
|
|
|
# Test other implementations with SDE
|
|
|
|
if [ $(uname -m) == "x86_64" ] && command -V sde64 >/dev/null 2>&1; then
|
|
|
|
# Compile tests
|
|
|
|
$MAKE -f Makefile.unx -j $cpus checks
|
|
|
|
# Loop through architectures
|
|
|
|
while [ $# -gt 0 ]
|
|
|
|
do
|
|
|
|
test_start "SDE test on $1 architecture"
|
|
|
|
time sde64 -$1 -- $MAKE -f Makefile.unx -j $cpus D="TEST_SEED=$S" check
|
|
|
|
test_start "SDE test on $1 architecture" $?
|
|
|
|
# Drop architecture from list, to test the next one
|
|
|
|
shift;
|
|
|
|
done
|
|
|
|
msg+=$'Running tests with SDE: Pass\n'
|
|
|
|
else
|
|
|
|
msg+=$'Running tests with SDE: Skip\n'
|
|
|
|
fi
|
|
|
|
|
2017-09-05 22:29:50 +02:00
|
|
|
# Try mingw build
|
2019-10-28 23:52:48 +01:00
|
|
|
if [ $(uname -m) == "x86_64" ] && command -V x86_64-w64-mingw32-gcc >/dev/null 2>&1; then
|
2018-08-14 22:31:27 +02:00
|
|
|
test_start "mingw_build"
|
2017-09-05 22:29:50 +02:00
|
|
|
time $MAKE -f Makefile.unx -j $cpus arch=mingw
|
2018-09-04 19:59:30 +02:00
|
|
|
test_end "mingw_build" $?
|
2017-09-05 22:29:50 +02:00
|
|
|
msg+=$'Mingw build: Pass\n'
|
|
|
|
|
|
|
|
if command -V wine >/dev/null 2>&1; then
|
2018-08-14 22:31:27 +02:00
|
|
|
test_start "mingw_check_tests"
|
2017-12-12 00:14:06 +01:00
|
|
|
time $MAKE -f Makefile.unx -j $cpus arch=mingw D="TEST_SEED=$S" check
|
2018-09-04 19:59:30 +02:00
|
|
|
test_end "mingw_check_tests" $?
|
2017-09-05 22:29:50 +02:00
|
|
|
msg+=$'Mingw check tests: Pass\n'
|
|
|
|
else
|
|
|
|
msg+=$'No wine, mingw check: Skip\n'
|
|
|
|
fi
|
|
|
|
$MAKE -f Makefile.unx arch=mingw clean
|
|
|
|
else
|
|
|
|
msg+=$'No mingw build: Skip\n'
|
|
|
|
fi
|
|
|
|
|
|
|
|
set +x
|
|
|
|
echo
|
|
|
|
echo "Summary test $0:"
|
|
|
|
echo "Build opt: $build_opt"
|
|
|
|
echo "$msg"
|
|
|
|
echo "$0: Final: Pass"
|