6 A harness for test cases in the DTrace test suite.
8 usage: $(basename $0) <testfile>
25 local dflags exe exstatus pid retval status
31 drp.DTRACEDROP_*.d|err.*.d|tst.*.d)
35 tag=$(gettag "$TFILE")
40 tag=$(gettag "$TFILE")
48 if [ -f "$exe" -a -x "$exe" ]; then
51 dflags="$dflags ${pid}"
54 dtrace -C -s "${TFILE}" $dflags >$STDOUT 2>$STDERR
57 if [ $status -ne $exstatus ]; then
58 ERRMSG="dtrace exited with status ${status}, expected ${exstatus}"
60 elif [ -n "${tag}" ] && ! grep -Fq " [${tag}] " ${STDERR}; then
61 ERRMSG="dtrace's error output did not contain expected tag ${tag}"
65 if [ -n "$pid" ]; then
66 kill -0 $pid >/dev/null 2>&1 && kill -9 $pid >/dev/null 2>&1
71 expr "$TFILE" : 'err.*' >/dev/null && exstatus=1
73 ksh "$TFILE" /usr/sbin/dtrace >$STDOUT 2>$STDERR
76 if [ $status -ne $exstatus ]; then
77 ERRMSG="script exited with status ${status}, expected ${exstatus}"
82 ERRMSG="unexpected test file name $TFILE"
92 readonly STDERR=$(mktemp)
93 readonly STDOUT=$(mktemp)
94 readonly TFILE=$(basename $1)
95 readonly EXOUT=${TFILE}.out
97 kldstat -q -m dtrace_test || kldload dtrace_test
102 if [ $RESULT -eq 0 -a -f $EXOUT -a -r $EXOUT ] && \
103 ! cmp $STDOUT $EXOUT >/dev/null 2>&1; then
104 ERRMSG="test output mismatch"
108 if [ $RESULT -ne 0 ]; then
109 echo "test $TFILE failed: $ERRMSG" >&2
110 if [ $(stat -f '%z' $STDOUT) -gt 0 ]; then
118 if [ $(stat -f '%z' $STDERR) -gt 0 ]; then
128 rm -f $STDERR $STDOUT