Path: blob/main/tests/sys/geom/class/eli/attach_test.sh
39635 views
1. $(atf_get_srcdir)/conf.sh23atf_test_case attach_d cleanup4attach_d_head()5{6atf_set "descr" "geli attach -d will cause the provider to detach on last close"7atf_set "require.user" "root"8}9attach_d_body()10{11geli_test_setup1213sectors=10014attach_md md -t malloc -s `expr $sectors + 1`1516atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none1718atf_check geli init -B none -P -K keyfile ${md}19atf_check geli attach -d -p -k keyfile ${md}2021# Be sure it doesn't detach on read.22atf_check dd if=/dev/${md}.eli of=/dev/null status=none23sleep 124if [ ! -c /dev/${md}.eli ]; then25atf_fail "Detached on last close of a reader"26fi2728# It should detach on last close of a writer29true > /dev/${md}.eli30sleep 131if [ -c /dev/${md}.eli ]; then32atf_fail "Did not detach on last close of a writer"33fi3435}36attach_d_cleanup()37{38geli_test_cleanup39}4041atf_test_case atach_multiple_fails cleanup42attach_multiple_fails_head()43{44atf_set "descr" "test multiple failed attach of geli provider"45atf_set "require.user" "root"46}47attach_multiple_fails_body()48{49geli_test_setup5051sectors=100052attach_md md -t malloc -s `expr $sectors + 1`53atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none5455atf_check geli init -B none -P -K keyfile ${md}56atf_check geli attach -d -p -k keyfile ${md}5758for i in $(jot 100); do59atf_check -s not-exit:0 -e ignore -- geli attach -d -p -k keyfile ${md}60done61atf_check -o ignore -- newfs ${md}.eli62}63attach_multiple_fails_cleanup()64{65geli_test_cleanup66}676869atf_test_case attach_r cleanup70attach_r_head()71{72atf_set "descr" "geli attach -r will create a readonly provider"73atf_set "require.user" "root"74}75attach_r_body()76{77geli_test_setup7879sectors=10080attach_md md -t malloc -s `expr $sectors + 1`81atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none8283atf_check geli init -B none -P -K keyfile ${md}84atf_check geli attach -r -p -k keyfile ${md}8586atf_check -o match:"^Flags: .*READ-ONLY" geli list ${md}.eli8788# Verify that writes are verbotten89atf_check -s not-exit:0 -e match:"Read-only" \90dd if=/dev/zero of=/dev/${md}.eli count=191}92attach_r_cleanup()93{94geli_test_cleanup95}9697atf_test_case attach_multiple cleanup98attach_multiple_head()99{100atf_set "descr" "geli attach can attach multiple providers"101atf_set "require.user" "root"102}103attach_multiple_body()104{105geli_test_setup106107sectors=100108attach_md md0 -t malloc -s `expr $sectors + 1`109attach_md md1 -t malloc -s `expr $sectors + 1`110attach_md md2 -t malloc -s `expr $sectors + 1`111atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none112113atf_check geli init -B none -P -K keyfile ${md0}114atf_check geli init -B none -P -K keyfile ${md1}115atf_check geli init -B none -P -K keyfile ${md2}116atf_check geli attach -p -k keyfile ${md0} ${md1} ${md2}117# verify that it did create all 3 geli devices118atf_check -s exit:0 test -c /dev/${md0}.eli119atf_check -s exit:0 test -c /dev/${md1}.eli120atf_check -s exit:0 test -c /dev/${md2}.eli121}122attach_multiple_cleanup()123{124geli_test_cleanup125}126127atf_test_case nokey cleanup128nokey_head()129{130atf_set "descr" "geli attach fails if called with no key component"131atf_set "require.user" "root"132}133nokey_body()134{135geli_test_setup136137sectors=100138attach_md md -t malloc -s `expr $sectors + 1`139atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none140141atf_check geli init -B none -P -K keyfile ${md}142atf_check -s not-exit:0 -e match:"No key components given" \143geli attach -p ${md} 2>/dev/null144}145nokey_cleanup()146{147geli_test_cleanup148}149150atf_init_test_cases()151{152atf_add_test_case attach_d153atf_add_test_case attach_r154atf_add_test_case attach_multiple155atf_add_test_case attach_multiple_fails156atf_add_test_case nokey157}158159160