]>
Commit | Line | Data |
---|---|---|
9f95a23c TL |
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" $? | |
9f95a23c TL |
113 | test_start "igzip_hist_perf" |
114 | ./igzip_hist_perf $in_file | |
115 | test_end "igzip_hist_perf" $? | |
116 | test_start "igzip_semi_dyn_file_perf" | |
117 | ./igzip_semi_dyn_file_perf $in_file | |
118 | test_end "igzip_semi_dyn_file_perf" $? | |
9f95a23c TL |
119 | test_start "igzip_fuzz_inflate" |
120 | ./igzip_fuzz_inflate $in_file | |
121 | test_end "igzip_fuzz_inflate" $? | |
122 | msg+=$'Other tests run: Pass\n' | |
123 | ||
124 | if 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' | |
133 | else | |
134 | msg+=$'Compression file test: Skip\n' | |
135 | fi | |
136 | ||
137 | time $MAKE -f Makefile.unx -j $cpus $build_opt ex | |
138 | msg+=$'Examples build: Pass\n' | |
139 | ||
140 | test_start "ec_simple_example" | |
141 | ./ec_simple_example -r $S | |
142 | test_end "ec_simple_example" $? | |
143 | test_start "crc_simple_test" | |
144 | ./crc_simple_test | |
145 | test_end "crc_simple_test" $? | |
146 | test_start "crc64_example" | |
147 | ./crc64_example | |
148 | test_end "crc64_example" $? | |
149 | test_start "xor_example" | |
150 | ./xor_example | |
151 | test_end "xor_example" $? | |
152 | test_start "igzip_example" | |
153 | ./igzip_example ${in_file} ${in_file}.cmp | |
154 | test_end "igzip_example" $? | |
155 | rm -rf ${in_file}.cmp | |
156 | msg+=$'Examples run: Pass\n' | |
157 | ||
158 | # Test custom hufftables | |
159 | test_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 | |
164 | diff -q static_inflate.h igzip/static_inflate.h | |
165 | rm -rf static_inflate.h | |
166 | rm -rf hufftables_c.c | |
167 | test_end "generate_custom_hufftables" $? | |
168 | ||
169 | msg+=$'Custom hufftable build: Pass\n' | |
170 | ||
171 | $MAKE -f Makefile.unx clean | |
172 | ||
173 | # noarch build | |
174 | test_start "noarch_build" | |
175 | time $MAKE -f Makefile.unx -j $cpus arch=noarch $build_opt | |
176 | test_end "noarch_build" $? | |
177 | test_start "noarch_build_random" | |
178 | time $MAKE -f Makefile.unx -j $cpus arch=noarch $build_opt D="TEST_SEED=$S" check | |
179 | test_end "noarch_build_random" $? | |
180 | $MAKE -f Makefile.unx arch=noarch clean | |
181 | msg+=$'Noarch build: Pass\n' | |
182 | ||
183 | # Try mingw build | |
f67539c2 | 184 | if [ $(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 | |
199 | else | |
200 | msg+=$'No mingw build: Skip\n' | |
201 | fi | |
202 | ||
203 | set +x | |
204 | echo | |
205 | echo "Summary test $0:" | |
206 | echo "Build opt: $build_opt" | |
207 | echo "$msg" | |
208 | echo "$0: Final: Pass" |