Commit graph

726 commits

Author SHA1 Message Date
David Sterba 836e7ca8ff btrfs-progs: tests: fix quick-test compilation and rename it
There's an old test for btree code that could be used in the testsuite.
Still needs some polishing and review what tests make sense.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-11-03 18:04:37 +01:00
David Sterba 54439594a6 btrfs-progs: tests: add back removed functionality
Previously the XFS-specific code was commented out so we don't need the
headers for building fsstress, this changes how the utility behaves
compared to the one in fstests, e.g. randomness or additional open/close
operations. Add enough code from xfsprogs to make it compile and enable
the #if0-ed code.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-11-03 18:04:37 +01:00
David Sterba 9dcb5afa15 btrfs-progs: tests: fix -Wshadow warnings in fssum and fsstress
Signed-off-by: David Sterba <dsterba@suse.com>
2023-11-03 18:04:37 +01:00
Qu Wenruo 208073c373 btrfs-progs: tests: add test image of out-of-order inline backref items
Issue #622 reported a case where ntfs2btrfs can generate out-of-order
inline backref items, which can lead to kernel transaction abort, but
not detected by btrfs-check.

This patch would add such image, whose extent tree looks like this for
the only data extent:

        item 0 key (13631488 EXTENT_ITEM 4096) itemoff 16172 itemsize 111
                refs 3 gen 7 flags DATA
                (178 0xdfb591fa80d95ea) extent data backref root FS_TREE objectid 257 offset 0 count 1
                (178 0xdfb591fbbf5f519) extent data backref root FS_TREE objectid 258 offset 0 count 1
                (178 0xdfb591f49f9f8e7) extent data backref root FS_TREE objectid 259 offset 0 count 1

While the original good base image has the following backrefs for the
same data extent:

        item 0 key (13631488 EXTENT_ITEM 4096) itemoff 16172 itemsize 111
                refs 3 gen 7 flags DATA
                (178 0xdfb591fbbf5f519) extent data backref root FS_TREE objectid 258 offset 0 count 1
                (178 0xdfb591fa80d95ea) extent data backref root FS_TREE objectid 257 offset 0 count 1
                (178 0xdfb591f49f9f8e7) extent data backref root FS_TREE objectid 259 offset 0 count 1

Notice the sequence (the 2nd number in the round brackets) should be
descending.  (Meanwhile type should be ascending, but it's way harder to
create.)

For now we don't have a way to fix it, but at least we should detect it.

Issue: #622
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-11-03 18:04:37 +01:00
David Sterba 1357983f69 btrfs-progs: tests: add case for subvolume create -p
Signed-off-by: David Sterba <dsterba@suse.com>
2023-10-21 15:51:07 +02:00
Qu Wenruo 83ae2d58c9 btrfs-progs: tests: make sure rootdir inode gets its attributes copied
The new test case would:

- Prepare two loopback devices
  One is for storing the source directory (on a btrfs).
  This is to ensure we can set xattr for the directory, as filesystems
  like tmpfs (mostly utilized by mktemp) is not supporting xattr.

  The other one is the real target fs where we call
  "mkfs.btrfs --rootdir" on.

- Create the source directory with the following contents:
  * rootdir inode attributs:
    # mode (750)
    # uid (1000)
    # gid (1000)
    # xattr (user.rootdir)
  * one regular file, with attributes:
    # xattr (user.foorbar)

- Execute "mkfs.btrfs --rootdir" and mount the new fs

- Verify the above attributes
  The target fs should have the same attributes, especially for the
  rootdir inode.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-10-21 15:51:07 +02:00
David Sterba 4f2c9e8ade btrfs-progs: tests: do not run test-convert under test target
The convert tests take a long time and are not necessary for quick test
rounds under the convenience target 'make test'. We still run the tests
in CI.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-10-17 19:34:00 +02:00
David Sterba 05d338d4ab btrfs-progs: tests: add basic mkfs tests for zoned + rst
Test all combinations of data x metadata for the supported profiles.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-10-17 19:33:59 +02:00
David Sterba 863fedd1cb btrfs-progs: tests: add basic mkfs test for raid-stripe-tree
Signed-off-by: David Sterba <dsterba@suse.com>
2023-10-17 19:33:59 +02:00
David Sterba 63e4532f3b btrfs-progs: tests: fix description of mkfs/024-fst-bitmaps
Signed-off-by: David Sterba <dsterba@suse.com>
2023-10-17 19:33:59 +02:00
David Sterba 00628edb26 btrfs-progs: tests: add basic mkfs test for block-group-tree
Signed-off-by: David Sterba <dsterba@suse.com>
2023-10-17 19:33:59 +02:00
David Sterba 8c9243160b btrfs-progs: tests: add array API test template
Signed-off-by: David Sterba <dsterba@suse.com>
2023-10-17 19:33:58 +02:00
David Sterba 777b1d8c27 btrfs-progs: tests: check that qgroup show does not crash on stale qgroups
Create subvolumes and delete every N-th to generate output where we can
also see how the stale qgroups are placed (at the end).

