3 . $(atf_get_srcdir)/conf.sh
5 atf_test_case attach_d cleanup
8 atf_set "descr" "geli attach -d will cause the provider to detach on last close"
9 atf_set "require.user" "root"
16 md=$(attach_md -t malloc -s `expr $sectors + 1`)
18 atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none
20 atf_check geli init -B none -P -K keyfile ${md}
21 atf_check geli attach -d -p -k keyfile ${md}
23 # Be sure it doesn't detach on read.
24 atf_check dd if=/dev/${md}.eli of=/dev/null status=none
26 if [ ! -c /dev/${md}.eli ]; then
27 atf_fail "Detached on last close of a reader"
30 # It should detach on last close of a writer
33 if [ -c /dev/${md}.eli ]; then
34 atf_fail "Did not detach on last close of a writer"
43 atf_test_case attach_r cleanup
46 atf_set "descr" "geli attach -r will create a readonly provider"
47 atf_set "require.user" "root"
54 md=$(attach_md -t malloc -s `expr $sectors + 1`)
55 atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none
57 atf_check geli init -B none -P -K keyfile ${md}
58 atf_check geli attach -r -p -k keyfile ${md}
60 atf_check -o match:"^Flags: .*READ-ONLY" geli list ${md}.eli
62 # Verify that writes are verbotten
63 atf_check -s not-exit:0 -e match:"Read-only" \
64 dd if=/dev/zero of=/dev/${md}.eli count=1
71 atf_test_case attach_multiple cleanup
72 attach_multiple_head()
74 atf_set "descr" "geli attach can attach multiple providers"
75 atf_set "require.user" "root"
77 attach_multiple_body()
82 md0=$(attach_md -t malloc -s `expr $sectors + 1`)
83 md1=$(attach_md -t malloc -s `expr $sectors + 1`)
84 md2=$(attach_md -t malloc -s `expr $sectors + 1`)
85 atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none
87 atf_check geli init -B none -P -K keyfile ${md0}
88 atf_check geli init -B none -P -K keyfile ${md1}
89 atf_check geli init -B none -P -K keyfile ${md2}
90 atf_check geli attach -p -k keyfile ${md0} ${md1} ${md2}
91 # verify that it did create all 3 geli devices
92 atf_check -s exit:0 test -c /dev/${md0}.eli
93 atf_check -s exit:0 test -c /dev/${md1}.eli
94 atf_check -s exit:0 test -c /dev/${md2}.eli
96 attach_multiple_cleanup()
101 atf_test_case nokey cleanup
104 atf_set "descr" "geli attach fails if called with no key component"
105 atf_set "require.user" "root"
112 md=$(attach_md -t malloc -s `expr $sectors + 1`)
113 atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none
115 atf_check geli init -B none -P -K keyfile ${md}
116 atf_check -s not-exit:0 -e match:"No key components given" \
117 geli attach -p ${md} 2>/dev/null
124 atf_init_test_cases()
126 atf_add_test_case attach_d
127 atf_add_test_case attach_r
128 atf_add_test_case attach_multiple
129 atf_add_test_case nokey