Commit Graph

448 Commits (master)

Author SHA1 Message Date
Qu Wenruo bb305ae832 btrfs-progs: tests: Add test case to check file hole extents with NO_HOLES flag
Add test case which we have NO_HOLES incompat flag while still have
hole file extent.

This can be created by enabling NO_HOLES feature on an existing
filesystem, which lowmem mode would cause false alert for it.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[ minor adjustments ]
Signed-off-by: David Sterba <dsterba@suse.com>
2017-06-26 17:10:02 +02:00
Filipe Manana c1c9875034 btrfs-progs: test for restoring multiple devices fs into a single device
Test that we are able to create an image from a multiple devices fs, that
we are able to restore that image into a single device and finally that we
are able to mount it.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Liu Bo <bo.li.liu@oracle.com>
[ added shell quotation and chmod a+w so testsuite on NFS works ]
Signed-off-by: David Sterba <dsterba@suse.com>
2017-06-26 17:07:54 +02:00
Tsutomu Itoh 8dcc1b6f65 btrfs-progs: tests: remove variable quotation from convert-tests
In btrfs-progs-v4.11-rc1, the following convert-tests failed.

    [TEST/conv]   008-readonly-image
    [TEST/conv]     readonly image test, btrfs defaults
failed: mke2fs -t ext4 -b 4096 -F /Build/btrfs-progs-v4.11-rc1/tests/test.img
test failed for case 008-readonly-image
Makefile:271: recipe for target 'test-convert' failed
make: *** [test-convert] Error 1
    [TEST/conv]   009-common-inode-flags
    [TEST/conv]     common inode flags test, btrfs defaults
failed: mke2fs -t ext4 -b 4096 -F /Build/btrfs-progs-v4.11-rc1/tests/test.img
test failed for case 009-common-inode-flags
Makefile:271: recipe for target 'test-convert' failed
make: *** [test-convert] Error 1

So, remove quotes from $default_mke2fs.

Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-06-26 17:07:48 +02:00
David Sterba 68d303bdbb btrfs-progs: tests: fix misc/019-receive-clones-on-munted-subvol
Patches "btrfs-progs: tests: correctly receive clones to mounted subvol"
(8eaf63bc9a) and followup are missing last
unmount which leads to failure of misc/020.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-05-15 16:36:11 +02:00
Lakshmipathi.G ca1be56db5 btrfs-progs: tests: add variable quotation to convert-tests
Signed-off-by: Lakshmipathi.G <Lakshmipathi.G@giis.co.in>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-05-15 16:13:17 +02:00
David Sterba b75c0720a4 btrfs-progs: fssum: fix warning, include correct header for major()
tests/fssum.c:599:13: warning: In the GNU C Library, "major" is defined
 by <sys/sysmacros.h>. For historical compatibility, it is
 currently defined by <sys/types.h> as well, but we plan to
 remove this soon. To use "major", include <sys/sysmacros.h>
 directly. If you did not intend to use a system-defined macro
 "major", you should undefine it after including <sys/types.h>.
    sum_add_u64(&cs, major(st.st_rdev));

Signed-off-by: David Sterba <dsterba@suse.com>
2017-05-02 16:23:54 +02:00
Lu Fengqi fd4526fe68 btrfs-progs: tests: fssum, fix memory leak
Free the alloced memory and close dir before exit.

Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-05-02 16:17:52 +02:00
Lakshmipathi.G 467b49ccbb btrfs-progs: tests: add variable quotation to fsck-tests
Signed-off-by: Lakshmipathi.G <Lakshmipathi.G@giis.co.in>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-05-02 16:13:29 +02:00
Lakshmipathi.G 57909d702c btrfs-progs: misc-tests: Superblock corruption and recovery using backup
Signed-off-by: Lakshmipathi.G <Lakshmipathi.G@giis.co.in>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-04-19 19:06:26 +02:00
Christian Brauner 27c5e540be btrfs-progs: tests: misc/018-receive use receive -e to terminate on end marker
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
[ enhance tests to take extra options and use for -e ]
Signed-off-by: David Sterba <dsterba@suse.com>
2017-04-19 18:06:57 +02:00
Qu Wenruo 583cab2e2c btrfs-progs: tests: Add SHARED_DATA_REF test image for check lowmem mode
Introduce a new image, which contains external SHARED_DATA_REF items to
trigger a lowmem mode false alert.

The image only contains external SHARED_DATA_REF and no inlined data
backref.

Before the image, we only have inlined shared data ref, which is not
enough to trigger lowmem mode false alert.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-31 14:17:48 +02:00
David Sterba 02947f4105 btrfs-progs: tests: misc/019, use fssum
The fssum utility is now ready to use, test still passes.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-16 17:02:44 +01:00
David Sterba b5d4b3cef3 btrfs-progs: tests: fssum, switch from MD5 to SHA256
Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-16 17:02:44 +01:00
David Sterba 4ddd6055c3 btrfs-progs: tests: add SHA256
In order to drop dependency on SSL library to compute MD5 in fssum,
we'll use the reference implementation from RFC 6234.

The checksum is not in a cryptographically sensitive context, but we're
going to skip MD5 and SHA-1 anyway.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-16 17:02:44 +01:00
David Sterba 1d684ec0e0 btrfs-progs: tests: fssum, update includes
Remove unneeded and add headers that define time_te and int types.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-16 17:02:44 +01:00
David Sterba 17b964dc91 btrfs-progs: tests: fssum, drop *_SOURCE defines, already provided via config.h
In file included from /usr/include/stdio.h:27:0,
                 from kerncompat.h:22,
                 from tests/fssum.c:25:
/usr/include/features.h:148:3: warning: #warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-Wcpp]
 # warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"
   ^~~~~~~

We've solved that long time ago and config.h now provides the macros.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-16 17:02:44 +01:00
David Sterba 855b4272a4 btrfs-progs: tests: fssum, use our endianity helper
The function htonll is not provided by the standard library and we can
replace it by our cpu-to-XX helpers. This switches the endianity of the
checksummed value to LE, but this is not a problem.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-16 17:02:44 +01:00
David Sterba 12cae4c2c6 btrfs-progs: tests: fssum, drop unnecessray build defines
Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-16 17:02:44 +01:00
David Sterba 9a98589f00 btrfs-progs: tests: add fssum utility
Copy from fstests, originally from
git://git.kernel.org/pub/scm/linux/kernel/git/arne/far-progs.git

Needs libcrypto to link but this check is now missing in configure.

Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-16 17:02:44 +01:00
David Sterba c2d3f54996 btrfs-progs: tests: cleanup use of IMAGE and replace by helpers
Nearly each use of IMAGE can be replaced by common helpers as there are
no specific requirements on the testing filesystem. There are still a
few left that need to be evaluated and converted eventually.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-16 17:02:44 +01:00
David Sterba d4eb5a77d7 btrfs-progs: tests: mkfs/002 and 003: use TEST_DEV instead of IMAGE
As we don't know what's the TEST_DEV like, use the explicit mkfs limit.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-16 17:02:44 +01:00
David Sterba b7eb8f7650 btrfs-progs: tests: use TEST_DEV in cli-tests
IMAGE points to the fallback image, tests should use TEST_DEV.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-16 17:02:44 +01:00
David Sterba 3727d89b41 btrfs-progs: docs: add preliminary do's & dont's for tests
Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-16 17:02:44 +01:00
David Sterba ea3d522cc6 btrfs-progs: tests: do test build of library-test.static
Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-16 17:02:44 +01:00
David Sterba 21e8582d32 btrfs-progs: tests: port 019-receive-clones-on-munted-subvol
Port from fstests.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-16 17:02:44 +01:00
Benedikt Morbach 8eaf63bc9a btrfs-progs: tests: correctly receive clones to mounted subvol
clone needs to resolve the paths of the involved subvolumes in the target
fs from their UUIDs. When doing so it might need to strip the prefix
that is mounted as the root of the fs from those paths.

It didn't do so correctly when processing the source of "clone" commands

This is a regression test for
    btrfs-progs: receive: handle root subvol path in clone

