xref: /freebsd/cddl/usr.bin/ztest/tests/ztest.sh (revision fe75646a0234a261c0013bf1840fdac4acaf0cec)
1#
2# Test Case: ztest
3#
4atf_test_case ztest
5ztest_head()
6{
7	atf_set "descr" "Run ztest"
8	atf_set "timeout" 900
9	atf_set "require.config" "rt_long"
10}
11
12ztest_body()
13{
14	ARGS="-VVVVV -f ${TMPDIR:-/tmp}"
15	if atf_config_has ztest_extra_args; then
16		ARGS="${ARGS} $(atf_config_get ztest_extra_args)"
17	fi
18	ztest ${ARGS}
19	if [ $? != 0 ]; then
20		echo "failing"
21		save_ztest_artifacts
22		atf_fail "Testcase failed"
23	else
24		echo "passing"
25		atf_pass
26	fi
27}
28
29#
30# ATF Test Program Init Function
31#
32atf_init_test_cases()
33{
34	atf_add_test_case ztest
35}
36
37save_ztest_artifacts()
38{
39	# If artifacts_dir is defined, save test artifacts for
40	# post-mortem analysis
41	if atf_config_has artifacts_dir; then
42		TC_ARTIFACTS_DIR=`atf_config_get artifacts_dir`/cddl/usr.bin/ztest/$(atf_get ident)
43		mkdir -p $TC_ARTIFACTS_DIR
44		TC_CORE_DIR=/var/crash
45		if atf_config_has core_dir; then
46			TC_CORE_DIR=`atf_config_get core_dir`
47		fi
48		mv *ztest*.core* $TC_ARTIFACTS_DIR || true
49		mv ${TC_CORE_DIR}/*ztest*.core* $TC_ARTIFACTS_DIR || true
50	fi
51}
52