Skip to contentSkip to conversation

tests/functional: fix log placement when run directly

PATCH Superseded Daniel P. Berrangé 2 participants 3 messages Mar 9 – Mar 10 Arm/Amlogic Meson SoC support

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests/functional: fix log placement when run directly

When running functional tests directly there are some heuristics to figure out where the build directory lives, along with the possibility to override the logic by setting the QEMU_BUILD_DIR env variable. This env var is set as part of the test env when run via Meson but not when run directly.

A particular flaw with the currently logic is that it silently uses the wrong location when the build directory is a sub-dir under "./build", which is a common usage scenario for some devs.

With the recent introduction of the 'run' script, we now have the MESON_BUILD_DIR env variable set unconditionally, so we can rely on that from the functional tests to get the correct location in all scenarios.

---
 tests/functional/meson.build         | 2 +-
 tests/functional/qemu_test/config.py | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
tests/functional/meson.build +1 -1
index b979cff2b9..d34aefa8b0 100644
@@ -74,7 +74,7 @@ foreach speed : ['quick', 'thorough']
       test_deps += [qemu_img]
     endif
     test_env.set('QEMU_TEST_QEMU_BINARY', test_emulator.full_path())
-    test_env.set('QEMU_BUILD_ROOT', meson.project_build_root())
+    test_env.set('MESON_BUILD_ROOT', meson.project_build_root())
     test_env.set('PYTHONPATH', meson.project_source_root() / 'python:' +
                                meson.current_source_dir())
 
tests/functional/qemu_test/config.py +2 -2
index 6d4c9c3ce1..0192027233 100644
@@ -21,7 +21,7 @@ def _source_dir():
     return Path(__file__).parent.parent.parent.parent
 
 def _build_dir():
-    root = os.getenv('QEMU_BUILD_ROOT')
+    root = os.getenv('MESON_BUILD_ROOT')
     if root is not None:
         return Path(root)
     # Makefile.mtest only exists in build dir, so if it is available, use CWD
@@ -32,7 +32,7 @@ def _build_dir():
     if os.path.exists(root):
         return Path(root)
 
-    raise Exception("Cannot identify build dir, set QEMU_BUILD_ROOT")
+    raise Exception("Cannot identify build dir, set MESON_BUILD_ROOT")
 
 BUILD_DIR = _build_dir()
 
Signature · 1 line
2.53.0
#1 lore raw
Quoted 6 lines · Daniel P. Berrangé

When running functional tests directly there are some heuristics to figure out where the build directory lives, along with the possibility to override the logic by setting the QEMU_BUILD_DIR env variable. This env var is set as part of the test env when run via Meson but not when run directly.

Quoted 6 lines

A particular flaw with the currently logic is that it silently uses the wrong location when the build directory is a sub-dir under "./build", which is a common usage scenario for some devs.

With the recent introduction of the 'run' script, we now have the MESON_BUILD_DIR env variable set unconditionally, so we

s/MESON_BUILD_DIR/MESON_BUILD_ROOT/

Quoted 2 lines

can rely on that from the functional tests to get the correct location in all scenarios.

That's a good idea!

Quoted 12 lines
---
  tests/functional/meson.build         | 2 +-
  tests/functional/qemu_test/config.py | 4 ++--
  2 files changed, 3 insertions(+), 3 deletions(-)
tests/functional/meson.build +0 -0
index b979cff2b9..d34aefa8b0 100644

tests/functional/meson.build foreach speed : ['quick', 'thorough'] · line 77

Quoted 5 lines
tests/functional/meson.build +1 -1
@@ -74,7 +74,7 @@ foreach speed : ['quick', 'thorough']
        test_deps += [qemu_img]
      endif
      test_env.set('QEMU_TEST_QEMU_BINARY', test_emulator.full_path())
-    test_env.set('QEMU_BUILD_ROOT', meson.project_build_root())
+    test_env.set('MESON_BUILD_ROOT', meson.project_build_root())

I think you could even completely remove this line now completely - if I've got that right, meson also sets this environment variable for tests automatically.

Thomas

Quoted 25 lines
tests/functional/meson.build +0 -0
      test_env.set('PYTHONPATH', meson.project_source_root() / 'python:' +
                                 meson.current_source_dir())
 
tests/functional/qemu_test/config.py +2 -2
index 6d4c9c3ce1..0192027233 100644
@@ -21,7 +21,7 @@ def _source_dir():
      return Path(__file__).parent.parent.parent.parent
 
  def _build_dir():
-    root = os.getenv('QEMU_BUILD_ROOT')
+    root = os.getenv('MESON_BUILD_ROOT')
      if root is not None:
          return Path(root)
      # Makefile.mtest only exists in build dir, so if it is available, use CWD
@@ -32,7 +32,7 @@ def _build_dir():
      if os.path.exists(root):
          return Path(root)
 
-    raise Exception("Cannot identify build dir, set QEMU_BUILD_ROOT")
+    raise Exception("Cannot identify build dir, set MESON_BUILD_ROOT")
 
  BUILD_DIR = _build_dir()
 
#2 lore raw
Quoted 28 lines · Thomas Huth
Quoted 6 lines · Daniel P. Berrangé

When running functional tests directly there are some heuristics to figure out where the build directory lives, along with the possibility to override the logic by setting the QEMU_BUILD_DIR env variable. This env var is set as part of the test env when run via Meson but not when run directly.

Quoted 6 lines

A particular flaw with the currently logic is that it silently uses the wrong location when the build directory is a sub-dir under "./build", which is a common usage scenario for some devs.

With the recent introduction of the 'run' script, we now have the MESON_BUILD_DIR env variable set unconditionally, so we

s/MESON_BUILD_DIR/MESON_BUILD_ROOT/

Quoted 2 lines

can rely on that from the functional tests to get the correct location in all scenarios.

That's a good idea!

Quoted 7 lines
---
  tests/functional/meson.build         | 2 +-
  tests/functional/qemu_test/config.py | 4 ++--
  2 files changed, 3 insertions(+), 3 deletions(-)
Quoted 14 lines

tests/functional/meson.build foreach speed : ['quick', 'thorough'] · line 77

Quoted 10 lines
tests/functional/meson.build +1 -1
index b979cff2b9..d34aefa8b0 100644
@@ -74,7 +74,7 @@ foreach speed : ['quick', 'thorough']
        test_deps += [qemu_img]
      endif
      test_env.set('QEMU_TEST_QEMU_BINARY', test_emulator.full_path())
-    test_env.set('QEMU_BUILD_ROOT', meson.project_build_root())
+    test_env.set('MESON_BUILD_ROOT', meson.project_build_root())

I think you could even completely remove this line now completely - if I've got that right, meson also sets this environment variable for tests automatically.

No, meson does not set MESON_BUILD_ROOT by default - that's something we have to do ourselves. For the 'run' script we define it in the 'devenv' environment, but for tests we need to define it here.

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|