1# $FreeBSD$ 2 3.if ${MACHINE_ARCH} == "amd64" 4BI_BITS= 5.endif 6 7_BINS= \ 8 filemontest \ 9 timed-forkb \ 10 sizeof_long 11 12BINS= ${_BINS} 13.if defined(BI_BITS) 14BINS+= ${_BINS:C/$/32/g} 15.endif 16 17bins: ${BINS} 18all: bins 19 20MAN= 21 22WARNS?= 6 23CFLAGS+= -I${.CURDIR}/../../../sys 24 25# We don't want to genreate CTF files. Force that here. 26MK_CTF=no 27 28CLEANFILES+= ${BINS} 29 30 31.for f32 in ${BINS} 32${f32}32: ${f32}.c 33 ${CC} -m32 -DBIT=\"32\" -o ${.TARGET} ${CFLAGS} ${.ALLSRC} 34.endfor 35 36tests: 37 kldstat | grep filemon 38 @echo "" 39 ${MAKE} test01 40 ${MAKE} test02 41.if defined(BI_BITS) 42 ${MAKE} test32 43.endif 44 @echo "filemon(4) tests passed." 45 46# Cannot use .OBJDIR -- 'filemontest' expects 'test_script.sh' in . 47test01: ${BINS:Mfilemontest*} ${BINS:Msizeof_long*} clean-test 48.for BIN in ${BINS:Mfilemontest} 49 cd ${.CURDIR} ; \ 50 for A in 1 2 3 4 5 6 7 8 9 0; do \ 51 for B in 1 2 3 4 5 6 7 8 9 0; do \ 52 for C in 1 2 3 4 5 6 7 8 9 0; do \ 53 test -x ${BIN} && ${.OBJDIR}/${BIN} ;\ 54 done ;\ 55 done ;\ 56 done 57 @cd ${.CURDIR} ; set +e ; egrep '(Start|Stop) .*\.' filemon_log.* | \ 58 grep -q -v '\.[0-9][0-9][0-9][0-9][0-9][0-9]$$' || printf "Time stamp format OK\n\n" 59.endfor 60 @cd ${.CURDIR} ; set +e ; for F in filemon_log.* ; do \ 61 tail -1 $$F | grep -q '# Bye bye' || echo "$$F missing filemon bye-bye" ; \ 62 NL=`wc -l $$F | awk '{print $$1}'` ; \ 63 if [ "$${NL}" != 97 ]; then echo "$$F BAD, contains $${NL} lines" ; exit 1 ; fi ; done 64 65test02: ${BINS:Mtimed-forkb*} 66 @echo "Without filemon(4) active:" 67 ./timed-forkb 68 @echo "With filemon(4) active:" 69 script -f typescript-timed-forkb ./timed-forkb 70 ls -l typescript-timed-forkb.filemon 71 72test32: ${BINS:M*32*} 73 script -f typescript.${.TARGET} ./sizeof_long32 >/dev/null 74 @tail -1 typescript.test32.filemon | grep -q '# Bye bye' || (echo '32-bit comapt filemon Missing "bye-bye"' ; exit 1) 75 @egrep -q '^X [0-9]+ 0$$' typescript.test32.filemon || (echo "32-bit binary exit ERROR" ; exit 1) 76 @printf "filemon(4) 32bit FreeBSD support passed.\n\n" 77 78CLEANFILES+= typescript-timed-forkb typescript-timed-forkb.filemon 79 80clean-test: 81 cd ${.CURDIR} ; rm -f filemon_log*.* 82 83clean-tests: clean-test 84 85.include <bsd.prog.mk> 86