3 # Extended tests: Run a few more options other than make check
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 "
23 src
=$
($READLINK -f $
(dirname $0))/..
24 source $src/tools
/test_tools.sh
28 if command -V lscpu
>/dev
/null
2>&1; then
29 cpus
=`lscpu -p | tail -1 | cut -d, -f 2`
31 elif command -V sysctl
; then
32 if sysctl
-n hw.ncpu
>/dev
/null
2>&1; then
33 cpus
=$
(sysctl
-n hw.ncpu
)
37 echo "Using $cpus cpu threads"
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"
43 msg
+="Running with TEST_SEED=$S".$
'\n'
46 if uname |
grep -q 'Darwin' 2>&1; then
47 export SED
=`which sed`
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
54 msg
+=$
'With extra tests\n'
56 if ldconfig
-p |
grep -q libefence.so
; then
57 build_opt
+="LDFLAGS+='-lefence' "
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'
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
77 test_end
"stack_nx_check" 0
78 msg
+=$
'Stack NX check bin/lib/libisal.so: Pass\n'
81 msg
+=$
'Stack NX check not supported: Skip\n'
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'
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'
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'
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 );
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'
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'
140 msg
+=$
'Compression file test: Skip\n'
143 time $MAKE -f Makefile.unx
-j $cpus $build_opt ex
144 msg
+=$
'Examples build: Pass\n'
146 test_start
"ec_simple_example"
147 .
/ec_simple_example
-r $S
148 test_end
"ec_simple_example" $?
149 test_start
"crc_simple_test"
151 test_end
"crc_simple_test" $?
152 test_start
"crc64_example"
154 test_end
"crc64_example" $?
155 test_start
"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'
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" $?
175 msg
+=$
'Custom hufftable build: Pass\n'
177 $MAKE -f Makefile.unx clean
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'
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'
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'
202 msg
+=$
'No wine, mingw check: Skip\n'
204 $MAKE -f Makefile.unx arch
=mingw clean
206 msg
+=$
'No mingw build: Skip\n'
211 echo "Summary test $0:"
212 echo "Build opt: $build_opt"
214 echo "$0: Final: Pass"