qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: "Gustavo Romero" <gustavo.romero@linaro.org>,
	qemu-devel@nongnu.org,
	"Daniel P . Berrangé" <berrange@redhat.com>
Cc: qemu-arm@nongnu.org, "Alex Bennée" <alex.bennee@linaro.org>
Subject: [RFC PATCH 1/2] tests/functional: Provide GDB to the functional tests
Date: Mon, 15 Sep 2025 14:42:06 +0200	[thread overview]
Message-ID: <20250915124207.42053-2-thuth@redhat.com> (raw)
In-Reply-To: <20250915124207.42053-1-thuth@redhat.com>

From: Gustavo Romero <gustavo.romero@linaro.org>

The probe of gdb is done in 'configure' and the full path is passed
to meson.build via the -Dgdb=option.

meson then can pass the location of gdb to the test via an environment
variable.

This patch is based on an earlier patch ("Support tests that require a
runner") by Gustavo Romero.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 configure                     | 2 ++
 meson.build                   | 4 ++++
 meson_options.txt             | 2 ++
 scripts/meson-buildoptions.sh | 2 ++
 tests/functional/meson.build  | 7 +++++++
 5 files changed, 17 insertions(+)

diff --git a/configure b/configure
index 274a7787642..8e2e2cd562a 100755
--- a/configure
+++ b/configure
@@ -1978,6 +1978,8 @@ if test "$skip_meson" = no; then
   test -n "${LIB_FUZZING_ENGINE+xxx}" && meson_option_add "-Dfuzzing_engine=$LIB_FUZZING_ENGINE"
   test "$plugins" = yes && meson_option_add "-Dplugins=true"
   test "$tcg" != enabled && meson_option_add "-Dtcg=$tcg"
+  test -n "$gdb_bin" && meson_option_add "-Dgdb=$gdb_bin"
+
   run_meson() {
     NINJA=$ninja $meson setup "$@" "$PWD" "$source_path"
   }
diff --git a/meson.build b/meson.build
index 3d738733566..4cbc3c8ac65 100644
--- a/meson.build
+++ b/meson.build
@@ -75,6 +75,10 @@ have_user = have_linux_user or have_bsd_user
 
 sh = find_program('sh')
 python = import('python').find_installation()
+# Meson python.get_path() on 'purelib' or 'platlib' doesn't properly return the
+# site-packages dir in pyvenv, so it is built manually.
+python_ver = python.language_version()
+python_site_packages = meson.build_root() / 'pyvenv/lib/python' + python_ver / 'site-packages'
 
 cc = meson.get_compiler('c')
 all_languages = ['c']
diff --git a/meson_options.txt b/meson_options.txt
index fff1521e580..5bb41bcbc43 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -36,6 +36,8 @@ option('trace_file', type: 'string', value: 'trace',
 option('coroutine_backend', type: 'combo',
        choices: ['ucontext', 'sigaltstack', 'windows', 'wasm', 'auto'],
        value: 'auto', description: 'coroutine backend to use')
+option('gdb', type: 'string', value: '',
+       description: 'Path to GDB')
 
 # Everything else can be set via --enable/--disable-* option
 # on the configure script command line.  After adding an option
diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh
index 0ebe6bc52a6..f4bd21220ee 100644
--- a/scripts/meson-buildoptions.sh
+++ b/scripts/meson-buildoptions.sh
@@ -58,6 +58,7 @@ meson_options_help() {
   printf "%s\n" '  --enable-ubsan           enable undefined behaviour sanitizer'
   printf "%s\n" '  --firmwarepath=VALUES    search PATH for firmware files [share/qemu-'
   printf "%s\n" '                           firmware]'
+  printf "%s\n" '  --gdb=VALUE              Path to GDB'
   printf "%s\n" '  --iasl=VALUE             Path to ACPI disassembler'
   printf "%s\n" '  --includedir=VALUE       Header file directory [include]'
   printf "%s\n" '  --interp-prefix=VALUE    where to find shared libraries etc., use %M for'
@@ -323,6 +324,7 @@ _meson_option_parse() {
     --disable-fuzzing) printf "%s" -Dfuzzing=false ;;
     --enable-gcrypt) printf "%s" -Dgcrypt=enabled ;;
     --disable-gcrypt) printf "%s" -Dgcrypt=disabled ;;
+    --gdb=*) quote_sh "-Dgdb=$2" ;;
     --enable-gettext) printf "%s" -Dgettext=enabled ;;
     --disable-gettext) printf "%s" -Dgettext=disabled ;;
     --enable-gio) printf "%s" -Dgio=enabled ;;
diff --git a/tests/functional/meson.build b/tests/functional/meson.build
index 2a0c5aa1418..c822eb66309 100644
--- a/tests/functional/meson.build
+++ b/tests/functional/meson.build
@@ -77,6 +77,12 @@ foreach speed : ['quick', 'thorough']
     test_env.set('PYTHONPATH', meson.project_source_root() / 'python:' +
                                meson.current_source_dir())
 
+    # Define the GDB environment variable if gdb is available.
+    gdb = get_option('gdb')
+    if gdb != ''
+      test_env.set('QEMU_TEST_GDB', gdb)
+    endif
+
     foreach test : target_tests
       testname = '@0@-@1@'.format(target_base, test)
       if fs.exists('generic' / 'test_' + test + '.py')
@@ -121,6 +127,7 @@ foreach speed : ['quick', 'thorough']
            priority: time_out,
            suite: suites)
     endforeach
+
   endforeach
 endforeach
 
-- 
2.51.0



  reply	other threads:[~2025-09-15 12:44 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-15 12:42 [RFC PATCH 0/2] tests/functional: Adapt reverse_debugging to run w/o Avocado (yet another try) Thomas Huth
2025-09-15 12:42 ` Thomas Huth [this message]
2025-09-15 16:11   ` [RFC PATCH 1/2] tests/functional: Provide GDB to the functional tests Alex Bennée
2025-09-15 22:02   ` Gustavo Romero
2025-09-16  9:20     ` Daniel P. Berrangé
2025-09-15 12:42 ` [RFC PATCH 2/2] tests/functional: Adapt reverse_debugging to run w/o Avocado Thomas Huth
2025-09-15 16:14   ` Alex Bennée
2025-09-15 22:02   ` Gustavo Romero
2025-09-16  9:22   ` Daniel P. Berrangé
2025-09-15 16:13 ` [RFC PATCH 0/2] tests/functional: Adapt reverse_debugging to run w/o Avocado (yet another try) Alex Bennée
2025-09-15 16:18   ` Thomas Huth
2025-09-15 18:27     ` Alex Bennée
2025-09-15 22:03     ` Gustavo Romero
2025-09-15 22:02 ` Gustavo Romero
2025-09-16  9:15 ` Daniel P. Berrangé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250915124207.42053-2-thuth@redhat.com \
    --to=thuth@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=berrange@redhat.com \
    --cc=gustavo.romero@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).