Commit Graph

28 Commits (master)

Author SHA1 Message Date
David Sterba 402ac7a140 btrfs-progs: tests: update log markers
Use visual markers that separate tests and individual commands run via
the run_* helpers.

Signed-off-by: David Sterba <dsterba@suse.com>
2018-06-07 16:37:32 +02:00
David Sterba e44f595dd7 btrfs-progs: tests: unify test drivers, make ready for extenral testsuite
Make the TOP variable more configurable, allow to set it to any path
where to find binaries when the testsuite is exported, or fallback to
system binaries.

There's now more code duplication, the logic is now more complex so it's
left open coded for clarity. Further cleanups are possible.

Signed-off-by: David Sterba <dsterba@suse.com>
2018-02-13 16:19:48 +01:00
Gu Jinxiang cebf3b3722 btrfs-progs: introduce TEST_TOP and INTERNAL_BIN for tests
Use TEST_TOP as base for tests to reference any files, this will be used
for git and external testsuite.

INTERNAL_BIN is needed for referencing binaries that could reside in
different paths in git vs external testsuite.

Signed-off-by: Gu Jinxiang <gujx@cn.fujitsu.com>
[ add quotes around sourced files, update changelog ]
Signed-off-by: David Sterba <dsterba@suse.com>
2018-02-13 15:41:32 +01:00
Adam Buchbinder 50d037b459 btrfs-progs: tests: Fix missing internal deps in check and misc tests
Doing a straight 'make test' would fail because some misc and fsck
tests require particular tools to already be built. Add dependencies
at the Makefile and shell-script level.

Signed-off-by: Adam Buchbinder <abuchbinder@google.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-07-20 17:43:43 +02:00
David Sterba d4ce61f7a2 btrfs-progs: tests: add fallback to current directory for check_all_images
Reported-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-11-23 11:07:05 +01:00
David Sterba 4884ae2f5e btrfs-progs: tests: enhance TEST_LOG features
Add new keyword to dump the log file after any test fails. Can be useful
for remote analysis of test failures.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-11-23 10:51:43 +01:00
David Sterba 7dbb17dbb2 btrfs-progs: tests: add quotation around variables in support scripts
Signed-off-by: David Sterba <dsterba@suse.com>
2016-11-11 16:25:19 +01:00
David Sterba 4ad7a967d1 btrfs-progs: tests: check if kernel has btrfs support
Add some sanity checks, reported among other issues via bugzilla.

References: https://bugzilla.kernel.org/show_bug.cgi?id=177141
Signed-off-by: David Sterba <dsterba@suse.com>
2016-11-11 16:25:18 +01:00
David Sterba e5f8099464 btrfs-progs: tests: unify test drivers
Remove unnecessary code, add exports to all common variables.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-06-03 16:53:27 +02:00
Nicholas D Steeves bd2cc320af btrfs-progs: typo review of strings and comments
Signed-off-by: Nicholas D Steeves <nsteeves@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-06-01 14:56:56 +02:00
David Sterba 05d4159946 btrfs-progs: tests: print test type
Makes it a bit more clear:

    [TEST/conv]   ext4 32k nodesize, btrfs no-holes
    [TEST/conv]   ext2 64k nodesize, btrfs no-holes
    [TEST/conv]   ext3 64k nodesize, btrfs no-holes
    [TEST/conv]   ext4 64k nodesize, btrfs no-holes
    [TEST]        misc-tests.sh
    [TEST/misc]   001-btrfstune-features
    [TEST/misc]   002-uuid-rewrite
    [TEST/misc]   003-zero-log
    [TEST/misc]   004-shrink-fs
    [TEST/misc]   005-convert-progress-thread-crash
    [TEST/misc]   006-image-on-missing-device
    [TEST/misc]   007-subvolume-sync
    [TEST/misc]   008-leaf-crossing-stripes
    [TEST/misc]   009-subvolume-sync-must-wait
    [TEST/misc]   010-convert-delete-ext2-subvol
    [TEST/misc]   011-delete-missing-device
    [TEST]        fuzz-tests.sh
    [TEST/fuzz]   001-simple-unmounted

Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12 15:01:02 +01:00
Zhao Lei d4d500d341 btrfs-progs: tests: Introduce init_env to initialize common env variant
For example, $TEST_DIR is common used in severial tests, and have
duplicated code for initialize.

