From: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Thomas Huth" <thuth@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Pierrick Bouvier" <pierrick.bouvier@linaro.org>,
"Manos Pitsidianakis" <manos.pitsidianakis@linaro.org>
Subject: [PATCH 2/3] tests/functional: add --list-tests CLI arg
Date: Fri, 18 Jul 2025 12:12:53 +0300 [thread overview]
Message-ID: <20250718-functional_tests_args-v1-2-54d4c6207690@linaro.org> (raw)
In-Reply-To: <20250718-functional_tests_args-v1-0-54d4c6207690@linaro.org>
Add CLI argument to list tests and exit.
Example output (current dir is build directory under root dir):
$ export PYTHONPATH=../python:../tests/functional
$ export QEMU_TEST_QEMU_BINARY="$(pwd)/qemu-system-aarch64"
$ ./pyvenv/bin/python3 ../tests/functional/test_aarch64_virt.py --list-tests
test_aarch64_virt_gicv2 (test_aarch64_virt.Aarch64VirtMachine.test_aarch64_virt_gicv2)
test_aarch64_virt_gicv3 (test_aarch64_virt.Aarch64VirtMachine.test_aarch64_virt_gicv3)
test_alpine_virt_tcg_gic_max (test_aarch64_virt.Aarch64VirtMachine.test_alpine_virt_tcg_gic_max)
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
---
tests/functional/qemu_test/testcase.py | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/tests/functional/qemu_test/testcase.py b/tests/functional/qemu_test/testcase.py
index 24f0b452964012532530a92018b2c4367b39fb77..4455fcc38016c14db04019bbd64eaae9b47363c1 100644
--- a/tests/functional/qemu_test/testcase.py
+++ b/tests/functional/qemu_test/testcase.py
@@ -50,6 +50,11 @@ def parse_args(test_name: str) -> argparse.Namespace:
"This is equivalent to setting QEMU_TEST_KEEP_SCRATCH=1 in the "
"environment.",
)
+ parser.add_argument(
+ "--list-tests",
+ action="store_true",
+ help="List all tests that would be executed and exit.",
+ )
return parser.parse_args()
@@ -281,10 +286,13 @@ def tearDown(self):
def main():
path = os.path.basename(sys.argv[0])[:-3]
- # If argparse receives --help or an unknown argument, it will raise a
- # SystemExit which will get caught by the test runner. Parse the
- # arguments here too to handle that case.
- parse_args(path)
+ args = parse_args(path)
+ if args.list_tests:
+ loader = unittest.TestLoader()
+ for test_suite in loader.loadTestsFromName(path):
+ for test in test_suite:
+ print(test)
+ return
cache = os.environ.get("QEMU_TEST_PRECACHE", None)
if cache is not None:
--
2.47.2
next prev parent reply other threads:[~2025-07-18 9:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-18 9:12 [PATCH 0/3] tests/functional: add more CLI args Manos Pitsidianakis
2025-07-18 9:12 ` [PATCH 1/3] tests/functional: add --keep-scratch CLI arg Manos Pitsidianakis
2025-07-18 9:12 ` Manos Pitsidianakis [this message]
2025-07-18 9:12 ` [PATCH 3/3] tests/functional: add -k TEST_NAME_PATTERN " Manos Pitsidianakis
2025-07-18 9:37 ` Paolo Bonzini
2025-07-18 9:44 ` Manos Pitsidianakis
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=20250718-functional_tests_args-v1-2-54d4c6207690@linaro.org \
--to=manos.pitsidianakis@linaro.org \
--cc=alex.bennee@linaro.org \
--cc=berrange@redhat.com \
--cc=philmd@linaro.org \
--cc=pierrick.bouvier@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=thuth@redhat.com \
/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).