From nobody Sat Sep 6 17:20:23 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1757001003; cv=none; d=zohomail.com; s=zohoarc; b=TSU/CrbYAu1IiNcEJH5OcgFW5/ZsskCm6uo9nztaUPqbV3bc4PvC7AabRS7o3nYr9LeCid/1DEQ+6m8jHePj4k58PXbywGaje3WhLowwGo0xcYu2tk9eV6z1eOnVzEffZuVC82ZUxk9iz3j97PE0IVPrhq4b6bTjqzFTr7gzaNw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757001003; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Ly0Uw2HSTv1mCwT12MXqsgrBCGp5zOffCN0UNp08lAs=; b=OfZggZYiQRpHlny9GgxvORu62qroWABIQ2Pmvhuldsnqa/9jqPYDXg884y/YeUSUk+AP1D4x8aj+1tK4MErOfqG3qPnMZ5CWHwImQB4dAp6BHAkBNy1feIosDEMuWRyu5SHoPajtfW+O0jv0Zzr48laH04rS5VzelFzEgbTfrwU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1757001003144765.6551297853142; Thu, 4 Sep 2025 08:50:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uuCBq-00050w-Kf; Thu, 04 Sep 2025 11:47:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uuCBM-0004mN-8G for qemu-devel@nongnu.org; Thu, 04 Sep 2025 11:47:30 -0400 Received: from mail-vk1-xa2a.google.com ([2607:f8b0:4864:20::a2a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uuCBA-0008Qy-I9 for qemu-devel@nongnu.org; Thu, 04 Sep 2025 11:47:25 -0400 Received: by mail-vk1-xa2a.google.com with SMTP id 71dfb90a1353d-545e265e2d0so1010431e0c.1 for ; Thu, 04 Sep 2025 08:47:14 -0700 (PDT) Received: from gromero0.. ([186.215.58.133]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-544a666da0csm6497022e0c.28.2025.09.04.08.47.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Sep 2025 08:47:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1757000833; x=1757605633; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Ly0Uw2HSTv1mCwT12MXqsgrBCGp5zOffCN0UNp08lAs=; b=doUvwRRFbiP/9f6zGeOpZkfxYnDqumJGx/fRxmbXe1QB8jWyecURAmFy/hVlleZJdU 0nQXwRs2yolSp8JFnV631nP6HsSIMNAATXqPnlG0kS3XGFPERKDWpmqwpfqbW3EVB382 ju3MSxDXmk3Pdi37WhQiyqrdNjRFa38eQzEBTopXpkElUPodf5M0lnabQV13+Q9tef4C fg7d93u/sYKSCAAY7xmdPH+w7ZH6J9NBHlqNN7qDluSY8HUXxyG44Dw8v+3UMiKbVP/G ITJN2AfKqSUV6gE+mQkK7tRTRi5VxrBekVt9hCxnlDKruU11L6OFBOItGVRS79XaGbuP zjBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757000833; x=1757605633; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ly0Uw2HSTv1mCwT12MXqsgrBCGp5zOffCN0UNp08lAs=; b=sFSpKEbM60L4vrLmP63tuTrqHjXHonBRkYG1/IZzXvOJMgZeA73vbmOy3WSReCfh21 cXYWLgiA2fSaWFWnbMJXZigkUK5Sq//PZcAj6MP85lHgtqpwx8JWKBVs37ytn+u7Jb66 hlKe725w221kHB1IbTrMAsDKBFdRf9hkiPBPNnAwtwde5m8uhfFRNdUbov2AV9ru9m0h J+LclDrRQwOiSasCS/uCTiBZxhnk9LP6j1GI4WRrRvAtjRSGXx/W/kAMlP7yGOm9bKWs AhH4KTUSwSJYBmTnafb0WHESPYF40v2b/A9uoMmf8p8+s+cHfBL9kBWh+XZtake06zIv VpOw== X-Gm-Message-State: AOJu0YzZj8FUZf9WVFRWR72D+fRNOYwQzf0mCSOFCISDuZExoPI6foLJ sOvqIV6e1oOGfOuejM+8yIZGyyV2ZibTpYEBxkv5RNVyb7wOsBClYtQNCaNbiG7/ctB2MJMD78K FWTzfmtKHPQ== X-Gm-Gg: ASbGncvXp5Sa4fjamdEztOUHfFKedsjxQQX69Bia36vCBwR1Sj6pg+Qs3NxApKTqytB 3zYqrKM2x7maOyO+PfHl2xjMMlfmZGsxORG4AUKpbGuulVTceUtI/tLZ7rxMT4ju/JCj69L2MtH eIPpi/GACiPDiN/gmaCOz8iVn0MTuD+C/6ECIPry32jxRkK1v/N88r+ntov13ocjWHoKLrV7o93 uXE0Zbu4bXYCL0skzUOZ6NmaaSOY6Xq01CF03S4o+Hai4fDe3nfPHYam+4V9datSc4ekKcOAen7 LIiOYM3WSJCnZTrF8NM3rYKTWbfYmApoPtXSPz0P2V3Px3UOe/N3Cj+rkdJIevd7Yp3ZM6hExj7 Siw1md7Mx0sMkb+ke5ug97/85qKA5 X-Google-Smtp-Source: AGHT+IHFjcODdw0kEcwKl4L5wi+0ipardMLyHLfTEl29Z2W0X38mLEXrv+P1oEoTZZCCFwtg/vsT2Q== X-Received: by 2002:a05:6122:2022:b0:544:9414:105d with SMTP id 71dfb90a1353d-5449ff8d510mr7461027e0c.0.1757000832746; Thu, 04 Sep 2025 08:47:12 -0700 (PDT) From: Gustavo Romero To: qemu-devel@nongnu.org, alex.bennee@linaro.org, thuth@redhat.com, berrange@redhat.com Cc: qemu-arm@nongnu.org, 1844144@gmail.com, gustavo.romero@linaro.org Subject: [PATCH v2 4/5] tests/functional: Support tests that require a runner Date: Thu, 4 Sep 2025 15:46:39 +0000 Message-Id: <20250904154640.52687-5-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250904154640.52687-1-gustavo.romero@linaro.org> References: <20250904154640.52687-1-gustavo.romero@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::a2a; envelope-from=gustavo.romero@linaro.org; helo=mail-vk1-xa2a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1757001005784116600 Content-Type: text/plain; charset="utf-8" Add support for running tests that require a specific runner. The test is specified via a tuple (name, runner, protocol), where name is the test name as found in the tests/functional directory without the 'test_' prefix and the .py extension, runner is an array containing the runner and any arguments required by the runner, and protocol is the test protocol used by Meson to determine whether the test passed or failed. The test tuples are added to arrays that follow the current naming logic but with the suffix '_with_runner' appended to their names. In Meson it's not easy to select an element in an array at runtime based on its type, so it's simpler to have a new array for these new test types than use the current ones from the tests that don't require a runner, and so avoid mixing strings and tuples in the same array. Currently there is only one runner, the GDB runner, but more runners can be defined and associated to a test via the tuple. The GDB runner is only defined if GDB is detected. The probe is done in 'configure' and the full path is passed to meson.build via the -Dgdb=3D option. Signed-off-by: Gustavo Romero --- configure | 2 ++ meson.build | 4 +++ meson_options.txt | 2 ++ scripts/meson-buildoptions.sh | 2 ++ tests/functional/meson.build | 65 +++++++++++++++++++++++++++++++++++ 5 files changed, 75 insertions(+) diff --git a/configure b/configure index 274a778764..8e2e2cd562 100755 --- a/configure +++ b/configure @@ -1978,6 +1978,8 @@ if test "$skip_meson" =3D no; then test -n "${LIB_FUZZING_ENGINE+xxx}" && meson_option_add "-Dfuzzing_engin= e=3D$LIB_FUZZING_ENGINE" test "$plugins" =3D yes && meson_option_add "-Dplugins=3Dtrue" test "$tcg" !=3D enabled && meson_option_add "-Dtcg=3D$tcg" + test -n "$gdb_bin" && meson_option_add "-Dgdb=3D$gdb_bin" + run_meson() { NINJA=3D$ninja $meson setup "$@" "$PWD" "$source_path" } diff --git a/meson.build b/meson.build index 0d42de61ae..7e0afe8288 100644 --- a/meson.build +++ b/meson.build @@ -75,6 +75,10 @@ have_user =3D have_linux_user or have_bsd_user =20 sh =3D find_program('sh') python =3D import('python').find_installation() +# Meson python.get_path() on 'purelib' or 'platlib' doesn't properly retur= n the +# site-packages dir in pyvenv, so it is built manually. +python_ver =3D python.language_version() +python_site_packages =3D meson.build_root() / 'pyvenv/lib/python' + python= _ver / 'site-packages' =20 cc =3D meson.get_compiler('c') all_languages =3D ['c'] diff --git a/meson_options.txt b/meson_options.txt index fff1521e58..5bb41bcbc4 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') =20 # 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 0ebe6bc52a..f4bd21220e 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 san= itizer' printf "%s\n" ' --firmwarepath=3DVALUES search PATH for firmware fil= es [share/qemu-' printf "%s\n" ' firmware]' + printf "%s\n" ' --gdb=3DVALUE Path to GDB' printf "%s\n" ' --iasl=3DVALUE Path to ACPI disassembler' printf "%s\n" ' --includedir=3DVALUE Header file directory [inclu= de]' printf "%s\n" ' --interp-prefix=3DVALUE where to find shared librari= es etc., use %M for' @@ -323,6 +324,7 @@ _meson_option_parse() { --disable-fuzzing) printf "%s" -Dfuzzing=3Dfalse ;; --enable-gcrypt) printf "%s" -Dgcrypt=3Denabled ;; --disable-gcrypt) printf "%s" -Dgcrypt=3Ddisabled ;; + --gdb=3D*) quote_sh "-Dgdb=3D$2" ;; --enable-gettext) printf "%s" -Dgettext=3Denabled ;; --disable-gettext) printf "%s" -Dgettext=3Ddisabled ;; --enable-gio) printf "%s" -Dgio=3Denabled ;; diff --git a/tests/functional/meson.build b/tests/functional/meson.build index 2a0c5aa141..febd31a263 100644 --- a/tests/functional/meson.build +++ b/tests/functional/meson.build @@ -9,6 +9,25 @@ if get_option('tcg_interpreter') subdir_done() endif =20 +# Define the GDB runner if GDB is available. +gdb =3D get_option('gdb') +if gdb !=3D '' + gdb_runner_script =3D meson.project_source_root() + '/tests/guest-deb= ug/run-test.py' + gdb_runner =3D [gdb_runner_script, '--quiet', '--gdb', gdb, '--test'] + + message('GDB runner defined based on GDB found at: ', gdb) + + # A test with a runner is a tuple (name, runner, protocol). + # The tests must be elements of an array named like: + # + # test____with_runner =3D [ + # ['test0', gdb_runner, 'exitcode'], + # ... + # ] +else + message('GDB not found, skipping functional tests that rely on it.') +endif + subdir('aarch64') subdir('alpha') subdir('arm') @@ -61,9 +80,11 @@ foreach speed : ['quick', 'thorough'] suites =3D ['func-quick', 'func-' + target_base] target_tests =3D get_variable('tests_' + target_base + '_' + sysmode= + '_quick', []) \ + get_variable('tests_generic_' + sysmode) + target_tests_r =3D get_variable('tests_' + target_base + '_' + sysmo= de + '_quick_with_runner', []) else suites =3D ['func-' + speed, 'func-' + target_base + '-' + speed, sp= eed] target_tests =3D get_variable('tests_' + target_base + '_' + sysmode= + '_' + speed, []) + target_tests_r =3D get_variable('tests_' + target_base + '_' + sysmo= de + '_' + speed + '_with_runner', []) endif =20 test_deps =3D [roms, keymap_targets] @@ -121,6 +142,50 @@ foreach speed : ['quick', 'thorough'] priority: time_out, suite: suites) endforeach + + # Prepare tests that require a specific runner. + foreach test : target_tests_r + testname =3D '@0@-@1@'.format(target_base, test[0]) + testfile =3D target_base / 'test_' + test[0] + '.py' + testpath =3D meson.current_source_dir() / testfile + teststamp =3D testname + '.tstamp' + testrunner =3D test[1] + testproto =3D test[2] + + # python_site_packages, i.e., site packages from Python in pyvenv, is + # added to PYTHONPATH because some runners can run a program that ha= s its + # own Python hooks that, by its turn, will search for modules based = on + # PYTHONPATH independently of the Python used by the runner, like, f= or + # example, GDB using libpython. + test_r_precache_env =3D test_precache_env + test_r_precache_env.append('PYTHONPATH', python_site_packages) + # For similar reasons, PYTHONPATH must also include the path to the = test + # scripts, otherwise unittest's introspection will failed. + test_r_precache_env.append('PYTHONPATH', meson.current_source_dir() = / target_base) + + precache =3D custom_target('func-precache-' + testname, + output: teststamp, + command: [testrunner, testpath], + depend_files: files(testpath), + build_by_default: false, + env: test_r_precache_env) + precache_all +=3D precache + + # See comments above about PYTHONPATH in test_r_precache_env. + test_r_env =3D test_env + test_r_env.append('PYTHONPATH', python_site_packages) + test_r_env.append('PYTHONPATH', meson.current_source_dir() / target_= base) + + test('func-' + testname, + python, + depends: [test_deps, test_emulator, emulator_modules, plugin_mo= dules], + env: test_r_env, + args: [testrunner, testpath], + protocol: testproto, + timeout: time_out, + priority: time_out, + suite: suites) + endforeach endforeach endforeach =20 --=20 2.34.1