]> git.ipfire.org Git - thirdparty/linux.git/commit
btrfs: tests: add unit tests for pending extent walking functions
authorBoris Burkov <boris@bur.io>
Fri, 30 Jan 2026 00:11:22 +0000 (16:11 -0800)
committerDavid Sterba <dsterba@suse.com>
Tue, 3 Feb 2026 06:56:25 +0000 (07:56 +0100)
commit5341c98450df7cf8dacc907a80e3362f3155c847
treef79d83ecdc31c85ce898723b706f598df5e06c96
parentb14c5e04bd0f722ed631845599d52d03fcae1bc1
btrfs: tests: add unit tests for pending extent walking functions

I ran into another sort of trivial bug in v1 of the patch and concluded
that these functions really ought to be unit tested.

These two functions form the core of searching the chunk allocation
pending extent bitmap and have relatively easily definable semantics, so
unit testing them can help ensure the correctness of chunk allocation.

I also made a minor unrelated fix in volumes.h to properly forward
declare btrfs_space_info. Because of the order of the includes in the
new test, this was actually hitting a latent build warning.

Note:
This is an early example for me of a commit authored in part by an AI
agent, so I wanted to more clear about what I did. I defined a
trivial test and explained the set of tests I wanted to the agent and it
produced the large set of test cases seen here. I then checked each test
case to make sure it matched the description and simplified the
constants and numbers until they looked reasonable to me. I then checked
the looping logic to make sure it made sense to the original spirit of
the trivial test. Finally, carefully combed over all the lines it wrote
to loop over the tests it generated to make sure they followed our code
style guide.

Assisted-by: Claude:claude-opus-4-5
Signed-off-by: Boris Burkov <boris@bur.io>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/Makefile
fs/btrfs/tests/btrfs-tests.c
fs/btrfs/tests/btrfs-tests.h
fs/btrfs/tests/chunk-allocation-tests.c [new file with mode: 0644]
fs/btrfs/volumes.c
fs/btrfs/volumes.h