qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v4 00/12] Boot order tests
@ 2013-06-26 13:52 Markus Armbruster
  2013-06-26 13:52 ` [Qemu-devel] [PATCH v4 01/12] qtest: Don't reset on qtest chardev connect Markus Armbruster
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: Markus Armbruster @ 2013-06-26 13:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, jan.kiszka, mjt, alex.williamson, aviksil, afaerber

v4:
* Old PATCH 1-6 got merged, only tests left; cover letter changed
  accordingly
* PATCH 1,6 unchanged
* PATCH 2 fix system-reset race (Anthony)
* New PATCH 4,11 to make libqos/fw_cfg usable for the ppc, Sun4 tests
* New PATCH 3 shanghaied from Anthony, to make PATCH 4 compile without
  make clean.
* PATCH 5,10,12 use libqos/fw_cfg (Anthony)
* PATCH 7-9 rebased, minor tweaks
v3:
* Rebased, with only trivial conflicts
* PATCH 08 cosmetic improvements
* More test cases: new PATCH 09-16
v2:
* New PATCH 7 to make testing -boot once possible
* Old PATCH 5 reworked and extended became PATCH 8
* Writing more tests uncovered -no-fd-bootchk weirdness, cleaned up in
  new PATCH 5+6

Andreas Färber (1):
  boot-order-test: Add tests for PowerMacs

Anthony Liguori (1):
  libqos: include dependencies

Markus Armbruster (10):
  qtest: Don't reset on qtest chardev connect
  boot-order-test: New; covering just PC for now
  libqos: Add support for memory-mapped fw_cfg
  boot-order-test: Cover -boot once in ppc tests
  boot-order-test: Better separate target-specific and generic parts
  boot-order-test: Code motion for better readability
  boot-order-test: Add tests for PowerPC PREP
  boot-order-test: Add tests for Sun4m
  libqos: Generalize I/O-mapped fw_cfg
  boot-order-test: Add tests for Sun4u

 qtest.c                  |   7 +-
 tests/Makefile           |   7 +-
 tests/boot-order-test.c  | 209 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/fw_cfg-test.c      |   2 +-
 tests/libqos/fw_cfg-pc.c |  40 ---------
 tests/libqos/fw_cfg-pc.h |  20 -----
 tests/libqos/fw_cfg.c    |  55 +++++++++++++
 tests/libqos/fw_cfg.h    |   9 ++
 tests/libqos/malloc-pc.c |   2 +-
 9 files changed, 287 insertions(+), 64 deletions(-)
 create mode 100644 tests/boot-order-test.c
 delete mode 100644 tests/libqos/fw_cfg-pc.c
 delete mode 100644 tests/libqos/fw_cfg-pc.h

-- 
1.7.11.7

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Qemu-devel] [PATCH v4 01/12] qtest: Don't reset on qtest chardev connect
  2013-06-26 13:52 [Qemu-devel] [PATCH v4 00/12] Boot order tests Markus Armbruster
@ 2013-06-26 13:52 ` Markus Armbruster
  2013-06-26 13:52 ` [Qemu-devel] [PATCH v4 02/12] boot-order-test: New; covering just PC for now Markus Armbruster
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Markus Armbruster @ 2013-06-26 13:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, jan.kiszka, mjt, alex.williamson, aviksil, afaerber

libqtest's qtest_init() connecting to the qtest socket triggers reset.
This was coded in the hope we could use the same QEMU process for
multiple tests that way.  Never used.  Injects an extra reset even
when it's not used, and that can mess up tests such as the one of
-boot once I'm about to add.  Drop it.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 qtest.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/qtest.c b/qtest.c
index 07a9612..74f1842 100644
--- a/qtest.c
+++ b/qtest.c
@@ -472,7 +472,12 @@ static void qtest_event(void *opaque, int event)
 
     switch (event) {
     case CHR_EVENT_OPENED:
-        qemu_system_reset(false);
+        /*
+         * We used to call qemu_system_reset() here, hoping we could
+         * use the same process for multiple tests that way.  Never
+         * used.  Injects an extra reset even when it's not used, and
+         * that can mess up tests, e.g. -boot once.
+         */
         for (i = 0; i < ARRAY_SIZE(irq_levels); i++) {
             irq_levels[i] = 0;
         }
-- 
1.7.11.7

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Qemu-devel] [PATCH v4 02/12] boot-order-test: New; covering just PC for now
  2013-06-26 13:52 [Qemu-devel] [PATCH v4 00/12] Boot order tests Markus Armbruster
  2013-06-26 13:52 ` [Qemu-devel] [PATCH v4 01/12] qtest: Don't reset on qtest chardev connect Markus Armbruster
@ 2013-06-26 13:52 ` Markus Armbruster
  2013-06-26 13:52 ` [Qemu-devel] [PATCH v4 03/12] libqos: include dependencies Markus Armbruster
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Markus Armbruster @ 2013-06-26 13:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, jan.kiszka, mjt, alex.williamson, aviksil, afaerber


Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 tests/Makefile          |  2 ++
 tests/boot-order-test.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 75 insertions(+)
 create mode 100644 tests/boot-order-test.c

diff --git a/tests/Makefile b/tests/Makefile
index c107489..394e029 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -54,6 +54,7 @@ gcov-files-i386-y = hw/fdc.c
 check-qtest-i386-y += tests/ide-test$(EXESUF)
 check-qtest-i386-y += tests/hd-geo-test$(EXESUF)
 gcov-files-i386-y += hw/hd-geometry.c
+check-qtest-i386-y += tests/boot-order-test$(EXESUF)
 check-qtest-i386-y += tests/rtc-test$(EXESUF)
 check-qtest-i386-y += tests/i440fx-test$(EXESUF)
 check-qtest-i386-y += tests/fw_cfg-test$(EXESUF)
@@ -130,6 +131,7 @@ tests/m48t59-test$(EXESUF): tests/m48t59-test.o
 tests/fdc-test$(EXESUF): tests/fdc-test.o
 tests/ide-test$(EXESUF): tests/ide-test.o $(libqos-pc-obj-y)
 tests/hd-geo-test$(EXESUF): tests/hd-geo-test.o
+tests/boot-order-test$(EXESUF): tests/boot-order-test.o
 tests/tmp105-test$(EXESUF): tests/tmp105-test.o $(libqos-omap-obj-y)
 tests/i440fx-test$(EXESUF): tests/i440fx-test.o $(libqos-pc-obj-y)
 tests/fw_cfg-test$(EXESUF): tests/fw_cfg-test.o $(libqos-pc-obj-y)
