Skip to contentSkip to conversation

iotests: better heuristics to find I/O tests build/source dirs

PATCH Applied Daniel P. Berrangé 2 participants 2 messages Nov 11 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 iotests: better heuristics to find I/O tests build/source dirs

Currently the I/O tests cannot be run if executing directly from the source directory, even when wrapped by the 'run' script, due to inadequate heuristics to guess the directories.

If using the 'run' script, meson can tell us exactly where the top level build and source directories are, so we don't need to guess. Just read MESON_BUILD_ROOT and MESON_SOURCE_ROOT env variables if present.

If not using the 'run' script, we can do a bit better at guessing the path from the 'check' filename. Always resolve from sys.argv[0], even when it is not a symlink, instead of falling back to 'cwd()' which doesn't work since we stopped having in-tree builds. If invoked directly from the source tree, guess that the build root is the default 'build' name which often works.

With this change the following all work:

1. From root of build dir, with run script

cd build
./run tests/qemu-iotests/check 5

2. From root of build dir, without run script

cd build
tests/qemu-iotests/check 5

3. From I/O tests subdir of build dir, with run script

cd build/tests/qemu-iotests
../../run ./check 5

4. From I/O tests subdir of build dir, without run script

cd build/tests/qemu-iotests
./check 5

5. From root of source dir, with run script

./build/run tests/qemu-iotests/check 5

6. From root of source dir, without run script

tests/qemu-iotests/check 5

7. From I/O tests subdir of source dir, with run script

cd tests/qemu-iotests
../../build/run ./check 5

8. From I/O tests subdir of source dir, without run script

cd tests/qemu-iotests
./check 5

Before this commit, items 5-8 would always fail. Items 6 and 8 will not work if using a build directory with a name other than the default 'build'. For those scenarios use one of the other 6 possible variants.

---
 meson.build              |  1 +
 tests/qemu-iotests/check | 52 +++++++++++++++++++++++++++++-----------
 2 files changed, 39 insertions(+), 14 deletions(-)
meson.build +1 -0
index d7bcb581c18..9d15f2e9551 100644
@@ -3502,6 +3502,7 @@ genh += config_host_h
 
 devenv = environment()
 devenv.set('MESON_BUILD_ROOT', meson.project_build_root())
+devenv.set('MESON_SOURCE_ROOT', meson.project_source_root())
 devenv.set('VIRTUAL_ENV', meson.project_build_root() / 'pyvenv')
 devenv.prepend('PATH', meson.project_build_root() / 'pyvenv'/ 'bin')
 devenv.prepend('PYTHONPATH', meson.current_source_dir() / 'tests' / 'functional')
tests/qemu-iotests/check +38 -14

67 lines not on this page · raw message

Signature · 1 line
2.56.0
Applied
#1 lore raw

Am 11.11.2026 um 10:11 hat Daniel P. Berrangé geschrieben:

Quoted 57 lines

Currently the I/O tests cannot be run if executing directly from the source directory, even when wrapped by the 'run' script, due to inadequate heuristics to guess the directories.

If using the 'run' script, meson can tell us exactly where the top level build and source directories are, so we don't need to guess. Just read MESON_BUILD_ROOT and MESON_SOURCE_ROOT env variables if present.

If not using the 'run' script, we can do a bit better at guessing the path from the 'check' filename. Always resolve from sys.argv[0], even when it is not a symlink, instead of falling back to 'cwd()' which doesn't work since we stopped having in-tree builds. If invoked directly from the source tree, guess that the build root is the default 'build' name which often works.

With this change the following all work:

1. From root of build dir, with run script

cd build
./run tests/qemu-iotests/check 5

2. From root of build dir, without run script

cd build
tests/qemu-iotests/check 5

3. From I/O tests subdir of build dir, with run script

cd build/tests/qemu-iotests
../../run ./check 5

4. From I/O tests subdir of build dir, without run script

cd build/tests/qemu-iotests
./check 5

5. From root of source dir, with run script

./build/run tests/qemu-iotests/check 5

6. From root of source dir, without run script

tests/qemu-iotests/check 5

7. From I/O tests subdir of source dir, with run script

cd tests/qemu-iotests
../../build/run ./check 5

8. From I/O tests subdir of source dir, without run script

cd tests/qemu-iotests
./check 5

Quoted 6 lines

Before this commit, items 5-8 would always fail. Items 6 and 8 will not work if using a build directory with a name other than the default 'build'. For those scenarios use one of the other 6 possible variants.

Thanks, applied to the block branch.

Kevin