summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.cz>2015-06-03 13:59:55 +0200
committerDavid Sterba <dsterba@suse.cz>2015-06-03 14:04:02 +0200
commit551c4bb064808d500e089e395886c73384576a6d (patch)
tree5d3e5555dba3de3838ffe535e088eebf8921b371 /tests
parent0721c08dffdbbd959186ed3627c4b4728266e4fc (diff)
btrfs-progs: tests: add misc tests for uuid rewrite
Simple tests of the -u/-U options of btrfstune. Signed-off-by: David Sterba <dsterba@suse.cz>
Diffstat (limited to 'tests')
-rwxr-xr-xtests/misc-tests/002-uuid-rewrite/test.sh75
1 files changed, 75 insertions, 0 deletions
diff --git a/tests/misc-tests/002-uuid-rewrite/test.sh b/tests/misc-tests/002-uuid-rewrite/test.sh
new file mode 100755
index 00000000..488f756e
--- /dev/null
+++ b/tests/misc-tests/002-uuid-rewrite/test.sh
@@ -0,0 +1,75 @@
+#!/bin/bash
+# test btrfstune uuid rewriting options
+
+source $TOP/tests/common
+
+check_prereq btrfs-debug-tree
+check_prereq btrfs-show-super
+check_prereq mkfs.btrfs
+check_prereq btrfstune
+
+if [ -z $TEST_DEV ]; then
+ echo "\$TEST_DEV not given, use $TOP/test/test.img as fallback" >> \
+ $RESULTS
+ TEST_DEV="$TOP/tests/test.img"
+
+ # Need at least 1G to avoid mixed block group, which extent tree
+ # rebuild doesn't support.
+ run_check truncate -s 1G $TEST_DEV
+fi
+
+if [ -z $TEST_MNT ];then
+ echo " [NOTRUN] extent tree rebuild, need TEST_MNT variant"
+ exit 0
+fi
+
+get_fs_uuid() {
+ local image
+
+ image="$1"
+ run_check_stdout $TOP/btrfs-show-super "$image" | \
+ grep '^fsid' | awk '{print $2}'
+}
+
+test_uuid_random()
+{
+ local origuuid
+
+ origuuid=11111111-a101-4031-b29a-379d4f8b7a2d
+
+ run_check $SUDO_HELPER $TOP/mkfs.btrfs -f \
+ --uuid $origuuid \
+ --rootdir $TOP/Documentation \
+ $TEST_DEV
+ run_check $TOP/btrfs-show-super "$TEST_DEV"
+ run_check $TOP/btrfstune -f -u $TEST_DEV
+ # btrfs-show-super is called within get_fs_uuid
+ fsid=$(get_fs_uuid $TEST_DEV)
+ run_check $SUDO_HELPER $TOP/btrfs check $TEST_DEV
+}
+
+test_uuid_user()
+{
+ local origuuid
+ local newuuid
+
+ origuuid=22222222-d324-4f92-80e9-7658bf3b845f
+ newuuid=33333333-bfc9-4045-9399-a396dc6893b3
+
+ run_check $SUDO_HELPER $TOP/mkfs.btrfs -f \
+ --uuid $origuuid \
+ --rootdir $TOP/Documentation \
+ $TEST_DEV
+ run_check $TOP/btrfs-show-super "$TEST_DEV"
+ run_check $TOP/btrfstune -f -U $newuuid \
+ $TEST_DEV
+ # btrfs-show-super is called within get_fs_uuid
+ fsid=$(get_fs_uuid $TEST_DEV)
+ if ! [ $fsid = $newuuid ]; then
+ _fail "FAIL: UUID not rewritten"
+ fi
+ run_check $SUDO_HELPER $TOP/btrfs check $TEST_DEV
+}
+
+test_uuid_random
+test_uuid_user