diff --git a/tests/boot-order-test.c b/tests/boot-order-test.c
new file mode 100644
index 0000000..447be31
--- /dev/null
+++ b/tests/boot-order-test.c
@@ -0,0 +1,73 @@
+/*
+ * Boot order test cases.
+ *
+ * Copyright (c) 2013 Red Hat Inc.
+ *
+ * Authors:
+ *  Markus Armbruster <armbru@redhat.com>,
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include <glib.h>
+#include "libqtest.h"
+
+static void test_pc_cmos_byte(int reg, int expected)
+{
+    int actual;
+
+    outb(0x70, reg);
+    actual = inb(0x71);
+    g_assert_cmphex(actual, ==, expected);
+}
+
+static void test_pc_cmos(uint8_t boot1, uint8_t boot2)
+{
+    test_pc_cmos_byte(0x38, boot1);
+    test_pc_cmos_byte(0x3d, boot2);
+}
+
+static void test_pc_with_args(const char *test_args,
+                              uint8_t boot1, uint8_t boot2,
+                              uint8_t reboot1, uint8_t reboot2)
+{
+    char *args = g_strdup_printf("-nodefaults -display none %s", test_args);
+
+    qtest_start(args);
+    test_pc_cmos(boot1, boot2);
+    qmp("{ 'execute': 'system_reset' }");
+    /*
+     * system_reset only requests reset.  We get a RESET event after
+     * the actual reset completes.  Need to wait for that.
+     */
+    qmp("");                    /* HACK: wait for event */
+    test_pc_cmos(reboot1, reboot2);
+    qtest_quit(global_qtest);
+    g_free(args);
+}
+
+static void test_pc_boot_order(void)
+{
+    test_pc_with_args("", 0x30, 0x12, 0x30, 0x12);
+    test_pc_with_args("-no-fd-bootchk", 0x31, 0x12, 0x31, 0x12);
+    test_pc_with_args("-boot c", 0, 0x02, 0, 0x02);
+    test_pc_with_args("-boot nda", 0x10, 0x34, 0x10, 0x34);
+    test_pc_with_args("-boot order=", 0, 0, 0, 0);
+    test_pc_with_args("-boot order= -boot order=c", 0, 0x02, 0, 0x02);
+    test_pc_with_args("-boot once=a", 0, 0x01, 0x30, 0x12);
+    test_pc_with_args("-boot once=a -no-fd-bootchk", 0x01, 0x01, 0x31, 0x12);
+    test_pc_with_args("-boot once=a,order=c", 0, 0x01, 0, 0x02);
+    test_pc_with_args("-boot once=d -boot order=nda", 0, 0x03, 0x10, 0x34);
+    test_pc_with_args("-boot once=a -boot once=b -boot once=c",
+                      0, 0x02, 0x30, 0x12);
+}
+
+int main(int argc, char *argv[])
+{
+    g_test_init(&argc, &argv, NULL);
+
+    qtest_add_func("boot-order/pc", test_pc_boot_order);
+
+    return g_test_run();
+}
-- 
1.7.11.7

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Qemu-devel] [PATCH v4 03/12] libqos: include dependencies
  2013-06-26 13:52 [Qemu-devel] [PATCH v4 00/12] Boot order tests Markus Armbruster
  2013-06-26 13:52 ` [Qemu-devel] [PATCH v4 01/12] qtest: Don't reset on qtest chardev connect Markus Armbruster
  2013-06-26 13:52 ` [Qemu-devel] [PATCH v4 02/12] boot-order-test: New; covering just PC for now Markus Armbruster
@ 2013-06-26 13:52 ` Markus Armbruster
  2013-06-26 13:52 ` [Qemu-devel] [PATCH v4 04/12] libqos: Add support for memory-mapped fw_cfg Markus Armbruster
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Markus Armbruster @ 2013-06-26 13:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, jan.kiszka, mjt, alex.williamson, aviksil, afaerber

From: Anthony Liguori <aliguori@us.ibm.com>

Otherwise rebuilds can fail when libqos is modified.

Reported-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 tests/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/Makefile b/tests/Makefile
index 394e029..34a2325 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -224,3 +224,4 @@ check-block: $(patsubst %,check-%, $(check-block-y))
 check: check-unit check-qtest
 
 -include $(wildcard tests/*.d)
+-include $(wildcard tests/libqos/*.d)
-- 
1.7.11.7

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Qemu-devel] [PATCH v4 04/12] libqos: Add support for memory-mapped fw_cfg
  2013-06-26 13:52 [Qemu-devel] [PATCH v4 00/12] Boot order tests Markus Armbruster
                   ` (2 preceding siblings ...)
  2013-06-26 13:52 ` [Qemu-devel] [PATCH v4 03/12] libqos: include dependencies Markus Armbruster
@ 2013-06-26 13:52 ` Markus Armbruster
  2013-06-26 13:52 ` [Qemu-devel] [PATCH v4 05/12] boot-order-test: Add tests for PowerMacs Markus Armbruster
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Markus Armbruster @ 2013-06-26 13:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, jan.kiszka, mjt, alex.williamson, aviksil, afaerber

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 tests/libqos/fw_cfg.c | 29 +++++++++++++++++++++++++++++
 tests/libqos/fw_cfg.h |  3 +++
 2 files changed, 32 insertions(+)

diff --git a/tests/libqos/fw_cfg.c b/tests/libqos/fw_cfg.c
index e386ff7..49d1683 100644
--- a/tests/libqos/fw_cfg.c
+++ b/tests/libqos/fw_cfg.c
@@ -2,15 +2,19 @@
  * libqos fw_cfg support
  *
  * Copyright IBM, Corp. 2012-2013
+ * Copyright (C) 2013 Red Hat Inc.
  *
  * Authors:
  *  Anthony Liguori   <aliguori@us.ibm.com>
+ *  Markus Armbruster <armbru@redhat.com>
  *
  * This work is licensed under the terms of the GNU GPL, version 2 or later.
  * See the COPYING file in the top-level directory.
  */
 
+#include <glib.h>
 #include "libqos/fw_cfg.h"
+#include "libqtest.h"
 #include "qemu/bswap.h"
 
 void qfw_cfg_select(QFWCFG *fw_cfg, uint16_t key)
@@ -50,3 +54,28 @@ uint64_t qfw_cfg_get_u64(QFWCFG *fw_cfg, uint16_t key)
     return le64_to_cpu(value);
 }
 
