From: Josef Bacik <jbacik@fusionio.com>
To: <linux-btrfs@vger.kernel.org>
Subject: [PATCH 5/5] Btrfs-progs: add make test framework
Date: Mon, 9 Sep 2013 16:41:58 -0400 [thread overview]
Message-ID: <1378759318-3305-5-git-send-email-jbacik@fusionio.com> (raw)
In-Reply-To: <1378759318-3305-1-git-send-email-jbacik@fusionio.com>
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>
---
Makefile | 7 +++++
tests/fsck-tests.sh | 31 +++++++++++++++++++++++
tests/fsck-tests/001-bad-file-extent-bytenr.img | Bin 0 -> 4096 bytes
3 files changed, 38 insertions(+), 0 deletions(-)
create mode 100644 tests/fsck-tests.sh
create mode 100644 tests/fsck-tests/001-bad-file-extent-bytenr.img
diff --git a/Makefile b/Makefile
index 3fade14..0e812cc 100644
--- a/Makefile
+++ b/Makefile
@@ -19,6 +19,7 @@ libbtrfs_objects = send-stream.o send-utils.o rbtree.o btrfs-list.o crc32c.o \
libbtrfs_headers = send-stream.h send-utils.h send.h rbtree.h btrfs-list.h \
crc32c.h list.h kerncompat.h radix-tree.h extent-cache.h \
extent_io.h ioctl.h ctree.h btrfsck.h
+TESTS = fsck-tests.sh
INSTALL = install
prefix ?= /usr/local
@@ -123,6 +124,12 @@ $(BUILDDIRS):
@echo "Making all in $(patsubst build-%,%,$@)"
$(Q)$(MAKE) $(MAKEOPTS) -C $(patsubst build-%,%,$@)
+test:
+ $(Q)for t in $(TESTS); do \
+ echo " [TEST] $$t"; \
+ bash tests/$$t || exit 1; \
+ done
+
#
# NOTE: For static compiles, you need to have all the required libs
# static equivalent available
diff --git a/tests/fsck-tests.sh b/tests/fsck-tests.sh
new file mode 100644
index 0000000..c1490bf
--- /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
diff --git a/tests/fsck-tests/001-bad-file-extent-bytenr.img b/tests/fsck-tests/001-bad-file-extent-bytenr.img
new file mode 100644
index 0000000000000000000000000000000000000000..d2a05bb8f83d7f1bdc4be1441d3d8d35a89e142e
GIT binary patch
literal 4096
zcmeH}eK^y5AIJB=HZis#ld?QS9Mv4_Of8wM<gsInnB$m-GN*JVVaYO&p%sNVl8|UD
zhty$=hFxhUNzWdRrbKy4$Pwm9=f3MY*M0wcU+22+KG*O1d|$uM^}W8o-{<|u`};X{
zAnVA$h94RLe+6`T1+F~HfL<m5fVh(1e?)+2g=@ge=<<oLe=MheV!=lyHm&Soeq_MI
zmArqYvVvdJR|UQ*@Xt|z)jh=)R-FW@AtEWNxE}^T95kIuxTQO`GeSj$OAocZ8ZFG&
z<3eK!w-`IcHv_L`f(<;t>b+Xy{-7?nK7F$e6<y&8(6k1*npyVVPR;^XbD9d3T8KhU
z<dV1dX5Uut3yan!b4PzMp+~U;!K%0@F_3{e9)}18WH>QQb1IAX+fGlXZfMf;0!Vkj
zJvX_KWEOFo=%gw@5vC86umI%0Q@Kpn;Kos~t8AM#5}}Iev<%H_=M(YY>vRsP6|{X%
z%!njroW!5@!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R(9*wW()
z4y9ABlN`RYlfaxf&7e`6?DMK7L3k&Q_;{D3F6PL5ba=L`VPOQvqfN=VRfD)JCSOJ)
wdAHD-c}bH<S;ReLS9EfZAgz)e^M5^=b9|?PO*Mu1f6h4e^-sPk@IO`HPtN?u?f?J)
literal 0
HcmV?d00001
--
1.7.7.6
prev parent reply other threads:[~2013-09-09 20:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-09 20:41 [PATCH 1/5] Btrfs-progs: setup framework to corrupt specific fields of an inode Josef Bacik
2013-09-09 20:41 ` [PATCH 2/5] Btrfs-progs: allow fsck to fix directory isize errors Josef Bacik
2013-09-09 20:41 ` [PATCH 3/5] Btrfs-progs: make btrfsck fix backrefs that are broken Josef Bacik
2013-09-09 20:41 ` [PATCH 4/5] Btrfs-progs: add ability to corrupt file extent disk bytenr Josef Bacik
2013-09-09 20:41 ` Josef Bacik [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1378759318-3305-5-git-send-email-jbacik@fusionio.com \
--to=jbacik@fusionio.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).