Signed-off-by: Benedikt Morbach <benedikt.morbach@googlemail.com>
[ copied the fstests version, will be updated later ]
Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-16 17:02:44 +01:00
David Sterba 839de9c033 btrfs-progs: tests: use dd in 025-file-extents for creating files
Drop the dependency on xfs_io as it's not a standard tool, though it
provides convenience. We use a simple write here so dd can manage.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-08 13:00:49 +01:00
David Sterba 62d4aa5fba btrfs-progs: tests: fix permissions of temporary files in 025-file-extents
If the tests are started from non-root user, the fallocate and xfs_io
fail. Use the root helper as a workaround, we'd should fix the perms
instead.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-08 13:00:49 +01:00
Lu Fengqi a0e44021ab btrfs-progs: check: Fix lowmem mode override to allow it skip repair work
Current common.local doesn't handle lowmem mode well.
It passes "--mode=lowmem" alone with "--repair", making it unable to
check lowmem mode.

It's caused by the following bugs:

1) Wrong variable in test/common.local
   We should check TEST_ARGS_CHECK, not TEST_CHECK, which is not defined
   so we never return 1.

2) Wrong parameter passed to _cmd_spec() in test/common
   This prevents us from grepping the correct parameters.

Fix it.

Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-08 13:00:49 +01:00
Qu Wenruo cbaa289d3d btrfs-progs: tests: Add new test case for file extent false alerts
Lowmem mode exposed several false alerts, all related to file extents
check.

1) Partly written prealloc extent
   Cause lowmem mode to report missing csum or prealloc extent should
   not have csum

2) Compressed inline extent
   Cause lowmem mode to find mismatch on inline len and item len.
   While no error message is output but exit silently.

Reported-by: Chris Murphy <chris@colorremedies.com>
Reported-by: Christoph Anton Mitterer <calestyo@scientia.net>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-08 13:00:49 +01:00
Qu Wenruo 381b43a020 btrfs-progs: tests: Make fsck-test/013 compatible with lowmem mode
fsck-tests/013-extent-tree-rebuild uses "--init-extent-tree", which
implies "--repair".

But the test script doesn't specify "--repair" for lowmem mode test to
detect it.

Add it so lowmem mode test can be happy with it.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-08 13:00:49 +01:00
Qu Wenruo 6203e63672 btrfs-progs: tests: Add test image for lowmem mode block group false alert
Add a minimal image which can reproduce the block group used space
false alert for lowmem mode fsck.

Reported-by: Christoph Anton Mitterer <calestyo@scientia.net>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-08 13:00:49 +01:00
Qu Wenruo fa77a1b5a3 btrfs-progs: tests: Move fsck-tests/015 to fuzz tests
The test case fsck-tests/015-check-bad-memory-access can't be repair by
btrfs check, and it's a fortunate bug makes original mode to forget the
error code from extent tree, making original mode pass it.

So fuzz-tests is more suitable for it.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-08 13:00:49 +01:00
David Sterba 78e1787c55 btrfs-progs: tests: use built binaries for 004-send-parent-multi-subvol
Signed-off-by: David Sterba <dsterba@suse.com>
2017-01-27 12:20:43 +01:00
David Sterba 2182142471 btrfs-progs: tests: add variable quotation to cli-tests
Signed-off-by: David Sterba <dsterba@suse.com>
2017-01-27 12:20:43 +01:00
Tsutomu Itoh 55e3a60195 btrfs-progs: tests: add test for --sync option of qgroup show
Simple test script for the following patch.

   btrfs-progs: qgroup: add sync option to 'qgroup show'

Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-01-27 12:20:42 +01:00
David Sterba 0e95fff4ff btrfs-progs: tests: 005-qgroup-show
Signed-off-by: David Sterba <dsterba@suse.com>
2017-01-25 09:48:00 +01:00
Qu Wenruo 46b8ea0e99 btrfs-progs: convert-test: trigger chunk allocation after convert
Populate fs after convert so we can trigger data chunk allocation.
This can expose too restrict old rollback condition