+static void mm_fw_cfg_select(QFWCFG *fw_cfg, uint16_t key)
+{
+    writew(fw_cfg->base, key);
+}
+
+static void mm_fw_cfg_read(QFWCFG *fw_cfg, void *data, size_t len)
+{
+    uint8_t *ptr = data;
+    int i;
+
+    for (i = 0; i < len; i++) {
+        ptr[i] = readb(fw_cfg->base + 2);
+    }
+}
+
+QFWCFG *mm_fw_cfg_init(uint64_t base)
+{
+    QFWCFG *fw_cfg = g_malloc0(sizeof(*fw_cfg));
+
+    fw_cfg->base = base;
+    fw_cfg->select = mm_fw_cfg_select;
+    fw_cfg->read = mm_fw_cfg_read;
+
+    return fw_cfg;
+}
diff --git a/tests/libqos/fw_cfg.h b/tests/libqos/fw_cfg.h
index 44fc42b..19bb053 100644
--- a/tests/libqos/fw_cfg.h
+++ b/tests/libqos/fw_cfg.h
@@ -20,6 +20,7 @@ typedef struct QFWCFG QFWCFG;
 
 struct QFWCFG
 {
+    uint64_t base;
     void (*select)(QFWCFG *fw_cfg, uint16_t key);
     void (*read)(QFWCFG *fw_cfg, void *data, size_t len);
 };
@@ -31,4 +32,6 @@ uint16_t qfw_cfg_get_u16(QFWCFG *fw_cfg, uint16_t key);
 uint32_t qfw_cfg_get_u32(QFWCFG *fw_cfg, uint16_t key);
 uint64_t qfw_cfg_get_u64(QFWCFG *fw_cfg, uint16_t key);
 
+QFWCFG *mm_fw_cfg_init(uint64_t base);
+
 #endif
-- 
1.7.11.7

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Qemu-devel] [PATCH v4 05/12] boot-order-test: Add tests for PowerMacs
  2013-06-26 13:52 [Qemu-devel] [PATCH v4 00/12] Boot order tests Markus Armbruster
                   ` (3 preceding siblings ...)
  2013-06-26 13:52 ` [Qemu-devel] [PATCH v4 04/12] libqos: Add support for memory-mapped fw_cfg Markus Armbruster
@ 2013-06-26 13:52 ` Markus Armbruster
  2013-06-26 13:52 ` [Qemu-devel] [PATCH v4 06/12] boot-order-test: Cover -boot once in ppc tests Markus Armbruster
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Markus Armbruster @ 2013-06-26 13:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: aliguori, jan.kiszka, mjt, Alexander Graf, alex.williamson,
	qemu-ppc, aviksil, afaerber

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
Converted to libqos/fw_cfg on Anthony's request.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 tests/Makefile          |  4 +++-
 tests/boot-order-test.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 52 insertions(+), 2 deletions(-)

diff --git a/tests/Makefile b/tests/Makefile
index 34a2325..8c7352d 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
 
@@ -131,7 +133,7 @@ tests/m48t59-test$(EXESUF): tests/m48t59-test.o
 tests/fdc-test$(EXESUF): tests/fdc-test.o
 tests/ide-test$(EXESUF): tests/ide-test.o $(libqos-pc-obj-y)
 tests/hd-geo-test$(EXESUF): tests/hd-geo-test.o
-tests/boot-order-test$(EXESUF): tests/boot-order-test.o
+tests/boot-order-test$(EXESUF): tests/boot-order-test.o $(libqos-obj-y)
 tests/tmp105-test$(EXESUF): tests/tmp105-test.o $(libqos-omap-obj-y)
 tests/i440fx-test$(EXESUF): tests/i440fx-test.o $(libqos-pc-obj-y)
 tests/fw_cfg-test$(EXESUF): tests/fw_cfg-test.o $(libqos-pc-obj-y)
diff --git a/tests/boot-order-test.c b/tests/boot-order-test.c
index 447be31..766981d 100644
--- a/tests/boot-order-test.c
+++ b/tests/boot-order-test.c
@@ -10,7 +10,9 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include <string.h>
 #include <glib.h>
+#include "libqos/fw_cfg.h"
 #include "libqtest.h"
 
 static void test_pc_cmos_byte(int reg, int expected)
@@ -63,11 +65,57 @@ 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 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);
+    QFWCFG *fw_cfg = mm_fw_cfg_init(newworld ? MAC99_CFG_ADDR
+                                    : G3BEIGE_CFG_ADDR);
+    uint16_t actual;
+
+    qtest_start(args);
+    actual = qfw_cfg_get_u16(fw_cfg, FW_CFG_BOOT_DEVICE);
+    g_assert_cmphex(actual, ==, expected_boot);
+    qmp("{ 'execute': 'system_reset' }");
+    actual = qfw_cfg_get_u16(fw_cfg, 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

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Qemu-devel] [PATCH v4 06/12] boot-order-test: Cover -boot once in ppc tests
  2013-06-26 13:52 [Qemu-devel] [PATCH v4 00/12] Boot order tests Markus Armbruster
                   ` (4 preceding siblings ...)
  2013-06-26 13:52 ` [Qemu-devel] [PATCH v4 05/12] boot-order-test: Add tests for PowerMacs Markus Armbruster
@ 2013-06-26 13:52 ` Markus Armbruster
  2013-06-26 13:52 ` [Qemu-devel] [PATCH v4 07/12] boot-order-test: Better separate target-specific and generic parts Markus Armbruster
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Markus Armbruster @ 2013-06-26 13:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: aliguori, jan.kiszka, mjt, Alexander Graf, alex.williamson,
	qemu-ppc, aviksil, afaerber

Cc: 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/boot-order-test.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/boot-order-test.c b/tests/boot-order-test.c
index 766981d..1a8e22a 100644
--- a/tests/boot-order-test.c
+++ b/tests/boot-order-test.c
@@ -102,6 +102,7 @@ static void test_powermac_boot_order(void)
         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');
+        test_powermac_with_args(newworld, "-boot once=d,order=c", 'd', 'c');
     }
 }
 
-- 
1.7.11.7

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Qemu-devel] [PATCH v4 07/12] boot-order-test: Better separate target-specific and generic parts
  2013-06-26 13:52 [Qemu-devel] [PATCH v4 00/12] Boot order tests Markus Armbruster
                   ` (5 preceding siblings ...)
  2013-06-26 13:52 ` [Qemu-devel] [PATCH v4 06/12] boot-order-test: Cover -boot once in ppc tests Markus Armbruster
