Commit Graph

406 Commits (5f5c497c8b556712c10975070a8d234ab19e64a2)

Author SHA1 Message Date
Su Yue 82cb226f51 btrfs-progs: misc-tests/029: exit manually after run_mayfail()
Since the commmit 8dd3e5dc2d
("btrfs-progs: tests: fix misc-tests/029 to run on NFS") added the
compatibility of NFS, it called run_mayfail() in the last of the test.

However, run_mayfail() always return the original code. If the test
case is not running on NFS, the last `run_mayfail rmdir "$SUBVOL_MNT"`
will fail with return value 1 then the test fails:
================================================================
====== RUN MAYFAIL rmdir btrfs-progs/tests/misc-tests/029-send-p-different-mountpoints/subvol_mnt
rmdir: failed to remove 'btrfs-progs/tests/misc-tests/029-send-p-different-mountpoints/subvol_mnt': No such file or director
failed (ignored, ret=1): rmdir btrfs-progs/tests/misc-tests/029-send-p-different-mountpoints/subvol_mnt
test failed for case 029-send-p-different-mountpoints
=================================================================

Every instrument in this script handles its error well, so do exit 0
manually in the last.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=202645
Fixes: 8dd3e5dc2d ("btrfs-progs: tests: fix misc-tests/029 to run on NFS")
Signed-off-by: Su Yue <Damenly_Su@gmx.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-03 20:49:04 +02:00
David Sterba 604ffe8876 btrfs-progs: tests: simple test for subvol show output
Test the recent changes in 'subvol show' that prints quota information.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-03 13:31:15 +02:00
David Sterba 2570cff076 btrfs-progs: test: cleanup misc-tests/034
Cleanups:
- add quotation
- use _log for messages
- unify spelling of metadata_uuid as feature and incompat bit
- add -- separators
- minor whitespace adjustments

Signed-off-by: David Sterba <dsterba@suse.com>
2019-06-05 20:27:32 +02:00
David Sterba 7caf934f04 btrfs-progs: tests: misc-tests/034: use sudo helper for module probing
All module operations need root, add the helper support and run the
critical calls with checks.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-06-05 20:27:32 +02:00
David Sterba 8dd3e5dc2d btrfs-progs: tests: fix misc-tests/029 to run on NFS
The directories created under default path needs a fallback in case it's
on NFS and root cannot create the directory. Update the test to create
only one additional mount point and use the TEST_MNT as the toplevel
one.

The error message we're looking for is now a bit weaker due to the less
specific path.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-06-05 20:27:32 +02:00
David Sterba 81ada30fec btrfs-progs: switch to mkfs helper
Signed-off-by: David Sterba <dsterba@suse.com>
2019-06-05 20:27:32 +02:00
David Sterba 2a24192454 btrfs-progs: tests: add helper for common mkfs on TEST_DEV
Lots of test opencode the mkfs phase with no special needs, add a helper
that forcibly creates fileystem on TEST_DEV. Any options can be added,
except devices.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-06-05 20:27:32 +02:00
Nikolay Borisov ea4d99157c btrfs-progs: tests: Test fs on image files is correctly recognised
This ensures that 'btrfs filesystem show' can correctly identify a
filesystem on a newly created local file.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-06-05 20:27:31 +02:00
David Sterba 485da9d52d btrfs-progs: tests: unmount testing mount point recursively
The test misc-tests/035-receive-common-mount-point-prefix does another
mount inside TEST_MNT but current 'make test-clean' will not properly
undo the nested mount and this will break subsequent tests. The
recursive unmount can handle that.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-05-27 16:08:23 +02:00
David Sterba 936eaf9a36 btrfs-progs: tests: disable misc-tests/035-receive-common-mount-point-prefix
The fix was reverted, skip the test so the testsuite can proceed.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-05-17 13:02:22 +02:00
Qu Wenruo f4be6432c9 btrfs-progs: tests: detecting compressed extent without csum
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-05-17 12:32:38 +02:00
David Sterba 50b9312f3a btrfs-progs: tests: update test number of bad-free-space-cache-inode-mode
There was a duplication, increase the number for patch as they were
merged.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-05-17 12:32:38 +02:00
David Sterba 639d949f9f btrfs-progs: tests: stream dump and max_error counts
The --dump option of receive must also respect the --max-errors
parameter.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-05-17 12:32:38 +02:00
David Sterba 3fe16a10da btrfs-progs: tests: fix misc/026 to run on NFS
The temporary files are not accessible if the testsuite is hosted on
NFS, pre-create them and allow writes.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-05-02 19:14:13 +02:00
Qu Wenruo 2437a88079 btrfs-progs: tests/fsck: Add test image for free space cache mode repair
The image has one free space cache inode with invalid mode (0).
        item 9 key (256 INODE_ITEM 0) itemoff 13702 itemsize 160
                generation 30 transid 30 size 65536 nbytes 1507328
                block group 0 mode 0 links 1 uid 0 gid 0 rdev 0
                sequence 23 flags 0x1b(NODATASUM|NODATACOW|NOCOMPRESS|PREALLOC)
                atime 0.0 (1970-01-01 08:00:00)
                ctime 1553491158.189771625 (2019-03-25 13:19:18)
                mtime 0.0 (1970-01-01 08:00:00)
                otime 0.0 (1970-01-01 08:00:00)

