summaryrefslogtreecommitdiff
path: root/tests
Commit message (Collapse)AuthorAge
* btrfs-progs: fsck-tests: add test case with keyed data backref with reloc ↵Su Yue2018-08-06
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* btrfs-progs: test/fuzz: Add image for BUG_ON() when opening the fs by btrfs ↵Qu Wenruo2018-08-06
| | | | | | | | 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>
* btrfs-progs: tests/fuzz: Add fuzzed test image for btrfs check BUG_ONQu Wenruo2018-08-06
| | | | | | | | | | | | | | | | | | | | | | 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>
* btrfs-progs: tests/fuzz: Add image for bko-200409Qu Wenruo2018-08-06
| | | | | | | 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>
* btrfs-progs: fsck-tests: Add test case for corrupted inline ram_bytesQu Wenruo2018-08-06
| | | | | Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: misc-tests: Fix 029 test cases for sudo test environmentQu Wenruo2018-08-06
| | | | | | | | | | | | | 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>
* btrfs-progs: tests: add fuzzed image that triggers crash in reloc setup on mountDavid Sterba2018-08-06
| | | | | Reported-by: Wen Xu <wen.xu@gatech.edu> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: fix fsck-tests/031 when on NFSDavid Sterba2018-06-07
| | | | | | | | 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>
* btrfs-progs: fsck-tests: add test case to check symlinks with bad flagsSu Yue2018-06-07
| | | | | | | | 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>
* btrfs-progs: tests: test mkfs.btrfs fails on small backing size thin ↵Su Yue2018-06-07
| | | | | | | | | | | | | | | 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>
* btrfs-progs: tests: Add test for collision DIR_ITEM handlingNikolay Borisov2018-06-07
| | | | | | | | | | | | | | 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>
* btrfs-progs: tests: Add test case to ensure btrfs check returns error for ↵Qu Wenruo2018-06-07
| | | | | | | | | | | | 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>
* btrfs-progs: tests: check btrfs qgroup parent-child relation outputLu Fengqi2018-06-07
| | | | | | | | | | | Since commit aaf2dac5ef37 ("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>
* btrfs-progs: tests: Add test case for dump-tree on heavily corrupted leafQu Wenruo2018-06-07
| | | | | Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: update log markersDavid Sterba2018-06-07
| | | | | | | Use visual markers that separate tests and individual commands run via the run_* helpers. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: add image with no extent with normal device sizeSu Yue2018-06-07
| | | | | | | | | | | | | | 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>
* btrfs-progs: tests/fsck: Add test case to check if btrfs check can skip data ↵Qu Wenruo2018-04-24
| | | | | | | csum verfication for metadata dump Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Remove deprecated btrfs-zero-log standalone toolNikolay Borisov2018-04-24
| | | | | | | | | | | Its function has been subsumed by "btrfs rescue zero-log". Remove its source file and adjust make/tests soruces accordingly. Deprecated since 4.0. Issue: #97 Signed-off-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: Test if btrfs-image can handle RAID1 missing deviceQu Wenruo2018-03-30
| | | | | Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: Test if mkfs.btrfs --rootdir can handle ng symlinkQu Wenruo2018-03-30
| | | | | Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: add shell quotes to misc test scriptsDavid Sterba2018-03-30
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: add shell quotes to mkfs test scriptsDavid Sterba2018-03-30
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: remove trivial use of local variablesDavid Sterba2018-03-30
| | | | | | | No need to use a temporary variable if the parameter usage is obvious from the context. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: add shell quoting to fuzz test scriptsDavid Sterba2018-03-30
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: convert/014 use shell builtin for generating contentDavid Sterba2018-03-30
| | | | | | | We can remove dependency on perl and use shell builtin go generate sequence of bytes. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: update README, images, coding styleDavid Sterba2018-03-30
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: mkfs fills uuid and otime for FS_TREEDavid Sterba2018-03-30
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: don't use fallocate in mkfs/014-rootdir-inline-extentDavid Sterba2018-03-30
| | | | | | | If fallocate is not supported, this test fails. Use a shell trick to fill with given number of bytes. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: Add testcase for rootdir inline extent sizeQu Wenruo2018-03-30
| | | | | | | | Add a test case for mkfs --rootdir, using files with different file sizes to check if invalid large inline extent could exist. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: test/convert: Add test case for invalid large inline data extentQu Wenruo2018-03-30
| | | | | Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* Btrfs-progs: add fsck test for filesystem with shared prealloc extentsFilipe Manana2018-03-30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Verify that a filesystem check operation (fsck) does not report the following scenario as an error: An extent is shared between two inodes, as a result of clone/reflink operation, and for one of the inodes, lets call it inode A, the extent is referenced through a file extent item as a prealloc extent, while for the other inode, call it inode B, the extent is referenced through a regular file extent item, that is, it was written to. The goal of this test is to make sure a filesystem check operation will not report "odd csum items" errors for the prealloc extent at inode A, because this scenario is valid since the extent was written through inode B and therefore it is expected to have checksum items in the filesystem's checksum btree for that shared extent. Such scenario can be created with the following steps for example: mkfs.btrfs -f /dev/sdb mount /dev/sdb /mnt touch /mnt/foo xfs_io -c "falloc 0 256K" /mnt/foo sync xfs_io -c "pwrite -S 0xab 0 256K" /mnt/foo touch /mnt/bar xfs_io -c "reflink /mnt/foo 0 0 256K" /mnt/bar xfs_io -c "fsync" /mnt/bar <power fail> mount /dev/sdb /mnt umount /mnt This scenario is fixed by the following patch for the filesystem checker: "Btrfs-progs: check, fix false error reports for shared prealloc extents" Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: fix source path for testsuiteDavid Sterba2018-03-30
| | | | | | | | The commit cebf3b37228cbde730a5 ("btrfs-progs: introduce TEST_TOP and INTERNAL_BIN for tests") did not convert all test paths. This would break the exported testsutie. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: Add test case with valid orphan inodeQu Wenruo2018-03-30
| | | | | | | | Regression test for false alerts in lowmem mode. Signed-off-by: Qu Wenruo <wqu@suse.com> [ update test ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fsck-tests: Introduce test case with keyed data backref with ↵Lu Fengqi2018-03-30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | the extent offset Add the testcase for false alert of data extent backref lost with the extent offset. The image can be reproduced by the following commands: ------ dev=~/test.img mnt=/mnt/btrfs umount $mnt &> /dev/null fallocate -l 128M $dev mkfs.btrfs $dev mount $dev $mnt for i in `seq 1 10`; do xfs_io -f -c "pwrite 0 2K" $mnt/file$i done xfs_io -f -c "falloc 0 64K" $mnt/file11 for i in `seq 1 32`; do xfs_io -f -c "reflink $mnt/file11 0 $(($i * 64))K 64K" $mnt/file11 done xfs_io -f -c "reflink $mnt/file11 32K $((33 * 64))K 32K" $mnt/file11 btrfs subvolume snapshot $mnt $mnt/snap1 umount $mnt btrfs-image -c9 $dev extent_data_ref.img ------ Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: add helper to log pipe stdoutDavid Sterba2018-02-19
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: add test for send -p on 2 mont pointsDavid Sterba2018-02-19
| | | | | | | Add testcase from issue, use reproducer from Axel Burri. Issue: #96 Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: document exported testsuiteDavid Sterba2018-02-13
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: test: update clean-test.sh after the TEST_TOP updateDavid Sterba2018-02-13
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: unify test drivers, make ready for extenral testsuiteDavid Sterba2018-02-13
| | | | | | | | | | | Make the TOP variable more configurable, allow to set it to any path where to find binaries when the testsuite is exported, or fallback to system binaries. There's now more code duplication, the logic is now more complex so it's left open coded for clarity. Further cleanups are possible. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: update README.mdDavid Sterba2018-02-13
| | | | | | Irregular proofreading with adjustments and enhancements. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: introduce TEST_TOP and INTERNAL_BIN for testsGu Jinxiang2018-02-13
| | | | | | | | | | | | Use TEST_TOP as base for tests to reference any files, this will be used for git and external testsuite. INTERNAL_BIN is needed for referencing binaries that could reside in different paths in git vs external testsuite. Signed-off-by: Gu Jinxiang <gujx@cn.fujitsu.com> [ add quotes around sourced files, update changelog ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: rework testsuite exportDavid Sterba2018-02-13
| | | | | | | | | | Move the testsuite to tests/ and make the tarball generation more deterministic. As there could be many random temporary files left in the test directories, we can't just copy them. Use 'git ls-tree' to filter just what we want, this needs a slight extension of the file list specification. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Add make testsuite command for export testsGu Jinxiang2018-02-13
| | | | | | | | | | | | | | | | | Export the testsuite files to a separate tar. Since fsck tests depend on btrfs-corrupt-block, and misc tests depends on both btrfs-corrupt-block and fssum, so set it as prerequisites for package commad. Because, althougth fssum can be generated by source that are all in tests directory, and has no rely on the btrfs's structure. But btrfs-corrupt-block deeply relys on btrfs's structure. For consistency, at the present stage, generete the two when create test tar. Signed-off-by: Gu Jinxiang <gujx@cn.fujitsu.com> [ applied without changes, the generated tarball will be different from the one after the follow up commits ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests common: remove meaningless colon in extract_image()Su Yue2018-02-07
| | | | | | | The colon is meaningless so remove it. Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fsck-tests: Cleanup the restored image for 028Qu Wenruo2018-02-06
| | | | | Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: chang tree-reloc-tree test number from 027 to 015Qu Wenruo2018-02-02
| | | | | | | | | | | | There are 2 fsck tests with the same number 027: tree-reloc-tree bad-extent-inline-ref-type And we also have a hole in 015, so just rename tree-reloc-tree to 015, to get rid of the duplicated test number and fill in the hole. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: fixup mount tests of fsck/028-unaligned-super-dev-sizesDavid Sterba2018-01-31
| | | | | | | This test was broken because it tried to mount a different image than what it had repaired. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: enhance common umount helper to take optional pathsDavid Sterba2018-01-31
| | | | | | | | | | | The run_check_umount_test_dev umounts the TEST_DEV and also optionally uses the arguments but this would not work as expected if the TEST_DEV is not a vald path for umount (eg. a restored image). Update the helper so it tries to umount all paths, or fallback to TEST_DEV to keep the current behaviour. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: disable some mkfs/010 testcases inside travisDavid Sterba2018-01-31
| | | | | | | | | Node sizes larger than 16k will fail due to enospc in the mount test. This is likely caused by the kernel. Keep the condition only local to travis so any other testing environment could see the failure eventually. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: treewide: Replace strerror(errno) with %m.Rosen Penev2018-01-31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As btrfs is specific to Linux, %m can be used instead of strerror(errno) in format strings. This has some size reduction benefits for embedded systems. glibc, musl, and uclibc-ng all support %m as a modifier to printf. A quick glance at the BIONIC libc source indicates that it has support for %m as well. BSDs and Windows do not but I do believe them to be beyond the scope of btrfs-progs. Compiled sizes on Ubuntu 16.04: Before: 3916512 btrfs 233688 libbtrfs.so.0.1 4899 bcp 2367672 btrfs-convert 2208488 btrfs-corrupt-block 13302 btrfs-debugfs 2152160 btrfs-debug-tree 2136024 btrfs-find-root 2287592 btrfs-image 2144600 btrfs-map-logical 2130760 btrfs-select-super 2152608 btrfstune 2131760 btrfs-zero-log 2277752 mkfs.btrfs 9166 show-blocks After: 3908744 btrfs 233256 libbtrfs.so.0.1 4899 bcp 2366560 btrfs-convert 2207432 btrfs-corrupt-block 13302 btrfs-debugfs 2151104 btrfs-debug-tree 2134968 btrfs-find-root 2281864 btrfs-image 2143536 btrfs-map-logical 2129704 btrfs-select-super 2151552 btrfstune 2130696 btrfs-zero-log 2276272 mkfs.btrfs 9166 show-blocks Total savings: 23928 (24 kilo)bytes Signed-off-by: Rosen Penev <rosenp@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>