Reported-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-12-21 16:29:06 +01:00
David Sterba 8fe3a7bfd0 btrfs-progs: tests: check for partscan support in misc/006-partitioned-loopdev
The travis CI does not have losetup with --partscan, skip the check in
that case so we can still run the mkfs testsuite.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-12-14 15:06:35 +01:00
David Sterba 26ad474e16 btrfs-progs: tests: add more gobal option to test 001-btrfs
Signed-off-by: David Sterba <dsterba@suse.com>
2016-12-14 15:06:34 +01:00
David Sterba 9d133083aa btrfs-progs: tests: end of stream conditions
Signed-off-by: David Sterba <dsterba@suse.com>
2016-11-30 12:42:24 +01:00
David Sterba 50e742a6b0 btrfs-progs: tests: add support for additional command arguments
Add convenient support for extending command arguments, now implemented
for 'btrfs check' to cover the low-memory mode. If defined, arguments
are inserted to any 'btrfs check' command in tests. Exceptions could be
defined in common.local.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-11-23 11:07:06 +01:00
David Sterba 55db7bf059 btrfs-progs: tests: more variable quoting in common scripts
Signed-off-by: David Sterba <dsterba@suse.com>
2016-11-23 11:07:06 +01:00
David Sterba c1d714f944 btrfs-progs: tests: drop redundant test for rwx number validity
The list of rwx permissions is now hardcoded but used to begenerated and
the invalid numbers filtered out. Not necessary anymore.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-11-23 11:07:06 +01:00
Tsutomu Itoh b0d8975582 btrfs-progs: test: fix how to make test files in fsck-tests 013
In my test environment, following error was occurred because the size
of /lib/modules/`uname -r`/* is larger than 1GB.

# make test-fsck
    [TEST]   fsck-tests.sh
    [TEST/fsck]   013-extent-tree-rebuild
failed: cp -aR /lib/modules/4.9.0-rc5/ /test/btrfs-progs/tests/mnt
test failed for case 013-extent-tree-rebuild
Makefile:272: recipe for target 'test-fsck' failed
make: *** [test-fsck] Error 1
#

In this test case, 'generate_dataset small' is enough for making the
test files, so I will use 'generate_dataset' instead of 'cp'.

For this, move 'generate_dataset()' from 'common.convert' to 'common'.

Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-11-23 11:07:06 +01:00
David Sterba d8f93ce802 btrfs-progs: Update README and other docs
Signed-off-by: David Sterba <dsterba@suse.com>
2016-11-23 11:07:05 +01: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 7cd40e125b btrfs-progs: tests: check for TEST_LOG values by a regex
The set of possible values will be extended so check for existence of
the keyword.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-11-23 10:51:38 +01:00
David Sterba 9da3ce40f5 btrfs-progs: tests: change options to list all loop devices
The option --list might not be available on older versions, the
equvalent is --all. Discovered via failed travis build.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-11-23 10:51:29 +01:00
David Sterba 6572f884ba btrfs-progs: tests: use the root helper for various info retrieval commands
The current user might not be able to peek into the loop files directly,
use the helper. Discovered by running tests in travis.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-11-23 10:51:21 +01:00
David Sterba 691d1ac8fa btrfs-progs: tests: add basic checks for bad stream on the receive side
Signed-off-by: David Sterba <dsterba@suse.com>
2016-11-23 10:50:29 +01:00
David Sterba 5ee216a86f btrfs-progs: tests: add more fuzzed images from bugzilla
Fixing the problems by one does not scale now. Add more images despite
the fuzz tests will fail. They have been for some time already.

Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-11-23 10:49:37 +01:00
David Sterba 9d0e6a67f9 btrfs-progs: tests: enhance run_mayfail description comment
Signed-off-by: David Sterba <dsterba@suse.com>
2016-11-11 16:25:19 +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 8dc653f003 btrfs-progs: tests: add quotation around variables in common.convert
Signed-off-by: David Sterba <dsterba@suse.com>
2016-11-11 16:25:19 +01:00
David Sterba cc0d3d3198 btrfs-progs: tests: add quotes around variables in common
Signed-off-by: David Sterba <dsterba@suse.com>
2016-11-11 16:25:19 +01:00
David Sterba 747146e237 btrfs-progs: tests: add path assertions to post-checks
Signed-off-by: David Sterba <dsterba@suse.com>
2016-11-11 16:25:19 +01:00
David Sterba 8a44fd062a btrfs-progs: tests: add assertion helper
Helper to extend sanity checks in various functions.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-11-11 16:25:18 +01:00
David Sterba 66b9b36805 btrfs-progs: tests: refactor post-convert check helpers
Separate checksum test from convert_test_post_check and use it to fix
the broken test 005 as reported.

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 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
Tsutomu Itoh f529d6472e btrfs-progs: tests: add checking of send multiple clone source option
Sending stream size of clone-src(-c) option is checked.
Fixed by "btrfs-progs: send: fix handling of -c option".

Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-11-11 16:23:30 +01:00
David Sterba 45827710e2 btrfs-progs: tests: teach extract_image about packed streams
Packed streams for testing purposes should be packed with 'xz -9' and
use suffix .stream.xz .

Signed-off-by: David Sterba <dsterba@suse.com>
2016-11-11 16:23:29 +01:00
David Sterba 0bd0d9c062 btrfs-progs: tests: teach scan-results about more errors
ASAN detects use after free.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-11-09 13:47:35 +01:00
David Sterba 29a1a78aaa btrfs-progs: tests: add test for multi-subvolume send from parent
Fixed by "btrfs-progs: send: fix handling of multiple snapshots (-p
option)".

Signed-off-by: David Sterba <dsterba@suse.com>
2016-11-09 13:47:30 +01:00
David Sterba c8d1c4c792 btrfs-progs: tests: switch to dump- commands from inspect
The dump-super and debug-tree commands are replacements for the
standalone tools.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-11-09 13:13:37 +01:00
Qu Wenruo 40de2f6279 btrfs-progs: fsck-tests: Check if clear space cache works
Add test case to check the basic function of --clear-space-cache.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-11-09 13:12:49 +01:00
Qu Wenruo 112514568f btrfs-progs: test: Add image for quota verify stack overflow
For image with tree reloc tree, if its height is over level 2, the root
node's backref will point to itself.  It's valid for kernel, but quota
verify code can't handle it and cause a infinite call, overflowing the
stack.

Add minimal image to reproduce the bug, as regression test.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[ minor cleanups in test.sh ]
Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-24 15:03:12 +02:00
Qu Wenruo 9119319ef9 btrfs-progs: test: Add test image for btrfsck qgroup rescan detection
Fixed by commit 7c646c538e btrfs-progs: qgroup: Fix regression leads
to corrupted qgroup status.

Add minimal test image for that fix.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[ minor cleanups in test.sh ]
Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-24 15:03:04 +02:00
Qu Wenruo 8c663f9f36 btrfs-progs: convert-test: Add test case for common inode flags
Add a new test case to check if btrfs-convert copies common inode flags
like append(a), immutable(i).

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[ minor fixes ]
Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-24 14:58:15 +02:00
Lakshmipathi.G 0ec02b118d btrfs-progs: Add fast,slow symlinks, fifo types to convert test
Signed-off-by: Lakshmipathi.G <Lakshmipathi.G@giis.co.in>
[ fix root helper use in fast_symlink ]
Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-24 14:57:51 +02:00
David Sterba ba253d4ea5 btrfs-progs: tests: add script to help build coverage
Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-10 09:46:51 +02:00
David Sterba a08ca376f7 btrfs-progs: tests: teach run_mayfail about sigabrt
Mayfail helper should stop when we encoutner an abort.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-05 12:39:01 +02:00
David Sterba b6bf79eb96 btrfs-progs: tests: don't treat segfault as ignorable error
Some fuzzed images cause various tools to crash but the mayfail helper
would not recognize that. We don't mind if the utility failes but it
must not crash.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-05 12:39:01 +02:00
David Sterba a5ac954153 btrfs-progs: tests: split test 004 to separate tests
Makes testing specific tool easier.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-05 12:39:01 +02:00
David Sterba 35d0588b64 btrfs-progs: tests: add fuzzed image with bad parent refs, qgroup-verify
Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-03 15:07:24 +02:00
David Sterba 801f15bdf1 btrfs-progs: tests: add fuzzed images with bad blocksize/lengh of eb
Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-03 15:07:24 +02:00
David Sterba 8d8de7c2e5 btrfs-progs: tests: add script to scan results for some known runtime errors
Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-03 15:07:21 +02:00
David Sterba 5a38a52194 btrfs-progs: tests: iterate over fuzzed images and test various tools
Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-03 15:07:21 +02:00
David Sterba da64ae3a0f btrfs-progs: reorganize extent_buffer and fix alignment of data
Reported by UBSAN, the checksum code tries to access unaligned data that
come from the extent_buffer.

struct extent_buffer {
        struct cache_extent        cache_node;           /*     0    48 */
        u64                        start;                /*    48     8 */
        u64                        dev_bytenr;           /*    56     8 */
        /* --- cacheline 1 boundary (64 bytes) --- */
        u32                        len;                  /*    64     4 */

        /* XXX 4 bytes hole, try to pack */

        struct extent_io_tree *    tree;                 /*    72     8 */
        struct list_head           lru;                  /*    80    16 */
        struct list_head           recow;                /*    96    16 */
        int                        refs;                 /*   112     4 */
        u32                        flags;                /*   116     4 */
        int                        fd;                   /*   120     4 */
        char                       data[0];              /*   124     0 */

        /* size: 128, cachelines: 2, members: 11 */
        /* sum members: 120, holes: 1, sum holes: 4 */
        /* padding: 4 */
};

Add explicit alignment to data.

Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=156471
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-21 11:50:05 +02:00
Wang Xiaoguang f9309584bf btrfs-progs: tests: add 021-partially-dropped-snapshot-case
Signed-off-by: Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-21 11:50:01 +02:00
David Sterba 2125a65533 btrfs-progs: tests: add fuzzed images for bad block group offset
Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-21 11:49:41 +02:00
David Sterba 5150103fcf btrfs-progs: tests: run check with various options on the fuzzed images
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-21 11:48:41 +02:00
David Sterba faaeee5bf3 btrfs-progs: tests: add fuzz test to try btrfs-image on all images
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-21 11:48:37 +02:00
David Sterba 9fc5aefe45 btrfs-progs: tests: rename test 001 to mention check
Make it more clear that the test does 'btrfs check'.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-21 11:48:24 +02:00
David Sterba 05b6d8b187 btrfs-progs: tests: add fuzzed image for a bad backref
Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-21 11:48:16 +02:00
Lakshmipathi.G c2f3212502 btrfs-progs: tests: post btrfs-convert verify permissions and ACLs
Signed-off-by: Lakshmipathi.G <Lakshmipathi.G@giis.co.in>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-21 11:47:24 +02:00
David Sterba 7d6307dcf3 btrfs-progs: tests: add fuzzed image for heap overflow while checking chunk items
Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-05 12:20:24 +02:00
David Sterba 386cdcd741 btrfs-progs: tests: add fuzzed image for invalid chunk sectorsize
Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-05 12:20:24 +02:00
David Sterba 083721de5c btrfs-progs: tests: add fuzzed image for invalid sys_array and stripe_len
Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-05 12:20:24 +02:00
David Sterba 1e4ef75053 btrfs-progs: tests: add fuzzed image for invalid sub_stripe value
Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-05 12:20:24 +02:00
David Sterba f919530b3a btrfs-progs: tests: add 015-dump-super-garbage
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-05 12:20:23 +02:00
David Sterba aa6baa178d btrfs-progs: tests README: fuzzed images
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-05 10:05:08 +02:00
Qu Wenruo 8607100a9b btrfs-progs: fuzz-test: Add test case for unaligned extent item
Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[ added bko-NNN- prefix to the files ]
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-05 10:05:05 +02:00
Qu Wenruo f51a34696b btrfs-progs: fuzz-test: Add test case for invalid drop level
Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[ added bko-NNN- prefix to the files ]
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-05 10:04:36 +02:00
Qu Wenruo ba23b7679f btrfs-progs: fuzz-test: Add image for unaligned tree block ptr
Add test case image for unaligned tree block ptr.
It should lead to BUG_ON in free_extent_buffer().

Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[ added bko-NNN- prefix to the files ]
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-05 10:04:27 +02:00
Qu Wenruo 767ae9e348 btrfs-progs: fuzz-test: Add image for wrong chunk item in root tree
Reported by Lukas and the same image from him.

DATA_RELOC tree's key type is modifed to CHUNK_ITEM, causing btrfsck
interpret it as CHUNK_ITEM and cause 0 num_stripes.

