From 9896b43f70df300feb792487f92b1b1ed87a49ce Mon Sep 17 00:00:00 2001 From: "Misono, Tomohiro" Date: Wed, 18 Oct 2017 11:00:43 +0900 Subject: [PATCH] btrfs-progs: test: add new cli-test for subvol get/set-default Add new test to check functionality of subvol get/set-default. Signed-off-by: Tomohiro Misono [ fix style issues, add missing SUDO_HELPER ] Signed-off-by: David Sterba --- .../008-subvolume-get-set-default/test.sh | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 tests/cli-tests/008-subvolume-get-set-default/test.sh diff --git a/tests/cli-tests/008-subvolume-get-set-default/test.sh b/tests/cli-tests/008-subvolume-get-set-default/test.sh new file mode 100755 index 00000000..9318002e --- /dev/null +++ b/tests/cli-tests/008-subvolume-get-set-default/test.sh @@ -0,0 +1,47 @@ +#!/bin/bash +# test for "subvolume get-default/set-default" + +check_default_id() +{ + id=$(run_check_stdout $SUDO_HELPER "$TOP/btrfs" subvolume get-default .) \ + || { echo "$id"; exit 1; } + if $(echo "$id" | grep -vq "ID $1"); then + _fail "subvolume get-default: default id is not $1, but $id" + fi +} + +source "$TOP/tests/common" + +check_prereq mkfs.btrfs +check_prereq btrfs + +setup_root_helper +prepare_test_dev + +run_check "$TOP/mkfs.btrfs" -f "$TEST_DEV" +run_check_mount_test_dev +cd "$TEST_MNT" + +check_default_id 5 + +# check "subvol set-default " +run_check $SUDO_HELPER "$TOP/btrfs" subvolume create sub +id=$(run_check_stdout "$TOP/btrfs" inspect-internal rootid sub) +run_check $SUDO_HELPER "$TOP/btrfs" subvolume set-default "$id" . +check_default_id "$id" + +run_mustfail "set-default to non existent id" \ + $SUDO_HELPER "$TOP/btrfs" subvolume set-default 100 . + +# check "subvol set-default " +run_check $SUDO_HELPER "$TOP/btrfs" subvolume create sub2 +id=$(run_check_stdout "$TOP/btrfs" inspect-internal rootid sub2) +run_check $SUDO_HELPER "$TOP/btrfs" subvolume set-default ./sub2 +check_default_id "$id" + +run_check $SUDO_HELPER mkdir sub2/dir +run_mustfail "set-default to normal directory" \ + $SUDO_HELPER "$TOP/btrfs" subvolume set-default ./sub2/dir + +cd .. +run_check_umount_test_dev