summaryrefslogtreecommitdiff
path: root/tests/fsck-tests.sh
diff options
context:
space:
mode:
authorJosef Bacik <jbacik@fusionio.com>2013-09-09 16:41:58 -0400
committerChris Mason <chris.mason@fusionio.com>2013-10-16 08:23:11 -0400
commit0d342f8fcb5d99fbdc0765974570d6c335460904 (patch)
tree20598ee3553c80dfc522852692d7e762bf897067 /tests/fsck-tests.sh
parentc2c5e53bf7fa9ab1bdeb57b902bc68db936c8f70 (diff)
Btrfs-progs: add make test framework
We need to start adding some sanity tests to btrfs-progs to make sure we aren't breaking things with our patches. The most important of these tools is btrfsck. This patch gets things started by adding a basic btrfsck test that makes sure we can fix a corruption problem we know we can fix. Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'tests/fsck-tests.sh')
-rw-r--r--tests/fsck-tests.sh31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/fsck-tests.sh b/tests/fsck-tests.sh
new file mode 100644
index 00000000..c1490bf3
--- /dev/null
+++ b/tests/fsck-tests.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+#
+# loop through all of our bad images and make sure fsck repairs them properly
+#
+# It's GPL, same as everything else in this tree.
+#
+
+here=`pwd`
+
+_fail()
+{
+ echo "$*" | tee -a fsck-tests-results.txt
+ exit 1
+}
+
+rm -f fsck-tests-results.txt
+
+for i in $(find $here/tests/fsck-tests -name '*.img')
+do
+ echo "testing image $i" >> fsck-tests-results.txt
+ $here/btrfs-image -r $i test.img >> fsck-tests-results.txt 2>&1 \
+ || _fail "restore failed"
+ $here/btrfsck test.img >> fsck-test-results.txt 2>&1
+ [ $? -eq 0 ] && _fail "btrfsck should have detected corruption"
+
+ $here/btrfsck --repair test.img >> fsck-test-results.txt 2>&1 || \
+ _fail "btrfsck should have repaired the image"
+
+ $here/btrfsck test.img >> fsck-test-results.txt 2>&1 || \
+ _fail "btrfsck did not correct corruption"
+done