@ 2013-06-26 13:52 ` Markus Armbruster
  2013-06-26 13:52 ` [Qemu-devel] [PATCH v4 08/12] boot-order-test: Code motion for better readability Markus Armbruster
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Markus Armbruster @ 2013-06-26 13:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: aliguori, jan.kiszka, mjt, Alexander Graf, alex.williamson,
	qemu-ppc, aviksil, afaerber

The initial version did just PC.  I didn't bother to separate out
generic parts, because I don't like to abstract from a single case.

Now we have two cases, PC and PowerMac, and I'm about to add more.
Time to do it right.

To ease review, this commit changes the code in-place, and the next
commit reorders it for better readability.

Cc: 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/boot-order-test.c | 148 +++++++++++++++++++++++++++++-------------------
 1 file changed, 91 insertions(+), 57 deletions(-)

diff --git a/tests/boot-order-test.c b/tests/boot-order-test.c
index 1a8e22a..78249fc 100644
--- a/tests/boot-order-test.c
+++ b/tests/boot-order-test.c
@@ -15,95 +15,126 @@
 #include "libqos/fw_cfg.h"
 #include "libqtest.h"
 
-static void test_pc_cmos_byte(int reg, int expected)
+static uint8_t read_mc146818(uint16_t port, uint8_t reg)
 {
-    int actual;
-
-    outb(0x70, reg);
-    actual = inb(0x71);
-    g_assert_cmphex(actual, ==, expected);
+    outb(port, reg);
+    return inb(port + 1);
 }
 
-static void test_pc_cmos(uint8_t boot1, uint8_t boot2)
+static uint64_t read_boot_order_pc(void)
 {
-    test_pc_cmos_byte(0x38, boot1);
-    test_pc_cmos_byte(0x3d, boot2);
+    uint8_t b1 = read_mc146818(0x70, 0x38);
+    uint8_t b2 = read_mc146818(0x70, 0x3d);
+
+    return b1 | (b2 << 8);
 }
 
-static void test_pc_with_args(const char *test_args,
-                              uint8_t boot1, uint8_t boot2,
-                              uint8_t reboot1, uint8_t reboot2)
+static void test_a_boot_order(const char *machine,
+                              const char *test_args,
+                              uint64_t (*read_boot_order)(void),
+                              uint64_t expected_boot,
+                              uint64_t expected_reboot)
 {
-    char *args = g_strdup_printf("-nodefaults -display none %s", test_args);
+    char *args;
+    uint64_t actual;
 
+    args = g_strdup_printf("-nodefaults -display none%s%s %s",
+                           machine ? " -M " : "",
+                           machine ?: "",
+                           test_args);
     qtest_start(args);
-    test_pc_cmos(boot1, boot2);
+    actual = read_boot_order();
+    g_assert_cmphex(actual, ==, expected_boot);
     qmp("{ 'execute': 'system_reset' }");
     /*
      * system_reset only requests reset.  We get a RESET event after
      * the actual reset completes.  Need to wait for that.
      */
     qmp("");                    /* HACK: wait for event */
-    test_pc_cmos(reboot1, reboot2);
+    actual = read_boot_order();
+    g_assert_cmphex(actual, ==, expected_reboot);
     qtest_quit(global_qtest);
     g_free(args);
 }
 
-static void test_pc_boot_order(void)
+typedef struct {
+    const char *args;
+    uint64_t expected_boot;
+    uint64_t expected_reboot;
+} boot_order_test;
+
+static void test_boot_orders(const char *machine,
+                             uint64_t (*read_boot_order)(void),
+                             const boot_order_test *tests)
 {
-    test_pc_with_args("", 0x30, 0x12, 0x30, 0x12);
-    test_pc_with_args("-no-fd-bootchk", 0x31, 0x12, 0x31, 0x12);
-    test_pc_with_args("-boot c", 0, 0x02, 0, 0x02);
-    test_pc_with_args("-boot nda", 0x10, 0x34, 0x10, 0x34);
-    test_pc_with_args("-boot order=", 0, 0, 0, 0);
-    test_pc_with_args("-boot order= -boot order=c", 0, 0x02, 0, 0x02);
-    test_pc_with_args("-boot once=a", 0, 0x01, 0x30, 0x12);
-    test_pc_with_args("-boot once=a -no-fd-bootchk", 0x01, 0x01, 0x31, 0x12);
-    test_pc_with_args("-boot once=a,order=c", 0, 0x01, 0, 0x02);
-    test_pc_with_args("-boot once=d -boot order=nda", 0, 0x03, 0x10, 0x34);
-    test_pc_with_args("-boot once=a -boot once=b -boot once=c",
-                      0, 0x02, 0x30, 0x12);
+    int i;
+
+    for (i = 0; tests[i].args; i++) {
+        test_a_boot_order(machine, tests[i].args,
+                          read_boot_order,
+                          tests[i].expected_boot,
+                          tests[i].expected_reboot);
+    }
 }
 
-#define G3BEIGE_CFG_ADDR 0xf0000510
-#define MAC99_CFG_ADDR   0xf0000510
+static const boot_order_test test_cases_pc[] = {
+    { "",
+      0x1230, 0x1230 },
+    { "-no-fd-bootchk",
+      0x1231, 0x1231 },
+    { "-boot c",
+      0x0200, 0x0200 },
+    { "-boot nda",
+      0x3410, 0x3410 },
+    { "-boot order=",
+      0, 0 },
+    { "-boot order= -boot order=c",
+      0x0200, 0x0200 },
+    { "-boot once=a",
+      0x0100, 0x1230 },
+    { "-boot once=a -no-fd-bootchk",
+      0x0101, 0x1231 },
+    { "-boot once=a,order=c",
+      0x0100, 0x0200 },
+    { "-boot once=d -boot order=nda",
+      0x0300, 0x3410 },
+    { "-boot once=a -boot once=b -boot once=c",
+      0x0200, 0x1230 },
+    {}
+};
+
+static void test_pc_boot_order(void)
+{
+    test_boot_orders(NULL, read_boot_order_pc, test_cases_pc);
+}
 
 #define NO_QEMU_PROTOS
 #include "hw/nvram/fw_cfg.h"
 #undef NO_QEMU_PROTOS
 
