aboutsummaryrefslogtreecommitdiff
path: root/sbin/bectl/tests/bectl_test.sh
diff options
context:
space:
mode:
Diffstat (limited to 'sbin/bectl/tests/bectl_test.sh')
-rwxr-xr-xsbin/bectl/tests/bectl_test.sh125
1 files changed, 91 insertions, 34 deletions
diff --git a/sbin/bectl/tests/bectl_test.sh b/sbin/bectl/tests/bectl_test.sh
index 0f167829cf46..8084b0a173f4 100755
--- a/sbin/bectl/tests/bectl_test.sh
+++ b/sbin/bectl/tests/bectl_test.sh
@@ -1,28 +1,7 @@
#
-# SPDX-License-Identifier: BSD-2-Clause
-#
# Copyright (c) 2018 Kyle Evans <kevans@FreeBSD.org>
#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-# SUCH DAMAGE.
+# SPDX-License-Identifier: BSD-2-Clause
#
ZPOOL_NAME_FILE=zpool_name
@@ -93,7 +72,6 @@ bectl_cleanup()
atf_test_case bectl_create cleanup
bectl_create_head()
{
-
atf_set "descr" "Check the various forms of bectl create"
atf_set "require.user" root
}
@@ -157,7 +135,6 @@ bectl_create_cleanup()
atf_test_case bectl_destroy cleanup
bectl_destroy_head()
{
-
atf_set "descr" "Check bectl destroy"
atf_set "require.user" root
}
@@ -240,14 +217,12 @@ bectl_destroy_body()
}
bectl_destroy_cleanup()
{
-
bectl_cleanup $(get_zpool_name)
}
atf_test_case bectl_export_import cleanup
bectl_export_import_head()
{
-
atf_set "descr" "Check bectl export and import"
atf_set "require.user" root
}
@@ -278,14 +253,12 @@ bectl_export_import_body()
}
bectl_export_import_cleanup()
{
-
bectl_cleanup $(get_zpool_name)
}
atf_test_case bectl_list cleanup
bectl_list_head()
{
-
atf_set "descr" "Check bectl list"
atf_set "require.user" root
}
@@ -323,14 +296,12 @@ bectl_list_body()
}
bectl_list_cleanup()
{
-
bectl_cleanup $(get_zpool_name)
}
atf_test_case bectl_mount cleanup
bectl_mount_head()
{
-
atf_set "descr" "Check bectl mount/unmount"
atf_set "require.user" root
}
@@ -367,14 +338,12 @@ bectl_mount_body()
}
bectl_mount_cleanup()
{
-
bectl_cleanup $(get_zpool_name)
}
atf_test_case bectl_rename cleanup
bectl_rename_head()
{
-
atf_set "descr" "Check bectl rename"
atf_set "require.user" root
}
@@ -403,14 +372,12 @@ bectl_rename_body()
}
bectl_rename_cleanup()
{
-
bectl_cleanup $(get_zpool_name)
}
atf_test_case bectl_jail cleanup
bectl_jail_head()
{
-
atf_set "descr" "Check bectl rename"
atf_set "require.user" root
atf_set "require.progs" jail
@@ -577,6 +544,94 @@ bectl_promotion_cleanup()
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 .)
+ 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_add_test_case bectl_create
@@ -587,4 +642,6 @@ atf_init_test_cases()
atf_add_test_case bectl_rename
atf_add_test_case bectl_jail
atf_add_test_case bectl_promotion
+ atf_add_test_case bectl_destroy_bootonce
+ atf_add_test_case bectl_rename_bootonce
}