* [PATCH] Btrfs-progs: add make test framework @ 2013-09-06 18:50 Josef Bacik 2013-09-09 16:32 ` David Sterba 0 siblings, 1 reply; 6+ messages in thread From: Josef Bacik @ 2013-09-06 18:50 UTC (permalink / raw) To: linux-btrfs 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/bad-file-extent-bytenr.img | Bin 0 -> 4096 bytes tests/fsck-tests.sh | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 0 deletions(-) create mode 100644 tests/bad-file-extent-bytenr.img create mode 100644 tests/fsck-tests.sh diff --git a/Makefile b/Makefile index c43cb68..9fbe292 100644 --- a/Makefile +++ b/Makefile @@ -19,6 +19,7 @@ libbtrfs_headers = send-stream.h send-utils.h send.h rbtree.h btrfs-list.h \ CHECKFLAGS= -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ -Wbitwise \ -Wuninitialized -Wshadow -Wundef DEPFLAGS = -Wp,-MMD,$(@D)/.$(@F).d,-MT,$@ +TESTS = fsck-tests.sh INSTALL = install prefix ?= /usr/local @@ -87,6 +88,12 @@ endif all: version.h $(progs) manpages +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/bad-file-extent-bytenr.img b/tests/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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uHf-Rx1c(OSAfiUp}yJ3!Fbn?Kptcj6K)|9-vi7E{l{51s`$ z=ygBq!a8*7oHiPVD8c5%@|X|@bb*5<N4q%(1r>2yqjR>4M(^gJ5T*El`%Mb|3IS)C zAoI*Z)MtDBqP>lfb}WQHr8venClWZri%xBi2t+Tq$_+{kCwAAAJvFUN&Bv-rrV7~h zCa8Q_YI`kO(|@`bPR4WBhuS9N0?eLd_gFO6_e{7+Euv;eb}K@u7(ynbeEvNKv<8hn z!`U4a23A^~^yx<XLLs1!P3en!+Lu`xX#;0dfUw0#!m=YvtKiL81d-y6GjR(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 diff --git a/tests/fsck-tests.sh b/tests/fsck-tests.sh new file mode 100644 index 0000000..b164c4e --- /dev/null +++ b/tests/fsck-tests.sh @@ -0,0 +1,34 @@ +#!/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. +# + +TEST_DEV="" +here=`pwd` + +_fail() +{ + echo "$*" | tee -a fsck-tests-results.txt + exit 1 +} + +[ -z $TEST_DEV ] && echo "Cannot run without a test device set" && exit 0 + +rm -f fsck-tests-results.txt + +for i in $(find tests -name '*.img') +do + echo "testing image $i" >> fsck-tests-results.txt + $here/btrfs-image -r $i $TEST_DEV >> fsck-tests-results.txt 2>&1 \ + || _fail "restore failed" + $here/btrfsck $TEST_DEV >> fsck-test-results.txt 2>&1 + [ $? -eq 0 ] && _fail "btrfsck should have detected corruption" + + $here/btrfsck --repair $TEST_DEV >> fsck-test-results.txt 2>&1 || \ + _fail "btrfsck should have repaired the image" + + $here/btrfsck $TEST_DEV >> fsck-test-results.txt 2>&1 || \ + _fail "btrfsck did not correct corruption" +done -- 1.7.7.6 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] Btrfs-progs: add make test framework 2013-09-06 18:50 [PATCH] Btrfs-progs: add make test framework Josef Bacik @ 2013-09-09 16:32 ` David Sterba 2013-09-09 17:13 ` Josef Bacik 0 siblings, 1 reply; 6+ messages in thread From: David Sterba @ 2013-09-09 16:32 UTC (permalink / raw) To: Josef Bacik; +Cc: linux-btrfs On Fri, Sep 06, 2013 at 02:50:56PM -0400, Josef Bacik wrote: > 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, That's great. I hope we're going to gather more tests so let's separate them to more categories from the beginning (mkfs, options coverage, corrupt-block, restore maybe, dunno what else). This makes it possible to do a quick run a subset of the tests (eg. mkfs related) after a fix is committed. > tests/bad-file-extent-bytenr.img | Bin 0 -> 4096 bytes > tests/fsck-tests.sh | 34 ++++++++++++++++++++++++++++++++++ I suggest to put them into a subdirectory (eg.) 'fsck' and prefix the images with numbers (just a sequence number). > --- /dev/null > +++ b/tests/fsck-tests.sh > @@ -0,0 +1,34 @@ > +#!/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. > +# > + > +TEST_DEV="" I found the current test hard to use, eg. I can't just do 'make test' from the toplevel dir. The script fsck-tests.sh expects TEST_DEV to be set, but there's no way to do that, because it's set unconditionally to empty string. > +here=`pwd` > + > +_fail() > +{ > + echo "$*" | tee -a fsck-tests-results.txt > + exit 1 > +} > + > +[ -z $TEST_DEV ] && echo "Cannot run without a test device set" && exit 0 > + > +rm -f fsck-tests-results.txt > + > +for i in $(find tests -name '*.img') > +do > + echo "testing image $i" >> fsck-tests-results.txt > + $here/btrfs-image -r $i $TEST_DEV >> fsck-tests-results.txt 2>&1 \ > + || _fail "restore failed" > + $here/btrfsck $TEST_DEV >> fsck-test-results.txt 2>&1 > + [ $? -eq 0 ] && _fail "btrfsck should have detected corruption" > + > + $here/btrfsck --repair $TEST_DEV >> fsck-test-results.txt 2>&1 || \ > + _fail "btrfsck should have repaired the image" > + > + $here/btrfsck $TEST_DEV >> fsck-test-results.txt 2>&1 || \ > + _fail "btrfsck did not correct corruption" > +done ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Btrfs-progs: add make test framework 2013-09-09 16:32 ` David Sterba @ 2013-09-09 17:13 ` Josef Bacik 2013-09-09 19:07 ` Eric Sandeen 0 siblings, 1 reply; 6+ messages in thread From: Josef Bacik @ 2013-09-09 17:13 UTC (permalink / raw) To: dsterba, Josef Bacik, linux-btrfs On Mon, Sep 09, 2013 at 06:32:04PM +0200, David Sterba wrote: > On Fri, Sep 06, 2013 at 02:50:56PM -0400, Josef Bacik wrote: > > 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, > > That's great. I hope we're going to gather more tests so let's separate > them to more categories from the beginning (mkfs, options coverage, > corrupt-block, restore maybe, dunno what else). > > This makes it possible to do a quick run a subset of the tests (eg. mkfs > related) after a fix is committed. > > > tests/bad-file-extent-bytenr.img | Bin 0 -> 4096 bytes > > tests/fsck-tests.sh | 34 ++++++++++++++++++++++++++++++++++ > > I suggest to put them into a subdirectory (eg.) 'fsck' and prefix the > images with numbers (just a sequence number). I'm not prefixing with numbers, I want to make it easy to tell what each image is testing for. I will move them into a fsck directory tho. > > > --- /dev/null > > +++ b/tests/fsck-tests.sh > > @@ -0,0 +1,34 @@ > > +#!/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. > > +# > > + > > +TEST_DEV="" > > I found the current test hard to use, eg. I can't just do 'make test' > from the toplevel dir. The script fsck-tests.sh expects TEST_DEV to be > set, but there's no way to do that, because it's set unconditionally to > empty string. Yeah I wasn't sure how I wanted to do this. At first I thought about making the fsck tester just make a loop device, but I didn't want to override something if people were already using a loop device. But maybe I'll just default to using loop5 or something big like that and then if the user wants to change it they can go into the script and change it themselves. How does that sound? Thanks, Josef ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Btrfs-progs: add make test framework 2013-09-09 17:13 ` Josef Bacik @ 2013-09-09 19:07 ` Eric Sandeen 2013-09-09 19:57 ` Josef Bacik 0 siblings, 1 reply; 6+ messages in thread From: Eric Sandeen @ 2013-09-09 19:07 UTC (permalink / raw) To: Josef Bacik; +Cc: dsterba, linux-btrfs On 9/9/13 12:13 PM, Josef Bacik wrote: > On Mon, Sep 09, 2013 at 06:32:04PM +0200, David Sterba wrote: >> On Fri, Sep 06, 2013 at 02:50:56PM -0400, Josef Bacik wrote: >>> 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, >> >> That's great. I hope we're going to gather more tests so let's separate >> them to more categories from the beginning (mkfs, options coverage, >> corrupt-block, restore maybe, dunno what else). >> >> This makes it possible to do a quick run a subset of the tests (eg. mkfs >> related) after a fix is committed. >> >>> tests/bad-file-extent-bytenr.img | Bin 0 -> 4096 bytes >>> tests/fsck-tests.sh | 34 ++++++++++++++++++++++++++++++++++ >> >> I suggest to put them into a subdirectory (eg.) 'fsck' and prefix the >> images with numbers (just a sequence number). > > I'm not prefixing with numbers, I want to make it easy to tell what each image > is testing for. I will move them into a fsck directory tho. David might have meant "001-bad-file-extent-bytenr.img" though. >> >>> --- /dev/null >>> +++ b/tests/fsck-tests.sh >>> @@ -0,0 +1,34 @@ >>> +#!/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. >>> +# >>> + >>> +TEST_DEV="" >> >> I found the current test hard to use, eg. I can't just do 'make test' >> from the toplevel dir. The script fsck-tests.sh expects TEST_DEV to be >> set, but there's no way to do that, because it's set unconditionally to >> empty string. > > Yeah I wasn't sure how I wanted to do this. At first I thought about making the > fsck tester just make a loop device, but I didn't want to override something if > people were already using a loop device. But maybe I'll just default to using > loop5 or something big like that and then if the user wants to change it they > can go into the script and change it themselves. How does that sound? Thanks, Dumb question, can you just point btrfsck at the image itself w/o setting up loopback? i.e. do something like: # btrfs-image -r 001-bad-file-extent-bytenr.img test.img # btrfsck --repair test.img -Eric > Josef > -- > To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Btrfs-progs: add make test framework 2013-09-09 19:07 ` Eric Sandeen @ 2013-09-09 19:57 ` Josef Bacik 2013-09-09 23:31 ` David Sterba 0 siblings, 1 reply; 6+ messages in thread From: Josef Bacik @ 2013-09-09 19:57 UTC (permalink / raw) To: Eric Sandeen; +Cc: Josef Bacik, dsterba, linux-btrfs On Mon, Sep 09, 2013 at 02:07:43PM -0500, Eric Sandeen wrote: > On 9/9/13 12:13 PM, Josef Bacik wrote: > > On Mon, Sep 09, 2013 at 06:32:04PM +0200, David Sterba wrote: > >> On Fri, Sep 06, 2013 at 02:50:56PM -0400, Josef Bacik wrote: > >>> 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, > >> > >> That's great. I hope we're going to gather more tests so let's separate > >> them to more categories from the beginning (mkfs, options coverage, > >> corrupt-block, restore maybe, dunno what else). > >> > >> This makes it possible to do a quick run a subset of the tests (eg. mkfs > >> related) after a fix is committed. > >> > >>> tests/bad-file-extent-bytenr.img | Bin 0 -> 4096 bytes > >>> tests/fsck-tests.sh | 34 ++++++++++++++++++++++++++++++++++ > >> > >> I suggest to put them into a subdirectory (eg.) 'fsck' and prefix the > >> images with numbers (just a sequence number). > > > > I'm not prefixing with numbers, I want to make it easy to tell what each image > > is testing for. I will move them into a fsck directory tho. > > David might have meant "001-bad-file-extent-bytenr.img" though. Oh yeah that may be good then. > > >> > >>> --- /dev/null > >>> +++ b/tests/fsck-tests.sh > >>> @@ -0,0 +1,34 @@ > >>> +#!/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. > >>> +# > >>> + > >>> +TEST_DEV="" > >> > >> I found the current test hard to use, eg. I can't just do 'make test' > >> from the toplevel dir. The script fsck-tests.sh expects TEST_DEV to be > >> set, but there's no way to do that, because it's set unconditionally to > >> empty string. > > > > Yeah I wasn't sure how I wanted to do this. At first I thought about making the > > fsck tester just make a loop device, but I didn't want to override something if > > people were already using a loop device. But maybe I'll just default to using > > loop5 or something big like that and then if the user wants to change it they > > can go into the script and change it themselves. How does that sound? Thanks, > > Dumb question, can you just point btrfsck at the image itself w/o setting up > loopback? i.e. do something like: > > # btrfs-image -r 001-bad-file-extent-bytenr.img test.img > # btrfsck --repair test.img Huh, I'm not sure...yes it looks like it, well that solves that problem. Thanks, Josef > > -Eric > > > Josef > > -- > > To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in > > the body of a message to majordomo@vger.kernel.org > > More majordomo info at http://vger.kernel.org/majordomo-info.html > > > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Btrfs-progs: add make test framework 2013-09-09 19:57 ` Josef Bacik @ 2013-09-09 23:31 ` David Sterba 0 siblings, 0 replies; 6+ messages in thread From: David Sterba @ 2013-09-09 23:31 UTC (permalink / raw) To: Josef Bacik; +Cc: Eric Sandeen, dsterba, linux-btrfs On Mon, Sep 09, 2013 at 03:57:17PM -0400, Josef Bacik wrote: > On Mon, Sep 09, 2013 at 02:07:43PM -0500, Eric Sandeen wrote: > > On 9/9/13 12:13 PM, Josef Bacik wrote: > > David might have meant "001-bad-file-extent-bytenr.img" though. > Oh yeah that may be good then. Yes that's what I meant. I thought the number could be useful as a shortcut additional to the human-readable part. > > > Yeah I wasn't sure how I wanted to do this. At first I thought about making the > > > fsck tester just make a loop device, but I didn't want to override something if > > > people were already using a loop device. But maybe I'll just default to using > > > loop5 or something big like that and then if the user wants to change it they > > > can go into the script and change it themselves. How does that sound? Thanks, > > > > Dumb question, can you just point btrfsck at the image itself w/o setting up > > loopback? i.e. do something like: > > > > # btrfs-image -r 001-bad-file-extent-bytenr.img test.img > > # btrfsck --repair test.img > > Huh, I'm not sure...yes it looks like it, well that solves that problem. > Thanks, If you need a blockdevice, you can use $ losetup -f /the/file (get a free loopdev) $ losetup -j /the/file /dev/loop2: ... and parse the loop name from the output. ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-09-09 23:31 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-09-06 18:50 [PATCH] Btrfs-progs: add make test framework Josef Bacik 2013-09-09 16:32 ` David Sterba 2013-09-09 17:13 ` Josef Bacik 2013-09-09 19:07 ` Eric Sandeen 2013-09-09 19:57 ` Josef Bacik 2013-09-09 23:31 ` David Sterba
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.