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