Changeset View
Changeset View
Standalone View
Standalone View
sbin/bectl/tests/bectl_test.sh
| Show First 20 Lines • Show All 87 Lines • ▼ Show 20 Lines | bectl_cleanup() | ||||
| elif zpool get health ${zpool} >/dev/null 2>&1; then | elif zpool get health ${zpool} >/dev/null 2>&1; then | ||||
| zpool destroy -f ${zpool} | zpool destroy -f ${zpool} | ||||
| fi | fi | ||||
| } | } | ||||
| atf_test_case bectl_create cleanup | atf_test_case bectl_create cleanup | ||||
| bectl_create_head() | bectl_create_head() | ||||
| { | { | ||||
| atf_set "descr" "Check the various forms of bectl create" | atf_set "descr" "Check the various forms of bectl create" | ||||
| atf_set "require.user" root | atf_set "require.user" root | ||||
| } | } | ||||
| bectl_create_body() | bectl_create_body() | ||||
| { | { | ||||
| if [ "$(atf_config_get ci false)" = "true" ] && \ | if [ "$(atf_config_get ci false)" = "true" ] && \ | ||||
| [ "$(uname -p)" = "i386" ]; then | [ "$(uname -p)" = "i386" ]; then | ||||
| atf_skip "https://bugs.freebsd.org/249055" | atf_skip "https://bugs.freebsd.org/249055" | ||||
| ▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | |||||
| bectl_create_cleanup() | bectl_create_cleanup() | ||||
| { | { | ||||
| bectl_cleanup $(get_zpool_name) | bectl_cleanup $(get_zpool_name) | ||||
| } | } | ||||
| atf_test_case bectl_destroy cleanup | atf_test_case bectl_destroy cleanup | ||||
| bectl_destroy_head() | bectl_destroy_head() | ||||
| { | { | ||||
| atf_set "descr" "Check bectl destroy" | atf_set "descr" "Check bectl destroy" | ||||
| atf_set "require.user" root | atf_set "require.user" root | ||||
| } | } | ||||
| bectl_destroy_body() | bectl_destroy_body() | ||||
| { | { | ||||
| if [ "$(atf_config_get ci false)" = "true" ] && \ | if [ "$(atf_config_get ci false)" = "true" ] && \ | ||||
| [ "$(uname -p)" = "i386" ]; then | [ "$(uname -p)" = "i386" ]; then | ||||
| atf_skip "https://bugs.freebsd.org/249055" | atf_skip "https://bugs.freebsd.org/249055" | ||||
| ▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | bectl_destroy_body() | ||||
| atf_check bectl -r ${zpool}/ROOT create default@test | atf_check bectl -r ${zpool}/ROOT create default@test | ||||
| atf_check bectl -r ${zpool}/ROOT create -e default@test default2 | atf_check bectl -r ${zpool}/ROOT create -e default@test default2 | ||||
| atf_check -e not-empty -s not-exit:0 bectl -r ${zpool}/ROOT destroy \ | atf_check -e not-empty -s not-exit:0 bectl -r ${zpool}/ROOT destroy \ | ||||
| default@test | default@test | ||||
| } | } | ||||
| bectl_destroy_cleanup() | bectl_destroy_cleanup() | ||||
| { | { | ||||
| bectl_cleanup $(get_zpool_name) | bectl_cleanup $(get_zpool_name) | ||||
| } | } | ||||
| atf_test_case bectl_export_import cleanup | atf_test_case bectl_export_import cleanup | ||||
| bectl_export_import_head() | bectl_export_import_head() | ||||
| { | { | ||||
| atf_set "descr" "Check bectl export and import" | atf_set "descr" "Check bectl export and import" | ||||
| atf_set "require.user" root | atf_set "require.user" root | ||||
| } | } | ||||
| bectl_export_import_body() | bectl_export_import_body() | ||||
| { | { | ||||
| if [ "$(atf_config_get ci false)" = "true" ] && \ | if [ "$(atf_config_get ci false)" = "true" ] && \ | ||||
| [ "$(uname -p)" = "i386" ]; then | [ "$(uname -p)" = "i386" ]; then | ||||
| atf_skip "https://bugs.freebsd.org/249055" | atf_skip "https://bugs.freebsd.org/249055" | ||||
| Show All 14 Lines | bectl_export_import_body() | ||||
| atf_check -x "bectl -r ${zpool}/ROOT import default2 < exported" | atf_check -x "bectl -r ${zpool}/ROOT import default2 < exported" | ||||
| atf_check -o not-empty zfs get mountpoint ${zpool}/ROOT/default2 | atf_check -o not-empty zfs get mountpoint ${zpool}/ROOT/default2 | ||||
| atf_check -e ignore bectl -r ${zpool}/ROOT destroy default2 | atf_check -e ignore bectl -r ${zpool}/ROOT destroy default2 | ||||
| atf_check -e not-empty -s not-exit:0 zfs get mountpoint \ | atf_check -e not-empty -s not-exit:0 zfs get mountpoint \ | ||||
| ${zpool}/ROOT/default2 | ${zpool}/ROOT/default2 | ||||
| } | } | ||||
| bectl_export_import_cleanup() | bectl_export_import_cleanup() | ||||
| { | { | ||||
| bectl_cleanup $(get_zpool_name) | bectl_cleanup $(get_zpool_name) | ||||
| } | } | ||||
| atf_test_case bectl_list cleanup | atf_test_case bectl_list cleanup | ||||
| bectl_list_head() | bectl_list_head() | ||||
| { | { | ||||
| atf_set "descr" "Check bectl list" | atf_set "descr" "Check bectl list" | ||||
| atf_set "require.user" root | atf_set "require.user" root | ||||
| } | } | ||||
| bectl_list_body() | bectl_list_body() | ||||
| { | { | ||||
| if [ "$(atf_config_get ci false)" = "true" ] && \ | if [ "$(atf_config_get ci false)" = "true" ] && \ | ||||
| [ "$(uname -p)" = "i386" ]; then | [ "$(uname -p)" = "i386" ]; then | ||||
| atf_skip "https://bugs.freebsd.org/249055" | atf_skip "https://bugs.freebsd.org/249055" | ||||
| Show All 21 Lines | bectl_list_body() | ||||
| atf_check -o not-empty grep 'default2' list.out | atf_check -o not-empty grep 'default2' list.out | ||||
| atf_check -e ignore bectl -r ${zpool}/ROOT destroy default2 | atf_check -e ignore bectl -r ${zpool}/ROOT destroy default2 | ||||
| atf_check -o save:list.out bectl -r ${zpool}/ROOT list | atf_check -o save:list.out bectl -r ${zpool}/ROOT list | ||||
| atf_check -s not-exit:0 grep 'default2' list.out | atf_check -s not-exit:0 grep 'default2' list.out | ||||
| # XXX TODO: Formatting checks | # XXX TODO: Formatting checks | ||||
| } | } | ||||
| bectl_list_cleanup() | bectl_list_cleanup() | ||||
| { | { | ||||
| bectl_cleanup $(get_zpool_name) | bectl_cleanup $(get_zpool_name) | ||||
| } | } | ||||
| atf_test_case bectl_mount cleanup | atf_test_case bectl_mount cleanup | ||||
| bectl_mount_head() | bectl_mount_head() | ||||
| { | { | ||||
| atf_set "descr" "Check bectl mount/unmount" | atf_set "descr" "Check bectl mount/unmount" | ||||
| atf_set "require.user" root | atf_set "require.user" root | ||||
| } | } | ||||
| bectl_mount_body() | bectl_mount_body() | ||||
| { | { | ||||
| if [ "$(atf_config_get ci false)" = "true" ] && \ | if [ "$(atf_config_get ci false)" = "true" ] && \ | ||||
| [ "$(uname -p)" = "i386" ]; then | [ "$(uname -p)" = "i386" ]; then | ||||
| atf_skip "https://bugs.freebsd.org/249055" | atf_skip "https://bugs.freebsd.org/249055" | ||||
| Show All 20 Lines | bectl_mount_body() | ||||
| # Then umount! | # Then umount! | ||||
| atf_check -o not-empty bectl -r ${zpool}/ROOT mount default ${root} | atf_check -o not-empty bectl -r ${zpool}/ROOT mount default ${root} | ||||
| atf_check -o not-empty -x "mount | grep '^${zpool}/ROOT/default'" | atf_check -o not-empty -x "mount | grep '^${zpool}/ROOT/default'" | ||||
| atf_check bectl -r ${zpool}/ROOT umount default | atf_check bectl -r ${zpool}/ROOT umount default | ||||
| atf_check -s not-exit:0 -x "mount | grep '^${zpool}/ROOT/default'" | atf_check -s not-exit:0 -x "mount | grep '^${zpool}/ROOT/default'" | ||||
| } | } | ||||
| bectl_mount_cleanup() | bectl_mount_cleanup() | ||||
| { | { | ||||
| bectl_cleanup $(get_zpool_name) | bectl_cleanup $(get_zpool_name) | ||||
| } | } | ||||
| atf_test_case bectl_rename cleanup | atf_test_case bectl_rename cleanup | ||||
| bectl_rename_head() | bectl_rename_head() | ||||
| { | { | ||||
| atf_set "descr" "Check bectl rename" | atf_set "descr" "Check bectl rename" | ||||
| atf_set "require.user" root | atf_set "require.user" root | ||||
| } | } | ||||
| bectl_rename_body() | bectl_rename_body() | ||||
| { | { | ||||
| if [ "$(atf_config_get ci false)" = "true" ] && \ | if [ "$(atf_config_get ci false)" = "true" ] && \ | ||||
| [ "$(uname -p)" = "i386" ]; then | [ "$(uname -p)" = "i386" ]; then | ||||
| atf_skip "https://bugs.freebsd.org/249055" | atf_skip "https://bugs.freebsd.org/249055" | ||||
| Show All 12 Lines | bectl_rename_body() | ||||
| bectl_create_setup ${zpool} ${disk} ${mount} | bectl_create_setup ${zpool} ${disk} ${mount} | ||||
| atf_check bectl -r ${zpool}/ROOT rename default default2 | atf_check bectl -r ${zpool}/ROOT rename default default2 | ||||
| atf_check -o not-empty zfs get mountpoint ${zpool}/ROOT/default2 | atf_check -o not-empty zfs get mountpoint ${zpool}/ROOT/default2 | ||||
| atf_check -e not-empty -s not-exit:0 zfs get mountpoint \ | atf_check -e not-empty -s not-exit:0 zfs get mountpoint \ | ||||
| ${zpool}/ROOT/default | ${zpool}/ROOT/default | ||||
| } | } | ||||
| bectl_rename_cleanup() | bectl_rename_cleanup() | ||||
| { | { | ||||
| bectl_cleanup $(get_zpool_name) | bectl_cleanup $(get_zpool_name) | ||||
| } | } | ||||
| atf_test_case bectl_jail cleanup | atf_test_case bectl_jail cleanup | ||||
| bectl_jail_head() | bectl_jail_head() | ||||
| { | { | ||||
| atf_set "descr" "Check bectl rename" | atf_set "descr" "Check bectl rename" | ||||
| atf_set "require.user" root | atf_set "require.user" root | ||||
| atf_set "require.progs" jail | atf_set "require.progs" jail | ||||
| } | } | ||||
| bectl_jail_body() | bectl_jail_body() | ||||
| { | { | ||||
| if [ "$(atf_config_get ci false)" = "true" ] && \ | if [ "$(atf_config_get ci false)" = "true" ] && \ | ||||
| [ "$(uname -p)" = "i386" ]; then | [ "$(uname -p)" = "i386" ]; then | ||||
| ▲ Show 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | bectl_jail_body() | ||||
| atf_check bectl -r ${zpool}/ROOT ujail default | atf_check bectl -r ${zpool}/ROOT ujail default | ||||
| } | } | ||||
| # If a test has failed, it's possible that the boot environment hasn't | # If a test has failed, it's possible that the boot environment hasn't | ||||
| # been 'unjail'ed. We want to remove the jail before 'bectl_cleanup' | # been 'unjail'ed. We want to remove the jail before 'bectl_cleanup' | ||||
| # attempts to destroy the zpool. | # attempts to destroy the zpool. | ||||
| bectl_jail_cleanup() | bectl_jail_cleanup() | ||||
| { | { | ||||
| if [ "$(atf_config_get ci false)" = "true" ] && \ | if [ "$(atf_config_get ci false)" = "true" ] && \ | ||||
kevans: It's not clear to me that this situation's actually resolved itself; did you try running these… | |||||
Done Inline ActionsAs I understand it, the cleanup is not run if the body is skipped? But I could be wrong. rcm: As I understand it, the cleanup is not run if the body is skipped? But I could be wrong. | |||||
Done Inline ActionsAt the time it was added that was not true, I don't think any work has been done in kyua to avoid running cleanup on skip since then kevans: At the time it was added that was not true, I don't think any work has been done in kyua to… | |||||
Done Inline ActionsI will add this back. rcm: I will add this back. | |||||
| [ "$(uname -p)" = "i386" ]; then | [ "$(uname -p)" = "i386" ]; then | ||||
| atf_skip "https://bugs.freebsd.org/249055" | atf_skip "https://bugs.freebsd.org/249055" | ||||
| fi | fi | ||||
| if [ "$(atf_config_get ci false)" = "true" ] && \ | if [ "$(atf_config_get ci false)" = "true" ] && \ | ||||
| [ "$(uname -p)" = "armv7" ]; then | [ "$(uname -p)" = "armv7" ]; then | ||||
| atf_skip "https://bugs.freebsd.org/249229" | atf_skip "https://bugs.freebsd.org/249229" | ||||
| fi | fi | ||||
| ▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | bectl_promotion_body() | ||||
| atf_check -o not-empty bectl -r ${zpool}/ROOT activate C | atf_check -o not-empty bectl -r ${zpool}/ROOT activate C | ||||
| atf_check -o inline:"-\n-\n" zfs list -Hr -o origin ${zpool}/ROOT/C | atf_check -o inline:"-\n-\n" zfs list -Hr -o origin ${zpool}/ROOT/C | ||||
| } | } | ||||
| bectl_promotion_cleanup() | bectl_promotion_cleanup() | ||||
| { | { | ||||
| bectl_cleanup $(get_zpool_name) | bectl_cleanup $(get_zpool_name) | ||||
| } | } | ||||
| atf_test_case bectl_destroy_bootonce cleanup | |||||
| bectl_destroy_bootonce_head() | |||||
| { | |||||
| atf_set "descr" "Check bectl destroy (bootonce)" | |||||
| atf_set "require.user" root | |||||
| } | |||||
| bectl_destroy_bootonce_body() | |||||
| { | |||||
| if [ "$(atf_config_get ci false)" = "true" ] && \ | |||||
| [ "$(uname -p)" = "i386" ]; then | |||||
| atf_skip "https://bugs.freebsd.org/249055" | |||||
| fi | |||||
| if [ "$(atf_config_get ci false)" = "true" ] && \ | |||||
| [ "$(uname -p)" = "armv7" ]; then | |||||
| atf_skip "https://bugs.freebsd.org/249229" | |||||
| fi | |||||
| cwd=$(realpath .) | |||||
Not Done Inline ActionsWhat was I smoking? kevans: What was I smoking? | |||||
| zpool=$(make_zpool_name) | |||||
| disk=${cwd}/disk.img | |||||
| mount=${cwd}/mnt | |||||
| root=${mount}/root | |||||
| be=default2 | |||||
| bectl_create_setup ${zpool} ${disk} ${mount} | |||||
| atf_check -s exit:0 -o empty bectl -r ${zpool}/ROOT create -e default ${be} | |||||
| # Create boot environment and bootonce activate it | |||||
| atf_check -s exit:0 -o ignore bectl -r ${zpool}/ROOT activate -t ${be} | |||||
| atf_check -s exit:0 -o inline:"zfs:${zpool}/ROOT/${be}:\n" zfsbootcfg -z ${zpool} | |||||
| # Destroy it | |||||
| atf_check -s exit:0 -o ignore bectl -r ${zpool}/ROOT destroy ${be} | |||||
| # Should be empty | |||||
| atf_check -s exit:0 -o empty zfsbootcfg -z ${zpool} | |||||
| } | |||||
| bectl_destroy_bootonce_cleanup() | |||||
| { | |||||
| bectl_cleanup $(get_zpool_name) | |||||
| } | |||||
| atf_test_case bectl_rename_bootonce cleanup | |||||
| bectl_rename_bootonce_head() | |||||
| { | |||||
| atf_set "descr" "Check bectl destroy (bootonce)" | |||||
| atf_set "require.user" root | |||||
| } | |||||
| bectl_rename_bootonce_body() | |||||
| { | |||||
| if [ "$(atf_config_get ci false)" = "true" ] && \ | |||||
| [ "$(uname -p)" = "i386" ]; then | |||||
| atf_skip "https://bugs.freebsd.org/249055" | |||||
| fi | |||||
| if [ "$(atf_config_get ci false)" = "true" ] && \ | |||||
| [ "$(uname -p)" = "armv7" ]; then | |||||
| atf_skip "https://bugs.freebsd.org/249229" | |||||
| fi | |||||
| cwd=$(realpath .) | |||||
| zpool=$(make_zpool_name) | |||||
| disk=${cwd}/disk.img | |||||
| mount=${cwd}/mnt | |||||
| root=${mount}/root | |||||
| be=default2 | |||||
| bectl_create_setup ${zpool} ${disk} ${mount} | |||||
| atf_check -s exit:0 -o empty bectl -r ${zpool}/ROOT create -e default ${be} | |||||
| # Create boot environment and bootonce activate it | |||||
| atf_check -s exit:0 -o ignore bectl -r ${zpool}/ROOT activate -t ${be} | |||||
| atf_check -s exit:0 -o inline:"zfs:${zpool}/ROOT/${be}:\n" zfsbootcfg -z ${zpool} | |||||
| # Rename it | |||||
| atf_check -s exit:0 -o ignore bectl -r ${zpool}/ROOT rename ${be} ${be}_renamed | |||||
| # Should be renamed | |||||
| atf_check -s exit:0 -o inline:"zfs:${zpool}/ROOT/${be}_renamed:\n" zfsbootcfg -z ${zpool} | |||||
| } | |||||
| bectl_rename_bootonce_cleanup() | |||||
| { | |||||
| bectl_cleanup $(get_zpool_name) | |||||
| } | |||||
| atf_init_test_cases() | atf_init_test_cases() | ||||
| { | { | ||||
| atf_add_test_case bectl_create | atf_add_test_case bectl_create | ||||
| atf_add_test_case bectl_destroy | atf_add_test_case bectl_destroy | ||||
| atf_add_test_case bectl_export_import | atf_add_test_case bectl_export_import | ||||
| atf_add_test_case bectl_list | atf_add_test_case bectl_list | ||||
| atf_add_test_case bectl_mount | atf_add_test_case bectl_mount | ||||
| atf_add_test_case bectl_rename | atf_add_test_case bectl_rename | ||||
| atf_add_test_case bectl_jail | atf_add_test_case bectl_jail | ||||
| atf_add_test_case bectl_promotion | atf_add_test_case bectl_promotion | ||||
| atf_add_test_case bectl_destroy_bootonce | |||||
| atf_add_test_case bectl_rename_bootonce | |||||
| } | } | ||||
It's not clear to me that this situation's actually resolved itself; did you try running these on an i386 kernel?