Add the image to fuzz-test.

Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[ added bko-NNN- prefix to the files ]
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-05 10:04:19 +02:00
Qu Wenruo 4f3ccdd518 btrfs-progs: convert-test: Check if the ext2_save/image is read only
Old convert codes uses both 0400 permission and INODE_READONLY flag to
make the converted ext2 image readonly.

While new convert treat the inode just as normal inode, with no special
inode flag and uses 0600 permission.
This makes user able to modify converted image unintentionally and make
rollback fails.

This test case will test the regression.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-19 13:53:28 +02:00
David Sterba ebbddd7fd4 btrfs-progs: tests: add 007-unsupported-block-sizes
Check if block sizes smaller than 4k expectedly fail to convert.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-07-15 01:25:12 +02:00
Luis Henriques 08c70e18de btrfs-progs: tests: 006-image-on-missing-device: fix btrfs tool path
If btrfs isn't in the path, this test will fail with:

    [TEST/misc]   006-image-on-missing-device
failed: btrfs fi show /dev/loop0
test failed for case 006-image-on-missing-device
Makefile:226: recipe for target 'test-misc' failed
make: *** [test-misc] Error 1

Fix the test script by adding $TOP to the path.

Signed-off-by: Luis Henriques <henrix@camandro.org>
[ updated to full command names ]
Signed-off-by: David Sterba <dsterba@suse.com>
2016-07-13 18:44:33 +02:00
David Sterba 52fda816e8 btrfs-progs: tests: use /bin/bash for scripts
Since we use 'source' in scripts, let's use bash everywhere.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-07-04 13:45:15 +02:00
Qu Wenruo 2e58edbdf4 btrfs-progs: convert-test: Add test case for discontinuous hole extent
For ext* fs containing a large hole(larger than 128M), btrfs-convert
will only insert one 128M hole extent and skip the remaining.

This leads to discontinuous file extents.

Add test case for it, and since it's a pinpoint regression test case, no
combination of convert options nor checksum verification.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-07-04 13:44:58 +02:00
Luis Henriques 82aaf603e0 btrfs-progs: tests: 001-simple-unmounted: fix test failure due to bashism
The usage of 'source' is a bashism, and '.' should be used instead.  This
is causing fuzz-tests/001-simple-unmounted to fail in systems where
/bin/sh isn't bash:

    [TEST/fuzz]   001-simple-unmounted
./test.sh: 5: ./test.sh: source: not found
./test.sh: 7: ./test.sh: setup_root_helper: not found
./test.sh: 8: ./test.sh: check_prereq: not found
./test.sh: 18: ./test.sh: check_all_images: not found

Since most (all?) tests actually use /bin/bash, change this test to use
bash too.

Signed-off-by: Luis Henriques <henrix@camandro.org>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-07-04 13:37:24 +02:00
David Sterba cd9b35c37a btrfs-progs: tests: fix filesytem type creation for convert tests
The extN filesystem type was lost when the separate tests were created
and we've been testing only ext2. The tests pass for ext3 and ext4
though.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-06-22 15:52:17 +02:00
David Sterba 670b73fe0a btrfs-progs: tests: add 005-delete-all-rollback
Test if a rollback works after deleing all files from btrfs.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-06-22 15:50:17 +02:00
David Sterba 1280c2bbbd btrfs-progs: tests: update README
Signed-off-by: David Sterba <dsterba@suse.com>
2016-06-22 14:28:23 +02:00
David Sterba ac1e484a0a btrfs-progs: tests: add test console
Add a wrapper that sets up environment the same way a test would use it.
Use it for quick prototyping or testing, the commands and output is
logged.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-06-22 14:07:46 +02:00
David Sterba 329ff544a4 btrfs-progs: tests: print shorter test name in the output
The full path is printed, we're interested in the last path component
only.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-06-22 11:30:24 +02:00
David Sterba f20f227877 btrfs-progs: tests: split convert_test
Split the big function to several helpers so we can use them separately.
Add comments and do minor tweaks.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-06-22 11:25:33 +02:00
David Sterba 81b427afcf btrfs-progs: tests: add 003-fi-resize-args
Check various resize option combinations.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-06-17 17:02:12 +02:00
David Sterba 75bf151ba3 btrfs-progs: tests: 004-ext2-backup-superblock-ranges, use common helpers for image loop
Signed-off-by: David Sterba <dsterba@suse.com>
2016-06-03 17:08:43 +02:00
David Sterba 933de7e034 btrfs-progs: tests: 004-ext2-backup-superblock-ranges, drop unnecessary root privs
We really use root only for mount/umount and access to the ext2_saved
image (that has 0600). Also switch to common variable so we can use
helpers.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-06-03 17:01:36 +02: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
David Sterba b5ab8d42b7 btrfs-progs: tests: convert: set common variables
Signed-off-by: David Sterba <dsterba@suse.com>
2016-06-03 16:53:27 +02:00
David Sterba b06f44e50b btrfs-progs: tests: clean up the test driver of convert tests
Everything is now in separate tests, and TEST=mask now works.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-06-03 16:53:27 +02:00
David Sterba bea73f33b9 btrfs-progs: tests: convert: separate ext4 tests
Signed-off-by: David Sterba <dsterba@suse.com>
2016-06-03 16:53:27 +02:00
David Sterba cf8cc8ea45 btrfs-progs: tests: convert: separate ext3 tests
Signed-off-by: David Sterba <dsterba@suse.com>
2016-06-03 16:53:27 +02:00
David Sterba 79b0946f03 btrfs-progs: tests: convert: separate ext2 tests
Signed-off-by: David Sterba <dsterba@suse.com>
2016-06-03 16:53:27 +02:00
David Sterba a8e6d4fdfb btrfs-progs: tests: move convert helpers to a separate file
Signed-off-by: David Sterba <dsterba@suse.com>
2016-06-03 16:53:27 +02:00
Qu Wenruo dc4bbc37a1 btrfs-progs: convert-tests: Add test case for backup superblock migration
New convert introduced simpler chunk/extent allocation algorithm, at the
cost of complex backup superblock migration codes.

Use specially built ext2 images to test if btrfs-convert can convert and
rollback images without problem.

All these special ext2 image have blocks/holes across 2nd btrfs backup
superblock.

The naming of test image is like the following:
	|<------superblock migration range----->|
	64M					64M + 64K
|-Data--|-Data--|/Hole//|-Data--|/Hole//|-Data--|--Data--| = drdhdhdrd

These test cases should check all typical layouts and make sure new
convert works.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-06-03 16:53:25 +02:00
Qu Wenruo fde5ae2e49 btrfs-progs: convert-tests: Add support for custom test scripts
Add support for custom convert test scripts, just like fsck tests.

Instead of generic convert tests, we need more specifically created images
for new convert tests.

This patch provide the needed infrastructure for later convert test
cases.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-06-03 15:22:18 +02:00
Qu Wenruo bb3c2ea224 btrfs-progs: convert-tests: Add test for backup superblock migration
New convert framework uses new and simpler chunk layout, while the cost
is the more complex superblock range migration logical, compared to old
convert.

Enhance the convert test script to create file which will takes up 2nd
backup superblock space, to ensure the superblock migration is working
as expected.

Suggested-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-06-01 15:37:23 +02:00
David Sterba 205bd5edbe btrfs-progs: tests: document cli-tests in readme
Signed-off-by: David Sterba <dsterba@suse.com>
2016-06-01 14:56:56 +02:00
David Sterba bff6828778 btrfs-progs: tests: convert: dump all superblocks after conversion
We want to see all of them, even if they're not valid.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-06-01 14:56:56 +02:00
David Sterba 0993ae5a73 btrfs-progs: tests: run rollback after conversion
Signed-off-by: David Sterba <dsterba@suse.com>
2016-06-01 14:56:56 +02:00
David Sterba 3f063f6bdc btrfs-progs: tests: convert, run md5sum with sudo helper
Some of the files might not end up in the checksum list because of
permissions. This is reported by md5sum as incorrectly formatted lines.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-06-01 14:56:56 +02:00
Lu Fengqi 9071a10210 btrfs-progs: tests: add 020-extent-ref-cases
In order to confirm that btrfsck supports to check a variety of
refs, add the
following cases:
* keyed_block_ref
* keyed_data_ref
* shared_block_ref
* shared_data_ref
* no_inline_ref (a extent item without inline ref)
* no_skinny_ref

Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-06-01 14:56:56 +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
Liu Bo f2873c47d7 btrfs-progs: add fuzzed testing images, superblock and chunks
This adds 4 fuzz testing images, btrfsck either doesn't detect errors
in them or crashes immediately.

Reported-by: Vegard Nossum <vegard.nossum@oracle.com>
Reported-by: Quentin Casasnovas <quentin.casasnovas@oracle.com>
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-11 16:37:48 +02:00
David Sterba 0121270a79 btrfs-progs: tests: add 002-balance-full-no-filters
Coverage of new balance option --full-balance.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-02 14:59:48 +02:00
David Sterba d75f0c12d2 btrfs-progs: tests: add support for command line coverage tests
Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-02 14:39:46 +02:00
David Sterba 39992e60a3 btrfs-progs: tests: update 001-basic-profiles, dup on multidev fs
Testcase for "btrfs-progs: mkfs: fix an error when using DUP on multidev
fs"

Signed-off-by: David Sterba <dsterba@suse.com>
2016-03-30 16:26:49 +02:00
David Sterba d7477bcd0b btrfs-progs: tests: add misc 014-filesystem-label
Test various label lengths on a mounted filesystem.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-03-30 16:26:09 +02:00
David Sterba 10d308d5ea btrfs-progs: tests: introduce mustfail helper
Invalid syntax, expected failure on corrupted data etc. Failure is
success.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-03-30 16:25:59 +02:00
David Sterba 92e922bafe btrfs-progs: tests: enumerate RWX in convert tests
Generating all valid combinations takes too much time.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-03-18 17:11:25 +01:00
Lakshmipathi.G 971d8e7476 btrfs-progs: tests: populate fs with small dataset for convert tests
Signed-off-by: Lakshmipathi.G <Lakshmipathi.G@giis.co.in>
[ minor tweaks ]
Signed-off-by: David Sterba <dsterba@suse.com>
2016-03-18 17:03:58 +01:00
David Sterba 974d2ed564 btrfs-progs: tests: add 013-subvolume-sync-crash
Test for "btrfs-progs: subvol sync: fix memory corruption, undersized
array", a lot of deleted subvolumes in the 'subvol sync' will not fit
into the array, should result in a glibc report.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-03-17 14:22:43 +01:00
David Sterba 9f76654de8 btrfs-progs: tests: add image for bko#96971 (bad checksum type)
Signed-off-by: David Sterba <dsterba@suse.com>
2016-03-14 13:42:47 +01:00
David Sterba 49fef369ff btrfs-progs: tests: fix misc/005-long-device-name-for-ssd
We use a device mapper device on top of a loop device, the change in
rotational status does not always propagate if change it at the loop
device sysfs node.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-03-14 13:42:47 +01:00
Qu Wenruo 154d28dd99 btrfs-progs: misc-test: Add regression test for find-root gives empty result
Add regression test for btrfs-find-root gives empty result even the fs
is OK.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[ enhanced test ]
Signed-off-by: David Sterba <dsterba@suse.com>
2016-02-26 17:27:58 +01:00
David Sterba 476d17fe38 btrfs-progs: tests: use common variables and helpers
Use TEST_DEV and the associated helpers to manage the tested image.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-02-23 19:02:23 +01:00
David Sterba 0ad5efde1a btrfs-progs: tests: store checksums in /tmp
We don't want to store the checksum on filesystem that we're converting.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-02-23 19:02:23 +01:00
Lakshmipathi.G cc57faac2e btrfs-progs: tests: do checksum verification with convert-tests
Signed-off-by: Lakshmipathi.G <Lakshmipathi.G@giis.co.in>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-02-23 19:02:23 +01:00
David Sterba ac45d64c04 btrfs-progs: tests: add missing prerequisites
Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12 15:16:11 +01:00
Naohiro Aota ebb66f20ae btrfs-progs: tests: test multiple-linked file corruption
This commit extends the leaf corruption test to try to repair a file
linked from multiple directory. It stresses a case that some links to a
file is broken but others kept valid.

Signed-off-by: Naohiro Aota <naota@elisp.net>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12 15:01:03 +01: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
David Sterba 5f03d1fc23 btrfs-progs: tests: add sys-array-num-stripes-0.raw.xz
Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-04 11:28:24 +01:00
Qu Wenruo 16e240eca7 btrfs-progs: tests: mkfs, check sectorsize and nodesize combinations
Add mkfs selftest for invalid and valid sectorsize/nodesize
combinations.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[ switched to TEST_DEV ]
Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-04 11:28:24 +01:00
David Sterba 1d37645dc3 btrfs-progs: tests: enhance 001-basic-profiles with --data DUP
Add the remaining valid combinations.

Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-26 16:22:16 +01:00
David Sterba 3504df7f02 btrfs-progs: tests: add 019-non-skinny-false-alert
Catch a buggy condition fixed by "btrfs-progs: fsck: Fix a false alert
where extent record has wrong metadata flag"

Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-26 15:20:35 +01:00
David Sterba b7a69afe69 btrfs-progs: tests: add 007-mix-nodesize-sectorsize
Test combinations of sectorsize and nodesize on a single device.

Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-19 16:37:15 +01:00
David Sterba a343805d58 btrfs-progs: tests: add 006-partitioned-loopdev
Create filesystem on a partitioned loop device, test for "btrfs-progs:
Fix partitioned loop devices resolving".

Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-16 14:23:46 +01:00
David Sterba 1b9876f761 btrfs-progs: tests: add 005-long-device-name-for-ssd
A test for "btrfs-progs: mkfs: increase buffer size in is_ssd". Create a
device with a long name through loop device wrapped to a device mapper
linear device, switch it to the "ssd" mode status.

Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-16 14:23:45 +01:00
David Sterba 87ab14013a btrfs-progs: tests: add 011-delete-missing-device
Test for "btrfs-progs: allow device deletion using 'missing' keyword
again".

Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-16 14:23:44 +01:00
David Sterba f2c844f65f btrfs-progs: mkfs: do not truncate the image when --rootdir is set
With the rootdir option we try to guess the final size of the image and
fill it with zeros, preceded by truncation. After patch

"Btrfs-progs: Do not force mixed block group creation unless '-M' option
 is specified"

the misc test 002 will fail, because of the non-mixed mode. I think we
should not touch the image size (no change for block devices) and try to
fit into whatever is provided by user.

Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-05 14:49:02 +01:00
David Sterba 835821f36a btrfs-progs: add initial tests/README
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02 15:10:14 +01:00
David Sterba cb10f56cb6 btrfs-progs: tests: add 003-mixed-with-wrong-nodesize
Mixed mode needs equal sectorsize and nodesize. This was fixed by

 "Btrfs-progs: Prevent creation of filesystem with 'mixed bgs' and
  having differing sectorsize and nodesize"

Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02 09:35:08 +01:00
David Sterba 425274ed8f btrfs-progs: tests: do not log output of run_mayfail to terminal
No need to log expected failures to the terminal, the results file is
fine; pass the return value of the command.

Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02 09:35:08 +01:00
David Sterba 1c4aefc2b8 btrfs-progs: tests: add support for command instrumentation
Add a way to wrap commands executed by the tests. This means the
common wrappers: run_check, run_check_stdout and run_mayfail , with the
exception of the use root_helper.

The contents of the shell variable INSTRUMENT are prepended to the
command, without quotes. Use with care.

Example: this has been tested with valgrind, the output goes to the
RESULTS file.

 $ INSTRUMENT=valgrind make test-misc

