4 . $(atf_get_srcdir)/conf.sh
6 atf_test_case resize cleanup
9 atf_set "descr" "geli resize will resize a geli provider"
10 atf_set "require.user" "root"
19 md=$(attach_md -t malloc -s40m)
22 atf_check -s exit:0 -o ignore gpart create -s BSD ${md}
23 atf_check -s exit:0 -o ignore gpart add -t freebsd-ufs -s 10m ${md}
26 atf_check geli init -Bnone -PKtmp.key ${md}a
27 atf_check geli attach -pk tmp.key ${md}a
29 atf_check -s exit:0 -o ignore newfs -U ${md}a.eli
30 atf_check -s exit:7 -o ignore fsck_ffs -Ffy ${md}a.eli
32 # Doing a backup, resize & restore must be forced (with -f) as geli
33 # verifies that the provider size in the metadata matches the consumer.
35 atf_check geli backup ${md}a tmp.meta
36 atf_check geli detach ${md}a.eli
37 atf_check -s exit:0 -o match:resized gpart resize -i1 -s 20m ${md}
38 atf_check -s not-exit:0 -e ignore geli attach -pktmp.key ${md}a
39 atf_check -s not-exit:0 -e ignore geli restore tmp.meta ${md}a
40 atf_check geli restore -f tmp.meta ${md}a
41 atf_check geli attach -pktmp.key ${md}a
42 atf_check -s exit:0 -o ignore growfs -y ${md}a.eli
43 atf_check -s exit:7 -o ignore fsck_ffs -Ffy ${md}a.eli
45 # Now do the resize properly
47 atf_check geli detach ${md}a.eli
48 atf_check -s exit:0 -o match:resized gpart resize -i1 -s 30m ${md}
49 atf_check geli resize -s20m ${md}a
50 atf_check -s not-exit:0 -e match:"Inconsistent provider.*metadata" \
51 geli resize -s20m ${md}a
52 atf_check geli attach -pktmp.key ${md}a
53 atf_check -s exit:0 -o ignore growfs -y ${md}a.eli
54 atf_check -s exit:7 -o ignore fsck_ffs -Ffy ${md}a.eli
56 atf_check geli detach ${md}a.eli
57 atf_check -s exit:0 -o ignore gpart destroy -F $md
60 # Verify that the man page example works, changing ada0 to $md,
61 # 1g to 20m, 2g to 30m and keyfile to tmp.key, and adding -B none
64 atf_check -s exit:0 -o ignore gpart create -s GPT $md
65 atf_check -s exit:0 -o ignore gpart add -s 20m -t freebsd-ufs -i 1 $md
66 atf_check geli init -B none -K tmp.key -P ${md}p1
67 atf_check -s exit:0 -o match:resized gpart resize -s 30m -i 1 $md
68 atf_check geli resize -s 20m ${md}p1
69 atf_check geli attach -k tmp.key -p ${md}p1
73 if [ -f "$TEST_MDS_FILE" ]; then
75 [ -c /dev/${md}a.eli ] && \
76 geli detach ${md}a.eli 2>/dev/null
77 [ -c /dev/${md}p1.eli ] && \
78 geli detach ${md}p1.eli
79 [ -c /dev/${md}.eli ] && \
80 geli detach ${md}.eli 2>/dev/null
81 mdconfig -d -u $md 2>/dev/null
88 atf_add_test_case resize