summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.cz>2015-06-05 18:26:32 +0200
committerDavid Sterba <dsterba@suse.cz>2015-06-05 18:29:58 +0200
commit281be9e7d5bc978940ea8b30f836b28c4fc99b47 (patch)
treedf181a348f14f73866fe2a9625df885d4190ae65 /tests
parent47de682c0ee7c8273a0d2038622bdb7edb523fbd (diff)
btrfs-progs: tests: add test for zero-log
Simple test to verify that the log_root is reset after the command, but we yet need to provide a testing image with log_root set to something sensible or crafted images with borked log_root pointer. Signed-off-by: David Sterba <dsterba@suse.cz>
Diffstat (limited to 'tests')
-rwxr-xr-xtests/misc-tests/003-zero-log/test.sh66
1 files changed, 66 insertions, 0 deletions
diff --git a/tests/misc-tests/003-zero-log/test.sh b/tests/misc-tests/003-zero-log/test.sh
new file mode 100755
index 00000000..da5b3510
--- /dev/null
+++ b/tests/misc-tests/003-zero-log/test.sh
@@ -0,0 +1,66 @@
+#!/bin/bash
+# test zero-log
+
+source $TOP/tests/common
+
+check_prereq btrfs-show-super
+check_prereq mkfs.btrfs
+check_prereq btrfs
+
+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_log_root()
+{
+ local image
+
+ image="$1"
+ $TOP/btrfs-show-super "$image" | \
+ grep '^log_root\>' | awk '{print $2}'
+}
+get_log_root_level() {
+ local image
+
+ image="$1"
+ $TOP/btrfs-show-super "$image" | \
+ grep '^log_root_level' | awk '{print $2}'
+}
+
+test_zero_log()
+{
+ # FIXME: we need an image with existing log_root
+ run_check $SUDO_HELPER $TOP/mkfs.btrfs -f \
+ --rootdir $TOP/Documentation \
+ $TEST_DEV
+ run_check $TOP/btrfs-show-super $TEST_DEV
+ if [ "$1" = 'standalone' ]; then
+ run_check $TOP/btrfs rescue zero-log $TEST_DEV
+ else
+ run_check $TOP/btrfs-zero-log $TEST_DEV
+ fi
+ log_root=$(get_log_root $TEST_DEV)
+ log_root_level=$(get_log_root $TEST_DEV)
+ if [ "$log_root" != 0 ]; then
+ _fail "FAIL: log_root not reset"
+ fi
+ if [ "$log_root_level" != 0 ]; then
+ _fail "FAIL: log_root_level not reset"
+ fi
+ run_check $TOP/btrfs-show-super $TEST_DEV
+ run_check $SUDO_HELPER $TOP/btrfs check $TEST_DEV
+}
+
+test_zero_log standalone
+test_zero_log internal