-static void test_powermac_with_args(bool newworld, const char *extra_args,
-                                    uint16_t expected_boot,
-                                    uint16_t expected_reboot)
+static uint64_t read_boot_order_pmac(void)
 {
-    char *args = g_strdup_printf("-nodefaults -display none -machine %s %s",
-                                 newworld ? "mac99" : "g3beige", extra_args);
-    QFWCFG *fw_cfg = mm_fw_cfg_init(newworld ? MAC99_CFG_ADDR
-                                    : G3BEIGE_CFG_ADDR);
-    uint16_t actual;
+    QFWCFG *fw_cfg = mm_fw_cfg_init(0xf0000510);
 
-    qtest_start(args);
-    actual = qfw_cfg_get_u16(fw_cfg, FW_CFG_BOOT_DEVICE);
-    g_assert_cmphex(actual, ==, expected_boot);
-    qmp("{ 'execute': 'system_reset' }");
-    actual = qfw_cfg_get_u16(fw_cfg, FW_CFG_BOOT_DEVICE);
-    g_assert_cmphex(actual, ==, expected_reboot);
-    qtest_quit(global_qtest);
-    g_free(args);
+    return qfw_cfg_get_u16(fw_cfg, FW_CFG_BOOT_DEVICE);
 }
 
-static void test_powermac_boot_order(void)
-{
-    int i;
+static const boot_order_test test_cases_fw_cfg[] = {
+    { "", 'c', 'c' },
+    { "-boot c", 'c', 'c' },
+    { "-boot d", 'd', 'd' },
+    { "-boot once=d,order=c", 'd', 'c' },
+    {}
+};
 
-    for (i = 0; i < 2; i++) {
-        bool newworld = (i == 1);
+static void test_pmac_oldworld_boot_order(void)
+{
+    test_boot_orders("g3beige", read_boot_order_pmac, test_cases_fw_cfg);
+}
 
-        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');
-        test_powermac_with_args(newworld, "-boot once=d,order=c", 'd', 'c');
-    }
+static void test_pmac_newworld_boot_order(void)
+{
+    test_boot_orders("mac99", read_boot_order_pmac, test_cases_fw_cfg);
 }
 
 int main(int argc, char *argv[])
@@ -115,7 +146,10 @@ int main(int argc, char *argv[])
     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);
+        qtest_add_func("boot-order/pmac_oldworld",
+                       test_pmac_oldworld_boot_order);
+        qtest_add_func("boot-order/pmac_newworld",
+                       test_pmac_newworld_boot_order);
     }
 
     return g_test_run();
-- 
1.7.11.7

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Qemu-devel] [PATCH v4 08/12] boot-order-test: Code motion for better readability
  2013-06-26 13:52 [Qemu-devel] [PATCH v4 00/12] Boot order tests Markus Armbruster
                   ` (6 preceding siblings ...)
  2013-06-26 13:52 ` [Qemu-devel] [PATCH v4 07/12] boot-order-test: Better separate target-specific and generic parts Markus Armbruster
@ 2013-06-26 13:52 ` Markus Armbruster
  2013-06-26 13:52 ` [Qemu-devel] [PATCH v4 09/12] boot-order-test: Add tests for PowerPC PREP Markus Armbruster
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Markus Armbruster @ 2013-06-26 13:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: aliguori, jan.kiszka, mjt, Alexander Graf, alex.williamson,
	qemu-ppc, aviksil, afaerber

Cc: 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/boot-order-test.c | 44 ++++++++++++++++++++++----------------------
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/tests/boot-order-test.c b/tests/boot-order-test.c
index 78249fc..c711c71 100644
--- a/tests/boot-order-test.c
+++ b/tests/boot-order-test.c
@@ -15,19 +15,15 @@
 #include "libqos/fw_cfg.h"
 #include "libqtest.h"
 
-static uint8_t read_mc146818(uint16_t port, uint8_t reg)
-{
-    outb(port, reg);
-    return inb(port + 1);
-}
-
-static uint64_t read_boot_order_pc(void)
-{
-    uint8_t b1 = read_mc146818(0x70, 0x38);
-    uint8_t b2 = read_mc146818(0x70, 0x3d);
+#define NO_QEMU_PROTOS
+#include "hw/nvram/fw_cfg.h"
+#undef NO_QEMU_PROTOS
 
-    return b1 | (b2 << 8);
-}
+typedef struct {
+    const char *args;
+    uint64_t expected_boot;
+    uint64_t expected_reboot;
+} boot_order_test;
 
 static void test_a_boot_order(const char *machine,
                               const char *test_args,
@@ -57,12 +53,6 @@ static void test_a_boot_order(const char *machine,
     g_free(args);
 }
 
-typedef struct {
-    const char *args;
-    uint64_t expected_boot;
-    uint64_t expected_reboot;
-} boot_order_test;
-
 static void test_boot_orders(const char *machine,
                              uint64_t (*read_boot_order)(void),
                              const boot_order_test *tests)
@@ -77,6 +67,20 @@ static void test_boot_orders(const char *machine,
     }
 }
 
+static uint8_t read_mc146818(uint16_t port, uint8_t reg)
+{
+    outb(port, reg);
+    return inb(port + 1);
+}
+
+static uint64_t read_boot_order_pc(void)
+{
+    uint8_t b1 = read_mc146818(0x70, 0x38);
+    uint8_t b2 = read_mc146818(0x70, 0x3d);
+
+    return b1 | (b2 << 8);
+}
+
 static const boot_order_test test_cases_pc[] = {
     { "",
       0x1230, 0x1230 },
@@ -108,10 +112,6 @@ static void test_pc_boot_order(void)
     test_boot_orders(NULL, read_boot_order_pc, test_cases_pc);
 }
 
-#define NO_QEMU_PROTOS
-#include "hw/nvram/fw_cfg.h"
-#undef NO_QEMU_PROTOS
-
 static uint64_t read_boot_order_pmac(void)
 {
     QFWCFG *fw_cfg = mm_fw_cfg_init(0xf0000510);
-- 
1.7.11.7

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Qemu-devel] [PATCH v4 09/12] boot-order-test: Add tests for PowerPC PREP
  2013-06-26 13:52 [Qemu-devel] [PATCH v4 00/12] Boot order tests Markus Armbruster
                   ` (7 preceding siblings ...)
  2013-06-26 13:52 ` [Qemu-devel] [PATCH v4 08/12] boot-order-test: Code motion for better readability Markus Armbruster
@ 2013-06-26 13:52 ` Markus Armbruster
  2013-06-26 13:52 ` [Qemu-devel] [PATCH v4 10/12] boot-order-test: Add tests for Sun4m Markus Armbruster
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Markus Armbruster @ 2013-06-26 13:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: aliguori, jan.kiszka, mjt, Alexander Graf, alex.williamson,
	qemu-ppc, aviksil, afaerber

