2017-09-05 22:29:50 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -xe #exit on fail
|
|
|
|
|
|
|
|
# Defaults
|
|
|
|
cpus=1
|
|
|
|
S=$RANDOM
|
|
|
|
MAKE=make
|
|
|
|
READLINK=readlink
|
|
|
|
|
|
|
|
# Override defaults if exist
|
|
|
|
command -V gmake >/dev/null 2>&1 && MAKE=gmake
|
|
|
|
command -V greadlink >/dev/null 2>&1 && READLINK=greadlink
|
|
|
|
|
|
|
|
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"
|
|
|
|
tmp_install_dir=$out/tmp_install
|
|
|
|
|
|
|
|
# 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"
|
|
|
|
|
|
|
|
# Pick a random test seed
|
|
|
|
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
|
|
|
|
echo "Running with TEST_SEED=$S"
|
|
|
|
|
|
|
|
# Fix Darwin issues
|
|
|
|
if uname | grep -q 'Darwin' 2>&1; then
|
|
|
|
export SED=`which sed`
|
|
|
|
fi
|
|
|
|
|
2018-05-07 23:14:32 +02:00
|
|
|
# Build and run check tests
|
2017-09-05 22:29:50 +02:00
|
|
|
time ./autogen.sh
|
|
|
|
time ./configure --prefix=$tmp_install_dir $opt_config_target
|
|
|
|
time $MAKE -j $cpus
|
2018-08-14 22:31:27 +02:00
|
|
|
test_start "check_tests"
|
2017-09-05 22:29:50 +02:00
|
|
|
time $MAKE check -j $cpus D="-D TEST_SEED=$S"
|
2018-09-04 19:59:30 +02:00
|
|
|
test_end "check_tests" $?
|
2018-05-07 23:14:32 +02:00
|
|
|
|
|
|
|
# Build other tests if deps found
|
2018-05-02 00:06:01 +02:00
|
|
|
if command -V ldconfig >/dev/null 2>&1; then
|
|
|
|
if ldconfig -p | grep -q libz.so; then
|
2018-08-14 22:31:27 +02:00
|
|
|
test_start "other_check_tests"
|
2018-05-02 00:06:01 +02:00
|
|
|
time $MAKE other -j $cpus
|
2018-09-04 19:59:30 +02:00
|
|
|
test_end "other_check_tests" $?
|
2018-08-14 22:31:27 +02:00
|
|
|
test_start "example_tests"
|
2018-05-02 00:06:01 +02:00
|
|
|
time $MAKE ex -j $cpus
|
2018-09-04 19:59:30 +02:00
|
|
|
test_end "example_tests" $?
|
2018-08-14 22:31:27 +02:00
|
|
|
test_start "unit_tests"
|
2018-05-02 00:06:01 +02:00
|
|
|
time $MAKE tests -j $cpus
|
2018-09-04 19:59:30 +02:00
|
|
|
test_end "unit_tests" $?
|
2018-05-02 00:06:01 +02:00
|
|
|
fi
|
|
|
|
fi
|
2018-08-14 22:31:27 +02:00
|
|
|
test_start "installation_test"
|
2017-09-05 22:29:50 +02:00
|
|
|
time $MAKE install
|
2018-09-04 19:59:30 +02:00
|
|
|
test_end "installation_test" $?
|
2017-09-05 22:29:50 +02:00
|
|
|
|
|
|
|
# Check for gnu executable stack set
|
|
|
|
if command -V readelf >/dev/null 2>&1; then
|
|
|
|
if readelf -W -l $tmp_install_dir/lib/libisal.so | grep 'GNU_STACK' | grep -q 'RWE'; then
|
|
|
|
echo Stack NX check $tmp_install_dir/lib/libisal.so Fail
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo Stack NX check $tmp_install_dir/lib/libisal.so Pass
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo Stack NX check not supported
|
|
|
|
fi
|
|
|
|
|
|
|
|
$MAKE clean
|
|
|
|
|
2018-05-02 00:06:01 +02:00
|
|
|
# Check that make clean did not leave any junk behind
|
|
|
|
if git status > /dev/null 2>&1; then
|
2018-05-07 23:14:32 +02:00
|
|
|
if git status --porcelain --ignored | grep -x '.*\.o\|.*\.lo\|.*\.a\|.*\.la\|.*\.s'; then
|
2018-05-02 00:06:01 +02:00
|
|
|
echo Clean directory check Fail
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo Clean directory check Pass
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo Clean directory check not supported
|
|
|
|
fi
|
2017-09-05 22:29:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
echo $0: Pass
|