]> git.proxmox.com Git - ceph.git/blame - ceph/src/spdk/isa-l/tools/test_extended.sh
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / spdk / isa-l / tools / test_extended.sh
CommitLineData
9f95a23c
TL
1#!/usr/bin/env bash
2
3# Extended tests: Run a few more options other than make check
4
5set -xe #exit on fail
6
7# Defaults
8cpus=1
9S=$RANDOM
10MAKE=make
11READLINK=readlink
12test_level=check
13build_opt=''
14msg=''
15
16# Override defaults if exist
17command -V gmake >/dev/null 2>&1 && MAKE=gmake
18command -V greadlink >/dev/null 2>&1 && READLINK=greadlink
19[ -n "$CC" ] && build_opt+="CC=$CC "
20[ -n "$AS" ] && build_opt+="AS=$AS "
21
22out="$PWD"
23src=$($READLINK -f $(dirname $0))/..
24source $src/tools/test_tools.sh
25cd "$src"
26
27# Run on mult cpus
28if command -V lscpu >/dev/null 2>&1; then
29 cpus=`lscpu -p | tail -1 | cut -d, -f 2`
30 cpus=$(($cpus + 1))
31elif command -V sysctl; then
32 if sysctl -n hw.ncpu >/dev/null 2>&1; then
33 cpus=$(sysctl -n hw.ncpu)
34 cpus=$(($cpus + 1))
35 fi
36fi
37echo "Using $cpus cpu threads"
38
39if [ -z "$S" ]; then
40 S=`tr -cd 0-9 </dev/urandom | head -c 4 | sed -e 's/^0*/1/g'`
41 [ "$S" -gt 0 ] 2> /dev/null || S="123"
42fi
43msg+="Running with TEST_SEED=$S".$'\n'
44
45# Fix Darwin issues
46if uname | grep -q 'Darwin' 2>&1; then
47 export SED=`which sed`
48fi
49
50# Check for test libs to add
51if command -V ldconfig >/dev/null 2>&1; then
52 if ldconfig -p | grep -q libz.so; then
53 test_level=test
54 msg+=$'With extra tests\n'
55 fi
56 if ldconfig -p | grep -q libefence.so; then
57 build_opt+="LDFLAGS+='-lefence' "
58 msg+=$'With efence\n'
59 fi
60fi
61
62# Std makefile build test
63$MAKE -f Makefile.unx clean
64test_start "extended_build_test"
65time $MAKE -f Makefile.unx -j $cpus $build_opt
66test_end "extended_build_test" $?
67msg+=$'Std makefile build: Pass\n'
68
69# Check for gnu executable stack set
70if command -V readelf >/dev/null 2>&1; then
71 test_start "stack_nx_check"
72 if readelf -W -l bin/libisal.so | grep 'GNU_STACK' | grep -q 'RWE'; then
73 echo $0: Stack NX check bin/libisal.so: Fail
74 test_end "stack_nx_check" 1
75 exit 1
76 else
77 test_end "stack_nx_check" 0
78 msg+=$'Stack NX check bin/lib/libisal.so: Pass\n'
79 fi
80else
81 msg+=$'Stack NX check not supported: Skip\n'
82fi
83
84# Std makefile build perf tests
85test_start "extended_perf_test"
86time $MAKE -f Makefile.unx -j $cpus perfs
87test_end "extended_perf_test" $?
88msg+=$'Std makefile build perf: Pass\n'
89
90# Std makefile run tests
91test_start "extended_makefile_tests"
92time $MAKE -f Makefile.unx -j $cpus $build_opt D="TEST_SEED=$S" $test_level
93test_end "extended_makefile_tests" $?
94msg+=$'Std makefile tests: Pass\n'
95
96# Std makefile build other
97test_start "extended_other_tests"
98time $MAKE -f Makefile.unx -j $cpus $build_opt D="TEST_SEED=$S" other
99test_end "extended_other_tests" $?
100msg+=$'Other tests build: Pass\n'
101
102# Try to pick a random src file
103if command -V shuf >/dev/null 2>&1; then
104 in_file=$(find $src -type f -size +0 -name \*.c -o -name \*.asm -print 2>/dev/null | shuf | head -1 );
105else
106 in_file=configure.ac
107fi
108
109echo Other tests using $in_file
110test_start "igzip_file_perf"
111./igzip_file_perf $in_file
112test_end "igzip_file_perf" $?
9f95a23c
TL
113test_start "igzip_hist_perf"
114./igzip_hist_perf $in_file
115test_end "igzip_hist_perf" $?
116test_start "igzip_semi_dyn_file_perf"
117./igzip_semi_dyn_file_perf $in_file
118test_end "igzip_semi_dyn_file_perf" $?
9f95a23c
TL
119test_start "igzip_fuzz_inflate"
120./igzip_fuzz_inflate $in_file
121test_end "igzip_fuzz_inflate" $?
122msg+=$'Other tests run: Pass\n'
123
124if command -V shuf >/dev/null 2>&1; then
125 in_files=$(find $src -type f -size +0 -print 2>/dev/null | shuf | head -10 );
126 test_start "igzip_rand_test"
127 ./igzip_rand_test $in_files
128 test_end "igzip_rand_test" $?
129 test_start "igzip_inflate_test"
130 ./igzip_inflate_test $in_files
131 test_end "igzip_inflate_test" $?
132 msg+=$'Compression file tests: Pass\n'
133else
134 msg+=$'Compression file test: Skip\n'
135fi
136
137time $MAKE -f Makefile.unx -j $cpus $build_opt ex
138msg+=$'Examples build: Pass\n'
139
140test_start "ec_simple_example"
141./ec_simple_example -r $S
142test_end "ec_simple_example" $?
143test_start "crc_simple_test"
144./crc_simple_test
145test_end "crc_simple_test" $?
146test_start "crc64_example"
147./crc64_example
148test_end "crc64_example" $?
149test_start "xor_example"
150./xor_example
151test_end "xor_example" $?
152test_start "igzip_example"
153./igzip_example ${in_file} ${in_file}.cmp
154test_end "igzip_example" $?
155rm -rf ${in_file}.cmp
156msg+=$'Examples run: Pass\n'
157
158# Test custom hufftables
159test_start "generate_custom_hufftables"
160./generate_custom_hufftables $in_file
161$MAKE -f Makefile.unx -j $cpus D="NO_STATIC_INFLATE_H" checks
162./igzip_rand_test $in_file
163./generate_static_inflate
164diff -q static_inflate.h igzip/static_inflate.h
165rm -rf static_inflate.h
166rm -rf hufftables_c.c
167test_end "generate_custom_hufftables" $?
168
169msg+=$'Custom hufftable build: Pass\n'
170
171$MAKE -f Makefile.unx clean
172
173# noarch build
174test_start "noarch_build"
175time $MAKE -f Makefile.unx -j $cpus arch=noarch $build_opt
176test_end "noarch_build" $?
177test_start "noarch_build_random"
178time $MAKE -f Makefile.unx -j $cpus arch=noarch $build_opt D="TEST_SEED=$S" check
179test_end "noarch_build_random" $?
180$MAKE -f Makefile.unx arch=noarch clean
181msg+=$'Noarch build: Pass\n'
182
183# Try mingw build
f67539c2 184if [ $(uname -m) == "x86_64" ] && [ command -V x86_64-w64-mingw32-gcc >/dev/null 2>&1 ]; then
9f95a23c
TL
185 test_start "mingw_build"
186 time $MAKE -f Makefile.unx -j $cpus arch=mingw
187 test_end "mingw_build" $?
188 msg+=$'Mingw build: Pass\n'
189
190 if command -V wine >/dev/null 2>&1; then
191 test_start "mingw_check_tests"
192 time $MAKE -f Makefile.unx -j $cpus arch=mingw D="TEST_SEED=$S" check
193 test_end "mingw_check_tests" $?
194 msg+=$'Mingw check tests: Pass\n'
195 else
196 msg+=$'No wine, mingw check: Skip\n'
197 fi
198 $MAKE -f Makefile.unx arch=mingw clean
199else
200 msg+=$'No mingw build: Skip\n'
201fi
202
203set +x
204echo
205echo "Summary test $0:"
206echo "Build opt: $build_opt"
207echo "$msg"
208echo "$0: Final: Pass"