These duplicated code not only benifits harddisk vendor, but have
inconsistent details, as:
  convert-tests.sh: lack of mkdir
  fsck-tests/012-leaf-corruption/test.sh: unnecessary mkdir
  fsck-tests/013-extent-tree-rebuild/test.sh: unnecessary init
  misc-tests/XXX ...
And severial error message:
  _fail "unable to create mount point on $TEST_MNT"
  _fail "failed to create mount point"
  ...

This patch move initizlizaton of $TEST_DIR to common init_env(),
to avoid above problem, and init_env() can be used to add more
things in future.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-09-01 14:02:48 +02:00
David Sterba a5afa55a30 btrfs-progs: tests: support testname glob
To run a given test set the variable TEST like

 $ make test TEST=002-bad-transid
 $ make test TEST=002-*

and only tests matching the value will be run. The pattern is glob and
pased to 'find -name'.

The convert tests do not follow the fsck and misc layout and are skipped
if TEST is set.

Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:09 +02:00
David Sterba 9842d57691 btrfs-progs: fsck tests: move code to a function
Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:09 +02:00
David Sterba 9e3e423d68 btrfs-progs: tests: use readlink -f to resolve path
The utility 'realpath' from coreutils is new enough to be missing on my
"old" reference build host.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-05-21 18:48:55 +02:00
David Sterba 7c6801606e btrfs-progs: tests: log the test name in results file
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-05-21 16:37:52 +02:00
Qu Wenruo 8720e15cd1 btrfs-progs: test-frame: Update variant names
Use upper case variant name for the following variants:
1) top -> TOP
2) script_dir -> SCRIPT_DIR

And change the following variant name:
1) RESULT -> RESULTS

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-07 17:22:30 +02:00
David Sterba ca7b429f26 btrfs-progs: tests, adjust alignment of the pretty command name
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-01-14 18:34:18 +01:00
Qu Wenruo e6bc739148 btrfs-progs: Move extent tree rebuild test to its dir
Move extent tree rebuild teset to its dir.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-01-14 18:34:18 +01:00
Qu Wenruo 5287625fcf btrfs-progs: New btrfsck test infrastructure
Change the old btrfsck test infrastructure (btrfs-image dump or xz raw
dump) to the new test infrastructure.

1) Test case layout
The new infrastructure is dir based, each dir is one test type, and can
contain multiple images/scripts for different corner cases.
So layout will be the following:
btrfs-progs
	|-tests
	    |-fsck-tests
		|-001-SOME-CORRUPT-TYPE
			|-IMAGE-FOR-CASE1
			|-IMAGE-FOR-CASE2

2) Test case image types
Only 2 types for test case images.
a) btrfs-image dump
   This one is the simplest case, one only needs to add the image to
   corresponding dir.

b) custom script
   This one is for all the resting cases which can't fit btrfs-image,
   like csum error or script can generate the image (this reduces the
   size obviously and good for review)
   The old binary dump also belongs to this type, so need to add script
   to extract them.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-01-14 18:34:17 +01:00
David Sterba 4f9d8b1ffa btrfs-progs: tests: build prerequisities, btrfs-image and btrfs
Build required utilities from the main Makefile and just check in the
test scripts.

Signed-off-by: David Sterba <dsterba@suse.cz>
2014-12-12 16:21:42 +01:00
David Sterba 6856b0a4ca btrfs-progs: tests: use 'btrfs check' instead of btrfsck
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-12-12 16:19:52 +01:00
David Sterba b9a799eb89 btrfs-progs: run fsck image tests in filename order
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-10-17 18:34:16 +02:00
Filipe Manana 555b7feaeb Btrfs-progs: check, ability to detect and fix outdated snapshot root items
This change adds code to detect and fix the issue introduced in the kernel
release 3.17, where creation of read-only snapshots lead to a corrupted
filesystem if they were created at a moment when the source subvolume/snapshot
had orphan items. The issue was that the on-disk root items became incorrect,
referring to the pre orphan cleanup root node instead of the post orphan
cleanup root node.

A test filesystem can be generated with the test case recently submitted for
xfstests/fstests, which is essencially the following (bash script):

    workout()
    {
	ops=$1
	procs=$2
	num_snapshots=$3

	_scratch_mkfs >> $seqres.full 2>&1
	_scratch_mount

	snapshot_cmd="$BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT"
	snapshot_cmd="$snapshot_cmd $SCRATCH_MNT/snap_\`date +'%H_%M_%S_%N'\`"
	run_check $FSSTRESS_PROG -p $procs \
	    -x "$snapshot_cmd" -X $num_snapshots -d $SCRATCH_MNT -n $ops
    }

    ops=10000
    procs=4
    snapshots=500
    workout $ops $procs $snapshots