Any use of root_helper/SUDO_HELPER will skip the instrumentation.

Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02 09:35:07 +01:00
David Sterba dfed5799db btrfs-progs: tests: 001-simple-unmounted: iterate over fuzzed images and run check
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02 09:35:07 +01:00
David Sterba b85c7b7694 btrfs-progs: tests: add test driver for fuzzed images
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02 09:35:07 +01:00
David Sterba 1fcb190793 btrfs-progs: tests: do not run sudo helper tests if not necessary
We use setup_root_helper in some helpers to make sure that the sudo
helper is set up, and adding that to each test. Make the real test run
only once.

Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02 09:35:06 +01:00
David Sterba 6105df64a1 btrfs-progs: tests: set default test image size to 2G
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02 09:35:06 +01:00
David Sterba 11f7a8c8de btrfs-progs: tests: add 010-convert-delete-ext2-subvol
Testcase for "Btrfs-progs: fix btrfs-convert rollback to check
ROOT_BACKREF", make sure we don't try a rollback if the ext2_subvol is
half-deleted.

Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02 09:35:06 +01:00
David Sterba 1e92cd0d9b btrfs-progs: tests: add 002-no-force-mixed-on-small-volume
Verify that we do not force mixed block groups on small volumes anymore.

Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02 09:35:05 +01:00
David Sterba ed54f0eee3 btrfs-progs: tests: add 001-basic-profiles mkfs tests
Basic test to cover block group profile combinations.

Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02 09:35:05 +01:00
David Sterba a141d51696 btrfs-progs: tests: add mkfs tests
Mkfs deserves it's own.

Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02 09:35:05 +01:00
David Sterba c2e85337f6 btrfs-progs: tests: print commands on terminal if requested
Set the variable TEST_LOG=tty (in the enviroment or as parameter to
make) to print commands executed by 'run_check' helpers to terminal (ie.
/dev/tty). This might be useful to see the test progress beside watching
the results file.

Signed-off-by: David Sterba <dsterba@suse.com>
2015-10-21 14:29:26 +02:00
David Sterba 982950b74b btrfs-progs: misc tests: add 009-subvolume-sync-must-wait
Test to verify that subovolume sync waits until the subvolume is
cleaned.

Signed-off-by: David Sterba <dsterba@suse.com>
2015-10-21 14:29:26 +02:00
Zhao Lei 9c3ce57e6b btrfs-progs: tests: Avoid printing useless warning in fsck tests
002-bad-transid outout 'transid verify failed' message in screen
which is just a warning in btrfs-image in normal condition of this
test.

This patch move above warning into $RESULTS, to:
1: Avoid trouble screen output
2: Let user known detail if other error happened in btrfs-image

Before patch:
  # ./fsck-tests.sh
    [TEST]   001-bad-file-extent-bytenr
    [TEST]   002-bad-transid
  parent transid verify failed on 29360128 wanted 9 found 755944791
  parent transid verify failed on 29360128 wanted 9 found 755944791
  Ignoring transid failure
    [TEST]   003-shift-offsets
    [TEST]   004-no-dir-index
  ...

After patch:
  # ./fsck-tests.sh
  [TEST]   001-bad-file-extent-bytenr
  [TEST]   002-bad-transid
  [TEST]   003-shift-offsets
  [TEST]   004-no-dir-index
  ...

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-10-19 11:48:24 +02:00
Zhao Lei 9e0c8e148d btrfs-progs: tests: Introduce misc-tests/008-leaf-crossing-stripes
To check is btrfs-convert create bad filesystem with
leaf across stripes.

It is happened in progs version <=v4.1.2, and fixed by patch titled:
btrfs: convert: Avoid allocating metadata extent crossing stripe boundary
which was merged in v4.2.

Notice thar this testcase can not report error in old version of
btrfs-progs, because "btrfs check" can't check this type of error
in those version, but we have another testcase in fsck-tests, to
check is "btrfs check" support this check.

So, the above 2 testcase together can check leaf-crossing-stripes
bug in all versions.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
[renamed and other minor changes]
Signed-off-by: David Sterba <dsterba@suse.com>
2015-10-19 11:48:24 +02:00
Zhao Lei 5f77daa6a1 btrfs-progs: tests: Introduce fsck-tests/018-leaf-crossing-stripes
To test if fsck can check detec "leaf crossing stripes".

