Index: head/cddl/usr.sbin/dtrace/tests/Makefile =================================================================== --- head/cddl/usr.sbin/dtrace/tests/Makefile (revision 280834) +++ head/cddl/usr.sbin/dtrace/tests/Makefile (revision 280835) @@ -1,17 +1,15 @@ # $FreeBSD$ .include TESTSDIR= ${TESTSBASE}/cddl/usr.sbin/dtrace TESTS_SUBDIRS+= common .PATH: ${.CURDIR:H:H:H:H}/tests KYUAFILE= YES -.PATH: ${.CURDIR:H:H:H}/contrib/opensolaris/cmd/dtrace/test/cmd/scripts +.PATH: ${.CURDIR}/tools SCRIPTSDIR= ${TESTSDIR} -SCRIPTS= dtest.pl - -SUBDIR_PARALLEL= +SCRIPTS= dtest.sh .include Index: head/cddl/usr.sbin/dtrace/tests/Makefile.inc1 =================================================================== --- head/cddl/usr.sbin/dtrace/tests/Makefile.inc1 (revision 280834) +++ head/cddl/usr.sbin/dtrace/tests/Makefile.inc1 (revision 280835) @@ -1,53 +1,52 @@ # $FreeBSD$ TESTGROUP= ${.CURDIR:H:T}/${.CURDIR:T} TESTSRC= ${.CURDIR:H:H:H:H:H}/contrib/opensolaris/cmd/dtrace/test/tst/${TESTGROUP} TESTSDIR= ${TESTSBASE}/cddl/usr.sbin/dtrace/${TESTGROUP} .if !defined(_RECURSING_PROGS) FILESGROUPS+= FILES ${TESTGROUP} ${TESTGROUP}EXE ${TESTGROUP}= ${TESTFILES} ${TESTGROUP}EXE= ${TESTEXES} ${TESTGROUP}EXEMODE= 0555 ${TESTGROUP}DIR= ${TESTSDIR} ${TESTGROUP}EXEDIR= ${TESTSDIR} TESTWRAPPER= t_dtrace_contrib ATF_TESTS_SH+= ${TESTWRAPPER} -TEST_METADATA.t_dtrace_contrib+= required_files="/usr/local/bin/perl" TEST_METADATA.t_dtrace_contrib+= required_files="/usr/local/bin/ksh" TEST_METADATA.t_dtrace_contrib+= required_user="root" GENTEST?= ${.CURDIR:H:H}/tools/gentest.sh EXCLUDE= ${.CURDIR:H:H}/tools/exclude.sh ${TESTWRAPPER}.sh: ${GENTEST} ${EXCLUDE} ${${TESTGROUP}} sh ${GENTEST} -e ${EXCLUDE} ${TESTGROUP} ${${TESTGROUP}:S/ */ /} > ${.TARGET} CLEANFILES+= ${TESTWRAPPER}.sh .endif # !defined(_RECURSING_PROGS) .PATH: ${TESTSRC} PROGS= ${CFILES:T:S/.c$/.exe/g} .for prog in ${PROGS} SRCS.${prog}+= ${prog:S/.exe$/.c/} BINDIR.${prog}= ${TESTSDIR} MAN.${prog}= .if exists(${prog:S/^tst.//:S/.exe$/.d/}) SRCS.${prog}+= ${prog:S/^tst.//:S/.exe$/.d/} .endif .endfor # Some tests depend on the internals of their corresponding test programs, # so make sure the optimizer doesn't interfere with them. CFLAGS+= -O0 # Test programs shouldn't be stripped; else we generally can't use the PID # provider. DEBUG_FLAGS= -g STRIP= .include Index: head/cddl/usr.sbin/dtrace/tests/tools/dtest.sh =================================================================== --- head/cddl/usr.sbin/dtrace/tests/tools/dtest.sh (nonexistent) +++ head/cddl/usr.sbin/dtrace/tests/tools/dtest.sh (revision 280835) @@ -0,0 +1,129 @@ +# $FreeBSD$ + +usage() +{ + cat >&2 <<__EOF__ +A harness for test cases in the DTrace test suite. + +usage: $(basename $0) +__EOF__ + exit 1 +} + +gettag() +{ + local tag + + tag=$(basename $1) + tag=${tag#*.} + tag=${tag%%[a-z.]*} + echo $tag +} + +runtest() +{ + local dflags exe exstatus pid retval status + + exstatus=0 + retval=0 + + case $TFILE in + drp.DTRACEDROP_*.d|err.*.d|tst.*.d) + case $TFILE in + drp.DTRACEDROP_*.d) + dflags="-x droptags" + tag=$(gettag "$TFILE") + ;; + err.D_*.d) + exstatus=1 + dflags="-x errtags" + tag=$(gettag "$TFILE") + ;; + err.*.d) + exstatus=1 + ;; + esac + + exe=${TFILE%.*}.exe + if [ -f "$exe" -a -x "$exe" ]; then + ./$exe & + pid=$! + dflags="$dflags ${pid}" + fi + + dtrace -C -s "${TFILE}" $dflags >$STDOUT 2>$STDERR + status=$? + + if [ $status -ne $exstatus ]; then + ERRMSG="dtrace exited with status ${status}, expected ${exstatus}" + retval=1 + elif [ -n "${tag}" ] && ! grep -Fq " [${tag}] " ${STDERR}; then + ERRMSG="dtrace's error output did not contain expected tag ${tag}" + retval=1 + fi + + if [ -n "$pid" ]; then + kill -0 $pid >/dev/null 2>&1 && kill -9 $pid >/dev/null 2>&1 + wait + fi + ;; + err.*.ksh|tst.*.ksh) + expr "$TFILE" : 'err.*' >/dev/null && exstatus=1 + + ksh "$TFILE" /usr/sbin/dtrace >$STDOUT 2>$STDERR + status=$? + + if [ $status -ne $exstatus ]; then + ERRMSG="script exited with status ${status}, expected ${exstatus}" + retval=1 + fi + ;; + *) + ERRMSG="unexpected test file name $TFILE" + retval=1 + ;; + esac + + return $retval +} + +[ $# -eq 1 ] || usage + +readonly STDERR=$(mktemp) +readonly STDOUT=$(mktemp) +readonly TFILE=$(basename $1) +readonly EXOUT=${TFILE}.out + +kldstat -q -m dtrace_test || kldload dtrace_test +cd $(dirname $1) +runtest +RESULT=$? + +if [ $RESULT -eq 0 -a -f $EXOUT -a -r $EXOUT ] && \ + ! cmp $STDOUT $EXOUT >/dev/null 2>&1; then + ERRMSG="test output mismatch" + RESULT=1 +fi + +if [ $RESULT -ne 0 ]; then + echo "test $TFILE failed: $ERRMSG" >&2 + if [ $(stat -f '%z' $STDOUT) -gt 0 ]; then + cat >&2 <<__EOF__ +test stdout: +-- +$(cat $STDOUT) +-- +__EOF__ + fi + if [ $(stat -f '%z' $STDERR) -gt 0 ]; then + cat >&2 <<__EOF__ +test stderr: +-- +$(cat $STDERR) +-- +__EOF__ + fi +fi + +rm -f $STDERR $STDOUT +exit $RESULT Property changes on: head/cddl/usr.sbin/dtrace/tests/tools/dtest.sh ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/cddl/usr.sbin/dtrace/tests/tools/gentest.sh =================================================================== --- head/cddl/usr.sbin/dtrace/tests/tools/gentest.sh (revision 280834) +++ head/cddl/usr.sbin/dtrace/tests/tools/gentest.sh (revision 280835) @@ -1,110 +1,110 @@ # $FreeBSD$ usage() { cat <<__EOF__ >&2 Generate ATF test cases from a set of DTrace tests. usage: sh $(basename $0) [-e ] [] excludes: A shell script which defines test cases that are to be skipped, or aren't expected to pass. category: The test category, in the form of /. For example, "common/aggs" is the test category for D aggregations. testfiles: The test files for the tests in the specified category. __EOF__ exit 1 } gentestcase() { local mod tcase tfile tfile=$1 tcase=$2 mod=$3 cat <<__EOF__ atf_test_case $tcase ${tcase}_head() { atf_set 'descr' 'DTrace test ${CATEGORY}/${tfile}' } ${tcase}_body() { $mod - atf_check -s exit:0 -o ignore -e ignore \\ - "\$(atf_get_srcdir)/../../dtest" -n "\$(atf_get_srcdir)/${tfile}" + atf_check -s exit:0 -o empty -e empty \\ + "\$(atf_get_srcdir)/../../dtest" "\$(atf_get_srcdir)/${tfile}" } __EOF__ } gentestcases() { local mod tcase tfile tfiles eval tfiles=\$$1 mod=$2 for tfile in ${tfiles}; do case $tfile in drp.*.d|err.*.d|tst.*.d|*.ksh) # Test names need to be mangled for ATF. tcase=$(echo "$tfile" | tr '.-' '_') gentestcase "$tfile" "$tcase" "$mod" TCASES="$TCASES $tcase" ;; esac done } set -e # # Parse arguments. # case $1 in -e) shift; EXCLUDES=$1; shift ;; esac CATEGORY=$1 shift if ! expr "$CATEGORY" : '[^/]*/[^/]*' >/dev/null 2>&1; then usage fi FEATURE=$(basename ${CATEGORY}) ARCH=$(dirname ${CATEGORY}) # # Remove skipped tests and expected failures from the main test list. # . $EXCLUDES EXFAILS=$(echo -e "$EXFAIL" | grep "^${CATEGORY}/" | xargs basename -a) SKIPS=$(echo -e "$SKIP" | grep "^${CATEGORY}/" | xargs basename -a) FILELIST=$(mktemp) trap 'rm -f $FILELIST' EXIT echo "$@" | tr ' ' '\n' | xargs basename -a | sort > ${FILELIST} TFILES=$(printf '%s\n%s' "$EXFAILS" "$SKIPS" | sort | comm -13 /dev/stdin $FILELIST) # # Generate test cases. # gentestcases SKIPS "atf_skip \"test may hang or cause system instability\"" gentestcases EXFAILS "atf_expect_fail \"test is known to fail\"" gentestcases TFILES # # Generate the test init function. # cat <<__EOF__ atf_init_test_cases() { $(for tcase in ${TCASES}; do echo " atf_add_test_case $tcase"; done) } __EOF__ rm -f $FILELIST