Both lowmem and original mode should be able to detect and fix it.

The extracted test image is pretty big (1G extracted), as kernel won't
cache small chunks.
Even with SSD, such test may still take some seconds just extracting the
image.

Signed-off-by: Qu Wenruo <wqu@suse.com>
2019-04-16 09:04:25 +08:00
Su Yue 84d433d861 btrfs-progs: fsck-test: enable lowmem repair for case 001
Lowmem can repair after commit
       'btrfs-progs: lowmem: move nbytes check before isize check',
so add the beacon file.

Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
2019-04-16 09:04:25 +08:00
Lu Fengqi 8a3aefc78d btrfs-progs: tests: add case for inode lose one file extent
The missing extent will lead to the existence of the gap between adjacent
extents. The fsck should can detect the gap correctly and repair by punch
a hole.

Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
2019-04-16 09:04:25 +08:00
David Sterba 2b209f70d0 btrfs-progs: tests: add option coverage for btrfstune
Add tests that exercise all command line options of btrfstune, the valid
and some invalid combinations.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-01-17 01:42:33 +01:00
Filipe Manana ccdd01a404 Btrfs-progs: add test for receive
Add a test for a scenario that used to fail due to find_mount_root()
incorrectly determining the mount point for the receive path due to the
fact that a different mount point with a path that is a prefix of the
receive path exists.

This is fixed by a recent patch titled:

  "Btrfs-progs: fix mount point detection due to partial prefix match"

Reported-by: David Disseldorp <ddiss@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
[ adjustments to make the test work when hosted on NFS ]
Signed-off-by: David Sterba <dsterba@suse.com>
2019-01-15 18:42:14 +01:00
David Sterba 4a654aead4 btrfs-progs: tests: speed up fsck/037 free space tree test
The runtime of the test is over 4 minutes when hosted on NFS, the
fallocate phase takes the most time. As fallocate can't take multiple
arguments, we can't save the overhead by creating the files at once.

Create the files in batches in the background, this improves the runtime
to 2 minutes.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-01-15 18:42:13 +01:00
Qu Wenruo f7f1700b58 btrfs-progs: tests: check: Make 026-bad-dir-item-name verify if btrfs-check can also repair
Just remove the customized 'test.sh', then generic fsck test will do the
check-repair-check.

Signed-off-by: Qu Wenruo <wqu@suse.com>
2019-01-15 18:42:13 +01:00
Qu Wenruo 81275c8bf5 btrfs-progs: tests: Add test image for dev extents beyond device boundary
Now two locations can detect such problem, either by device item
used/total bytes check, or by early dev extents check against device
boundary.

The image is hand-crafted image which uses DATA SINGLE chunk to feed
btrfs check.  As expected, as long as block group item, chunk item,
device used bytes match, older versions check can't detect such problem.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-01-15 18:42:13 +01:00
Nikolay Borisov 0de2e22ad2 btrfs-progs: tests: Add tests for changing fsid feature
Add a bunch of tests exercising the new btrfstune functionality. In
particular check that various restrictions are implemented correctly,
test that btrfs-image works as expected and also test the output of
btrfs inspect-internal dump-super is correct.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-01-15 16:20:09 +01:00
Qu Wenruo 9996feb94d btrfs-progs: misc-tests/021: Do extra btrfs check before mounting
Test case misc/021 is testing if we could mount a single disk btrfs
image recovered from multi disk fs.

The problem is, current kernel has extra check for block group, chunk
and dev extent.  This means no image can pass btrfs check for chunk
tree and the filesystem will not mount.

So do extra btrfs check before mount, this will also help us to locate
the problem in btrfs-image easier.

Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-12-05 15:47:24 +01:00
Qu Wenruo aedc3389a7 btrfs-progs: fsck-tests: Move reloc tree images to 020-extent-ref-cases
For reloc tree, despite of its short lifespan, it's still the backref,
where reloc tree root backref points back to itself, makes it special.

