Commit Graph

85 Commits (master)

Author SHA1 Message Date
Su Yue f0c607a137 btrfs-progs: misc-tests/038: fix wrong field filtered under root directory
Ran misc-tests/038 in /root/btrfs-progs:

  make test-misc TEST=038\*
      [TEST]   misc-tests.sh
      [TEST/misc]   038-backup-root-corruption
  ./test.sh: line 33: [: bytenr=65536,: integer expression expected
  Backup slot 2 is not in use
  test failed for case 038-backup-root-corruption
  make: *** [Makefile:401: test-misc] Error 1

It's caused by the wrong line filtered by
$(dump_super | grep root | head -n1 | awk '{print $2}').

The command $(dump-super | grep root) outputs:

  superblock: bytenr=65536, device=/root/btrfs-progs/tests/test.img
  root                    30605312
  chunk_root_generation   5
  root_level              0
  chunk_root              22036480
  chunk_root_level        0
  log_root                0
  log_root_transid        0
  log_root_level          0
  root_dir                6
  backup_roots[4]:

Here
"superblock: bytenr=65536, device=/root/btrfs-progs/tests/test.img" is
selected but not the line "root                    30605312".

Restricting the awk rule can fix it.

Fixes: 78a3831d46 ("btrfs-progs: tests: Test backup root retention logic")
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Su Yue <Damenly_Su@gmx.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2020-01-09 14:27:10 +01:00
Nikolay Borisov 78a3831d46 btrfs-progs: tests: Test backup root retention logic
This tests ensures that the kernel correctly persists backup roots in
case the filesystem has been mounted from a backup root.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
[ cleanup to use common helpers ]
Signed-off-by: David Sterba <dsterba@suse.com>
2019-11-18 19:21:09 +01:00
Anand Jain 3de68a0e87 btrfs-progs: tests: fix misc/021 when restoring overlapping stale data
As misc-tests/021 image dump is restored on the same original loop
device, this overlaps with the stale data and makes the test pass
falsely.

Fix this by using a new device for restore.

And also, the btrfs-image dump and restore doesn't restore the file
data, so any read on the files should be avoided. So instead of file
data use file stat data for the checksum.

Reported-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-10-14 17:28:02 +02:00
Nikolay Borisov fcebb87f52 btrfs-progs: tests: Check for metadata_uuid feature in misc-tests/034-metadata-uuid
Instead of checking the kernel version, explicitly check for the
presence of metadata_uuid file in sysfs. This allows the test to be run
on older kernels that might have this feature backported.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-09-04 16:06:30 +02:00
David Sterba 4e48f14f8b btrfs-progs: tests: switch messages to _log
The _log helper should be used for test log messages instead of raw echo
to the results file.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-26 17:46:42 +02:00
David Sterba 8dbcf826ca btrfs-progs: tests: request minimum kernel version for misc-tests/034-metadata-uuid
The CI environment has kernel 4.15, the test fails because of the
missing functionality. Skip it.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-04 15:36:01 +02:00
David Sterba a66d9aa2e3 btrfs-progs: tests: drop keyword function
The shell keyword function is not necessary and not used in many tests,
remove it from the few places that use it right now.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-04 15:36:01 +02:00
David Sterba 5d444edcb7 btrfs-progs: tests: use common loop device helpers in misc-tests/021
Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-04 15:36:00 +02:00
David Sterba 5dfbc7c42a btrfs-progs: tests: misc/021 run fs check with SUDO_HELPER
The travis-ci fails at test misc-tests/021-image-multi-devices because
the 'btrfs check' is not run with root permissions, unlike all the other
commands. The check is read-only by default, so that should be safe.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-04 02:06:34 +02:00
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 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
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 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
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
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
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
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
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
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
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
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
Nikolay Borisov df9158f20d btrfs-progs: Remove deprecated btrfs-zero-log standalone tool
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>
2018-04-24 13:00:10 +02:00
Qu Wenruo a4cd4ae0b3 btrfs-progs: tests: Test if btrfs-image can handle RAID1 missing device
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-03-30 22:15:55 +02:00
David Sterba dcb174ce2e btrfs-progs: tests: add shell quotes to misc test scripts
Signed-off-by: David Sterba <dsterba@suse.com>
2018-03-30 22:15:55 +02:00
David Sterba a855717a87 btrfs-progs: tests: remove trivial use of local variables
No need to use a temporary variable if the parameter usage is obvious
from the context.

Signed-off-by: David Sterba <dsterba@suse.com>
2018-03-30 22:15:55 +02:00
David Sterba e875cd98e3 btrfs-progs: tests: fix source path for testsuite
The commit cebf3b3722 ("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>
2018-03-30 22:15:54 +02:00
David Sterba 510bb4ccc4 btrfs-progs: tests: add helper to log pipe stdout
Signed-off-by: David Sterba <dsterba@suse.com>
2018-02-19 19:24:07 +01:00
David Sterba ea0956bb2a btrfs-progs: tests: add test for send -p on 2 mont points
Add testcase from issue, use reproducer from Axel Burri.

Issue: #96
Signed-off-by: David Sterba <dsterba@suse.com>
2018-02-19 19:07:32 +01:00
Gu Jinxiang cebf3b3722 btrfs-progs: introduce TEST_TOP and INTERNAL_BIN for tests
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>
2018-02-13 15:41:32 +01:00
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
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 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
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
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
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 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 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
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
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 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