This function was introduced from patch titled:
btrfs-progs: fsck: Check if a metadata tree block crossing stripe boundary

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
[renamed and other minor changes]
Signed-off-by: David Sterba <dsterba@suse.com>
2015-10-19 11:48:24 +02:00
Zhao Lei 5627eee02b btrfs-progs: tests: Move extract_image out of check_all_images for common use
Move code for extract image file to a function from check_all_images()
for common use, so caller can use this function to extrace single
image file.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
[minor reformatting and updates]
Signed-off-by: David Sterba <dsterba@suse.com>
2015-10-19 11:48:24 +02:00
Zhao Lei ebd6d2e683 btrfs-progs: tests: Add '-o loop' to mount command line in convert-tests.sh
To fix following bug:
 # ./convert-tests.sh
     [TEST]   ext2 4k nodesize, btrfs defaults
 failed: mount /root/btrfsprogs/tests/test.img /root/btrfsprogs/tests/mnt
 # tail convert-tests-results.txt
 ...
 ############### mount /root/btrfsprogs/tests/test.img /root/btrfsprogs/tests/mnt
 mount: /root/btrfsprogs/tests/test.img is not a block device (maybe try `-o loop'?)
 failed: mount /root/btrfsprogs/tests/test.img /root/btrfsprogs/tests/mnt

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-09-20 14:31:02 +02:00
David Sterba a365b84a32 btrfs-progs: tests: add crafted and fuzzed images
A collection of several images that were produced in a non-standard way
and cause various errors in check or image tools. They do not fit into
the fsck tests as we're not able to repair any of them, but the tools
should not crash or do out-of-bounds access.

Signed-off-by: David Sterba <dsterba@suse.com>
2015-09-09 17:09:01 +02:00
Zhao Lei 34fa747ec8 btrfs-progs: tests: Use mount_test_dev for misc-tests/007-subvolume-sync
So this test can support both block device and loop device simply.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-09-01 14:53:16 +02:00
Zhao Lei d4c4443c2d btrfs-progs: tests: Fix mount fail of 013-extent-tree-rebuild
mount command in old system can not add "-o loop" option automatically
for loop device, and make following test failed:
  # ./fsck-tests.sh
  ...
    [TEST]   013-extent-tree-rebuild
  failed: mount /data/btrfsprogs/tests/test.img /data/btrfsprogs/tests/mnt
  test failed for case 013-extent-tree-rebuild

Considering that $TEST_DEV can be block or loop device, we need determine
our mount option in a condition for both case.

This patch create a wrapper function for above request, to solve current
problem in 013-extent-tree-rebuild, and support similar request in future.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-09-01 14:53:16 +02:00
Zhao Lei 421e41df49 btrfs-progs: tests: introduce test dev mount helpers
mount command in old system can not add "-o loop" option automatically
for a loop device, and make following test 013-extent-tree-rebuild fail.

Considering that $TEST_DEV can be block or loop device, we need to determine
our mount option in a condition for both case.

Introduce a wrapper that will add the loop options if needed.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-09-01 14:53:16 +02:00
Zhao Lei 3ca185850b btrfs-progs: tests: Use --no-same-owner option for tar
Some test failed in my nfs dir:
  ...
    [TEST]   006-bad-root-items
  tar: test.img: Cannot change ownership to uid 1000, gid 1000: Invalid argument
  tar: Exiting with failure status due to previous errors
  failed to extract default_case.tar.xz
  test failed for case 006-bad-root-items

It is because the image file's owner is:
 # tar tvf default_case.tar.xz
 -rw-r--r-- fdmanana/fdmanana 2147483648 2014-10-17 17:59 test.img

And make tar failed in chown in nfs.

It is not a big issue because we don't use nfs commonly, but extract
the image file with ownership of current user will be a better choice.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-09-01 14:52:09 +02:00
Zhao Lei 107adbd05d btrfs-progs: tests: umount TEST_MNT in clean-tests.sh
If a testcase failed, we can't run it(or other tests needs mount) again,
  # ./misc-tests.sh 007
   [TEST]   007-subvolume-sync
   failed: fail
   test failed for case 007-subvolume-sync
  # ./misc-tests.sh 007
   [TEST]   007-subvolume-sync
   failed: mount /root/btrfs-progs/tests/test.img /root/btrfs-progs/tests/mnt
   test failed for case 007-subvolume-sync

This patch add "umount $TEST_MNT" to clean-tests.sh, to let user
clean mountpoint easily.

After patch:
  # ./misc-tests.sh  007
   [TEST]   007-subvolume-sync
   failed: fail
   test failed for case 007-subvolume-sync
  #
  # clean-tests.sh
  #
  # ./misc-tests.sh  007
   [TEST]   007-subvolume-sync
   failed: fail
   test failed for case 007-subvolume-sync

Suggested-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
[added sudo helper to umount]
Signed-off-by: David Sterba <dsterba@suse.com>
2015-09-01 14:02:48 +02: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
Zhao Lei f7ad593ca0 btrfs-progs: tests: Introduce subvolume sync test
Current code have following bug for subvolume sync:
1: If there are more than 1 subvolume to sync, the program will
   infinitely loop.
2: return !0 in exit

This patch add misc-tests/007-subvolume-sync for above case.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:14 +02:00
David Sterba 59df5b6e9a btrfs-progs: tests, verify that btrfs-image works on a missing device
Create a 2 device raid1 filesystem, fill with some data, delete one
device (the device node must not exist) and try to dump a filesystem
image.

Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:13 +02:00
David Sterba e547fdb166 btrfs-progs: tests, add more common helpers
Add support for failures of commands, log the output.

Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:12 +02:00
Qu Wenruo cc31e6cf50 btrfs-progs: fsck-tests: add case for inode losing all its extents
Add test case for inode with no file extents, but still non-zero size.
To test whether fsck will infinite loop.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:12 +02:00
Zhao Lei 02abd61aa0 btrfs-progs: Introduce a misc test for thread conflict in btrfs-convert
Current code of btrfs-convert have a bug of thread conflict, which caused
invalid memory accessing between threads, and make program panic.

This patch add a test item for above bug, as:
 # ./misc-tests.sh
    [TEST]   001-btrfstune-features
    [TEST]   002-uuid-rewrite
    [TEST]   003-zero-log
    [TEST]   004-convert-thread-conflict
 failed: btrfs-convert /root/btrfsprogs/tests/test.img
 test failed for case 004-convert-thread-conflict
 #
 # cat misc-tests-results.txt
 ...
 ############### btrfs-convert /root/btrfsprogs/tests/test.img
 trans 7 running 5
 ctree.c:363: btrfs_cow_block: Assertion `1` failed.
 btrfs-convert(btrfs_cow_block+0x92)[0x40acaf]
 btrfs-convert(btrfs_search_slot+0x1cb)[0x40c50f]
 btrfs-convert(btrfs_csum_file_block+0x20f)[0x41d83a]
 btrfs-convert[0x43422d]
 btrfs-convert[0x4342cd]
 btrfs-convert[0x4345ca]
 btrfs-convert[0x434767]
 btrfs-convert[0x435770]
 btrfs-convert[0x439748]
 btrfs-convert(main+0x13f8)[0x43b09d]
 /lib64/libc.so.6(__libc_start_main+0xfd)[0x335e01ecdd]
 btrfs-convert[0x407649]
 create btrfs filesystem:
         blocksize: 4096
         nodesize:  16384
         features:  extref, skinny-metadata (default)
 creating btrfs metadata.

 creating ext2fs image file.
 failed: btrfs-convert /root/btrfsprogs/tests/test.img
 test failed for case 004-convert-thread-conflict
 #

Note that this bug is not happened every time, especilly in slow
device as loop(slow cpu with fast block device is likely to trigger).
I set loop count to 20 to make bug happened in 90% tests.

Suggested-by: David Sterba <dsterba@suse.com>
Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:11 +02:00
Zhao Lei bafc3a33f5 btrfs-progs: tests: Move code to create loop device to common
This code block is used several tests, move it to ./common and add a
helper.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:11 +02:00
Zhao Lei 9e99b99fa0 btrfs-progs: tests: Add -o loop to fsck-tests/012-leaf-corruption
To avoid following mount error in test:
  mount: /root/btrfs/progs/tests/fsck-tests/012-leaf-corruption/test.img
  is not a block device (maybe try `-o loop'?)

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:10 +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 5b1c5b8878 btrfs-progs: inspect: add command min-dev-size
Previously in 'filesystem resize get_min_size', now
'inspect-internal min-dev-size'. We'd like to avoid cluttering the
'resize' syntax further.

The test has been updated to exercise the new option.

Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:08 +02:00
Filipe Manana a57606e815 Btrfs-progs: add feature to get mininum size for resizing a fs/device
Currently there is not way for a user to know what is the minimum size a
device of a btrfs filesystem can be resized to. Sometimes the value of
total allocated space (sum of all allocated chunks/device extents), which
can be parsed from 'btrfs filesystem show' and 'btrfs filesystem usage',
works as the minimum size, but sometimes it does not, namely when device
extents have to relocated to holes (unallocated space) within the new
size of the device (the total allocated space sum).

This change adds the ability to reliably compute such minimum value and
extents 'btrfs filesystem resize' with the following syntax to get such
value:

   btrfs filesystem resize [devid:]get_min_size

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:03 +02:00
Qu Wenruo fabf14c540 btrfs-progs: tests: Add test case for I_ERR_FILE_WRONG_NBYTES repair
Add a new test case for I_ERR_FILE_WRONG_NBYTES.
The new btrfs-image dump image contains a file in 12K size.
But nbytes in its inode item is a random number.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
2015-07-03 17:57:48 +02:00
David Sterba 4b4d742b26 btrfs-progs: tests: verify btrfstune output during uuid-rewrite
The 'Current fsid:' value does not match the real fsid.

Reported-by: Mike Fleetwood <mike.fleetwood@googlemail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-18 19:49:33 +02:00
David Sterba 281be9e7d5 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>
2015-06-05 18:29:58 +02:00
David Sterba 567d7569d8 btrfs-progs: tests: update convert tests to set fs features
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-04 19:19:08 +02:00
David Sterba 551c4bb064 btrfs-progs: tests: add misc tests for uuid rewrite
Simple tests of the -u/-U options of btrfstune.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-03 14:04:02 +02:00
David Sterba 6a4a3acbc2 btrfs-progs: btrfstune: add option to enable NO_HOLES
New option -n to enable the NO_HOLES feature.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-03 12:52:56 +02:00
David Sterba 1e9a6b6984 btrfs-progs: tests: add misc test for fs features
A sample test for the misc-test category. Verify that btrfstune sets the
requested fs features. Now implemented extrefs, skinny-metadata and
seeding.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-02 16:37:20 +02:00
David Sterba cf3d13132b btrfs-progs: tests: common: add helper run_check_stdout
Sometimes we need to process the output of the command, but run_check
captures all the output into results file.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-02 15:57:51 +02:00
David Sterba 10b6b0b3a8 btrfs-progs: tests: add driver script for misc tests
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-02 15:56:43 +02:00
David Sterba b51cc1d325 btrfs-progs: tests: add script to clean intermediate images
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-05-25 16:10:58 +02:00
David Sterba 1497c92e67 btrfs-progs: test: 015-check-bad-memory-access
Crafted images may trigger out-of-bounds access during check, fixed by
"btrfs-progs: Enhance read_tree_block to avoid memory corruption"

Now adding image for the first one, the other need enhancements in the
testing framework.

Reference: https://bugzilla.kernel.org/show_bug.cgi?id=97171
Reference: https://bugzilla.kernel.org/show_bug.cgi?id=97191
Reference: https://bugzilla.kernel.org/show_bug.cgi?id=97271
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-05-25 16:10:48 +02:00
David Sterba e413938ea9 btrfs-progs: tests: sort image files
If a test has several images let filenames enforce a particular order of
checks if desired.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-05-25 15:35:58 +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 d6cedbcdd3 btrfs-progs: tests: support more formats of test images
We're using he meta-dump images, now we support compressed meta-dump,
raw and compressed raw images.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-05-21 16:37:52 +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
WorMzy Tykashi c5b2f66d63 btrfs-progs: use local btrfs-image in leaf corruption test
Currently this test uses the system btrfs-image. If there isn't a
btrfs-image on $PATH, the test fails. The test should be using the
locally compiled btrfs-image, not the system one.

Signed-off-by: WorMzy Tykashi <wormzy.tykashi@gmail.com>
Reviewed-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-09 18:45:00 +02:00
David Sterba 54d316b5ec btrfs-progs: tests: remove duplicate output for fsck test 013
The test name is logged since it lives in it's own directory.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-07 18:37:49 +02:00
David Sterba 047dd1bf5d btrfs-progs: tests: split make rule for fsck and convert tests, fix prerequisities
We'd like to run each class of tests separately. There were some missing
prerequisities that should be/are verified by the tests, makefile rules
have been synced.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-07 18:36:59 +02:00
David Sterba 35d53302ac btrfs-progs: convert tests: preserve test image permissions
If the test image is eg. on NFS it's not writable for root, so chmod
0777 fixes that but then we must not delete the file.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-07 18:36:55 +02:00
Qu Wenruo 45678c3048 btrfs-progs: convert-tests: Add check for converted btrfs with regular file extent.
Regression test for previous patch "btrfs-progs: convert: Make
ext*_image file obey datacsum setting."

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-07 17:23:12 +02:00
Qu Wenruo 0d9bbdc5e3 btrfs-progs: convert-tests: Update to use test framework infrastructure.
Also change the test() to convert_test(), to avoid conflict name with
bash test function.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-07 17:22:35 +02:00
Qu Wenruo a18f8b1665 btrfs-progs: fsck-tests: Add fallback TEST_DEV for test case 013
Add fallback TEST_DEV for test case 013.
Fallback to $TOP/tests/test.img.

Now all test cases of btrfs-progs need no extra setting except sudo.

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
Qu Wenruo 691695fe34 btrfs-progs: fsck-tests: Update 013-extent-tree-rebuild to use more test framework infrastructure.
Update 013-extent-tree-rebuild to use more framework infrastructure,
including:
1) Use run_check other than open-coded redirect
2) Add root privillege
3) Add dependency on 'btrfs-debug-tree' command

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
Qu Wenruo 74dc9d82af btrfs-progs: fsck-tests: Remove duplicatesd TEST_MNT setup.
Since we have already had TEST_MNT fallback setup to $TOP/tests/mnt,
just remove duplicated setting in 012-leaf-corruption/test.sh

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
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 d738c3d292 btrfs-progs: convert tests: add remaining supported nodesizes
That's 8k, 32k and 64k.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-03-23 16:57:03 +01:00
Sebastian Thorarensen 362936b03e btrfs-progs: Add nodesize test for btrfs-convert
convert-tests now test both 4096 and 16384 nodesizes.