So it's more approriate to put them into 020-extent-ref-cases.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-12-05 15:46:28 +01:00
Josh Soref 584749488a btrfs-progs: tests: fsck/025, fix typo in helpre name
Generated by https://github.com/jsoref/spelling

Issue: #154
Author: Josh Soref <jsoref@users.noreply.github.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-11-26 17:54:19 +01:00
Josh Soref 0509c05ae6 btrfs-progs: tests: fix typos in test comments
Generated by https://github.com/jsoref/spelling

Issue: #154
Author: Josh Soref <jsoref@users.noreply.github.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-11-26 17:53:43 +01:00
Josh Soref 2e67bf0ed6 btrfs-progs: docs: fix typos in READMEs, INSTALL and CHANGES
Generated by https://github.com/jsoref/spelling

Issue: #154
Author: Josh Soref <jsoref@users.noreply.github.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-11-26 17:47:22 +01:00
Su Yanjun b4843d3669 btrfs-progs: tests: Add the testcase for subvolume name length limit test
Total of three conditions are tested. One for short name, one with
name length 255, the last one with more than 255.

This case should pass after commit
'btrfs-progs: change filename limit to 255 when creating subvolume'.

Signed-off-by: Su Yanjun <suyj.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-10-25 16:11:40 +02:00
David Sterba 9d3303fa1b btrfs-progs: tests: add runtime check for free-space-tree
The CI hosts have old kernel that does not support the FST, make the
test fail gracefully.