Issue: #687
Signed-off-by: David Sterba <dsterba@suse.com>
2023-10-13 18:13:12 +02:00
Qu Wenruo 4c6f41f2b8 btrfs-progs: enable -Wshadow for default build
With all the known one fixed, we can enable -Wshadow now.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-10-10 19:23:10 +02:00
David Sterba f96e5fe3ba btrfs-progs: tests: disable log scanning after tests
This partially reverts commit 2726a83952,
the part where the test runner scripts call the log scanning. There are
still unfixed extent buffer leak reported by fuzz tests. Disable it
temporarily so CI can pass and do other pre-release checks. Scanning
will be enabled after release again.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-10-03 18:49:50 +02:00
Anand Jain 86b1e47c80 btrfs-progs: test: misc/034 remove kernel support
The kernel patch, ("btrfs: reject device with CHANGING_FSID_V2 flag"),
removes kernel support for the CHANGING_FSID_V2 flag. So, drop its
related testcase.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-10-03 01:11:55 +02:00
Anand Jain 9290442c46 btrfs-progs: tests: update misc/034 for btrfstune -m|M ability to fix previous failures
The misc-test/034-metadata_uuid test case, has four sets of disk images
to simulate failed writes during btrfstune -m|M operations. As of now,
this tests kernel only. Update the test case to verify btrfstune -m|M's
functionality to recover from the same scenarios.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-10-03 01:11:55 +02:00
David Sterba 2726a83952 btrfs-progs: tests: scan test results
Some errors may be reported in the logs only, scan the file each time
there are fresh results. The scanning script will return error that is
supposed to be caught by the testsuite environment.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-09-12 23:18:35 +02:00
David Sterba 7a7df06f98 btrfs-progs: tests: extend scan-results.sh to scan only a given file
Scanning all results is meant for the whole testsuite, we'd like to make
it more fine grained to verify them once a test is run via the test
running wrappers.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-09-12 23:18:35 +02:00
David Sterba e0263f2b31 btrfs-progs: tests: fix test case name detection scan-results.sh
The test markers have changed in 4.17 so the result scanner does not
print the test names (but still detects the errors).

Signed-off-by: David Sterba <dsterba@suse.com>
2023-09-12 23:18:34 +02:00
David Sterba 634e9a4792 btrfs-progs: tests: fix build -Wmissing-prototypes warnings
Signed-off-by: David Sterba <dsterba@suse.com>
2023-09-12 23:18:34 +02:00
Anand Jain e8e5537d8c btrfs-progs: tests: add prefixes to error messages in misc-test/034
Add appropriate prefix to the error messages to make it easier to track
down which case failed.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-09-01 13:58:46 +02:00
David Sterba 5c7f36b141 btrfs-progs: tests: fix typo in README
The correct helper name is check_global_prereq, this was once
seen accidentally used in a test.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-08-28 17:24:25 +02:00
David Sterba 2b35741a39 btrfs-progs: fix more typos found by codespell
Signed-off-by: David Sterba <dsterba@suse.com>
2023-08-28 17:24:24 +02:00
David Sterba ebd046eb8d btrfs-progs: tests: renumber json test cases so they match the parameter
The test utility takes a numeric parameter from 1 to max tests but this
is off by one to the test case function names. Unify that so it's clear
which test fails.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-08-28 17:24:24 +02:00
David Sterba ede538f98d btrfs-progs: print null value for empty uuid in json
This is a potentially breaking change to json output. An all zeros uuid
was printed as "-" but we can utilize native json type null for that.
Note the va_copy must be used as va_arg advances the pointer.

{
	"nulluuid": null
}

Signed-off-by: David Sterba <dsterba@suse.com>
2023-08-28 17:24:23 +02:00
David Sterba 386765be15 btrfs-progs: tests: fix build warnings in json tests (-Wmissing-prototypes)
The test cases should be static, otherwise it leads to a warning like

    [LD]     json-formatter-test
tests/json-formatter-test.c:40:6: warning: no previous prototype for ‘test_simple_empty’ [-Wmissing-prototypes]
   40 | void test_simple_empty()
      |      ^~~~~~~~~~~~~~~~~

Signed-off-by: David Sterba <dsterba@suse.com>
2023-08-28 17:24:23 +02:00
David Sterba be5cb7dfe9 btrfs-progs: add bool type to json
Signed-off-by: David Sterba <dsterba@suse.com>
2023-08-28 17:24:23 +02:00
Anand Jain 57cd29c895 btrfs-progs: tests: return metadata_uuid or fsid as per METADATA_UUID flag
Previous commit "btrfs-progs: dump-super: print actual metadata_uuid
value" changed the value of the super_block::metadata_uuid to be printed
as it is, without tweaking it depending on the METADATA_UUID flag.

Apply similar tweak in the common helper functions used to read the
metadata_uuid so that test-cases still be successful.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-08-23 19:36:31 +02:00
Qu Wenruo cb19235991 btrfs-progs: tests: misc/046: fix false alerts on write detection
[BUG]
Test case misc/046-seed-multi-mount would always fail with the following
error:

    [TEST]   misc-tests.sh
    [TEST/misc]   046-seed-multi-mount
unexpected success: writable file despite read-only mount
test failed for case 046-seed-multi-mount

[CAUSE]
Although mounting seed device is indeed read-only, sprouting it with a
new device would always make it read-write by itself.

The behavior is already there for a long time, thus expecting a new
behavior (not changing the read-only flag) is a little weird.

[FIX]
Instead of doing the write check after the sprout, do it before the
sprout.

This looks more correct, and would not rely on the kernel behavior
change (if we determine to go that path).

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-08-23 19:36:31 +02:00
Qu Wenruo e6b412b359 btrfs-progs: tests: misc/058: reduce the space requirement and speed up the test
[BUG]
When I was testing misc/058, the fs still has around 7GiB free space,
but during that test case, btrfs kernel module reports write failures
and even git commands failed inside that fs.

And obviously the test case failed.

[CAUSE]
It turns out that, the test case itself would require 6GiB (4 data
disks) + 1.5GiB x 2 (the two replace target), thus it requires 9 GiB
free space.

And obviously my partition is not that large and failed.

[FIX]
In fact, we really don't need that much space at all.

The test verifies that two consecutive replace operations can be started
and enqueued, the sleep of 1 second is not strictly necessary as the
first command should start the replace right away.

Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-08-23 19:36:31 +02:00
Qu Wenruo 885fe371c8 btrfs-progs: tests: misc/030: do not require v1 cache for the test case
[PROBLEM]
Since we have migrated to default v2 cache, the test case
misc/030-missing-device-image is no longer executed:

    [TEST/misc]   030-missing-device-image
    [NOTRUN] unable to create v1 space cache

