From: Thomas Huth <thuth@redhat.com>
To: qemu-devel@nongnu.org, "Alex Bennée" <alex.bennee@linaro.org>,
"Peter Maydell" <peter.maydell@linaro.org>
Cc: "Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"Richard Henderson" <richard.henderson@linaro.org>
Subject: [PATCH 3/6] tests/qtest/display-vga-test: Add proper checks if a device is available
Date: Mon, 30 Jan 2023 11:44:43 +0100 [thread overview]
Message-ID: <20230130104446.1286773-4-thuth@redhat.com> (raw)
In-Reply-To: <20230130104446.1286773-1-thuth@redhat.com>
display-vga-test currently tries to guess the usable VGA devices
according to the target architecture that is used for the test.
This of course does not work if QEMU has been built with the
"--without-default-devices" configure switch. To fix this, use the
qtest_has_device() function for the decision instead. This way
we can also consolidate most of the test functions into one single
function (that takes a parameter with the device name now), except
for the multihead test that tries to instantiate two devices and
thus is a little bit different.
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
tests/qtest/display-vga-test.c | 65 +++++++++++++---------------------
1 file changed, 25 insertions(+), 40 deletions(-)
diff --git a/tests/qtest/display-vga-test.c b/tests/qtest/display-vga-test.c
index ace3bb28e0..1a26a66061 100644
--- a/tests/qtest/display-vga-test.c
+++ b/tests/qtest/display-vga-test.c
@@ -8,61 +8,46 @@
*/
#include "qemu/osdep.h"
-#include "libqtest-single.h"
-
-static void pci_cirrus(void)
-{
- qtest_start("-vga none -device cirrus-vga");
- qtest_end();
-}
-
-static void pci_stdvga(void)
-{
- qtest_start("-vga none -device VGA");
- qtest_end();
-}
-
-static void pci_secondary(void)
-{
- qtest_start("-vga none -device secondary-vga");
- qtest_end();
-}
+#include "libqtest.h"
static void pci_multihead(void)
{
- qtest_start("-vga none -device VGA -device secondary-vga");
- qtest_end();
-}
+ QTestState *qts;
-static void pci_virtio_gpu(void)
-{
- qtest_start("-vga none -device virtio-gpu-pci");
- qtest_end();
+ qts = qtest_init("-vga none -device VGA -device secondary-vga");
+ qtest_quit(qts);
}
-static void pci_virtio_vga(void)
+static void test_vga(gconstpointer data)
{
- qtest_start("-vga none -device virtio-vga");
- qtest_end();
+ QTestState *qts;
+
+ qts = qtest_initf("-vga none -device %s", (const char *)data);
+ qtest_quit(qts);
}
int main(int argc, char **argv)
{
- const char *arch = qtest_get_arch();
+ const char *devices[] = {
+ "cirrus-vga",
+ "VGA",
+ "secondary-vga",
+ "virtio-gpu-pci",
+ "virtio-vga"
+ };
g_test_init(&argc, &argv, NULL);
- if (strcmp(arch, "alpha") == 0 || strcmp(arch, "i386") == 0 ||
- strcmp(arch, "mips") == 0 || strcmp(arch, "x86_64") == 0) {
- qtest_add_func("/display/pci/cirrus", pci_cirrus);
+ for (int i = 0; i < ARRAY_SIZE(devices); i++) {
+ if (qtest_has_device(devices[i])) {
+ char *testpath = g_strdup_printf("/display/pci/%s", devices[i]);
+ qtest_add_data_func(testpath, devices[i], test_vga);
+ g_free(testpath);
+ }
}
- qtest_add_func("/display/pci/stdvga", pci_stdvga);
- qtest_add_func("/display/pci/secondary", pci_secondary);
- qtest_add_func("/display/pci/multihead", pci_multihead);
- qtest_add_func("/display/pci/virtio-gpu", pci_virtio_gpu);
- if (g_str_equal(arch, "i386") || g_str_equal(arch, "x86_64") ||
- g_str_equal(arch, "hppa") || g_str_equal(arch, "ppc64")) {
- qtest_add_func("/display/pci/virtio-vga", pci_virtio_vga);
+
+ if (qtest_has_device("secondary-vga")) {
+ qtest_add_func("/display/pci/multihead", pci_multihead);
}
return g_test_run();
--
2.31.1
next prev parent reply other threads:[~2023-01-30 10:46 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-30 10:44 [PATCH 0/6] Shorten the runtime of some gitlab-CI shared runner jobs Thomas Huth
2023-01-30 10:44 ` [PATCH 1/6] gitlab-ci.d/buildtest: Remove ppc-softmmu from the clang-system job Thomas Huth
2023-01-30 22:37 ` Philippe Mathieu-Daudé
2023-01-30 10:44 ` [PATCH 2/6] gitlab-ci.d/buildtest: Remove aarch64-softmmu from the build-system-ubuntu job Thomas Huth
2023-01-30 10:44 ` Thomas Huth [this message]
2023-01-30 21:13 ` [PATCH 3/6] tests/qtest/display-vga-test: Add proper checks if a device is available Richard Henderson
2023-01-30 10:44 ` [PATCH 4/6] gitlab-ci.d/buildtest: Merge the --without-default-* jobs Thomas Huth
2023-01-30 13:28 ` Fabiano Rosas
2023-01-31 8:02 ` Thomas Huth
2023-01-30 17:45 ` Alex Bennée
2023-01-30 22:43 ` Philippe Mathieu-Daudé
2023-01-30 10:44 ` [PATCH 5/6] gitlab-ci.d/buildtest: Merge the two gprof-gcov jobs Thomas Huth
2023-01-30 17:42 ` Alex Bennée
2023-01-31 7:53 ` Thomas Huth
2023-01-30 10:44 ` [PATCH 6/6] gitlab-ci.d/buildtest: Disintegrate the build-coroutine-sigaltstack job Thomas Huth
2023-01-30 10:58 ` Daniel P. Berrangé
2023-01-30 12:05 ` Thomas Huth
2023-02-03 11:23 ` Thomas Huth
2023-02-03 12:08 ` Kevin Wolf
2023-02-03 15:44 ` Thomas Huth
2023-02-03 15:47 ` Peter Maydell
2023-02-03 21:14 ` Juan Quintela
2023-02-04 10:23 ` Peter Maydell
2023-02-06 9:36 ` Juan Quintela
2023-02-06 7:44 ` Thomas Huth
2023-02-06 8:46 ` Juan Quintela
2023-02-06 10:47 ` Peter Maydell
2023-02-03 21:10 ` Juan Quintela
2023-02-02 11:30 ` [PATCH 0/6] Shorten the runtime of some gitlab-CI shared runner jobs Philippe Mathieu-Daudé
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=20230130104446.1286773-4-thuth@redhat.com \
--to=thuth@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=stefanha@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).