source: trunk/test/testcompile.sh@ 25

Last change on this file since 25 was 22, checked in by rainer, 19 years ago

Minor code revisions.

File size: 17.0 KB
Line 
1#! /bin/sh
2
3MAXTEST=56; export MAXTEST
4
5run_smatch ()
6{
7 export CDIR=`pwd`;
8
9 if [ -z "$doall" ]; then
10 [ -z "$quiet" ] && log_skip $2 ${MAXTEST} "$TEST (smatch)";
11 return 0
12 fi
13
14 if [ "x$3" = "xdebug" ]; then memcheck=debug; else memcheck=simple; fi
15 if [ -f ../sm_scripts/smatch.pm ]; then
16 (
17 cd ../sm_scripts;
18
19 for i in ${CDIR}/*.c.sm ; do
20 # echo $i;
21 cat $i | ./unreached_code.pl;
22 cat $i | ./ampersand_missing.sh;
23 cat $i | ./uninitialized.pl;
24 cat $i | ./eqeq.pl;
25 cat $i | ./for_bounds.pl;
26 cat $i | ./unchecked_returns.pl;
27 cat $i | ./unreached_code.pl;
28 cat $i | ./uninitialized.pl;
29 # from http://people.redhat.com/mstefani/wine/smatch/
30 if [ -f ./while_for_check.pl ]; then
31 cat $i | ./while_for_check.pl;
32 fi
33 # --> end wine <--
34 # samhain specific
35 if [ $memcheck = xsimple ]; then
36 if [ -f ./samhain_unfree.pl ]; then
37 cat $i | ./samhain_unfree.pl | \
38 egrep -v 'x_cutest_.*Test_' | \
39 egrep -v 'x_sh_unix.c .... .... sh_unix_copyenv';
40 fi
41 fi
42 if [ $memcheck = xdebug ]; then
43 if [ -f ./samhain_unfree_debug.pl ]; then
44 cat $i | ./samhain_unfree_debug.pl | \
45 egrep -v 'x_cutest_.*Test_' | \
46 egrep -v 'x_sh_unix.c .... .... sh_unix_copyenv';
47 fi
48 fi
49 # --> end samhain specific <--
50 #cat $i | ./unfree.pl | \
51 # egrep -v 'x_cutest_.*Test_' | \
52 # grep -v 'x_sh_unix.c .... .... sh_unix_copyenv';
53 touch list_null_funcs_uniq;
54 cat $i | ./deference_check.pl;
55 rm -f list_null_funcs_uniq;
56 rm -f $i
57 done
58 ) >test_log_smatch 2>&1
59 if [ -f test_log_smatch ]; then
60 lines=`cat test_log_smatch | wc -l`
61 if [ $lines -ne 0 ]; then
62 cat test_log_smatch
63 rm -f test_log_smatch
64 [ -z "$quiet" ] && log_fail $2 ${MAXTEST} "$TEST (smatch)";
65 return 1
66 fi
67 fi
68 [ -z "$quiet" ] && log_ok $2 ${MAXTEST} "$TEST (smatch)";
69 return 0
70 fi
71 [ -z "$quiet" ] && log_skip $2 ${MAXTEST} "$TEST (smatch)";
72 return 0
73}
74
75testmake ()
76{
77 fail=0
78 if test x$1 = x0; then
79 [ -z "$verbose" ] || log_msg_ok "configure... $TEST";
80 $MAKE ${SMATCH} cutest > /dev/null 2>> test_log
81 if test x$? = x0; then
82 [ -z "$verbose" ] || log_msg_ok "make cutest... $TEST";
83 else
84 [ -z "$quiet" ] && log_msg_fail "make cutest... $TEST";
85 fail=1
86 fi
87 else
88 [ -z "$quiet" ] && log_msg_fail "configure... $TEST";
89 if [ x"$3" = xskip ]; then
90 [ -z "$quiet" ] && log_skip $2 ${MAXTEST} "$TEST";
91 fi
92 fail=1
93 fi
94 if [ $fail -eq 1 ]; then
95 [ -z "$quiet" ] && log_fail $2 ${MAXTEST} "$TEST";
96 return 1
97 fi
98 [ -z "$quiet" ] && log_ok $2 ${MAXTEST} "$TEST";
99 return 0
100}
101
102testcompile ()
103{
104 log_start "COMPILE"
105
106 if [ -f /usr/local/gcc-smatch/bin/gcc ]; then
107 SAVE_CC="${CC}"
108 SMATCH="DBGDEF=--smatch"; export SMATCH
109 CC="/usr/local/gcc-smatch/bin/gcc"; export CC
110 fi
111
112 num=0
113 numfail=0
114
115 #
116 # test standalone compilation
117 #
118 TEST="${S}standalone w/suidcheck${E}"
119 #
120 if test -r "Makefile"; then
121 $MAKE distclean
122 fi
123 #
124 ${TOP_SRCDIR}/configure --quiet --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test --enable-suidcheck > /dev/null 2>> test_log
125 #
126 let "num = num + 1" >/dev/null
127 testmake $? $num || let "numfail = numfail + 1" >/dev/null
128 let "num = num + 1" >/dev/null
129 run_smatch $? $num || let "numfail = numfail + 1" >/dev/null
130
131 #
132 # test standalone compilation
133 #
134 TEST="${S}standalone w/mounts-check w/userfiles${E}"
135 #
136 if test -r "Makefile"; then
137 $MAKE distclean
138 fi
139 #
140 ${TOP_SRCDIR}/configure --quiet --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test --enable-mounts-check --enable-userfiles > /dev/null 2>> test_log
141 #
142 let "num = num + 1" >/dev/null
143 testmake $? $num || let "numfail = numfail + 1" >/dev/null
144 let "num = num + 1" >/dev/null
145 run_smatch $? $num || let "numfail = numfail + 1" >/dev/null
146
147
148 #
149 # test standalone compilation
150 #
151 TEST="${S}standalone w/timeserver and w/msgqueue${E}"
152 #
153 if test -r "Makefile"; then
154 $MAKE clean
155 fi
156 #
157 ${TOP_SRCDIR}/configure --quiet --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test --enable-message-queue --with-timeserver=127.0.0.1 > /dev/null 2>> test_log
158 #
159 let "num = num + 1" >/dev/null
160 testmake $? $num || let "numfail = numfail + 1" >/dev/null
161 let "num = num + 1" >/dev/null
162 run_smatch $? $num || let "numfail = numfail + 1" >/dev/null
163
164 #
165 # test standalone compilation with --with-nocl=PW
166 #
167 TEST="${S}standalone w/nocl${E}"
168 #
169 if test -r "Makefile"; then
170 $MAKE clean
171 fi
172 #
173 ${TOP_SRCDIR}/configure --quiet --prefix=$PW_DIR --enable-nocl="owl" --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log
174 #
175 let "num = num + 1" >/dev/null
176 testmake $? $num || let "numfail = numfail + 1" >/dev/null
177 let "num = num + 1" >/dev/null
178 run_smatch $? $num || let "numfail = numfail + 1" >/dev/null
179
180 #
181 # test standalone compilation w/ debug
182 #
183 TEST="${S}standalone w/debug${E}"
184 #
185 if test -r "Makefile"; then
186 $MAKE clean
187 fi
188 #
189 ${TOP_SRCDIR}/configure --quiet --enable-debug --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log
190 #
191 let "num = num + 1" >/dev/null
192 testmake $? $num || let "numfail = numfail + 1" >/dev/null
193 let "num = num + 1" >/dev/null
194 run_smatch $? $num debug || let "numfail = numfail + 1" >/dev/null
195
196 #
197 # test standalone compilation w/ gpg
198 #
199 TEST="${S}standalone w/gpg${E}"
200 #
201 GPG=`find_path gpg`
202 let "num = num + 1" >/dev/null
203 #
204 if [ -z "$GPG" ]; then
205 log_skip $num $MAXTEST 'gpg not in PATH'
206 else
207 if test -r "Makefile"; then
208 $MAKE clean
209 fi
210 #
211 ${TOP_SRCDIR}/configure --quiet --with-gpg=$GPG --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log
212 #
213 testmake $? $num || let "numfail = numfail + 1" >/dev/null
214 let "num = num + 1" >/dev/null
215 run_smatch $? $num || let "numfail = numfail + 1" >/dev/null
216 fi
217
218 #
219 # test standalone compilation w/stealth
220 #
221 TEST="${S}standalone w/stealth${E}"
222 #
223 if test -r "Makefile"; then
224 $MAKE clean
225 fi
226 #
227 ${TOP_SRCDIR}/configure --quiet --enable-stealth=128 --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log
228 #
229 let "num = num + 1" >/dev/null
230 testmake $? $num || let "numfail = numfail + 1" >/dev/null
231 let "num = num + 1" >/dev/null
232 run_smatch $? $num || let "numfail = numfail + 1" >/dev/null
233
234 #
235 # test standalone compilation w/logwatch
236 #
237 TEST="${S}standalone w/login-watch${E}"
238 #
239 if test -r "Makefile"; then
240 $MAKE clean
241 fi
242 #
243 ${TOP_SRCDIR}/configure --quiet --enable-login-watch --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log
244 #
245 let "num = num + 1" >/dev/null
246 testmake $? $num || let "numfail = numfail + 1" >/dev/null
247 let "num = num + 1" >/dev/null
248 run_smatch $? $num || let "numfail = numfail + 1" >/dev/null
249
250 #
251 # test standalone compilation w/mysql
252 #
253 TEST="${S}standalone w/mysql${E}"
254 #
255 if test -r "Makefile"; then
256 $MAKE clean
257 fi
258 #
259 ${TOP_SRCDIR}/configure --quiet --enable-xml-log --with-database=mysql --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log
260 #
261 let "num = num + 1" >/dev/null
262 testmake $? $num "skip" || let "numfail = numfail + 1" >/dev/null
263 let "num = num + 1" >/dev/null
264 run_smatch $? $num || let "numfail = numfail + 1" >/dev/null
265
266 #
267 # test standalone compilation w/postgresql
268 #
269 TEST="${S}standalone w/postgresql${E}"
270 #
271 if test -r "Makefile"; then
272 $MAKE clean
273 fi
274 #
275 ${TOP_SRCDIR}/configure --quiet --enable-xml-log --with-database=postgresql --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log
276 #
277 let "num = num + 1" >/dev/null
278 testmake $? $num "skip" || let "numfail = numfail + 1" >/dev/null
279 let "num = num + 1" >/dev/null
280 run_smatch $? $num || let "numfail = numfail + 1" >/dev/null
281
282 #
283 # test standalone compilation
284 #
285 TEST="${S}standalone w/o mail${E}"
286 #
287 if test -r "Makefile"; then
288 $MAKE clean
289 fi
290 #
291 ${TOP_SRCDIR}/configure --quiet --disable-mail --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log
292 #
293 let "num = num + 1" >/dev/null
294 testmake $? $num || let "numfail = numfail + 1" >/dev/null
295 let "num = num + 1" >/dev/null
296 run_smatch $? $num || let "numfail = numfail + 1" >/dev/null
297
298 #
299 # test standalone compilation
300 #
301 TEST="${S}standalone w/o external${E}"
302 #
303 if test -r "Makefile"; then
304 $MAKE clean
305 fi
306 #
307 ${TOP_SRCDIR}/configure --quiet --disable-external-scripts --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log
308 #
309 let "num = num + 1" >/dev/null
310 testmake $? $num || let "numfail = numfail + 1" >/dev/null
311 let "num = num + 1" >/dev/null
312 run_smatch $? $num || let "numfail = numfail + 1" >/dev/null
313
314 # echo; echo "${S}__ TEST CLIENT/SERVER __${E}"; echo;
315
316 #
317 # test client/server compilation
318 #
319 TEST="${S}client/server application w/timeserver${E}"
320 #
321 if test -r "Makefile"; then
322 $MAKE clean
323 fi
324 #
325 ${TOP_SRCDIR}/configure --quiet --enable-network=client --enable-srp --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test --with-timeserver=127.0.0.1 > /dev/null 2>> test_log
326 #
327 let "num = num + 1" >/dev/null
328 testmake $? $num || let "numfail = numfail + 1" >/dev/null
329 let "num = num + 1" >/dev/null
330 run_smatch $? $num || let "numfail = numfail + 1" >/dev/null
331
332 if test -r "Makefile"; then
333 $MAKE clean
334 fi
335 #
336 ${TOP_SRCDIR}/configure --quiet --enable-network=server --enable-srp --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test --with-timeserver=127.0.0.1 > /dev/null 2>> test_log
337 #
338 let "num = num + 1" >/dev/null
339 testmake $? $num || let "numfail = numfail + 1" >/dev/null
340 let "num = num + 1" >/dev/null
341 run_smatch $? $num || let "numfail = numfail + 1" >/dev/null
342
343 #
344 # test c/s compilation w/ gpg
345 #
346 TEST="${S}client/server application w/gpg${E}"
347 #
348 GPG=`find_path gpg`
349 let "num = num + 1" >/dev/null
350 #
351 if [ -z "$GPG" ]; then
352 log_skip $num $MAXTEST 'gpg not in PATH'
353 let "num = num + 1" >/dev/null
354 log_skip $num $MAXTEST 'gpg not in PATH'
355 else
356 if test -r "Makefile"; then
357 $MAKE clean
358 fi
359 #
360 ${TOP_SRCDIR}/configure --quiet --enable-network=server --enable-srp --with-gpg=$GPG --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log
361 #
362 testmake $? $num || let "numfail = numfail + 1" >/dev/null
363 let "num = num + 1" >/dev/null
364 run_smatch $? $num || let "numfail = numfail + 1" >/dev/null
365 #
366 if test -r "Makefile"; then
367 $MAKE clean
368 fi
369 #
370 ${TOP_SRCDIR}/configure --quiet --enable-network=client --enable-srp --with-gpg=$GPG --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log
371 #
372 let "num = num + 1" >/dev/null
373 testmake $? $num || let "numfail = numfail + 1" >/dev/null
374 let "num = num + 1" >/dev/null
375 run_smatch $? $num || let "numfail = numfail + 1" >/dev/null
376 fi
377
378
379 #
380 # test client/server compilation
381 #
382 TEST="${S}client/server application w/o srp${E}"
383 #
384 if test -r "Makefile"; then
385 $MAKE clean
386 fi
387 #
388 ${TOP_SRCDIR}/configure --quiet --enable-network=server --disable-srp --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log
389 #
390 let "num = num + 1" >/dev/null
391 testmake $? $num || let "numfail = numfail + 1" >/dev/null
392 let "num = num + 1" >/dev/null
393 run_smatch $? $num || let "numfail = numfail + 1" >/dev/null
394 #
395 if test -r "Makefile"; then
396 $MAKE clean
397 fi
398 #
399 ${TOP_SRCDIR}/configure --quiet --enable-network=client --disable-srp --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log
400 #
401 let "num = num + 1" >/dev/null
402 testmake $? $num || let "numfail = numfail + 1" >/dev/null
403 let "num = num + 1" >/dev/null
404 run_smatch $? $num || let "numfail = numfail + 1" >/dev/null
405
406 #
407 # test client/server compilation w/ debug
408 #
409 TEST="${S}client/server application w/debug${E}"
410 #
411 if test -r "Makefile"; then
412 $MAKE clean
413 fi
414 #
415 ${TOP_SRCDIR}/configure --quiet --enable-network=server --enable-debug --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log
416 #
417 let "num = num + 1" >/dev/null
418 testmake $? $num || let "numfail = numfail + 1" >/dev/null
419 let "num = num + 1" >/dev/null
420 run_smatch $? $num debug || let "numfail = numfail + 1" >/dev/null
421 #
422 if test -r "Makefile"; then
423 $MAKE clean
424 fi
425 #
426 ${TOP_SRCDIR}/configure --quiet --enable-network=client --enable-debug --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log
427 #
428 let "num = num + 1" >/dev/null
429 testmake $? $num || let "numfail = numfail + 1" >/dev/null
430 let "num = num + 1" >/dev/null
431 run_smatch $? $num debug || let "numfail = numfail + 1" >/dev/null
432
433 #
434 # test client/server compilation w/stealth
435 #
436 TEST="${S}client/server application w/stealth${E}"
437 #
438 if test -r "Makefile"; then
439 $MAKE clean
440 fi
441 #
442 ${TOP_SRCDIR}/configure --quiet --enable-network=server --enable-srp --enable-stealth=128 --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log
443 #
444 let "num = num + 1" >/dev/null
445 testmake $? $num || let "numfail = numfail + 1" >/dev/null
446 let "num = num + 1" >/dev/null
447 run_smatch $? $num || let "numfail = numfail + 1" >/dev/null
448 #
449 if test -r "Makefile"; then
450 $MAKE clean
451 fi
452 #
453 ${TOP_SRCDIR}/configure --quiet --enable-network=client --enable-srp --enable-stealth=128 --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log
454 #
455 let "num = num + 1" >/dev/null
456 testmake $? $num || let "numfail = numfail + 1" >/dev/null
457 let "num = num + 1" >/dev/null
458 run_smatch $? $num || let "numfail = numfail + 1" >/dev/null
459
460 #
461 # test client/server compilation w/logwatch
462 #
463 TEST="${S}client/server application w/login-watch${E}"
464 #
465 if test -r "Makefile"; then
466 $MAKE clean
467 fi
468 #
469 ${TOP_SRCDIR}/configure --quiet --enable-network=server --enable-srp --enable-login-watch --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log
470 #
471 let "num = num + 1" >/dev/null
472 testmake $? $num || let "numfail = numfail + 1" >/dev/null
473 let "num = num + 1" >/dev/null
474 run_smatch $? $num || let "numfail = numfail + 1" >/dev/null
475 #
476 if test -r "Makefile"; then
477 $MAKE clean
478 fi
479 #
480 ${TOP_SRCDIR}/configure --quiet --enable-network=client --enable-srp --enable-login-watch --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log
481 #
482 let "num = num + 1" >/dev/null
483 testmake $? $num || let "numfail = numfail + 1" >/dev/null
484 let "num = num + 1" >/dev/null
485 run_smatch $? $num || let "numfail = numfail + 1" >/dev/null
486
487 #
488 # test client/server compilation
489 #
490 TEST="${S}client/server application w/o mail${E}"
491 #
492 if test -r "Makefile"; then
493 $MAKE clean
494 fi
495 #
496 ${TOP_SRCDIR}/configure --quiet --enable-network=server --disable-mail --enable-srp --enable-stealth=128 --enable-debug --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log
497 #
498 let "num = num + 1" >/dev/null
499 testmake $? $num || let "numfail = numfail + 1" >/dev/null
500 let "num = num + 1" >/dev/null
501 run_smatch $? $num debug || let "numfail = numfail + 1" >/dev/null
502 #
503 if test -r "Makefile"; then
504 $MAKE clean
505 fi
506 #
507 ${TOP_SRCDIR}/configure --quiet --enable-network=client --disable-mail --enable-srp --enable-stealth=128 --enable-debug --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log
508 #
509 let "num = num + 1" >/dev/null
510 testmake $? $num || let "numfail = numfail + 1" >/dev/null
511 let "num = num + 1" >/dev/null
512 run_smatch $? $num debug || let "numfail = numfail + 1" >/dev/null
513
514 #
515 # test client/server compilation
516 #
517 TEST="${S}client/server application w/o external${E}"
518 #
519 if test -r "Makefile"; then
520 $MAKE clean
521 fi
522 #
523 ${TOP_SRCDIR}/configure --quiet --enable-network=server --disable-srp --disable-external-scripts --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log
524 #
525 let "num = num + 1" >/dev/null
526 testmake $? $num || let "numfail = numfail + 1" >/dev/null
527 let "num = num + 1" >/dev/null
528 run_smatch $? $num || let "numfail = numfail + 1" >/dev/null
529 #
530 if test -r "Makefile"; then
531 $MAKE clean
532 fi
533 #
534 ${TOP_SRCDIR}/configure --quiet --enable-network=client --disable-srp --disable-external-scripts --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test > /dev/null 2>> test_log
535 #
536 let "num = num + 1" >/dev/null
537 testmake $? $num || let "numfail = numfail + 1" >/dev/null
538 let "num = num + 1" >/dev/null
539 run_smatch $? $num || let "numfail = numfail + 1" >/dev/null
540
541 [ -z "${SMATCH}" ] || { CC="${SAVE_CC}"; export CC; }
542
543 log_end "COMPILE"
544}
Note: See TracBrowser for help on using the repository browser.