Example of btrfsck's (btrfs check) behaviour against such filesystem:

  $ btrfsck /dev/loop0
  root item for root 311, current bytenr 44630016, current gen 60, current level 1, new bytenr 44957696, new gen 61, new level 1
  root item for root 1480, current bytenr 1003569152, current gen 1271, current level 1, new bytenr 1004175360, new gen 1272, new level 1
  root item for root 1509, current bytenr 1037434880, current gen 1300, current level 1, new bytenr 1038467072, new gen 1301, new level 1
  root item for root 1562, current bytenr 33636352, current gen 1354, current level 1, new bytenr 34455552, new gen 1355, new level 1
  root item for root 3094, current bytenr 1011712000, current gen 2935, current level 1, new bytenr 1008484352, new gen 2936, new level 1
  root item for root 3716, current bytenr 80805888, current gen 3578, current level 1, new bytenr 73515008, new gen 3579, new level 1
  root item for root 4085, current bytenr 714031104, current gen 3958, current level 1, new bytenr 716816384, new gen 3959, new level 1
  Found 7 roots with an outdated root item.
  Please run a filesystem check with the option --repair to fix them.

  $ echo $?
  1

  $ btrfsck --repair /dev/loop0
  enabling repair mode
  fixing root item for root 311, current bytenr 44630016, current gen 60, current level 1, new bytenr 44957696, new gen 61, new level 1
  fixing root item for root 1480, current bytenr 1003569152, current gen 1271, current level 1, new bytenr 1004175360, new gen 1272, new level 1
  fixing root item for root 1509, current bytenr 1037434880, current gen 1300, current level 1, new bytenr 1038467072, new gen 1301, new level 1
  fixing root item for root 1562, current bytenr 33636352, current gen 1354, current level 1, new bytenr 34455552, new gen 1355, new level 1
  fixing root item for root 3094, current bytenr 1011712000, current gen 2935, current level 1, new bytenr 1008484352, new gen 2936, new level 1
  fixing root item for root 3716, current bytenr 80805888, current gen 3578, current level 1, new bytenr 73515008, new gen 3579, new level 1
  fixing root item for root 4085, current bytenr 714031104, current gen 3958, current level 1, new bytenr 716816384, new gen 3959, new level 1
  Fixed 7 roots.
  Checking filesystem on /dev/loop0
  UUID: 2186e9b9-c977-4a35-9c7b-69c6609d4620
  checking extents
  checking free space cache
  cache and super generation don't match, space cache will be invalidated
  checking fs roots
  checking csums
  checking root refs
  found 618537000 bytes used err is 0
  total csum bytes: 130824
  total tree bytes: 601620480
  total fs tree bytes: 580288512
  total extent tree bytes: 18464768
  btree space waste bytes: 136939144
  file data blocks allocated: 34150318080
   referenced 27815415808
  Btrfs v3.17-rc3-2-gbbe1dd8

  $ echo $?
  0

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-10-17 18:24:54 +02:00
Josef Bacik 935457f164 btrfs-progs: skip extent rebuild test if no testdev
It is highly obnoxious to have to go put in a testdev when all you really want
is to run the quick image tests.  Make this part optional so if we don't have a
testdev specified we just don't run that particular test.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-10-10 10:38:36 +02:00
Wang Shilong 8efdd3ca4c Btrfs-progs: fsck: add tests for extent tree rebuilding
We need test to verify extent tree rebuilding work, this test
create a strange filesystem with some snapshots, destroy
extent root node, and run fsck with "--init-extent-tree".

Since this tests need btrfs internal tool(btrfs-corrupt-block),so
i add this test into btrfs-progs.

Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 14:43:10 +02:00
Josef Bacik 2454473dd1 Btrfs-progs: add a test image for the transid fixer in btrfsck
This is a verification test for the transid recow functionality of btrfsck.
I've also adjusted the test script to spit out which image it's testing so I can
be sure the image was getting tested.  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>
2013-10-16 08:23:12 -04:00
Josef Bacik 0d342f8fcb 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>
2013-10-16 08:23:11 -04:00