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