From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: aliguori@us.ibm.com, jan.kiszka@siemens.com,
Alexander Graf <agraf@suse.de>,
alex.williamson@redhat.com, qemu-ppc@nongnu.org,
aviksil@linux.vnet.ibm.com, afaerber@suse.de
Subject: [Qemu-devel] [PATCH v3 09/16] boot-order-test: Add tests for PowerMacs
Date: Fri, 14 Jun 2013 13:15:09 +0200 [thread overview]
Message-ID: <1371208516-7857-10-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1371208516-7857-1-git-send-email-armbru@redhat.com>
From: Andreas Färber <afaerber@suse.de>
They set the boot device via fw_cfg, which is then translated to a boot
path of "hd" or "cd" in OpenBIOS.
Signed-off-by: Andreas Färber <afaerber@suse.de>
Cc: Alexander Graf <agraf@suse.de>
Cc: qemu-ppc@nongnu.org
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
tests/Makefile | 2 ++
tests/boot-order-test.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 67 insertions(+), 1 deletion(-)
diff --git a/tests/Makefile b/tests/Makefile
index 394e029..9653fce 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -67,6 +67,8 @@ gcov-files-sparc-y += hw/m48t59.c
gcov-files-sparc64-y += hw/m48t59.c
check-qtest-arm-y = tests/tmp105-test$(EXESUF)
gcov-files-arm-y += hw/tmp105.c
+check-qtest-ppc-y += tests/boot-order-test$(EXESUF)
+check-qtest-ppc64-y += tests/boot-order-test$(EXESUF)
GENERATED_HEADERS += tests/test-qapi-types.h tests/test-qapi-visit.h tests/test-qmp-commands.h
diff --git a/tests/boot-order-test.c b/tests/boot-order-test.c
index 2215710..c1cc2a6 100644
--- a/tests/boot-order-test.c
+++ b/tests/boot-order-test.c
@@ -10,8 +10,10 @@
* See the COPYING file in the top-level directory.
*/
+#include <string.h>
#include <glib.h>
#include "libqtest.h"
+#include "qemu/bswap.h"
static void test_pc_cmos_byte(int reg, int expected)
{
@@ -58,11 +60,73 @@ static void test_pc_boot_order(void)
0, 0x02, 0x30, 0x12);
}
+#define G3BEIGE_CFG_ADDR 0xf0000510
+#define MAC99_CFG_ADDR 0xf0000510
+
+#define NO_QEMU_PROTOS
+#include "hw/nvram/fw_cfg.h"
+#undef NO_QEMU_PROTOS
+
+static void powermac_fw_cfg_read(bool newworld, uint16_t cmd,
+ uint8_t *buf, unsigned int len)
+{
+ unsigned int i;
+
+ writew(newworld ? MAC99_CFG_ADDR : G3BEIGE_CFG_ADDR, cmd);
+ for (i = 0; i < len; i++) {
+ buf[i] = readb((newworld ? MAC99_CFG_ADDR : G3BEIGE_CFG_ADDR) + 2);
+ }
+}
+
+static uint16_t powermac_fw_cfg_read16(bool newworld, uint16_t cmd)
+{
+ uint16_t value;
+
+ powermac_fw_cfg_read(newworld, cmd, (uint8_t *)&value, sizeof(value));
+ return le16_to_cpu(value);
+}
+
+static void test_powermac_with_args(bool newworld, const char *extra_args,
+ uint16_t expected_boot,
+ uint16_t expected_reboot)
+{
+ char *args = g_strdup_printf("-nodefaults -display none -machine %s %s",
+ newworld ? "mac99" : "g3beige", extra_args);
+ uint16_t actual;
+ qtest_start(args);
+ actual = powermac_fw_cfg_read16(newworld, FW_CFG_BOOT_DEVICE);
+ g_assert_cmphex(actual, ==, expected_boot);
+ qmp("{ 'execute': 'system_reset' }");
+ actual = powermac_fw_cfg_read16(newworld, FW_CFG_BOOT_DEVICE);
+ g_assert_cmphex(actual, ==, expected_reboot);
+ qtest_quit(global_qtest);
+ g_free(args);
+}
+
+static void test_powermac_boot_order(void)
+{
+ int i;
+
+ for (i = 0; i < 2; i++) {
+ bool newworld = (i == 1);
+
+ test_powermac_with_args(newworld, "", 'c', 'c');
+ test_powermac_with_args(newworld, "-boot c", 'c', 'c');
+ test_powermac_with_args(newworld, "-boot d", 'd', 'd');
+ }
+}
+
int main(int argc, char *argv[])
{
+ const char *arch = qtest_get_arch();
+
g_test_init(&argc, &argv, NULL);
- qtest_add_func("boot-order/pc", test_pc_boot_order);
+ if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
+ qtest_add_func("boot-order/pc", test_pc_boot_order);
+ } else if (strcmp(arch, "ppc") == 0 || strcmp(arch, "ppc64") == 0) {
+ qtest_add_func("boot-order/powermac", test_powermac_boot_order);
+ }
return g_test_run();
}
--
1.7.11.7
next prev parent reply other threads:[~2013-06-14 11:15 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-14 11:15 [Qemu-devel] [PATCH v3 00/16] -boot and -no-fd-bootchk fixes Markus Armbruster
2013-06-14 11:15 ` [Qemu-devel] [PATCH v3 01/16] vl: Clean up parsing of -boot option argument Markus Armbruster
2013-06-14 13:36 ` Anthony Liguori
2013-06-14 11:15 ` [Qemu-devel] [PATCH v3 02/16] qemu-option: check_params() is now unused, drop it Markus Armbruster
2013-06-14 13:36 ` Anthony Liguori
2013-06-14 11:15 ` [Qemu-devel] [PATCH v3 03/16] vl: Fix -boot order and once regressions, and related bugs Markus Armbruster
2013-06-14 13:38 ` Anthony Liguori
2013-06-14 11:15 ` [Qemu-devel] [PATCH v3 04/16] vl: Rename *boot_devices to *boot_order, for consistency Markus Armbruster
2013-06-14 13:38 ` Anthony Liguori
2013-06-14 11:15 ` [Qemu-devel] [PATCH v3 05/16] pc: Make -no-fd-bootchk stick across boot order changes Markus Armbruster
2013-06-14 13:40 ` Anthony Liguori
2013-06-18 11:39 ` Markus Armbruster
2013-07-08 1:24 ` Kevin O'Connor
2013-06-14 11:15 ` [Qemu-devel] [PATCH v3 06/16] doc: Drop ref to Bochs from -no-fd-bootchk documentation Markus Armbruster
2013-06-14 13:41 ` Anthony Liguori
2013-06-14 11:15 ` [Qemu-devel] [PATCH v3 07/16] qtest: Don't reset on qtest chardev connect Markus Armbruster
2013-06-14 13:44 ` Anthony Liguori
2013-06-18 11:41 ` Markus Armbruster
2013-06-14 11:15 ` [Qemu-devel] [PATCH v3 08/16] boot-order-test: New; covering just PC for now Markus Armbruster
2013-06-14 13:48 ` Anthony Liguori
2013-06-18 13:33 ` Markus Armbruster
2013-06-18 14:13 ` Andreas Färber
2013-06-18 15:02 ` Anthony Liguori
2013-06-14 11:15 ` Markus Armbruster [this message]
2013-06-14 13:49 ` [Qemu-devel] [PATCH v3 09/16] boot-order-test: Add tests for PowerMacs Anthony Liguori
2013-06-14 11:15 ` [Qemu-devel] [PATCH v3 10/16] boot-order-test: Cover -boot once in ppc tests Markus Armbruster
2013-06-14 13:50 ` Anthony Liguori
2013-06-14 11:15 ` [Qemu-devel] [PATCH v3 11/16] boot-order-test: Better separate target-specific and generic parts Markus Armbruster
2013-06-14 13:52 ` Anthony Liguori
2013-06-14 11:15 ` [Qemu-devel] [PATCH v3 12/16] boot-order-test: Code motion for better readability Markus Armbruster
2013-06-14 11:15 ` [Qemu-devel] [PATCH v3 13/16] boot-order-test: Add tests for PowerPC PREP Markus Armbruster
2013-06-14 11:15 ` [Qemu-devel] [PATCH v3 14/16] boot-order-test: Add tests for Sun4m Markus Armbruster
2013-06-14 11:15 ` [Qemu-devel] [PATCH v3 15/16] boot-order-test: Support fw_cfg in I/O space Markus Armbruster
2013-06-14 13:53 ` Anthony Liguori
2013-06-14 14:04 ` Andreas Färber
2013-06-19 6:49 ` Markus Armbruster
2013-06-19 18:47 ` Markus Armbruster
2013-06-14 11:15 ` [Qemu-devel] [PATCH v3 16/16] boot-order-test: Add tests for Sun4u Markus Armbruster
2013-06-21 15:34 ` [Qemu-devel] [PATCH v3 00/16] -boot and -no-fd-bootchk fixes Anthony Liguori
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=1371208516-7857-10-git-send-email-armbru@redhat.com \
--to=armbru@redhat.com \
--cc=afaerber@suse.de \
--cc=agraf@suse.de \
--cc=alex.williamson@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=aviksil@linux.vnet.ibm.com \
--cc=jan.kiszka@siemens.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@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).