[CAUSE]
The test case itself is trying its best to cover all paths, including
the data extent read path.

Thus the test case is requiring v1 cache, as that's the only way to
cover the data read path.

[FIX]
Just remove the v1 space cache requirement, it's still better to run the
test even it only exercises the metadata read path.

The good news is, after commit 3ff9d35257 ("btrfs-progs: use
read_data_from_disk() to replace read_extent_from_disk() and replace
read_extent_data()"), all data/metadata read paths are unified.
They only difference is the verification part.

Thus even if we didn't fully exercise the data read path, we didn't lose
much coverage anyway.

Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-08-23 19:36:31 +02:00
Qu Wenruo 005d2cc047 btrfs-progs: tests: mkfs/005: use udevadm settle to avoid false alerts
[BUG]
During my test runs of mkfs-tests, 005-long-device-name-for-ssd failed
with the following error messages:

  ====== RUN CHECK dmsetup remove btrfs-test-with-very-long-name-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQPGc
  device-mapper: remove ioctl on btrfs-test-with-very-long-name-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQPGc  failed: Device or resource busy
  Command failed.
  failed: dmsetup remove btrfs-test-with-very-long-name-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQPGc
  test failed for case 005-long-device-name-for-ssd

[CAUSE]
There seems to be a race between "btrfs inspect dump-super" and the
dmsetup removal.

[FIX]
Add a "udevadm settle" before removing the dm devices.

Also since we're here, use the same "udevadm settle" instead of the
manual sleep to wait for the new dm device to show up.

Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-08-23 19:36:31 +02:00
David Sterba 835526b120 btrfs-progs: tests: add script to check global prerequisities
Check for each test directory if the utilities requested by
check_global_prereq can be found on the system.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-08-11 19:59:29 +02:00
David Sterba 54c11ec03f btrfs-progs: tests: check if enqueued replace over replace waits
Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-27 14:45:29 +02:00
David Sterba 177a2eeadb btrfs-progs: tests: don't show grep output when checking stream version
The test misc/058 does not properly filter out the output due to -s that
only ignores non-existent files and was there due to previous changes.
We need to use -q.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-26 15:00:47 +02:00
Anand Jain b51117d68e btrfs-progs: tests: check for btrfs ACL support
Fix failures caused by the lack of ACL support in btrfs. For example:

  $ make test
    ::
    [TEST/misc]   057-btrfstune-free-space-tree
    failed: setfacl -m u:root:x /Volumes/ws/btrfs-progs/tests/mnt/acls/acls.1
    test failed for case 057-btrfstune-free-space-tree
    make: *** [Makefile:493: test-misc] Error 1

Similar failures occurred in the test cases convert/001-ext2-basic,
convert/003-ext4-basic, convert/005-delete-all-rollback, and
convert/006-large-hole-extent.

Resolve it by adding a check for ACL support using the
check_kernel_support_acl() helper function. It gracefully handles the case
when ACL support is not compiled by calling _not_run().

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-26 14:59:10 +02:00
Anand Jain 1fb1ae8ebb btrfs-progs: tests: add helper to check if ACLs are supported
Some test cases are failing when ACL is not compiled in the system.
Instead, they should be marked as 'not_run'.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-26 14:59:10 +02:00
Anand Jain d52686fc2a btrfs-progs: tests: move delete_subvol_children under HAVE_BTRFSUTIL_H fsstress.c
Bring the  'delete_subvol_children' function under the HAVE_BTRFSUTIL_H
define and fix the following warnings. This function is called only when
'HAVE_BTRFSUTILS_H' is defined.

tests/fsstress.c:1183:1: warning: ‘delete_subvol_children’ defined but not used [-Wunused-function]
 1183 | delete_subvol_children(int parid

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-26 14:59:10 +02:00
Anand Jain b31f1e6988 btrfs-progs: tests: move do_fallocate under HAVE_LINUX_FALLOC_H in fsstress.c
Move the entire 'do_fallocate' function under the 'HAVE_LINUX_FALLOC_H'
define and fix the following warnings. This function is called only when
'HAVE_LINUX_FALLOC_H' is defined.

tests/fsstress.c:3814:1: warning: ‘do_fallocate’ defined but not used [-Wunused-function]
 3814 | do_fallocate(opnum_t opno, long r, int mode)

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-26 14:59:10 +02:00
Anand Jain 282c05698a btrfs-progs: tests: move do_mmap under HAVE_SYS_MMAN_H in fsstress.c
Move the entire 'do_mmap' function under the 'HAVE_SYS_MMAN_H' define
and fix the following warnings. This function is called only when
'HAVE_SYS_MMAN_H' is defined.

tests/fsstress.c:4363:1: warning: ‘do_mmap’ defined but not used [-Wunused-function]
 4363 | do_mmap(opnum_t opno, long r, int prot)

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-26 14:59:10 +02:00
Anand Jain 3b8a552fd7 btrfs-progs: tests: fix missing prototype warnings in fssum.c
Annoying warnings when running 'make test' from the file tests/fssum.c.
gcc version 8.5.0. Fix the it by declaring the corresponding functions as static.

$ rm fssum
$ make TEST=001\* test-misc
::
tests/fssum.c:86:1: warning: no previous prototype for ‘getln’ [-Wmissing-prototypes]
   86 | getln(char *buf, int size, FILE *fp)
      | ^~~~~
tests/fssum.c:103:1: warning: no previous prototype for ‘parse_flag’ [-Wmissing-prototypes]
  103 | parse_flag(int c)
      | ^~~~~~~~~~
tests/fssum.c:123:1: warning: no previous prototype for ‘parse_flags’ [-Wmissing-prototypes]
  123 | parse_flags(char *p)
      | ^~~~~~~~~~~
tests/fssum.c:130:1: warning: no previous prototype for ‘usage’ [-Wmissing-prototypes]
  130 | usage(void)
      | ^~~~~
tests/fssum.c:163:1: warning: no previous prototype for ‘alloc’ [-Wmissing-prototypes]
  163 | alloc(size_t sz)
      | ^~~~~
tests/fssum.c:176:1: warning: no previous prototype for ‘sum_init’ [-Wmissing-prototypes]
  176 | sum_init(sum_t *cs)
      | ^~~~~~~~
tests/fssum.c:182:1: warning: no previous prototype for ‘sum_fini’ [-Wmissing-prototypes]
  182 | sum_fini(sum_t *cs)
      | ^~~~~~~~
tests/fssum.c:188:1: warning: no previous prototype for ‘sum_add’ [-Wmissing-prototypes]
  188 | sum_add(sum_t *cs, void *buf, int size)
      | ^~~~~~~
tests/fssum.c:194:1: warning: no previous prototype for ‘sum_add_sum’ [-Wmissing-prototypes]
  194 | sum_add_sum(sum_t *dst, sum_t *src)
      | ^~~~~~~~~~~
tests/fssum.c:200:1: warning: no previous prototype for ‘sum_add_u64’ [-Wmissing-prototypes]
  200 | sum_add_u64(sum_t *dst, uint64_t val)
      | ^~~~~~~~~~~
tests/fssum.c:207:1: warning: no previous prototype for ‘sum_add_time’ [-Wmissing-prototypes]
  207 | sum_add_time(sum_t *dst, time_t t)
      | ^~~~~~~~~~~~
tests/fssum.c:213:1: warning: no previous prototype for ‘sum_to_string’ [-Wmissing-prototypes]
  213 | sum_to_string(sum_t *dst)
      | ^~~~~~~~~~~~~
tests/fssum.c:225:1: warning: no previous prototype for ‘namecmp’ [-Wmissing-prototypes]
  225 | namecmp(const void *aa, const void *bb)
      | ^~~~~~~
tests/fssum.c:234:1: warning: no previous prototype for ‘sum_xattrs’ [-Wmissing-prototypes]
  234 | sum_xattrs(int fd, sum_t *dst)
      | ^~~~~~~~~~
tests/fssum.c:325:1: warning: no previous prototype for ‘sum_file_data_permissive’ [-Wmissing-prototypes]
  325 | sum_file_data_permissive(int fd, sum_t *dst)
      | ^~~~~~~~~~~~~~~~~~~~~~~~
tests/fssum.c:341:1: warning: no previous prototype for ‘sum_file_data_strict’ [-Wmissing-prototypes]
  341 | sum_file_data_strict(int fd, sum_t *dst)
      | ^~~~~~~~~~~~~~~~~~~~
tests/fssum.c:369:1: warning: no previous prototype for ‘escape’ [-Wmissing-prototypes]
  369 | escape(char *in)
      | ^~~~~~
tests/fssum.c:389:1: warning: no previous prototype for ‘excess_file’ [-Wmissing-prototypes]
  389 | excess_file(const char *fn)
      | ^~~~~~~~~~~
tests/fssum.c:395:1: warning: no previous prototype for ‘missing_file’ [-Wmissing-prototypes]
  395 | missing_file(const char *fn)
      | ^~~~~~~~~~~~
tests/fssum.c:401:1: warning: no previous prototype for ‘pathcmp’ [-Wmissing-prototypes]
  401 | pathcmp(const char *a, const char *b)
      | ^~~~~~~
tests/fssum.c:419:1: warning: no previous prototype for ‘check_match’ [-Wmissing-prototypes]
  419 | check_match(char *fn, char *local_m, char *remote_m,
      | ^~~~~~~~~~~
tests/fssum.c:438:1: warning: no previous prototype for ‘check_manifest’ [-Wmissing-prototypes]
  438 | check_manifest(char *fn, char *m, char *c, int last_call)
      | ^~~~~~~~~~~~~~
tests/fssum.c:509:1: warning: no previous prototype for ‘sum’ [-Wmissing-prototypes]
  509 | sum(int dirfd, int level, sum_t *dircs, char *path_prefix, char *path_in)
      | ^~~
    [LD]     fsstress
tests/fsstress.c:4363:1: warning: ‘do_mmap’ defined but not used [-Wunused-function]
 4363 | do_mmap(opnum_t opno, long r, int prot)
      | ^~~~~~~
tests/fsstress.c:3814:1: warning: ‘do_fallocate’ defined but not used [-Wunused-function]
 3814 | do_fallocate(opnum_t opno, long r, int mode)
      | ^~~~~~~~~~~~
tests/fsstress.c:1183:1: warning: ‘delete_subvol_children’ defined but not used [-Wunused-function]
 1183 | delete_subvol_children(int parid)

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-26 14:59:10 +02:00
David Sterba 8a59d12c92 btrfs-progs: tests: support starting from a given test
Add make command line variable TEST_FROM that takes a glob from where to
start the test sequence. Update docs and fix some trivial typos.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-06-21 16:44:30 +02:00
David Sterba ab32c4445d btrfs-progs: qgroup show: fix formatting of limit values in json output
There are reports that json output of 'qgroup show' crashes due to
internal error when printing the limit values:

  INTERNAL ERROR: unknown unit base, mode 2304
  btrfs(internal_error+0x10a)[0x5605c37ce48a]
  btrfs(pretty_size_snprintf+0x5c)[0x5605c37d105c]
  btrfs(fmt_print+0x44e)[0x5605c37d178e]
  btrfs(+0x7ed1d)[0x5605c3800d1d]
  btrfs(main+0x8f)[0x5605c379beff]
  /lib64/libc.so.6(+0x27bb0)[0x7f83924ddbb0]
  /lib64/libc.so.6(__libc_start_main+0x8b)[0x7f83924ddc79]
  btrfs(_start+0x25)[0x5605c379d405]
  common/units.c:82: pretty_size_snprintf: Assertion `0` failed, value 0
  btrfs(+0x1d4b1)[0x5605c379f4b1]
  btrfs(pretty_size_snprintf+0x7b)[0x5605c37d107b]
  btrfs(fmt_print+0x44e)[0x5605c37d178e]
  btrfs(+0x7ed1d)[0x5605c3800d1d]
  btrfs(main+0x8f)[0x5605c379beff]
  /lib64/libc.so.6(+0x27bb0)[0x7f83924ddbb0]
  /lib64/libc.so.6(__libc_start_main+0x8b)[0x7f83924ddc79]
  btrfs(_start+0x25)[0x5605c379d405]

This is caused by "size" format that requires the unit mode, but it was not
specified and some stack value used. As json prints the raw values, use
the plain %llu format.

Link: https://bugzilla.opensuse.org/show_bug.cgi?id=1206960
Link: https://bugzilla.opensuse.org/show_bug.cgi?id=1209136#c15
Signed-off-by: David Sterba <dsterba@suse.com>
2023-05-26 18:02:33 +02:00
David Sterba 5d2aa5fa1e btrfs-progs: tests: sync fsstress from fstests
Source level sync:

- syscall to 64 variants
- removed some callbacks

Signed-off-by: David Sterba <dsterba@suse.com>
2023-05-26 18:02:32 +02:00
Qu Wenruo 1ea7292354 btrfs-progs: tests: convert: add a test case to check the csum for the image file
The new test case would create an empty ext4 with 64K block size, which
can lead to a new data chunk which is no longer 1:1 mapped.

Then convert the fs and verify it with --check-data-csum to make sure
the image file is fine.

Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-05-26 18:02:31 +02:00
Josef Bacik a754fe29d9 btrfs-progs: sync uapi/btrfs.h into btrfs-progs
We want to keep this file locally as we want to be uptodate with
upstream, so we can build btrfs-progs regardless of which kernel is
currently installed.  Sync this with the upstream version and put it in
kernel-shared/uapi to maintain some semblance of where this file comes
from.

There are some changes that need to be synced back to kernel. A local
definition of static_assert is used to avoid compilation problems on gcc
(< 9) due to mandatory 2nd parameter.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-05-26 18:02:28 +02:00
Josef Bacik 4c078a8536 btrfs-progs: tests: use SUDO_HELPER in convert tests for temp files
While running make test-convert as a normal user I ran into this problem
where we do sudo find <blah> into a mktemp file that's created as the
normal user.  This results in find getting a EPERM while trying to mess
with that temp file.  Fix this by using $SUDO_HELPER for all the
tempfile manipulations so that root is the owner of everything, which
allows the convert tests to run as a normal user.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-05-26 18:02:27 +02:00
Qu Wenruo 54afdeecda btrfs-progs: tests: add case to verify btrfstune --convert-to-free-space-tree option
The new test case would create a fs without free space tree, then
populate it, convert to free-space-tree feature, and make sure
everything is fine.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-05-26 18:02:27 +02:00
Anand Jain 2d872fec8c btrfs-progs: tests/nullb fix kernel support check
I have a setup where null_blk is not a module but is built-in, so to check
if the kernel supports null_blk, use 'modinfo -n'.

Also fix a comment.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-05-26 18:02:27 +02:00
Qu Wenruo 9c9805869e btrfs-progs: tests: mkfs/021: update to use -O instead of deprecated -R
-R option is deprecated since commit 4dbe66ca2f ("btrfs-progs: mkfs: make
-R|--runtime-features option deprecated"), migrate the test case to
follow the change.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-05-26 18:02:27 +02:00
David Sterba 455b1cf094 btrfs-progs: tune: rename bgt conversion options
Rename the options so they more accurately reflect what the command is
actually doing. The feature is enabled/disabled in the end but it's not
a simple on/off like for others, the conversion takes time.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-04-27 14:23:52 +02:00
psykose c9abbf6264 btrfs-progs: stop using legacy *64 interfaces
The *64 interfaces, such as fstat64, off64_t, etc, are legacy interfaces
created at a time when 64-bit file support was still new. They are
generally exposed when defining a macro named _LARGEFILE64_SOURCE, as
e.g. the glibc docs[0] say.

The modern way to utilise largefile support, is to continue to use the
regular interfaces (off_t, fstat, ..), and define _FILE_OFFSET_BITS=64.

We already use the autoconf macro AC_SYS_LARGEFILE[1] which arranges this
and sets this macro for us. Therefore, we can utilise the non-64 names
without fear of breaking on 32-bit systems.

This fixes the build against musl libc, ever since musl dropped the
*64 compat from interfaces by default[2] just for _GNU_SOURCE, unless
_LARGEFILE64_SOURCE is defined. However, there are plans for a future
removal of the whole *64 header API, and that workaround (adding another
define) might cease to exist.

So, rename all *64 API use to the regular non-suffixed names. For
consistency, rename the internal functions that were *64 named
(lstat64_path, ..) too.

This should have no regressions on any platform.

[0]: https://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html#index-_005fLARGEFILE64_005fSOURCE
[1]: https://www.gnu.org/software/autoconf/manual/autoconf-2.67/html_node/System-Services.html
[2]: 25e6fee27f

Pull-request: #615
Signed-off-by: psykose <alice@ayaya.dev>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-04-25 16:59:42 +02:00
David Sterba f6bbe06c08 btrfs-progs: tests: add protection against running out of test suite
Executing the script inside the directories as './test.sh' is not
supposed to work but could happen accidentally. With an exit after
attempting to source the we can fix that.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-04-25 16:59:41 +02:00
David Sterba 0ee736b1f0 btrfs-progs: tests: update features tested with btrfs-convert
We've changed mkfs defaults in 5.15 so it's not necessary to test the
features separately with convert. Instead use only defaults and add
other features that can be selected independently.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-04-25 16:59:41 +02:00
David Sterba 0e59430167 btrfs-progs: tests: add basic extent tree to bgt conversion
Test simple conversion from now default extent tree to block-group-tree,
no mount test.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-04-19 01:10:24 +02:00
David Sterba 5a0398bac5 btrfs-progs: tests: mkfs/023, use option -O for free-space-tree
The option -O now allows to set all features at mkfs time, use it.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-04-17 19:28:06 +02:00
David Sterba 0005022d3d btrfs-progs: ci: remove old travis workarounds
Some tests have been skipped due to travis.org CI environment but we're
not using it anymore.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-04-17 19:28:06 +02:00
David Sterba 36c136edd8 btrfs-progs: tests: reorder prereq checks and root device setup, fuzz and mkfs tests
The prerequisites should be called before the root helper or device is
setup, as preferred style.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-04-17 19:28:06 +02:00
David Sterba 257a3a3744 btrfs-progs: tests: reorder prereq checks and root device setup, cli and convert tests
The prerequisites should be called before the root helper or device is
setup, as preferred style.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-04-17 19:28:05 +02:00
David Sterba b9b732c29d btrfs-progs: tests: explicitly setup root helper
There are some helpers that invoke setup_root_helper internally so it's
not needed to run test.sh without root, but it should be there in case
the test calls SUDO_HELPER so it's always paired.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-04-12 01:56:43 +02:00
Josef Bacik ecb66fd754 btrfs-progs: tests: fix fsck-tests/060 to run without root
We need to call the setup_root_helper before we start messing with the
loop devices.

Reviewed-by: Neal Gompa <neal@gompa.dev>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-04-12 01:56:41 +02:00
Josef Bacik 0001f0a735 btrfs-progs: tests: fix fsck-tests/059 to run without root
We missed a couple of $SUDO_HELPER uses in this test that made it
impossible to run without root.  Add them in so we can run as a normal
user.

Reviewed-by: Neal Gompa <neal@gompa.dev>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-04-12 01:56:39 +02:00
Josef Bacik 63565db53b btrfs-progs: tests: fix fsck-tests/057 to run without root
The setup_root_helper needs to be called before messing with the loop
devices, and btrfs check needs to be run with $SUDO_HELPER.

Reviewed-by: Neal Gompa <neal@gompa.dev>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-04-12 01:56:36 +02:00
Josef Bacik 30fde12728 btrfs-progs: tests: fix fsck-tests/056 to run without root
We need to make sure the root helper is setup before calling the loop
helpers, and additionally we need to use $SUDO_HELPER when we run the
final btrfs check.  With this patch we can now run this test as a normal
user.

Reviewed-by: Neal Gompa <neal@gompa.dev>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-04-12 01:56:28 +02:00
David Sterba 183eece927 btrfs-progs: tests: fix mkfs/025 detection of zoned support
When 'nullb setup' fails to detect something, e.g. the null_blk module,
the whole test fails though the failure is supposed to be caught and
test not run. Use the correct helper that handles potential failures.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-03-22 14:34:21 +01:00
Qu Wenruo 788e30f7ea btrfs-progs: tests: fix failure of misc/034
[BUG]
Test case misc/034 can fail like this:

  ====== RUN CHECK mount /dev/loop16 /home/adam/btrfs-progs/tests/mnt
  mount: /home/adam/btrfs-progs/tests/mnt: wrong fs type, bad option, bad superblock on /dev/loop16, missing codepage or helper program, or other error.
         dmesg(1) may have more information after failed mount system call.
  failed: mount /dev/loop16 /home/adam/btrfs-progs/tests/mnt

And the dmesg looks like this:

  loop16: detected capacity change from 0 to 1024000
  loop17: detected capacity change from 0 to 1024000
  BTRFS: device fsid 593e23af-a7e6-4360-b16a-229f415de697 devid 1 transid 6 /dev/loop16 scanned by mount (79348)
  BTRFS info (device loop16): using crc32c (crc32c-intel) checksum algorithm
  BTRFS info (device loop16): found metadata UUID change in progress flag, clearing
  BTRFS info (device loop16): disk space caching is enabled
  BTRFS error (device loop16): devid 2 uuid cde07de6-db7e-4b34-909e-d3db6e7c0b06 is missing
  BTRFS error (device loop16): failed to read the system array: -2
  BTRFS error (device loop16): open_ctree failed

[CAUSE]
From the dmesg, it shows that although both loopback devices are
properly registered, only one is properly scanned by mount.

Thus the other device is missing, and without "-o degraded" the
filesystem failed to be mounted.

[FIX]
Before we mount the filesystem, also scan them in their passed order
to properly assemble the device list for mount.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-03-21 02:59:06 +01:00
David Sterba 600f374058 btrfs-progs: qgroup show: fix formatting of qgroupid on json output
On a 32bit host the split qgroupid is wrong due to the way the numbers
are passed to the formatter as variable length arguments. The level is
u16, promoted to int and then parsed as u64. This means that the values
are shifted and some stack data are printed instead.

Example error messages from yast2-bootloader:

  SystemCmd.cc(addLine):569 Adding Line 7 "      "qgroupid": "21474836480/23885859321282560","

The value 21474836480 = 0x5000000 is 0x5 shifted by 32 bits,
23885859321282560 is 0x54dc1000000000 and shifting by 32 does not
lead to a valid value which should be 0 in this case.

Bugzilla: https://bugzilla.suse.com/show_bug.cgi?id=1209136
Signed-off-by: David Sterba <dsterba@suse.com>
2023-03-16 15:48:41 +01:00
David Sterba 306ee04ffd btrfs-progs: tests: add more build tests for old microarchitectures
As reported in #588, build fails on some microarchitectures when the
blake2 macros do not coverall combinations. Extend the build tests and
add some uarchs to test.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-03-07 20:50:16 +01:00
David Sterba f09e9c9543 btrfs-progs: tests: add more targets to build test
Add config for crypto backends (they could fail for the static targets
due to missing static libraries). Reiserfs is not tested and it slowly
disappears from distros.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-03-01 18:53:46 +01:00
Qu Wenruo e3a24cf11a btrfs-progs: tests: fix cli/017 test case failure
[BUG]
Test case cli/017 fails with the following errors:

    [TEST]   cli-tests.sh
    [TEST/cli]   017-fi-show-missing
  didn't find exact missing device
  test failed for case 017-fi-show-missing

[CAUSE]
After kernel commit cb3e217bdb39 ("btrfs: use btrfs_dev_name() helper to
handle missing devices better"), all dev info ioctl call on missing
device would only return "<missing disk>" for its path.

Thus "btrfs filesystem show" would never report detailed device path for
missing disks.

[FIX]
Instead of relying on the device path, change the check to rely on devid
instead.

Now cli/017 can properly pass.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 20:11:23 +01:00
David Sterba 8098e6d5c1 btrfs-progs: tests: fix paths of library-test.c includes
There are now own copies of ioctl.h and kerncompat.h just for libbtrfs
so the library test should use them.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 20:11:23 +01:00
David Sterba d4c7f01e37 btrfs-progs: libbtrfs: move version.h to the directory
The header is part of the public API and not used by any other code so
move it to the other files.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-01-05 14:18:07 +01:00
Qu Wenruo c339846763 btrfs-progs: misc-tests: add a test case to make sure uuid is correctly reported
The new test case will execute "btrfs subvolume list -u" on the newly
create btrfs.

Since the v0 root item is already deprecated for a long time, newly
created btrfs should be already using the new root item, thus "btrfs
subvolume list -u" should always report the correct uuid.

The test case relies on external program "uuidparse" which should be
provided by util-linux.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-01-02 14:00:10 +01:00
David Sterba ecbb6a7fcd btrfs-progs: add json formatter for escaped string
Add formatter type 'str' where the string must be escaped, e.g. paths or
internal data. Otherwise plain %s can be printed if it's known that
there are no special characters.

Signed-off-by: David Sterba <dsterba@suse.com>
2022-12-16 00:40:32 +01:00
David Sterba 9793474e22 btrfs-progs: tests: add string-table test framework
Signed-off-by: David Sterba <dsterba@suse.com>
2022-12-05 20:32:02 +01:00
Qu Wenruo fbb1170111 btrfs-progs: tests: add test case for degraded raid5
The new test case will make sure btrfs check is fine checking a degraded
raid5 filesystem.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2022-11-24 17:29:12 +01:00
David Sterba bd2b4158c8 btrfs-progs: tests: update stream version checks in misc/058
The send stream v2 is supported if the file exists and does not contain
"1". The previous fix reversed the condition but this does not work on
kernel with v1 only support.

Signed-off-by: David Sterba <dsterba@suse.com>
2022-11-04 20:23:22 +01:00
Josef Bacik 584b3e1d55 btrfs-progs: properly test for send_stream_version
We want to notrun if this test fails, not if it succeeds.  Additionally
we want -s, as -q will still print an error if it gets ENOENT from the
file we're trying to grep.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2022-10-31 15:26:50 +01:00
David Sterba 1414ecbb6f btrfs-progs: replace strerror(errno) with %m in printf formats
We're using the %m format where possible.

Signed-off-by: David Sterba <dsterba@suse.com>
2022-10-26 09:46:22 +02:00
David Sterba 5b2889853a btrfs-progs: tests: add case for clearing stale qgroups
Signed-off-by: David Sterba <dsterba@suse.com>
2022-10-26 09:31:19 +02:00
Qu Wenruo 666f3c971d btrfs-progs: tests: add support check to convert-tests/022
[BUG]
The test case convert/022 will fail if the system doesn't have
reiserfs support nor reiserfs user space tools:

  # make TEST=022\* test-convert
    [TEST]   convert-tests.sh
  WARNING: reiserfs filesystem not listed in /proc/filesystems, some tests might be skipped
    [TEST/conv]   022-reiserfs-parent-ref
  Failed system wide prerequisities: mkreiserfs
  test failed for case 022-reiserfs-parent-ref
  make: *** [Makefile:443: test-convert] Error 1

[CAUSE]
Unlike other test cases, convert/022 doesn't even check if we have
kernel support for it.

[FIX]
Add the proper check before doing system wide prerequisities checks.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2022-10-11 09:08:12 +02:00
Qu Wenruo 53b3a947e8 btrfs-progs: tests: fix the wrong kernel version check
[BUG]
After upgrading to kernel v6.0-rc, btrfs-progs selftest mkfs/001 no
longer checks single device RAID0 and other new features introduced in
v5.13:

  # make TEST=001\* test-mkfs
    [TEST]   mkfs-tests.sh
    [TEST/mkfs]   001-basic-profiles
  $ grep -IR "RAID0\/1" tests/mkfs-tests-results.txt
  ^^^ No output

[CAUSE]
The existing check_min_kernel_version() is doing an incorrect check.

The old check looks like this:

	[ "$unamemajor" -lt "$argmajor" ] || return 1
	[ "$unameminor" -lt "$argminor" ] || return 1
	return 0

For 6.0-rc kernels, we have the following values for mkfs/001

 $unamemajor = 6
 $unameminor = 0
 $argmajor   = 5
 $argminor   = 12

The first check doesn't exit immediately, as 6 > 5.
Then we check the minor, which is already incorrect.

If our major is larger than target major, we should exit immediate with
0.

[FIX]
Fix the check and add extra comment.

Personally speaking I'm not a fan or short compare and return, thus all
the checks will explicit "if []; then fi" checks.

Now mkfs/001 works as expected:

  # make TEST=001\* test-mkfs
    [TEST]   mkfs-tests.sh
    [TEST/mkfs]   001-basic-profiles
  $ grep -IR "RAID0\/1" tests/mkfs-tests-results.txt
   Data,RAID0/1:          204.75MiB
   Metadata,RAID0/1:      204.75MiB
   System,RAID0/1:          8.00MiB

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2022-10-11 09:08:12 +02:00
David Sterba 163aa3cc62 btrfs-progs: tests: add mkfs/025 to test parallel zone reset
Create a few emulated zoned devices and run mkfs, the zone reset is
expected to be run in parallel. It's using memory-backed devices so it's
too fast to measure the differences and we can't expect availability of
slow zoned devices so this test is very simplistic.

Signed-off-by: David Sterba <dsterba@suse.com>
2022-10-11 09:08:08 +02:00
David Sterba 6a968e0f55 btrfs-progs: tags: add nullb for testing zoned devices
I've written a simple shell wrapper for null_blk configuration
(https://github.com/kdave/nullb). Make a local copy of version 0.1 to
avoid external dependency for our tests.

Signed-off-by: David Sterba <dsterba@suse.com>
2022-10-11 09:08:08 +02:00
David Sterba 9cb5b0d058 btrfs-progs: tests: in mkfs/002 use grep -E instead of egrep
The egrep command is deprecated (per manual page of grep) for a long
time and will probably be removed, the replacement is 'grep -E'.

Signed-off-by: David Sterba <dsterba@suse.com>
2022-10-11 09:08:08 +02:00
David Sterba 20496884a9 btrfs-progs: tests: detect send stream version in misc/053
The encoded stream is supported since protocol version 2, detect
support.

Signed-off-by: David Sterba <dsterba@suse.com>
2022-10-11 09:06:13 +02:00
David Sterba 7d06a7e561 btrfs-progs: tests: use _mktemp_local for temporary files
Signed-off-by: David Sterba <dsterba@suse.com>
2022-10-11 09:06:13 +02:00
David Sterba caa57c1689 btrfs-progs: tests: use _mktemp for creating files
Signed-off-by: David Sterba <dsterba@suse.com>
2022-10-11 09:06:12 +02:00
David Sterba 500f826f31 btrfs-progs: tests: add helper for creating local temporary file
Some tests don't use the /tmp temporary files and store it locally in
the test directory. To support NFS this needs to be created by a few
commands. To avoid accidental breakage add a convenience helper.

Signed-off-by: David Sterba <dsterba@suse.com>
2022-10-11 09:06:12 +02:00
David Sterba 1c3ab87c92 btrfs-progs: tests: check that receive --dump escapes target paths
Verify that receive --dump escapes paths for rename, symlink and
hardlink when it's the "dest=" value.

Signed-off-by: David Sterba <dsterba@suse.com>
2022-10-11 09:06:12 +02:00
David Sterba cdd74d8ac5 btrfs-progs: tests: fix misc/016 encoded write, permissions of send stream file
To be able to run the test suite on NFS the temporary files need to be
writeable for all, root due to send and owner due to the way it's
created.

Signed-off-by: David Sterba <dsterba@suse.com>
2022-09-12 18:42:21 +02:00
Qu Wenruo 192d436503 btrfs-progs: tests: add test case for shrunk device
Create a filesystem on a file backed loop block device, then shrink the
file (and its loop block device), then make sure btrfs check can detect
such shrunk device.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2022-09-12 15:31:18 +02:00
David Sterba 8c9bd8e6a8 btrfs-progs: tests: add matching line for extent leaks to scan-results
The extent leaks are detected in debug builds but tests/scan-build.sh
does not look for them, so add the match expression.

Signed-off-by: David Sterba <dsterba@suse.com>
2022-09-12 15:31:13 +02:00
David Sterba e97c158b36 btrfs-progs: tests: fix udev build test option name
Signed-off-by: David Sterba <dsterba@suse.com>
2022-08-16 15:18:12 +02:00
Josef Bacik 06b6ad5e01 btrfs-progs: check: check for invalid free space tree entries
While testing some changes to how we reclaim block groups I started
hitting failures with my TEST_DEV.  This occurred because I had a bug
and failed to properly remove a block groups free space tree entries.
However this wasn't caught in testing when it happened because
btrfs check only checks that the free space cache for the existing block
groups is valid, it doesn't check for free space entries that don't have
a corresponding block group.

Fix this by checking for free space entries that don't have a
corresponding block group.  Additionally add a test image to validate
this fix.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2022-08-16 15:18:12 +02:00
Chung-Chiang Cheng 91a0881200 btrfs-progs: tests: remove duplicated helper
The helper `check_min_kernel_version` is duplicated and can be removed.

Signed-off-by: Chung-Chiang Cheng <cccheng@synology.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2022-08-16 15:18:12 +02:00
Mike Fleetwood 7b6922c988 btrfs-progs: dump-super: exit with failure when printing bad superblock
Attempting to dump a bad btrfs superblock returns successful exit status
zero.  According to the manual page non-zero should be returned on
failure.  Fix this.

    $ btrfs inspect-internal dump-super /dev/zero
    superblock: bytenr=65536, device=/dev/zero
    ---------------------------------------------------------
    ERROR: bad magic on superblock on /dev/zero at 65536

    $ echo $?
    0

Signed-off-by: Mike Fleetwood <mike.fleetwood@googlemail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2022-08-16 15:18:12 +02:00
Nikolay Borisov f4da3ea032 btrfs-progs: tests: add test for fi show and missing device
Add a test to ensure that 'btrfs fi show' on a mounted filesystem, which
has a missing device will explicitly print which device is missing.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2022-08-16 15:18:11 +02:00
Boris Burkov 4bfdd4eafd btrfs-progs: receive: add tests for basic encoded_write send/receive
Adapt the existing send/receive tests by passing '-o compress-force' to
the mount commands in a new test. After writing a few files in the
various compression formats, send/receive them with and without
--force-decompress to test both the encoded_write path and the fallback
to decode+write.

Signed-off-by: Boris Burkov <boris@bur.io>
Signed-off-by: David Sterba <dsterba@suse.com>
2022-08-16 15:18:09 +02:00