Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Add a testcase about the schg flags
Baptiste Daroussin committed 10 years ago
commit 398527977b1af7aa78c1b5d5d724cf63b4b8e796
parent 287256f
2 files changed +49 -4
modified tests/frontend/extract.sh
@@ -1,12 +1,15 @@
#!/usr/bin/env atf-sh

. $(atf_get_srcdir)/test_environment.sh
+
CLEANUP=chflags_schg
tests_init \
	basic \
	basic_dirs \
	setuid \
	setuid_hardlinks \
-
	chflags
+
	chflags \
+
	chflags_schg
+


basic_body()
{
@@ -170,11 +173,10 @@ EOF

chflags_body()
{
-
	test -x /sbin/chflags || atf_skip "Requires chflags"
+
	test -x /bin/chflags || atf_skip "Requires chflags"
	# use nodump as it is the only one supported as user, by zfs and by
	# libarchive
	touch ${TMPDIR}/a
-
	chflags schg ${TMPDIR}/a
	new_pkg "test" "test" "1" || atf_fail "fail to create the ucl file"
	echo "@(,,,nodump) ${TMPDIR}/a" > test.plist
	atf_check \
@@ -197,3 +199,43 @@ chflags_body()
		ls -ol ${TMPDIR}/target${TMPDIR}/a

}
+

+
chflags_schg_body()
+
{
+
	test -x /bin/chflags || atf_skip "Requires chflags"
+
	test $(id -u) = 0 || atf_skip "Can only be run as root"
+

+
	touch ${TMPDIR}/a
+
	new_pkg "test" "test" "1" || atf_fail "fail to create the ucl file"
+
	echo "@(root,wheel,,schg) ${TMPDIR}/a" > test.plist
+
	atf_check \
+
		-o empty \
+
		-e empty \
+
		-s exit:0 \
+
		pkg create -M test.ucl -p test.plist
+

+
	mkdir ${TMPDIR}/target
+
	atf_check \
+
		-o empty \
+
		-e empty \
+
		-s exit:0 \
+
		pkg -r ${TMPDIR}/target install -qfy ${TMPDIR}/test-1.txz
+

+
	atf_check \
+
		-o match:"schg" \
+
		-e empty \
+
		-s exit:0 \
+
		ls -ol ${TMPDIR}/target${TMPDIR}/a
+

+
	# reinstall to for removal
+
	atf_check \
+
		-o empty \
+
		-e empty \
+
		-s exit:0 \
+
		pkg -r ${TMPDIR}/target install -qfy ${TMPDIR}/test-1.txz
+
}
+

+
chflags_schg_cleanup()
+
{
+
	chflags -R noschg ${TMPDIR}
+
}
modified tests/frontend/test_environment.sh.in
@@ -16,7 +16,10 @@ tests_init()
	TESTS="$@"
	export TESTS
	for t; do
-
		atf_test_case $t
+
		case " ${CLEANUP:-ENOCLEANUP} " in
+
		*\ $t\ *) atf_test_case $t cleanup ;;
+
		*) atf_test_case $t ;;
+
		esac
	done
}