summaryrefslogtreecommitdiff
path: root/tests
Commit message (Collapse)AuthorAge
* 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>
* btrfs-progs: tests: truncate test image to 0 firstDavid Sterba2018-01-31
| | | | | | | | We use the prepare_test_dev helper to make sure the image has at least this size. The "at least" part is not desired by some tests as the device might be larger than the test expects. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: add more coverage to mkfs-tests/013-reserved-1M-for-singleDavid Sterba2018-01-31
| | | | | | | Though the newly added mkfs profiles should not be affected, let's add the remaining valid single device profiles for better coverage. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: mkfs: don't overwrite first 1M for singleQu Wenruo2018-01-31
| | | | | | | | | Add test case to check if the first device extent is occupying reserved 0~1M range. 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:mkfs/010: Output minimal device sizeQu Wenruo2018-01-31
| | | | | | | To make debugging a little easier. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: 029-super-recovery: cleanup the testDavid Sterba2018-01-31
| | | | | | | Transform the test to the common helpers and don't manage the loop devices here. The test category changes from check to misc. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: Add test for super block recoveryNikolay Borisov2018-01-31
| | | | | | | | | This functionality regressed some time ago and it was never caught. Seems no one complained of that, but to be sure add a regression test to prevent future regressions. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: Explictly state test.sh must be executableNikolay Borisov2018-01-31
| | | | | | Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: fix typo in error messageDavid Sterba2018-01-08
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests/mkfs: verify that mkfs.btrfs rootdir+shrink behaves correctlyQu Wenruo2018-01-08
| | | | | Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests/mkfs: Introduce test case to check if mkfs rootdir can ↵Qu Wenruo2018-01-08
| | | | | | | | | | | create a new file To test regression 460e93f25754 ("btrfs-progs: mkfs: check the status of file at mkfs"). Signed-off-by: Qu Wenruo <wqu@suse.com> [ update test to create a out of /tmp ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: test/mkfs: Test if the minimal device size is validQu Wenruo2018-01-08
| | | | | | | | | New test case to test if the minimal device size given by "mkfs.btrfs" failure case is valid. Signed-off-by: Qu Wenruo <wqu@suse.com> [ renamed script ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests/convert: ensure btrfs-convert won't rollback the ↵Qu Wenruo2018-01-03
| | | | | | | | filesystem after balance Signed-off-by: Qu Wenruo <wqu@suse.com> [ add shell quotes, rename test ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: test/common: Enhance prepare_test_dev to reset device sizeQu Wenruo2018-01-03
| | | | | | | | | So prepare_test_dev() can be called several times in one test case, to test different device sizes. Signed-off-by: Qu Wenruo <wqu@suse.com> [ switch to [ ] ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: test/common: Introduce run_mustfail_stdoutQu Wenruo2018-01-03
| | | | | | | For later test case which needs info from stderr. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: fix typos in test namesDavid Sterba2018-01-03
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: mkfs/008 mkfs with forceDavid Sterba2018-01-03
| | | | | | | With extended tests in the following patch a file based filesystem image also needs -f, otherwise it will fail. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: test/fsck/021: Cleanup custom check by overriding check_imageQu Wenruo2018-01-03
| | | | | | Signed-off-by: Qu Wenruo <wqu@suse.com> [ update comment ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: test/fsck/020: Cleanup custom check function by overriding ↵Qu Wenruo2018-01-03
| | | | | | | check_image function Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: test/fsck: Introduce test images containing tree reloc treeQu Wenruo2018-01-03
| | | | | | | | | | | | | Reloc tree is a special tree with very short life span. It acts as a special snapshot for any tree, with related nodes/leaves or EXTENT_DATA modified to point to new position. Considering the short life span and its special purpose, it should be quite reasonable to keep them as both corner case for fsck and educational dump for anyone interested in relocation. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fsck-tests: Introduce test case with keyed data backref with ↵Qu Wenruo2018-01-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | shared tree blocks For snapshot shared tree blocks with source subvolume, the keyed backref counter only counts the exclusive owned references. In the following case, 258 is a snapshot of 257, which inherits all the reference to this data extent. ------ item 4 key (12582912 EXTENT_ITEM 524288) itemoff 3741 itemsize 140 refs 179 gen 9 flags DATA extent data backref root 257 objectid 258 offset 0 count 49 extent data backref root 257 objectid 257 offset 0 count 1 extent data backref root 256 objectid 258 offset 0 count 128 extent data backref root 256 objectid 257 offset 0 count 1 ------ 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: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fsck-test: Add new image with shared block ref only metadata ↵Qu Wenruo2018-01-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | backref The image is dumped by modifying kernel to sleep long enough before merging relocation trees, so we can just copy the whole image to other place before kernel begins to merge reloc trees. And the base image is created by the following script to bump metadata size: ------ dev=~/test.img mnt=/mnt/btrfs umount $mnt &> /dev/null fallocate -l 128M $dev mkfs.btrfs -f -n 4k -m single -d single $dev mount $dev $mnt -o nospace_cache,max_inline=2048 btrfs subvolume create $mnt/src for i in $(seq -w 0 128); do xfs_io -f -c "pwrite 0 2k" $mnt/src/file_$i > /dev/null done for i in $(seq -w 0 64); do btrfs subvolume snapshot $mnt/src/ $mnt/snapshot_$i touch $mnt/snapshot_$i/new done sync ------ The image triggers several corner cases that the old lowmem mode didn't consider. Like metadata backref with FULL_BACKREF flag and only SHARED_BLOCK_REF backrefs for metadata. And several tree reloc trees with shared leaves/nodes to confuse old lowmem mode. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fsck-test: Introduce test case for false data extent backref lostQu Wenruo2018-01-03
| | | | | | | | | | | Introduce a new test image, which has an extent item with no inlined extent data ref, but all keyed extent data ref. Only in this case we can trigger fase data extent backref lost bug in lowmem mode. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: test: Add test image for lowmem mode referencer count mismatch ↵Lu Fengqi2017-11-14
| | | | | | | | | | | false alert Add a image which can reproduce the extent item referencer count mismatch false alert for lowmem mode. Reported-by: Marc MERLIN <marc@merlins.org> Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: test: Add test image for lowmem mode file extent interruptLu Fengqi2017-11-14
| | | | | | | | Add a image that the inlined extent coexist with the regular extent. Reported-by: Marc MERLIN <marc@merlins.org> Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: extend fsck/028 to test fix-device-size and mountDavid Sterba2017-11-14
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests/fsck: Add test case image for 'rescue fix-dev-size'Qu Wenruo2017-11-14
| | | | | | | | | | | | | | | | The image has 2 problems mixed: 1) Too small super total_bytes This super total_bytes is manually modified to create such problem. 2) Unaligned dev item total_bytes This is created by v4.12 kernel, with 128M + 2K device added, and original device removed. Then we can create such image with unaligned dev item total_bytes. Signed-off-by: Qu Wenruo <quwenruo.btrfs@gmx.com> Reviewed-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests/common: Display warning only after searching for btrfs ↵Lakshmipathi.G2017-11-14
| | | | | | | kernel module Signed-off-by: Lakshmipathi.G <lakshmipathi.g@giis.co.in> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: don't pass size to prepare_test_dev if not necessaryDavid Sterba2017-11-14
| | | | | | | Most tests don't need a specific size of the test device, the default 2GiB should be fine. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: test: add new cli-test for subvol get/set-defaultMisono, Tomohiro2017-11-14
| | | | | | | | Add new test to check functionality of subvol get/set-default. Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com> [ fix style issues, add missing SUDO_HELPER ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fsck-tests: 027/bad_extent_inline_ref_typeSu Yue2017-11-14
| | | | | | | | This case is for avoiding crash in lowmem check mode. Field type of extent_inline_ref in an extent is corrupted. Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>