From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:57235) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UWTXa-0001vd-76 for qemu-devel@nongnu.org; Sun, 28 Apr 2013 11:29:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UWTXY-0004WZ-Tm for qemu-devel@nongnu.org; Sun, 28 Apr 2013 11:29:26 -0400 Message-ID: <517D4052.9050702@suse.de> Date: Sun, 28 Apr 2013 17:29:22 +0200 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1366123521-4330-1-git-send-email-aliguori@us.ibm.com> <1366123521-4330-8-git-send-email-aliguori@us.ibm.com> In-Reply-To: <1366123521-4330-8-git-send-email-aliguori@us.ibm.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 7/7] fw_cfg: add qtest test case List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: qemu-ppc , qemu-devel@nongnu.org, Alexander Graf Am 16.04.2013 16:45, schrieb Anthony Liguori: > This validates some basic characteristics of fw_cfg. >=20 > Signed-off-by: Anthony Liguori > --- > tests/Makefile | 2 + > tests/fw_cfg-test.c | 141 ++++++++++++++++++++++++++++++++++++++++++++= ++++++++ > 2 files changed, 143 insertions(+) > create mode 100644 tests/fw_cfg-test.c [...] > diff --git a/tests/fw_cfg-test.c b/tests/fw_cfg-test.c > new file mode 100644 > index 0000000..c284c4d > --- /dev/null > +++ b/tests/fw_cfg-test.c > @@ -0,0 +1,141 @@ > +/* > + * qtest fw_cfg test case > + * > + * Copyright IBM, Corp. 2012-2013 > + * > + * Authors: > + * Anthony Liguori > + * > + * This work is licensed under the terms of the GNU GPL, version 2 or = later. > + * See the COPYING file in the top-level directory. > + */ > + > +#define NO_QEMU_PROTOS > + > +#include "libqtest.h" > +#include "hw/nvram/fw_cfg.h" > +#include "libqos/fw_cfg-pc.h" > + > +#include > +#include > + > +static uint64_t ram_size =3D 128 << 20; > +static uint16_t nb_cpus =3D 1; > +static uint16_t max_cpus =3D 1; > +static uint64_t nb_nodes =3D 0; > +static uint16_t boot_menu =3D 0; > +static QFWCFG *fw_cfg =3D NULL; > + > +static void test_fw_cfg_signature(void) > +{ > + char buf[5]; > + > + qfw_cfg_get(fw_cfg, FW_CFG_SIGNATURE, buf, 4); > + buf[4] =3D 0; > + > + g_assert_cmpstr(buf, =3D=3D, "QEMU"); > +} > + > +static void test_fw_cfg_id(void) > +{ > + g_assert_cmpint(qfw_cfg_get_u32(fw_cfg, FW_CFG_ID), =3D=3D, 1); Breaks on ppc: GTESTER check-qtest-i386 main-loop: WARNING: I/O thread spun for 1000 iterations main-loop: WARNING: I/O thread spun for 1000 iterations main-loop: WARNING: I/O thread spun for 1000 iterations ** ERROR:/home/andreas/QEMU/qemu/tests/fw_cfg-test.c:41:test_fw_cfg_id: assertion failed (qfw_cfg_get_u32(fw_cfg, FW_CFG_ID) =3D=3D 1): (16777216= =3D=3D 1) GTester: last random seed: R02Seb06159fdb5cae93a76e1fb2021712e6 ** ERROR:/home/andreas/QEMU/qemu/tests/fw_cfg-test.c:58:test_fw_cfg_ram_size= : assertion failed (qfw_cfg_get_u64(fw_cfg, FW_CFG_RAM_SIZE) =3D=3D ram_siz= e): (34359738368 =3D=3D 134217728) GTester: last random seed: R02Sb790037de99dc72c4011de8746bcf891 ** ERROR:/home/andreas/QEMU/qemu/tests/fw_cfg-test.c:68:test_fw_cfg_nb_cpus:= assertion failed (qfw_cfg_get_u16(fw_cfg, FW_CFG_NB_CPUS) =3D=3D nb_cpus): (256 =3D= =3D 1) GTester: last random seed: R02S8cbc5ce02a292007de9990e752915719 ** ERROR:/home/andreas/QEMU/qemu/tests/fw_cfg-test.c:73:test_fw_cfg_max_cpus= : assertion failed (qfw_cfg_get_u16(fw_cfg, FW_CFG_MAX_CPUS) =3D=3D max_cpu= s): (256 =3D=3D 1) GTester: last random seed: R02S81c8abd06614ef0eef55cedea5f37429 make: *** [check-qtest-i386] Fehler 1 Andreas > +} > + > +static void test_fw_cfg_uuid(void) > +{ > + uint8_t buf[16]; > + static const uint8_t uuid[16] =3D { > + 0x46, 0x00, 0xcb, 0x32, 0x38, 0xec, 0x4b, 0x2f, > + 0x8a, 0xcb, 0x81, 0xc6, 0xea, 0x54, 0xf2, 0xd8, > + }; > + > + qfw_cfg_get(fw_cfg, FW_CFG_UUID, buf, 16); > + g_assert(memcmp(buf, uuid, sizeof(buf)) =3D=3D 0); > +} > + > +static void test_fw_cfg_ram_size(void) > +{ > + g_assert_cmpint(qfw_cfg_get_u64(fw_cfg, FW_CFG_RAM_SIZE), =3D=3D, = ram_size); > +} > + > +static void test_fw_cfg_nographic(void) > +{ > + g_assert_cmpint(qfw_cfg_get_u16(fw_cfg, FW_CFG_NOGRAPHIC), =3D=3D,= 0); > +} > + > +static void test_fw_cfg_nb_cpus(void) > +{ > + g_assert_cmpint(qfw_cfg_get_u16(fw_cfg, FW_CFG_NB_CPUS), =3D=3D, n= b_cpus); > +} > + > +static void test_fw_cfg_max_cpus(void) > +{ > + g_assert_cmpint(qfw_cfg_get_u16(fw_cfg, FW_CFG_MAX_CPUS), =3D=3D, = max_cpus); > +} > + > +static void test_fw_cfg_numa(void) > +{ > + uint64_t *cpu_mask; > + uint64_t *node_mask; > + > + g_assert_cmpint(qfw_cfg_get_u64(fw_cfg, FW_CFG_NUMA), =3D=3D, nb_n= odes); > + > + cpu_mask =3D g_malloc0(sizeof(uint64_t) * max_cpus); > + node_mask =3D g_malloc0(sizeof(uint64_t) * nb_nodes); > + > + qfw_cfg_read_data(fw_cfg, cpu_mask, sizeof(uint64_t) * max_cpus); > + qfw_cfg_read_data(fw_cfg, node_mask, sizeof(uint64_t) * nb_nodes); > + > + if (nb_nodes) { > + g_assert(cpu_mask[0] & 0x01); > + g_assert_cmpint(node_mask[0], =3D=3D, ram_size); > + } > + > + g_free(node_mask); > + g_free(cpu_mask); > +} > + > +static void test_fw_cfg_boot_menu(void) > +{ > + g_assert_cmpint(qfw_cfg_get_u16(fw_cfg, FW_CFG_BOOT_MENU), =3D=3D,= boot_menu); > +} > + > +int main(int argc, char **argv) > +{ > + QTestState *s; > + char *cmdline; > + int ret; > + > + g_test_init(&argc, &argv, NULL); > + > + fw_cfg =3D pc_fw_cfg_init(); > + > + g_test_add_func("/fw_cfg/signature", test_fw_cfg_signature); > + g_test_add_func("/fw_cfg/id", test_fw_cfg_id); > + g_test_add_func("/fw_cfg/uuid", test_fw_cfg_uuid); > + g_test_add_func("/fw_cfg/ram_size", test_fw_cfg_ram_size); > + g_test_add_func("/fw_cfg/nographic", test_fw_cfg_nographic); > + g_test_add_func("/fw_cfg/nb_cpus", test_fw_cfg_nb_cpus); > +#if 0 > + g_test_add_func("/fw_cfg/machine_id", test_fw_cfg_machine_id); > + g_test_add_func("/fw_cfg/kernel", test_fw_cfg_kernel); > + g_test_add_func("/fw_cfg/initrd", test_fw_cfg_initrd); > + g_test_add_func("/fw_cfg/boot_device", test_fw_cfg_boot_device); > +#endif > + g_test_add_func("/fw_cfg/max_cpus", test_fw_cfg_max_cpus); > + g_test_add_func("/fw_cfg/numa", test_fw_cfg_numa); > + g_test_add_func("/fw_cfg/boot_menu", test_fw_cfg_boot_menu); > + > + cmdline =3D g_strdup_printf("-display none " > + "-uuid 4600cb32-38ec-4b2f-8acb-81c6ea54f= 2d8 "); > + s =3D qtest_start(cmdline); > + g_free(cmdline); > + > + ret =3D g_test_run(); > + > + if (s) { > + qtest_quit(s); > + } > + > + return ret; > +} >=20 --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg