Commit Graph

286 Commits (e4c6772f69bff7bb75d8df0d5010a1091d6e47eb)

Author SHA1 Message Date
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