Signed-off-by: Sebastian Thorarensen <sebth@naju.se>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-03-23 16:54:51 +01:00
David Sterba c392c2b5af btrfs-progs: tests, common: fix typo after cleanup
The previous value for unknown was -1.

Reported-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-03-10 14:11:18 +01:00
David Sterba 02e1c10e28 btrfs-progs: tests, clean up scripts
Rename variables, use caps, call true by full path, add quotation to
variables and a few wording fixes.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-03-09 12:30:26 +01:00
Qu Wenruo a624680b0e btrfs-progs: fsck-test: Add check_sudo to check valid root/sudo privilege
Although fsck-test/012 uses sudo, it uses 'sudo -n', which won't prompt
user to input password and will return 1 if no valid credential is
found.

And this makes test result quite annoying since it fails to mount and
still continue, which will always fail.

This patch will check 'sudo -v -n' and 'sudo -n true' to determine
whether sudo works fine in different version/settings, since in some
setting/version, 'sudo -v -n' will fail even the user is set NOPASSWD.

Also, remove the 'have_root_helper' variant, since there is a
possibility that sudo credential will timeout during the test and
'have_root_helper' won't help to detect such problem.
New '_sudo' command will do credential check if needed to avoid such
problem.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-03-09 12:08:56 +01:00
Josef Bacik 8ab2d7a9dd btrfs-progs: deal with no extent info
Previously we used to just set FULL_BACKREF if we couldn't lookup an extent info
for an extent.  Now we just bail out if we can't lookup the extent info, which
is less than good since fsck is supposed to fix these very problems.  So instead
figure out the flag we are supposed to use and pass that along instead.  This
patch also provides a test image to test this functionality.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
2015-02-09 14:53:07 -05:00
David Sterba 188e79e2fc btrfs-progs: tests, use non-interactive sudo helper
Sudo may not be configured to run without user prompt, in that case the
tests would be stuck.

Reported-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-01-19 19:09:28 +01: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
David Sterba 8fa12c10e7 btrfs-progs: tests, use the root helper in 012
We need it to mount/umount, to traverse lost+found and stat the results.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-01-14 18:34:18 +01:00
David Sterba 522e13d6d9 btrfs-progs: tests, add support for running commands under root
Most of the checks run fine without root, but some of them may need to
do a mount test or access the data. Add the support to selectively run
commands under root, hardcoded to sudo for now.

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 21afe4a316 btrfs-progs: Move leaf-corruption no extent data case and add verification script
Move leaf-corruption type no extent data case to its dir, and add
verification script in test.sh

The verification script is based on manual btrfs-debug-tree check.

The image can also be reused to other leaf-corruption type, like
corrupted leaf contains regular file extent data case.

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 a65701b88e btrfs-progs: Move bad root items test cases to its corresponding dir
Now 006-bad-root-items has two cases, one for default case, and one for
skinny metadata case.

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 ebe2f5cac3 btrfs-progs: Move btrfs-image dump to corresponding dir
Move these obvious btrfs-image to its corresponding dir to use the new
infrastructure.

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
Qu Wenruo 501c8eeda2 btrfs-progs: Add testcase for leaf-corrupted btrfsck repairing.
Add testcase for leaf-corrupted btrfsck repairing using the new
generate_image.sh method.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
2014-12-18 17:30:53 +01:00
Josef Bacik 2ac6d5a76b Btrfs-progs: add two new test images
This adds two new test images

1) 008-bad-offset-snapshots.  This has a corrupt item with multiple snapshots
pointing to it, to make sure the bad block repair stuff doesn't loop and
actually repairs stuff.  It also requires the dir index repair stuff to pass our
built in tests which is why it's not tied to the same commit.

2) 009-bad-dir-index-name.img. This has a corrupt name in a dir index to make
sure our dir index repair stuff is working properly.

Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
2014-12-18 17:28:02 +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
Josef Bacik 1e3da6d65e Btrfs-progs: test images for new btrfsck functionality
These test the recreating of missing dir item/dir index pairs, fixing the no
rootdir inode item and no inode item for normal files.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
2014-11-14 11:01:57 +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 01f868b5a9 btrfs-progs: make fsck deal with bogus items
We can deal with corrupt items by deleting them in a few cases.  Fsck can easily
recover from a missing extent item or a dir index item.  So if we notice a item
is completely bogus and it is of a key that we know we can repair then just
delete it and carry on.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-10-14 11:10:36 +02:00
Josef Bacik 187b85436b btrfs-progs: add the ability to fix shifted item offsets
A user had a corrupted fs where the items had been shifted improperly.  This
patch adds the ability to fix this sort of problem within fsck.  We will simply
shift the item over to the proper offset and update the offsets to make sure
they are correct.  I tested this with a hand crafted fs that was broken in the
same way as the user, and I've included the file as a new test.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-10-14 11:04:08 +02:00
Josef Bacik 6863bcf74f Btrfs-progs: repair missing dir index
If we have an inode backref entry then we know enough to add back a missing dir
index.  When messing with the inode backrefs we need to do all of that first
before we process the inode recs themselves as we may clear errors on the inode
recs as we fix the directory indexes.  This adds the framework for fixing
backref errors and fixes missing dir index issues.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-10-13 23:20:44 +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
Adam Buchbinder 4156fadc53 btrfs-progs: Use sparse files for filesystem conversion tests
On my system, this brings the FS conversion test suite's runtime from over
ten seconds down to under two.

Thanks to Julien Muchembled for the suggestion.

Signed-off-by: Adam Buchbinder <abuchbinder@google.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 14:43:09 +02:00
Adam Buchbinder 2100836188 btrfs-progs: Add some simple end-to-end tests for btrfs-convert
These use the system's mke2fs, and don't require loop devices
or root privileges.

They don't pick up anything with the default flags right now,
but they do pick up some sanitizer issues when the tools are
compiled with any of -fsanitize={address,memory,thread}.

Signed-off-by: Adam Buchbinder <abuchbinder@google.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 14:39:35 +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