Cc: 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/boot-order-test.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/tests/boot-order-test.c b/tests/boot-order-test.c
index c711c71..75b1642 100644
--- a/tests/boot-order-test.c
+++ b/tests/boot-order-test.c
@@ -112,6 +112,30 @@ static void test_pc_boot_order(void)
     test_boot_orders(NULL, read_boot_order_pc, test_cases_pc);
 }
 
+static uint8_t read_m48t59(uint64_t addr, uint16_t reg)
+{
+    writeb(addr, reg & 0xff);
+    writeb(addr + 1, reg >> 8);
+    return readb(addr + 3);
+}
+
+static uint64_t read_boot_order_prep(void)
+{
+    return read_m48t59(0x80000000 + 0x74, 0x34);
+}
+
+static const boot_order_test test_cases_prep[] = {
+    { "", 'c', 'c' },
+    { "-boot c", 'c', 'c' },
+    { "-boot d", 'd', 'd' },
+    {}
+};
+
+static void test_prep_boot_order(void)
+{
+    test_boot_orders("prep", read_boot_order_prep, test_cases_prep);
+}
+
 static uint64_t read_boot_order_pmac(void)
 {
     QFWCFG *fw_cfg = mm_fw_cfg_init(0xf0000510);
@@ -146,6 +170,7 @@ int main(int argc, char *argv[])
     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/prep", test_prep_boot_order);
         qtest_add_func("boot-order/pmac_oldworld",
                        test_pmac_oldworld_boot_order);
         qtest_add_func("boot-order/pmac_newworld",
-- 
1.7.11.7

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Qemu-devel] [PATCH v4 10/12] boot-order-test: Add tests for Sun4m
  2013-06-26 13:52 [Qemu-devel] [PATCH v4 00/12] Boot order tests Markus Armbruster
                   ` (8 preceding siblings ...)
  2013-06-26 13:52 ` [Qemu-devel] [PATCH v4 09/12] boot-order-test: Add tests for PowerPC PREP Markus Armbruster
@ 2013-06-26 13:52 ` Markus Armbruster
  2013-06-26 13:52 ` [Qemu-devel] [PATCH v4 11/12] libqos: Generalize I/O-mapped fw_cfg Markus Armbruster
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Markus Armbruster @ 2013-06-26 13:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: aliguori, jan.kiszka, mjt, Blue Swirl, alex.williamson, aviksil,
	afaerber

Cc: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 tests/boot-order-test.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/tests/boot-order-test.c b/tests/boot-order-test.c
index 75b1642..a3928ed 100644
--- a/tests/boot-order-test.c
+++ b/tests/boot-order-test.c
@@ -161,6 +161,18 @@ static void test_pmac_newworld_boot_order(void)
     test_boot_orders("mac99", read_boot_order_pmac, test_cases_fw_cfg);
 }
 
+static uint64_t read_boot_order_sun4m(void)
+{
+    QFWCFG *fw_cfg = mm_fw_cfg_init(0xd00000510ULL);
+
+    return qfw_cfg_get_u16(fw_cfg, FW_CFG_BOOT_DEVICE);
+}
+
+static void test_sun4m_boot_order(void)
+{
+    test_boot_orders("SS-5", read_boot_order_sun4m, test_cases_fw_cfg);
+}
+
 int main(int argc, char *argv[])
 {
     const char *arch = qtest_get_arch();
@@ -175,6 +187,8 @@ int main(int argc, char *argv[])
                        test_pmac_oldworld_boot_order);
         qtest_add_func("boot-order/pmac_newworld",
                        test_pmac_newworld_boot_order);
+    } else if (strcmp(arch, "sparc") == 0) {
+        qtest_add_func("boot-order/sun4m", test_sun4m_boot_order);
     }
 
     return g_test_run();
-- 
1.7.11.7

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Qemu-devel] [PATCH v4 11/12] libqos: Generalize I/O-mapped fw_cfg
  2013-06-26 13:52 [Qemu-devel] [PATCH v4 00/12] Boot order tests Markus Armbruster
                   ` (9 preceding siblings ...)
  2013-06-26 13:52 ` [Qemu-devel] [PATCH v4 10/12] boot-order-test: Add tests for Sun4m Markus Armbruster
@ 2013-06-26 13:52 ` Markus Armbruster
  2013-06-26 13:52 ` [Qemu-devel] [PATCH v4 12/12] boot-order-test: Add tests for Sun4u Markus Armbruster
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Markus Armbruster @ 2013-06-26 13:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, jan.kiszka, mjt, alex.williamson, aviksil, afaerber

Provide a constructor that takes the base address in addition to the
PC-specific one.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 tests/Makefile           |  2 +-
 tests/fw_cfg-test.c      |  2 +-
 tests/libqos/fw_cfg-pc.c | 40 ----------------------------------------
 tests/libqos/fw_cfg-pc.h | 20 --------------------
 tests/libqos/fw_cfg.c    | 26 ++++++++++++++++++++++++++
 tests/libqos/fw_cfg.h    |  6 ++++++
 tests/libqos/malloc-pc.c |  2 +-
 7 files changed, 35 insertions(+), 63 deletions(-)
 delete mode 100644 tests/libqos/fw_cfg-pc.c
 delete mode 100644 tests/libqos/fw_cfg-pc.h

diff --git a/tests/Makefile b/tests/Makefile
index 8c7352d..708eb79 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -124,7 +124,7 @@ tests/test-mul64$(EXESUF): tests/test-mul64.o libqemuutil.a
 
 libqos-obj-y = tests/libqos/pci.o tests/libqos/fw_cfg.o
 libqos-obj-y += tests/libqos/i2c.o
-libqos-pc-obj-y = $(libqos-obj-y) tests/libqos/pci-pc.o tests/libqos/fw_cfg-pc.o
+libqos-pc-obj-y = $(libqos-obj-y) tests/libqos/pci-pc.o
 libqos-pc-obj-y += tests/libqos/malloc-pc.o
 libqos-omap-obj-y = $(libqos-obj-y) tests/libqos/i2c-omap.o
 
diff --git a/tests/fw_cfg-test.c b/tests/fw_cfg-test.c
index c284c4d..b86e49a 100644
--- a/tests/fw_cfg-test.c
+++ b/tests/fw_cfg-test.c
@@ -14,7 +14,7 @@
 
 #include "libqtest.h"
 #include "hw/nvram/fw_cfg.h"
-#include "libqos/fw_cfg-pc.h"
+#include "libqos/fw_cfg.h"
 
 #include <string.h>
 #include <glib.h>
