diff --git a/cddl/usr.bin/ztest/Makefile b/cddl/usr.bin/ztest/Makefile index 31163d95c2cc..63ec0ff9cc66 100644 --- a/cddl/usr.bin/ztest/Makefile +++ b/cddl/usr.bin/ztest/Makefile @@ -25,4 +25,7 @@ CSTD= c99 # it without debugging. CFLAGS+= -g -DDEBUG=1 -Wno-format +HAS_TESTS= +SUBDIR.${MK_TESTS}+= tests + .include diff --git a/cddl/usr.bin/ztest/tests/Makefile b/cddl/usr.bin/ztest/tests/Makefile new file mode 100644 index 000000000000..edf2a537dbe3 --- /dev/null +++ b/cddl/usr.bin/ztest/tests/Makefile @@ -0,0 +1,7 @@ +# $FreeBSD$ + +.include + +ATF_TESTS_SH+= ztest + +.include diff --git a/cddl/usr.bin/ztest/tests/ztest.sh b/cddl/usr.bin/ztest/tests/ztest.sh new file mode 100755 index 000000000000..9945d1a45aa9 --- /dev/null +++ b/cddl/usr.bin/ztest/tests/ztest.sh @@ -0,0 +1,52 @@ +# +# Test Case: ztest +# $FreeBSD$ +# +atf_test_case ztest +ztest_head() +{ + atf_set "descr" "Run ztest" + atf_set "timeout" 900 + atf_set "require.config" "rt_long" +} + +ztest_body() +{ + ARGS="-VVVVV -f ${TMPDIR:-/tmp}" + if atf_config_has ztest_extra_args; then + ARGS="${ARGS} $(atf_config_get ztest_extra_args)" + fi + ztest ${ARGS} + if [ $? != 0 ]; then + echo "failing" + save_ztest_artifacts + atf_fail "Testcase failed" + else + echo "passing" + atf_pass + fi +} + +# +# ATF Test Program Init Function +# +atf_init_test_cases() +{ + atf_add_test_case ztest +} + +save_ztest_artifacts() +{ + # If artifacts_dir is defined, save test artifacts for + # post-mortem analysis + if atf_config_has artifacts_dir; then + TC_ARTIFACTS_DIR=`atf_config_get artifacts_dir`/cddl/usr.bin/ztest/$(atf_get ident) + mkdir -p $TC_ARTIFACTS_DIR + TC_CORE_DIR=/var/crash + if atf_config_has core_dir; then + TC_CORE_DIR=`atf_config_get core_dir` + fi + mv *ztest*.core* $TC_ARTIFACTS_DIR || true + mv ${TC_CORE_DIR}/*ztest*.core* $TC_ARTIFACTS_DIR || true + fi +} diff --git a/etc/mtree/BSD.tests.dist b/etc/mtree/BSD.tests.dist index 05b00f5cbf17..35107e8dc0c7 100644 --- a/etc/mtree/BSD.tests.dist +++ b/etc/mtree/BSD.tests.dist @@ -67,6 +67,8 @@ usr.bin ctfconvert .. + ztest + .. .. usr.sbin dtrace