From: Thomas Huth <thuth@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Victor Kaplansky" <victork@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
qemu-block@nongnu.org, qemu-s390x@nongnu.org,
"Peter Maydell" <peter.maydell@linaro.org>,
"Hervé Poussineau" <hpoussin@reactos.org>,
"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>
Subject: [Qemu-devel] [PATCH 3/3] tests/cdrom-test: Test that -cdrom parameter is working
Date: Thu, 15 Mar 2018 08:49:05 +0100 [thread overview]
Message-ID: <1521100145-15304-4-git-send-email-thuth@redhat.com> (raw)
In-Reply-To: <1521100145-15304-1-git-send-email-thuth@redhat.com>
Commit 1454509726719e0933c800 recently broke the "-cdrom" parameter
on a couple of boards without that we noticed it immediately. Thus
add a test which checks that "-cdrom" can at least be used to start
QEMU with certain machine types.
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
tests/Makefile.include | 7 +++++-
tests/cdrom-test.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 68 insertions(+), 2 deletions(-)
diff --git a/tests/Makefile.include b/tests/Makefile.include
index a104222..b744fea 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -321,8 +321,9 @@ check-qtest-microblaze-y = tests/boot-serial-test$(EXESUF)
check-qtest-mips-y = tests/endianness-test$(EXESUF)
check-qtest-mips64-y = tests/endianness-test$(EXESUF)
+check-qtest-mips64-y += tests/cdrom-test$(EXESUF)
-check-qtest-mips64el-y = tests/endianness-test$(EXESUF)
+check-qtest-mips64el-y = $(check-qtest-mips64-y)
check-qtest-moxie-y = tests/boot-serial-test$(EXESUF)
@@ -356,6 +357,7 @@ check-qtest-ppc64-y += tests/display-vga-test$(EXESUF)
check-qtest-ppc64-y += tests/numa-test$(EXESUF)
check-qtest-ppc64-$(CONFIG_IVSHMEM) += tests/ivshmem-test$(EXESUF)
check-qtest-ppc64-y += tests/cpu-plug-test$(EXESUF)
+check-qtest-ppc64-y += tests/cdrom-test$(EXESUF)
check-qtest-sh4-y = tests/endianness-test$(EXESUF)
@@ -365,10 +367,12 @@ check-qtest-sparc-y = tests/prom-env-test$(EXESUF)
check-qtest-sparc-y += tests/m48t59-test$(EXESUF)
gcov-files-sparc-y = hw/timer/m48t59.c
check-qtest-sparc-y += tests/boot-serial-test$(EXESUF)
+check-qtest-sparc-y += tests/cdrom-test$(EXESUF)
check-qtest-sparc64-y = tests/endianness-test$(EXESUF)
check-qtest-sparc64-y += tests/prom-env-test$(EXESUF)
check-qtest-sparc64-y += tests/boot-serial-test$(EXESUF)
+check-qtest-sparc64-y += tests/cdrom-test$(EXESUF)
check-qtest-arm-y = tests/tmp105-test$(EXESUF)
check-qtest-arm-y += tests/ds1338-test$(EXESUF)
@@ -384,6 +388,7 @@ check-qtest-arm-y += tests/sdhci-test$(EXESUF)
check-qtest-aarch64-y = tests/numa-test$(EXESUF)
check-qtest-aarch64-y += tests/sdhci-test$(EXESUF)
check-qtest-aarch64-y += tests/boot-serial-test$(EXESUF)
+check-qtest-aarch64-y += tests/cdrom-test$(EXESUF)
check-qtest-microblazeel-y = $(check-qtest-microblaze-y)
diff --git a/tests/cdrom-test.c b/tests/cdrom-test.c
index 1fc5230..5e516dd 100644
--- a/tests/cdrom-test.c
+++ b/tests/cdrom-test.c
@@ -13,6 +13,7 @@
#include "qemu/osdep.h"
#include "libqtest.h"
#include "boot-sector.h"
+#include "qapi/qmp/qdict.h"
static char isoimage[] = "cdrom-boot-iso-XXXXXX";
@@ -62,7 +63,13 @@ static int prepare_image(const char *arch, char *isoimage)
goto cleanup;
}
} else {
- g_assert_not_reached();
+ /* Just create a dummy file */
+ char txt[] = "empty disc";
+ codefile = g_strdup_printf("%s/readme.txt", srcdir);
+ if (!g_file_set_contents(codefile, txt, sizeof(txt) - 1, NULL)) {
+ fprintf(stderr, "Failed to create '%s'\n", codefile);
+ goto cleanup;
+ }
}
ret = gen_iso("-quiet -l -no-emul-boot -b %s -o %s %s",
@@ -81,6 +88,32 @@ cleanup:
return ret;
}
+/**
+ * Check that at least the -cdrom parameter is basically working, i.e. we can
+ * see the filename of the ISO image in the output of "info block" afterwards
+ */
+static void test_cdrom_param(gconstpointer data)
+{
+ QTestState *qts;
+ char *resp;
+
+ qts = qtest_startf("-M %s -cdrom %s", (const char *)data, isoimage);
+ resp = qtest_hmp(qts, "info block");
+ g_assert(strstr(resp, isoimage) != 0);
+ g_free(resp);
+ qtest_quit(qts);
+}
+
+static void add_cdrom_param_tests(const char **machines)
+{
+ while (*machines) {
+ char *testname = g_strdup_printf("cdrom/param/%s", *machines);
+ qtest_add_data_func(testname, *machines, test_cdrom_param);
+ g_free(testname);
+ machines++;
+ }
+}
+
static void test_cdboot(gconstpointer data)
{
QTestState *qts;
@@ -145,6 +178,34 @@ int main(int argc, char **argv)
add_x86_tests();
} else if (g_str_equal(arch, "s390x")) {
add_s390x_tests();
+ } else if (g_str_equal(arch, "ppc64")) {
+ const char *ppcmachines[] = {
+ "pseries", "mac99", "g3beige", "40p", "prep", NULL
+ };
+ add_cdrom_param_tests(ppcmachines);
+ } else if (g_str_equal(arch, "sparc")) {
+ const char *sparcmachines[] = {
+ "LX", "SPARCClassic", "SPARCbook", "SS-10", "SS-20", "SS-4",
+ "SS-5", "SS-600MP", "Voyager", "leon3_generic", NULL
+ };
+ add_cdrom_param_tests(sparcmachines);
+ } else if (g_str_equal(arch, "sparc64")) {
+ const char *sparc64machines[] = {
+ "niagara", "sun4u", "sun4v", NULL
+ };
+ add_cdrom_param_tests(sparc64machines);
+ } else if (!strncmp(arch, "mips64", 6)) {
+ const char *mips64machines[] = {
+ "magnum", "malta", "mips", "mipssim", "pica61", NULL
+ };
+ add_cdrom_param_tests(mips64machines);
+ } else if (g_str_equal(arch, "aarch64")) {
+ const char *aarch64machines[] = {
+ "realview-eb", "realview-eb-mpcore", "realview-pb-a8",
+ "realview-pbx-a9", "versatileab", "versatilepb", "vexpress-a15",
+ "vexpress-a9", "virt", NULL
+ };
+ add_cdrom_param_tests(aarch64machines);
}
ret = g_test_run();
--
1.8.3.1
next prev parent reply other threads:[~2018-03-15 7:49 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-15 7:49 [Qemu-devel] [PATCH 0/3] Add new CD-ROM related qtests Thomas Huth
2018-03-15 7:49 ` [Qemu-devel] [PATCH 1/3] tests/boot-sector: Add magic bytes to s390x boot code header Thomas Huth
2018-03-15 8:10 ` [Qemu-devel] [qemu-s390x] " Christian Borntraeger
2018-03-15 11:47 ` [Qemu-devel] " Philippe Mathieu-Daudé
2018-03-15 19:32 ` Thomas Huth
2018-03-15 20:18 ` Michael S. Tsirkin
2018-03-15 7:49 ` [Qemu-devel] [PATCH 2/3] tests/cdboot: Test booting from CD-ROM ISO image file Thomas Huth
2018-03-15 9:21 ` Daniel P. Berrangé
2018-03-15 10:48 ` Thomas Huth
2018-03-15 11:57 ` Eric Blake
2018-03-15 7:49 ` Thomas Huth [this message]
2018-03-15 11:42 ` [Qemu-devel] [PATCH 3/3] tests/cdrom-test: Test that -cdrom parameter is working Philippe Mathieu-Daudé
2018-03-15 19:34 ` Thomas Huth
2018-03-15 11:58 ` Eric Blake
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=1521100145-15304-4-git-send-email-thuth@redhat.com \
--to=thuth@redhat.com \
--cc=hpoussin@reactos.org \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=mst@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=victork@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).