btrfs-progs: tests: hide RST related mkfs tests behind experimental builds

Currently we unconditionally run mkfs/029 and mkfs/030 as we export
RST feature through mkfs.btrfs as supported features.

But considering the mkfs.btrfs features don't match kernel support (only
a BTRFS_DEBUG kernel can support that), we're going to hide RST behind
experimental builds.

In that case RST related tests cases also need to be behind experimental
builds as regular builds of mkfs.btrfs will no longer support RST
feature.

Introduce two helpers:

- _test_config()
  To verify if certain config is set to 1

- check_experimental_build()
  A wrapper of "_test_config EXPERIMENTAL", and skip the test if
  btrfs-progs has no experimental features.

So that test cases can be skipped for non-experimental builds.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Qu Wenruo 2024-06-13 08:36:41 +09:30
parent 142bf60082
commit c5f6cfba00
3 changed files with 25 additions and 0 deletions

View file

@ -6,6 +6,22 @@
# Temporary array for building the final command, injecting arguments as needed
declare -a cmd_array
# Check if a given option in config.h is set to 1
# $1: config option name
_test_config()
{
local feature="$1"
if [ ! -f "$TOP/include/config.h" ]; then
echo "include/config.h not exists"
exit 1
fi
if grep -q "$feature.*1" "${TOP}/include/config.h"; then
return 0
fi
return 1
}
# assert that argument is not empty and is an existing path (file or directory)
_assert_path()
{
@ -376,6 +392,13 @@ run_mustfail_stdout()
fi
}
check_experimental_build()
{
if ! _test_config "EXPERIMENTAL"; then
_not_run "This test requires experimental build"
fi
}
check_prereq()
{
# Internal tools for testing, not shipped with the package

View file

@ -3,6 +3,7 @@
source "$TEST_TOP/common" || exit
check_experimental_build
check_prereq mkfs.btrfs
check_prereq btrfs

View file

@ -3,6 +3,7 @@
source "$TEST_TOP/common" || exit
check_experimental_build
setup_root_helper
setup_nullbdevs 4 128 4
prepare_nullbdevs