xref: /freebsd/tests/sys/geom/class/eli/detach_test.sh (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
1
2. $(atf_get_srcdir)/conf.sh
3
4atf_test_case detach_l cleanup
5detach_l_head()
6{
7	atf_set "descr" "geli detach -l will cause a provider to detach on last close"
8	atf_set "require.user" "root"
9}
10detach_l_body()
11{
12	geli_test_setup
13
14	sectors=100
15	attach_md md -t malloc -s `expr $sectors + 1`
16
17	atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none
18
19	atf_check geli init -B none -P -K keyfile ${md}
20	atf_check geli attach -p -k keyfile ${md}
21
22	# Be sure it doesn't detach before 'detach -l'.
23	atf_check dd if=/dev/${md}.eli of=/dev/null status=none
24	sleep 1
25	if [ ! -c /dev/${md}.eli ]; then
26		atf_fail "provider detached on last close without detach -l"
27	fi
28	atf_check geli detach -l ${md}
29	if [ ! -c /dev/${md}.eli ]; then
30		atf_fail "Provider detached before last close"
31	fi
32	atf_check dd if=/dev/${md}.eli of=/dev/null status=none
33	sleep 1
34	if [ -c /dev/${md}.eli ]; then
35		atf_fail "Provider did not detach on last close"
36	fi
37}
38detach_l_cleanup()
39{
40	geli_test_cleanup
41}
42
43atf_init_test_cases()
44{
45	atf_add_test_case detach_l
46}
47