Signed-off-by: David Sterba <dsterba@suse.com>
2018-10-25 16:11:40 +02:00
Nikolay Borisov 1cf5833aa6 btrfs-progs: tests: Test for FST corruption detection/repair
Simple test case which preps a filesystem, then corrupts the FST and
finally repairs it. Tests both extent based and bitmap based FSTs.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-10-25 16:11:40 +02:00
Nikolay Borisov 5950bcd121 btrfs-progs: tests: add test for missing device delete error value
Add a test which ensures the kernel returns the correct error value
when missing device removal is requested. This test verifies that kernel
refactoring didn't break the return value.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-10-23 14:48:39 +02:00
David Sterba b3b0c40465 btrfs-progs: tests: renumber last fsck test to 036-rescan-not-kicked-in
The commit d99615284a ("btrfs-progs:
fsck-tests: Add test image to check if btrfs check reports uninitialized
rescan as error") added test 035, should have been 036.

Signed-off-by: David Sterba <dsterba@suse.com>
2018-10-23 14:48:38 +02:00
Qu Wenruo d99615284a btrfs-progs: fsck-tests: Add test image to check if btrfs check reports uninitialized rescan as error
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-08-06 15:06:32 +02:00
Su Yue e6203e6ff9 btrfs-progs: fsck-tests: add test case with keyed data backref with reloc tree blocks
For trees have been balanced, leaves are with flag BTRFS_HEADER_FLAG_RELOC and
extent data backrefs are shared. Like:
=====================
       item 0 key (11927552 EXTENT_ITEM 524288) itemoff 3932 itemsize 63
                refs 129 gen 7 flags DATA
                shared data backref parent 35897344 count 41
                shared data backref parent 35426304 count 37
                shared data backref parent 35422208 count 51
=====================

Then make the leaf which owns the extent data cowed. The shared data
backref was to transferred to keyed data ref, but remaining backrefs are
still shared. Like:
=====================
        item 0 key (11927552 EXTENT_ITEM 524288) itemoff 3887 itemsize 108
                refs 129 gen 7 flags DATA
                extent data backref root 5 objectid 258 offset 0 count 40
                extent data backref root 5 objectid 257 offset 0 count 1
                shared data backref parent 35426304 count 37
                shared data backref parent 35422208 count 51
=====================

However lowmem mode used to iterate the whole inode to find all
references, and doesn't care if a reference is already counted by the
shared tree block.

Add the test case to check it.

Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-08-06 15:03:16 +02:00
Qu Wenruo d6f5504239 btrfs-progs: test/fuzz: Add image for BUG_ON() when opening the fs by btrfs check
Link: https://bugzilla.kernel.org/show_bug.cgi?id=199839
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-08-06 15:03:11 +02:00
Qu Wenruo 3fcef50906 btrfs-progs: tests/fuzz: Add fuzzed test image for btrfs check BUG_ON
This fuzzed image will not only cause kernel BUG_ON(), but also btrfs
check BUG_ON() for original mode.

Checking filesystem on /home/adam/btrfs/crafted_images/runtime/0.img
UUID: 3381d111-94a3-4ac7-8f39-611bbbdab7e6
checking extents
check/main.c:3677: check_owner_ref: BUG_ON `rec->is_root` triggered, value 1
btrfs(+0x572c2)[0x562d65da72c2]
btrfs(+0x6098d)[0x562d65db098d]
btrfs(+0x60bb6)[0x562d65db0bb6]
btrfs(+0x6179b)[0x562d65db179b]
btrfs(cmd_check+0x1199)[0x562d65db5589]
btrfs(main+0x88)[0x562d65d62768]
/usr/lib/libc.so.6(__libc_start_main+0xeb)[0x7f4fcbb1b06b]
btrfs(_start+0x2a)[0x562d65d6288a]

Link: https://bugzilla.kernel.org/show_bug.cgi?id=200403
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-08-06 15:03:09 +02:00
Qu Wenruo beb3ede39a btrfs-progs: tests/fuzz: Add image for bko-200409
Reported-by: Xu Wen <wen.xu@gatech.edu>
Link: https://bugzilla.kernel.org/show_bug.cgi?id=200409
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-08-06 15:03:02 +02:00
Qu Wenruo 866740418c btrfs-progs: fsck-tests: Add test case for corrupted inline ram_bytes
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-08-06 15:01:16 +02:00
Qu Wenruo 014a0db6cb btrfs-progs: misc-tests: Fix 029 test cases for sudo test environment
Test misc/029 only works if the test case is executed as root, while for
sudo usage, it doesn't work as initial mkdir and final cleanup doesn't
use $SUDO_HELPER.

Add "run_check $SUDO_HELPER" for such cases to allow it works under sudo
usage.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-08-06 14:59:49 +02:00
David Sterba 8aee4b000d btrfs-progs: tests: add fuzzed image that triggers crash in reloc setup on mount
Reported-by: Wen Xu <wen.xu@gatech.edu>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-08-06 14:59:40 +02:00
David Sterba 686dc0864e btrfs-progs: tests: fix fsck-tests/031 when on NFS
The restore target file does not exist and creating by root does not
work on NFS, so precreating will make that work. Also fix the image name
to be deleted.

Signed-off-by: David Sterba <dsterba@suse.com>
2018-06-07 16:37:40 +02:00
Su Yue 6386ae4d8c btrfs-progs: fsck-tests: add test case to check symlinks with bad flags
There are two bad symlinks in the test case.  One is with immutable
attribute.  Another one is with append attribute.

Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-06-07 16:37:38 +02:00
Su Yue e2eb6dc4d4 btrfs-progs: tests: test mkfs.btrfs fails on small backing size thin provision device
This tests is most similar to xfstests generic/405.
It calls device mapper to create a thin provision device with small
backing size and big virtual size. mkfs.btrfs should fail on such
devices.

This test should pass after commit e805b143a4fe
("btrfs-progs: mkfs: return nozero value on thin provisioned device").

Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-06-07 16:37:36 +02:00
Nikolay Borisov e889fd7c11 btrfs-progs: tests: Add test for collision DIR_ITEM handling
Verify that if we have an otherwise clean filesystem, containging
collided DIR_ITEM, btrfs check lowmem's mode can correctly handle those
and not produce any false positives.

This if fixed by commit titled:

 "btrfs-progs: check: fix DIR_ITEM checking in lowmem"

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-06-07 16:37:33 +02:00
Qu Wenruo 7e0ae73fb4 btrfs-progs: tests: Add test case to ensure btrfs check returns error for corrupted qgroups
Since the test case uses run_mustfail(), which is pretty easy pass due to
other unexpected problems, so here an extra run_check() is added to
ensure we don't only report qgroup error, but also fix it without
problem.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-06-07 16:37:33 +02:00
Lu Fengqi f841497b60 btrfs-progs: tests: check btrfs qgroup parent-child relation output
Since commit aaf2dac5ef ("btrfs-progs: qgroup: split update_qgroup to
reduce arguments") cause qgroup show to output the wrong qgroup
parent-child relationship, in addition to fixing the problem, a test case
is needed to prevent the similar problem in the future.

Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-06-07 16:37:33 +02:00
Qu Wenruo 0ef6797205 btrfs-progs: tests: Add test case for dump-tree on heavily corrupted leaf
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-06-07 16:37:32 +02:00
David Sterba 402ac7a140 btrfs-progs: tests: update log markers
Use visual markers that separate tests and individual commands run via
the run_* helpers.

Signed-off-by: David Sterba <dsterba@suse.com>
2018-06-07 16:37:32 +02:00
Su Yue bd52df0502 btrfs-progs: tests: add image with no extent with normal device size
This new image misses one extent which leads lowmem mode to allocate new
chunks in repair.

Rename original image to no_extent_bad_dev.img.
Because of its bad used bytes, it should let lowmem mode
exclude blocks in repair.

Due to problems of btrfs-image, choose xz as compression tool.

Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-06-07 16:37:32 +02:00