Commit graph

368 commits

Author SHA1 Message Date
David Sterba de802a47e0 btrfs-progs: tests: 029-super-recovery: cleanup the test
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>
2018-01-31 15:14:02 +01:00
Nikolay Borisov e764625f90 btrfs-progs: tests: Add test for super block recovery
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>
2018-01-31 15:14:01 +01:00
Nikolay Borisov 058fad5b92 btrfs-progs: tests: Explictly state test.sh must be executable
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-31 15:14:01 +01:00
David Sterba 6e8571e2df btrfs-progs: tests: fix typo in error message
Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-08 19:50:27 +01:00
Qu Wenruo 0ba347f315 btrfs-progs: tests/mkfs: verify that mkfs.btrfs rootdir+shrink behaves correctly
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-08 18:15:22 +01:00
Qu Wenruo 0ca2f5a724 btrfs-progs: tests/mkfs: Introduce test case to check if mkfs rootdir can create a new file
To test regression 460e93f257 ("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>
2018-01-08 18:15:18 +01:00
Qu Wenruo 5d0783ad14 btrfs-progs: test/mkfs: Test if the minimal device size is valid
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>
2018-01-08 18:11:35 +01:00
Qu Wenruo 1f36022071 btrfs-progs: tests/convert: ensure btrfs-convert won't rollback the filesystem after balance
Signed-off-by: Qu Wenruo <wqu@suse.com>
[ add shell quotes, rename test ]
Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-03 17:29:19 +01:00
Qu Wenruo 2c2db167c7 btrfs-progs: test/common: Enhance prepare_test_dev to reset device size
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>
2018-01-03 17:10:05 +01:00
Qu Wenruo 2bf30fb3b1 btrfs-progs: test/common: Introduce run_mustfail_stdout
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>
2018-01-03 17:10:03 +01:00
David Sterba c12a6e4dca btrfs-progs: tests: fix typos in test names
Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-03 17:09:59 +01:00
David Sterba dc06cda3d6 btrfs-progs: tests: mkfs/008 mkfs with force
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>
2018-01-03 17:09:54 +01:00
Qu Wenruo 37c737d7cb btrfs-progs: test/fsck/021: Cleanup custom check by overriding check_image
Signed-off-by: Qu Wenruo <wqu@suse.com>
[ update comment ]
Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-03 17:09:53 +01:00
Qu Wenruo 17538334e1 btrfs-progs: test/fsck/020: Cleanup custom check function by overriding check_image function
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-03 17:09:49 +01:00
Qu Wenruo 4e4c5d3549 btrfs-progs: test/fsck: Introduce test images containing tree reloc tree
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>
2018-01-03 17:09:42 +01:00
Qu Wenruo 263184c7d2 btrfs-progs: fsck-tests: Introduce test case with keyed data backref with 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>
2018-01-03 17:09:27 +01:00
Qu Wenruo 95dd77e2d5 btrfs-progs: fsck-test: Add new image with shared block ref only metadata 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>
2018-01-03 17:09:23 +01:00
Qu Wenruo fe23461921 btrfs-progs: fsck-test: Introduce test case for false data extent backref lost
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>
2018-01-03 17:09:15 +01:00
Lu Fengqi febfb10263 btrfs-progs: test: Add test image for lowmem mode referencer count mismatch 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>
2017-11-14 15:59:01 +01:00
Lu Fengqi 752f42d2c0 btrfs-progs: test: Add test image for lowmem mode file extent interrupt
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>
2017-11-14 15:59:01 +01:00
David Sterba f49e2bc3dc btrfs-progs: tests: extend fsck/028 to test fix-device-size and mount
Signed-off-by: David Sterba <dsterba@suse.com>
2017-11-14 15:59:00 +01:00
Qu Wenruo 5a78f577a3 btrfs-progs: tests/fsck: Add test case image for 'rescue fix-dev-size'
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>
2017-11-14 15:59:00 +01:00
Lakshmipathi.G 7a060ea026 btrfs-progs: tests/common: Display warning only after searching for btrfs kernel module
Signed-off-by: Lakshmipathi.G <lakshmipathi.g@giis.co.in>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-11-14 15:59:00 +01:00
David Sterba a6e5cdef43 btrfs-progs: tests: don't pass size to prepare_test_dev if not necessary
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>
2017-11-14 15:59:00 +01:00
Misono, Tomohiro 9896b43f70 btrfs-progs: test: add new cli-test for subvol get/set-default
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>
2017-11-14 15:59:00 +01:00
Su Yue 59e067ada7 btrfs-progs: fsck-tests: 027/bad_extent_inline_ref_type
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>
2017-11-14 15:59:00 +01:00
Qu Wenruo eca65a8977 btrfs-progs: tests: Allow check test to repair in lowmem mode for certain errors
Since lowmem mode can repair certain corruptions (mostly in fs tree),
insert a beacon into each fsck test cases to allow some of them be
tested in lowmem mode.

With this patch, fsck option override will check the beacon file
".lowmem_repairable" in the same directory of the test image, and if the
beacon exists, then it will also run lowmem mode repair to repair the
image.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-10-16 20:33:00 +02:00
David Sterba 5286ec58f5 btrfs-progs: tests: add more configure option coverage
* test convert spec string
* explicitly ask for zstd, as it is now autodetected

Signed-off-by: David Sterba <dsterba@suse.com>
2017-10-13 20:15:54 +02:00
David Sterba a69c1917c2 btrfs-progs: tests: fsck/007 fix so check --force works
Signed-off-by: David Sterba <dsterba@suse.com>
2017-10-13 20:15:47 +02:00
Su Yue 7dbd7f21d5 btrfs-progs: tests: arg override in command line
Lowmem mode only repairs few cases which has a beacon file
".lowmem_repairable" in the case' directory.

However, defining TEST_ENABLE_OVERRIDE=true in command line does work
in above strategy.
Because _skip_spec() in tests/common.local isn't interpreted by shell
in that case.

Solve it by making _skip_spec() always be defined in common.local.

Reported-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
[ keep the _skip_spec check ]
Signed-off-by: David Sterba <dsterba@suse.com>
2017-10-06 13:41:46 +02:00
David Sterba 1d4224e4aa btrfs-progs: tests: don't list toplevel subvolme in 'subvol list'
Signed-off-by: David Sterba <dsterba@suse.com>
2017-10-06 13:41:42 +02:00
Misono, Tomohiro fa5b3a7fe2 btrfs-progs: misc-test: use raid1 for data to enable mount with -o degraded
kernel 4.14 introduces new function for checking if all chunks is ok for
mount with -o degraded option.

  commit 21634a19f646 ("btrfs: Introduce a function to check if all
  chunks a OK for degraded rw mount")

As a result, raid0 profile cannot be mounted with -o degraded on 4.14.
This causes failure of the misc-test 011 "delete missing device".

Fix this by using raid1 profile for both data and metadata.
This also should work for kernel before 4.13.

Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-10-06 13:41:34 +02:00
David Sterba 5faec98439 btrfs-progs: tests: check there are no unprintable characters in btrfs-image -ss output
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:18:46 +02:00
Nicholas D Steeves 5b2fbc6f4e btrfs-progs: tests: Remove misleading BCP 78 boilerplate from SHA implementation
BCP 78 applies to RFC 6234, but sha224-256.c is Simplified BSD.

This causes the following lintian error when building on Debian and
Debian derivatives:

    E: btrfs-progs source: license-problem-non-free-RFC-BCP78
       tests/sha224-256.c

Please consult the following email from debian-legal@lists.debian.org
for more information:

https://lists.debian.org/debian-legal/2017/08/msg00004.html
Signed-off-by: Nicholas D Steeves <nsteeves@gmail.com>
[ I've copied too much from the RFC that's not related to the code,
  covered by the explicit copyright notice in the file ]
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:18:15 +02:00
Nicholas D Steeves ac71751828 btrfs-progs: tests: Add required IETF Trust copyright to SHA implementation
Signed-off-by: Nicholas D Steeves <nsteeves@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:18:12 +02:00
David Sterba 509af95c92 btrfs-progs: tests: make sure _is_file_or_command does not get confused
The test cli/007-check-force reports something like:

$ type -p '--string that starts with dashes'
bash: type: --: invalid option

Add the option/argument separator.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:18:05 +02:00
David Sterba 01bcf68cf5 btrfs-progs: tests: remove temporary images in mkfs/005 and mkfs/006
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:17:31 +02:00
David Sterba 03fb34b6b4 btrfs-progs: tests: remove temporary loopdev files
Remove files for testing loop devices when using the helper.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:17:28 +02:00
Nick Terrell 0766330f85 btrfs-progs: tests: add testing image for zstd for btrfs-restore
Adds tests for the new features based on a prebuilt btrfs image with a
zstd compressed file.

Split from the previous patch.

Signed-off-by: Nick Terrell <terrelln@fb.com>
[ with some cleanups ]
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:17:15 +02:00
David Sterba 67b7b4bc40 btrfs-progs: tests: fix run_mustfail in cli-tests/007-check-force
The sanity check in run_mustfail does not work as expected and allowed
the command to continue without the missing parameter

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=196893
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:17:06 +02:00
Misono, Tomohiro a351dd8478 btrfs-progs: test: add new test for inspect-internal rootid
This new test checks inspect-internal rootid
 - handle path to subvolume/directory/file as an argument
 - get different id for each subvolume
 - get the expected id for each file/directory (i.e. the same as
	 containing subvolume)

Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 6fb88e2859 btrfs-progs: tests: check for kernel support for reiserfs
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 7299e0d294 btrfs-progs: tests: enhance post-rollback fsck tests
The post-rollback helper still assumes just extN, we need an extra
argument that'll get passed to fsck. Change all callsites at once so the
tests do not fail temporarily.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
Misono, Tomohiro cb39164f9d btrfs-progs: test: fix name generation not to contain trailing spaces
First patch causes test-convert fails.  This is because
generate_dataset() creates a name containing trailing spaces for
"slow_symlink" type, and cause getfacl error in convert_test_perm().
(This is not noticed since original run_check_stdout() throws away the
error.)

Fix this by use space for delimiter for cut.

Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
Misono, Tomohiro 02e9bb9f23 btrfs-progs: test: fix run_check_stdout() call _fail()
run_check_stdout() uses "... | tee ... || _fail".  However, since tee
won't fail, _fail() is not called even if first command fails.

Fix this by checking PIPESTATUS in the end.

Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
Qu Wenruo dbe96ecd3f btrfs-progs: tests: Add test case for mkfs --rootdir parameter
Add test case which checks if -r|--rootdir mkfs option can handle
symlink/char/block/fifo files.

Signed-off-by: Qu Wenruo <quwenruo.btrfs@gmx.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba df4a04484a btrfs-progs: tests: missing device and slack space report
Verify that a missing device will not result in reporting a negative
value interpreted as 16EiB.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba f47587d83d btrfs-progs: tests: convert misc/011-delete-missing-device to loopdevs
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 83fe48c54b btrfs-progs: tests: convert misc/006-image-on-missing-device to loopdevs
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 528a5bf6ad btrfs-progs: tests: move loopdev helpers out of the testcase to common
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 3a6895b823 btrfs-progs: tests: cleanup loop device helpers
Make the loop device helpers a bit more generic before moving them to
the common helpers.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 872837ebbf btrfs-progs: tests: add testcase for 'fi du' and empty subvol
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba a36d92cb8b btrfs-progs: tests: add test for check --force
Basic test of the --force functionality, on an empty filesystem.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 4851de27f1 btrfs-progs: tests: add more sanitizer message patterns to log scanner
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba c9141313ec btrfs-progs: tests: limit size of log dump from conver tests
The convert tests generate lots of log material, travis CI has limit 4MB
so we don't see anything useful when a late test fails.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba eae83c46f7 btrfs-progs: tests: fix TEST_LOG=dump in convert tests
Test failure in convert tests with log dump does not happen because
_fail is called before that and exits. Other test types are ok.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba c4dd5fef8a btrfs-progs: tests: update README
Wording, runtime dependencies.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 847ff667ce btrfs-progs: tests: add more checks for tools used in convert tests
Tools that may not be present in common installations should be checked
in the tests.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba ee37252115 btrfs-progs: tests: add build checks for sanitization features
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 092698b40a btrfs-progs: tests: add more fuzzed images from bugzilla
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
Jeff Mahoney e75f466ddd btrfs-progs: tests: add support for converting reiserfs
Many of the test cases for convert apply regardless of what the source
file system is and using ext4 is sufficient.  I've included several
test cases that are reiserfs-specific.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
[ patch split from the previous one, minor cleanups in common.convert ]
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba fb0d53a937 btrfs-progs: tests: fix _is_file_or_command detection
type -p returns an empty string for nonexistent commands, but the -f
test on an empty string does not behave the same on all shells. To be
safe, use the quoted value.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-08-25 15:58:05 +02:00
David Sterba d7dd9d00e9 btrfs-progs: tests: catch bad usage of run_mustfail
This function has an extra argument and can get forgotten, add a sanity
check so the bad usage can be caught during development.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-08-24 19:08:18 +02:00
David Sterba f0c7703671 btrfs-progs: tests: scan results for commands not found
In case of typos or messed up command execution, we'd like to be able to
catch that.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-08-24 19:08:02 +02:00
Su Yue 515ea7dc2f btrfs-progs: fsck-test: case for corrupted dir item name
In this test case, all name in dir_item, dir_index, inode_ref
are corrupted to another one.
btrfs check should report errors about the corrupted dir_item but
btrfs can't repair the case now.

Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-08-24 19:07:58 +02:00
Jeff Mahoney 0cd4485178 btrfs-progs: tests: fix typo in convert-tests/008-readonly-image
The dd in convert-tests/008-readonly-image is expected to fail, so
there being a typo in the file name has gone unnoticed.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-08-24 19:07:37 +02:00
Adam Buchbinder 5c2cf48a4c btrfs-progs: tests: Use '-t btrfs' mount option in tests
Without it, mount (at least from util-linux 2.20.1) tries (and fails) to
mount some filesystems as NTFS.

Signed-off-by: Adam Buchbinder <abuchbinder@google.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-07-20 19:46:11 +02:00
David Sterba 18b519e694 btrfs-progs: tests: use separate helper for mounting convert filesystems
We'll enforce the btrfs type for mount everwhere so we must provide a
way to mount converted filesystems. Add a new helper that will try to
mount the given type.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-07-20 19:42:59 +02:00
David Sterba 46809a7287 btrfs-progs: tests: enhance API to request type of the converted filesystem
We'll use mount -t $fstype later on, extend the API so we don't have to
parse the type from other parameters.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-07-20 19:42:42 +02:00
Adam Buchbinder 50d037b459 btrfs-progs: tests: Fix missing internal deps in check and misc tests
Doing a straight 'make test' would fail because some misc and fsck
tests require particular tools to already be built. Add dependencies
at the Makefile and shell-script level.

Signed-off-by: Adam Buchbinder <abuchbinder@google.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-07-20 17:43:43 +02:00
Qu Wenruo bb305ae832 btrfs-progs: tests: Add test case to check file hole extents with NO_HOLES flag
Add test case which we have NO_HOLES incompat flag while still have
hole file extent.

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

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

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

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

So, remove quotes from $default_mke2fs.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

It's caused by the following bugs:

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

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

Fix it.

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

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

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

Reported-by: Chris Murphy <chris@colorremedies.com>
Reported-by: Christoph Anton Mitterer <calestyo@scientia.net>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-08 13:00:49 +01:00