diff --git a/tests/libqos/fw_cfg-pc.c b/tests/libqos/fw_cfg-pc.c
deleted file mode 100644
index 613604d..0000000
--- a/tests/libqos/fw_cfg-pc.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * libqos fw_cfg support for PC
- *
- * Copyright IBM, Corp. 2012-2013
- *
- * Authors:
- *  Anthony Liguori   <aliguori@us.ibm.com>
- *
- * This work is licensed under the terms of the GNU GPL, version 2 or later.
- * See the COPYING file in the top-level directory.
- */
-
-#include "libqos/fw_cfg-pc.h"
-#include "libqtest.h"
-#include <glib.h>
-
-static void pc_fw_cfg_select(QFWCFG *fw_cfg, uint16_t key)
-{
-    outw(0x510, key);
-}
-
-static void pc_fw_cfg_read(QFWCFG *fw_cfg, void *data, size_t len)
-{
-    uint8_t *ptr = data;
-    int i;
-
-    for (i = 0; i < len; i++) {
-        ptr[i] = inb(0x511);
-    }
-}
-
-QFWCFG *pc_fw_cfg_init(void)
-{
-    QFWCFG *fw_cfg = g_malloc0(sizeof(*fw_cfg));
-
-    fw_cfg->select = pc_fw_cfg_select;
-    fw_cfg->read = pc_fw_cfg_read;
-
-    return fw_cfg;
-}
diff --git a/tests/libqos/fw_cfg-pc.h b/tests/libqos/fw_cfg-pc.h
deleted file mode 100644
index 444bd79..0000000
--- a/tests/libqos/fw_cfg-pc.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * libqos fw_cfg support for PC
- *
- * Copyright IBM, Corp. 2012-2013
- *
- * Authors:
- *  Anthony Liguori   <aliguori@us.ibm.com>
- *
- * This work is licensed under the terms of the GNU GPL, version 2 or later.
- * See the COPYING file in the top-level directory.
- */
-
-#ifndef LIBQOS_FW_CFG_PC_H
-#define LIBQOS_FW_CFG_PC_H
-
-#include "libqos/fw_cfg.h"
-
-QFWCFG *pc_fw_cfg_init(void);
-
-#endif
diff --git a/tests/libqos/fw_cfg.c b/tests/libqos/fw_cfg.c
index 49d1683..ef00fed 100644
--- a/tests/libqos/fw_cfg.c
+++ b/tests/libqos/fw_cfg.c
@@ -79,3 +79,29 @@ QFWCFG *mm_fw_cfg_init(uint64_t base)
 
     return fw_cfg;
 }
+
+static void io_fw_cfg_select(QFWCFG *fw_cfg, uint16_t key)
+{
+    outw(fw_cfg->base, key);
+}
+
+static void io_fw_cfg_read(QFWCFG *fw_cfg, void *data, size_t len)
+{
+    uint8_t *ptr = data;
+    int i;
+
+    for (i = 0; i < len; i++) {
+        ptr[i] = inb(fw_cfg->base + 1);
+    }
+}
+
+QFWCFG *io_fw_cfg_init(uint16_t base)
+{
+    QFWCFG *fw_cfg = g_malloc0(sizeof(*fw_cfg));
+
+    fw_cfg->base = base;
+    fw_cfg->select = io_fw_cfg_select;
+    fw_cfg->read = io_fw_cfg_read;
+
+    return fw_cfg;
+}
diff --git a/tests/libqos/fw_cfg.h b/tests/libqos/fw_cfg.h
index 19bb053..61b1548 100644
--- a/tests/libqos/fw_cfg.h
+++ b/tests/libqos/fw_cfg.h
@@ -33,5 +33,11 @@ uint32_t qfw_cfg_get_u32(QFWCFG *fw_cfg, uint16_t key);
 uint64_t qfw_cfg_get_u64(QFWCFG *fw_cfg, uint16_t key);
 
 QFWCFG *mm_fw_cfg_init(uint64_t base);
+QFWCFG *io_fw_cfg_init(uint16_t base);
+
+static inline QFWCFG *pc_fw_cfg_init(void)
+{
+    return io_fw_cfg_init(0x510);
+}
 
 #endif
diff --git a/tests/libqos/malloc-pc.c b/tests/libqos/malloc-pc.c
index adc36c4..db1496c 100644
--- a/tests/libqos/malloc-pc.c
+++ b/tests/libqos/malloc-pc.c
@@ -11,7 +11,7 @@
  */
 
 #include "libqos/malloc-pc.h"
-#include "libqos/fw_cfg-pc.h"
+#include "libqos/fw_cfg.h"
 
 #define NO_QEMU_PROTOS
 #include "hw/nvram/fw_cfg.h"
-- 
1.7.11.7

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Qemu-devel] [PATCH v4 12/12] boot-order-test: Add tests for Sun4u
  2013-06-26 13:52 [Qemu-devel] [PATCH v4 00/12] Boot order tests Markus Armbruster
                   ` (10 preceding siblings ...)
  2013-06-26 13:52 ` [Qemu-devel] [PATCH v4 11/12] libqos: Generalize I/O-mapped fw_cfg Markus Armbruster
