Path: blob/main/tests/sys/geom/class/eli/resize_test.sh
39635 views
#!/bin/sh12. $(atf_get_srcdir)/conf.sh34atf_test_case resize cleanup5resize_head()6{7atf_set "descr" "geli resize will resize a geli provider"8atf_set "require.user" "root"9}10resize_body()11{12geli_test_setup1314BLK=51215BLKS_PER_MB=20481617attach_md md -t malloc -s40m1819# Initialise20atf_check -s exit:0 -o ignore gpart create -s BSD ${md}21atf_check -s exit:0 -o ignore gpart add -t freebsd-ufs -s 10m ${md}2223echo secret >tmp.key24atf_check geli init -Bnone -PKtmp.key ${md}a25atf_check geli attach -pk tmp.key ${md}a2627atf_check -s exit:0 -o ignore newfs -U ${md}a.eli28atf_check -s exit:7 -o ignore fsck_ffs -Ffy ${md}a.eli2930# Doing a backup, resize & restore must be forced (with -f) as geli31# verifies that the provider size in the metadata matches the consumer.3233atf_check geli backup ${md}a tmp.meta34atf_check geli detach ${md}a.eli35atf_check -s exit:0 -o match:resized gpart resize -i1 -s 20m ${md}36atf_check -s not-exit:0 -e ignore geli attach -pktmp.key ${md}a37atf_check -s not-exit:0 -e ignore geli restore tmp.meta ${md}a38atf_check geli restore -f tmp.meta ${md}a39atf_check geli attach -pktmp.key ${md}a40atf_check -s exit:0 -o ignore growfs -y ${md}a.eli41atf_check -s exit:7 -o ignore fsck_ffs -Ffy ${md}a.eli4243# Now do the resize properly4445atf_check geli detach ${md}a.eli46atf_check -s exit:0 -o match:resized gpart resize -i1 -s 30m ${md}47atf_check geli resize -s20m ${md}a48atf_check -s not-exit:0 -e match:"Inconsistent provider.*metadata" \49geli resize -s20m ${md}a50atf_check geli attach -pktmp.key ${md}a51atf_check -s exit:0 -o ignore growfs -y ${md}a.eli52atf_check -s exit:7 -o ignore fsck_ffs -Ffy ${md}a.eli5354atf_check geli detach ${md}a.eli55atf_check -s exit:0 -o ignore gpart destroy -F $md565758# Verify that the man page example works, changing ada0 to $md,59# 1g to 20m, 2g to 30m and keyfile to tmp.key, and adding -B none60# to geli init.6162atf_check -s exit:0 -o ignore gpart create -s GPT $md63atf_check -s exit:0 -o ignore gpart add -s 20m -t freebsd-ufs -i 1 $md64atf_check geli init -B none -K tmp.key -P ${md}p165atf_check -s exit:0 -o match:resized gpart resize -s 30m -i 1 $md66atf_check geli resize -s 20m ${md}p167atf_check geli attach -k tmp.key -p ${md}p168}69resize_cleanup()70{71if [ -f "$TEST_MDS_FILE" ]; then72while read md; do73[ -c /dev/${md}a.eli ] && \74geli detach ${md}a.eli 2>/dev/null75[ -c /dev/${md}p1.eli ] && \76geli detach ${md}p1.eli77[ -c /dev/${md}.eli ] && \78geli detach ${md}.eli 2>/dev/null79mdconfig -d -u $md 2>/dev/null80done < $TEST_MDS_FILE81fi82}8384atf_init_test_cases()85{86atf_add_test_case resize87}888990