@ 2013-06-26 13:52 ` Markus Armbruster
  2013-07-18 16:33 ` [Qemu-devel] [PATCH v4 00/12] Boot order tests Markus Armbruster
  2013-07-23 19:04 ` Anthony Liguori
  13 siblings, 0 replies; 15+ messages in thread
From: Markus Armbruster @ 2013-06-26 13:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: aliguori, jan.kiszka, mjt, Blue Swirl, alex.williamson, aviksil,
	afaerber

Cc: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 tests/boot-order-test.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/tests/boot-order-test.c b/tests/boot-order-test.c
index a3928ed..4b233d0 100644
--- a/tests/boot-order-test.c
+++ b/tests/boot-order-test.c
@@ -173,6 +173,18 @@ static void test_sun4m_boot_order(void)
     test_boot_orders("SS-5", read_boot_order_sun4m, test_cases_fw_cfg);
 }
 
+static uint64_t read_boot_order_sun4u(void)
+{
+    QFWCFG *fw_cfg = io_fw_cfg_init(0x510);
+
+    return qfw_cfg_get_u16(fw_cfg, FW_CFG_BOOT_DEVICE);
+}
+
+static void test_sun4u_boot_order(void)
+{
+    test_boot_orders("sun4u", read_boot_order_sun4u, test_cases_fw_cfg);
+}
+
 int main(int argc, char *argv[])
 {
     const char *arch = qtest_get_arch();
@@ -189,6 +201,8 @@ int main(int argc, char *argv[])
                        test_pmac_newworld_boot_order);
     } else if (strcmp(arch, "sparc") == 0) {
         qtest_add_func("boot-order/sun4m", test_sun4m_boot_order);
+    } else if (strcmp(arch, "sparc64") == 0) {
+        qtest_add_func("boot-order/sun4u", test_sun4u_boot_order);
     }
 
     return g_test_run();
-- 
1.7.11.7

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [Qemu-devel] [PATCH v4 00/12] Boot order tests
  2013-06-26 13:52 [Qemu-devel] [PATCH v4 00/12] Boot order tests Markus Armbruster
                   ` (11 preceding siblings ...)
  2013-06-26 13:52 ` [Qemu-devel] [PATCH v4 12/12] boot-order-test: Add tests for Sun4u Markus Armbruster
@ 2013-07-18 16:33 ` Markus Armbruster
  2013-07-23 19:04 ` Anthony Liguori
  13 siblings, 0 replies; 15+ messages in thread
From: Markus Armbruster @ 2013-07-18 16:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, jan.kiszka, mjt, alex.williamson, aviksil, afaerber

Ping?

Markus Armbruster <armbru@redhat.com> writes:

> v4:
> * Old PATCH 1-6 got merged, only tests left; cover letter changed
>   accordingly
> * PATCH 1,6 unchanged
> * PATCH 2 fix system-reset race (Anthony)
> * New PATCH 4,11 to make libqos/fw_cfg usable for the ppc, Sun4 tests
> * New PATCH 3 shanghaied from Anthony, to make PATCH 4 compile without
>   make clean.
> * PATCH 5,10,12 use libqos/fw_cfg (Anthony)
> * PATCH 7-9 rebased, minor tweaks
> v3:
> * Rebased, with only trivial conflicts
> * PATCH 08 cosmetic improvements
> * More test cases: new PATCH 09-16
> v2:
> * New PATCH 7 to make testing -boot once possible
> * Old PATCH 5 reworked and extended became PATCH 8
> * Writing more tests uncovered -no-fd-bootchk weirdness, cleaned up in
>   new PATCH 5+6
>
> Andreas Färber (1):
>   boot-order-test: Add tests for PowerMacs
>
> Anthony Liguori (1):
>   libqos: include dependencies
>
> Markus Armbruster (10):
>   qtest: Don't reset on qtest chardev connect
>   boot-order-test: New; covering just PC for now
>   libqos: Add support for memory-mapped fw_cfg
>   boot-order-test: Cover -boot once in ppc tests
>   boot-order-test: Better separate target-specific and generic parts
>   boot-order-test: Code motion for better readability
>   boot-order-test: Add tests for PowerPC PREP
>   boot-order-test: Add tests for Sun4m
>   libqos: Generalize I/O-mapped fw_cfg
>   boot-order-test: Add tests for Sun4u
>
>  qtest.c                  |   7 +-
>  tests/Makefile           |   7 +-
>  tests/boot-order-test.c  | 209 +++++++++++++++++++++++++++++++++++++++++++++++
>  tests/fw_cfg-test.c      |   2 +-
>  tests/libqos/fw_cfg-pc.c |  40 ---------
>  tests/libqos/fw_cfg-pc.h |  20 -----
>  tests/libqos/fw_cfg.c    |  55 +++++++++++++
>  tests/libqos/fw_cfg.h    |   9 ++
>  tests/libqos/malloc-pc.c |   2 +-
>  9 files changed, 287 insertions(+), 64 deletions(-)
>  create mode 100644 tests/boot-order-test.c
>  delete mode 100644 tests/libqos/fw_cfg-pc.c
>  delete mode 100644 tests/libqos/fw_cfg-pc.h

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Qemu-devel] [PATCH v4 00/12] Boot order tests
  2013-06-26 13:52 [Qemu-devel] [PATCH v4 00/12] Boot order tests Markus Armbruster
                   ` (12 preceding siblings ...)
  2013-07-18 16:33 ` [Qemu-devel] [PATCH v4 00/12] Boot order tests Markus Armbruster
@ 2013-07-23 19:04 ` Anthony Liguori
  13 siblings, 0 replies; 15+ messages in thread
From: Anthony Liguori @ 2013-07-23 19:04 UTC (permalink / raw)
  To: Markus Armbruster, qemu-devel
  Cc: aliguori, jan.kiszka, mjt, alex.williamson, aviksil, afaerber

Applied.  Thanks.

Regards,

Anthony Liguori

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2013-07-23 19:15 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-26 13:52 [Qemu-devel] [PATCH v4 00/12] Boot order tests Markus Armbruster
2013-06-26 13:52 ` [Qemu-devel] [PATCH v4 01/12] qtest: Don't reset on qtest chardev connect Markus Armbruster
2013-06-26 13:52 ` [Qemu-devel] [PATCH v4 02/12] boot-order-test: New; covering just PC for now Markus Armbruster
2013-06-26 13:52 ` [Qemu-devel] [PATCH v4 03/12] libqos: include dependencies Markus Armbruster
2013-06-26 13:52 ` [Qemu-devel] [PATCH v4 04/12] libqos: Add support for memory-mapped fw_cfg Markus Armbruster
2013-06-26 13:52 ` [Qemu-devel] [PATCH v4 05/12] boot-order-test: Add tests for PowerMacs Markus Armbruster
2013-06-26 13:52 ` [Qemu-devel] [PATCH v4 06/12] boot-order-test: Cover -boot once in ppc tests Markus Armbruster
2013-06-26 13:52 ` [Qemu-devel] [PATCH v4 07/12] boot-order-test: Better separate target-specific and generic parts Markus Armbruster
2013-06-26 13:52 ` [Qemu-devel] [PATCH v4 08/12] boot-order-test: Code motion for better readability Markus Armbruster
2013-06-26 13:52 ` [Qemu-devel] [PATCH v4 09/12] boot-order-test: Add tests for PowerPC PREP Markus Armbruster
2013-06-26 13:52 ` [Qemu-devel] [PATCH v4 10/12] boot-order-test: Add tests for Sun4m Markus Armbruster
2013-06-26 13:52 ` [Qemu-devel] [PATCH v4 11/12] libqos: Generalize I/O-mapped fw_cfg Markus Armbruster
2013-06-26 13:52 ` [Qemu-devel] [PATCH v4 12/12] boot-order-test: Add tests for Sun4u Markus Armbruster
2013-07-18 16:33 ` [Qemu-devel] [PATCH v4 00/12] Boot order tests Markus Armbruster
2013-07-23 19:04 ` Anthony Liguori

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).