All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: Anthony Liguori <aliguori@us.ibm.com>
Cc: qemu-ppc <qemu-ppc@nongnu.org>,
	qemu-devel@nongnu.org, Alexander Graf <agraf@suse.de>
Subject: Re: [Qemu-devel] [PATCH 7/7] fw_cfg: add qtest test case
Date: Sun, 28 Apr 2013 17:29:22 +0200	[thread overview]
Message-ID: <517D4052.9050702@suse.de> (raw)
In-Reply-To: <1366123521-4330-8-git-send-email-aliguori@us.ibm.com>

Am 16.04.2013 16:45, schrieb Anthony Liguori:
> This validates some basic characteristics of fw_cfg.
> 
> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
> ---
>  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   <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.
> + */
> +
> +#define NO_QEMU_PROTOS
> +
> +#include "libqtest.h"
> +#include "hw/nvram/fw_cfg.h"
> +#include "libqos/fw_cfg-pc.h"
> +
> +#include <string.h>
> +#include <glib.h>
> +
> +static uint64_t ram_size = 128 << 20;
> +static uint16_t nb_cpus = 1;
> +static uint16_t max_cpus = 1;
> +static uint64_t nb_nodes = 0;
> +static uint16_t boot_menu = 0;
> +static QFWCFG *fw_cfg = NULL;
> +
> +static void test_fw_cfg_signature(void)
> +{
> +    char buf[5];
> +
> +    qfw_cfg_get(fw_cfg, FW_CFG_SIGNATURE, buf, 4);
> +    buf[4] = 0;
> +
> +    g_assert_cmpstr(buf, ==, "QEMU");
> +}
> +
> +static void test_fw_cfg_id(void)
> +{
> +    g_assert_cmpint(qfw_cfg_get_u32(fw_cfg, FW_CFG_ID), ==, 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) == 1): (16777216 == 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) == ram_size):
(34359738368 == 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) == nb_cpus): (256 == 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) == max_cpus):
(256 == 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] = {
> +        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)) == 0);
> +}
> +
> +static void test_fw_cfg_ram_size(void)
> +{
> +    g_assert_cmpint(qfw_cfg_get_u64(fw_cfg, FW_CFG_RAM_SIZE), ==, ram_size);
> +}
> +
> +static void test_fw_cfg_nographic(void)
> +{
> +    g_assert_cmpint(qfw_cfg_get_u16(fw_cfg, FW_CFG_NOGRAPHIC), ==, 0);
> +}
> +
> +static void test_fw_cfg_nb_cpus(void)
> +{
> +    g_assert_cmpint(qfw_cfg_get_u16(fw_cfg, FW_CFG_NB_CPUS), ==, nb_cpus);
> +}
> +
> +static void test_fw_cfg_max_cpus(void)
> +{
> +    g_assert_cmpint(qfw_cfg_get_u16(fw_cfg, FW_CFG_MAX_CPUS), ==, 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), ==, nb_nodes);
> +
> +    cpu_mask = g_malloc0(sizeof(uint64_t) * max_cpus);
> +    node_mask = 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], ==, 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), ==, boot_menu);
> +}
> +
> +int main(int argc, char **argv)
> +{
> +    QTestState *s;
> +    char *cmdline;
> +    int ret;
> +
> +    g_test_init(&argc, &argv, NULL);
> +
> +    fw_cfg = 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 = g_strdup_printf("-display none "
> +                              "-uuid 4600cb32-38ec-4b2f-8acb-81c6ea54f2d8 ");
> +    s = qtest_start(cmdline);
> +    g_free(cmdline);
> +
> +    ret = g_test_run();
> +
> +    if (s) {
> +        qtest_quit(s);
> +    }
> +
> +    return ret;
> +}
> 


-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

  reply	other threads:[~2013-04-28 15:29 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-16 14:45 [Qemu-devel] [PATCH 0/7] qtest: add libqos Anthony Liguori
2013-04-16 14:45 ` [Qemu-devel] [PATCH 1/7] qtest: don't use system command to avoid double fork Anthony Liguori
2013-04-16 14:45 ` [Qemu-devel] [PATCH 2/7] qtest: add libqos including PCI support Anthony Liguori
2013-04-16 14:45 ` [Qemu-devel] [PATCH 3/7] libqos: add fw_cfg support Anthony Liguori
2013-04-16 14:45 ` [Qemu-devel] [PATCH 4/7] libqos: add malloc support Anthony Liguori
2013-04-16 14:45 ` [Qemu-devel] [PATCH 5/7] i440fx-test: add test to compare default register values Anthony Liguori
2013-04-16 15:56   ` Eric Blake
2013-04-16 15:59     ` Eric Blake
2013-04-16 18:13       ` Anthony Liguori
2013-04-16 14:45 ` [Qemu-devel] [PATCH 6/7] i440fx-test: add test for PAM functionality Anthony Liguori
2013-04-16 14:45 ` [Qemu-devel] [PATCH 7/7] fw_cfg: add qtest test case Anthony Liguori
2013-04-28 15:29   ` Andreas Färber [this message]
2013-04-22 18:35 ` [Qemu-devel] [PATCH 0/7] qtest: add libqos 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=517D4052.9050702@suse.de \
    --to=afaerber@suse.de \
    --cc=agraf@suse.de \
    --cc=aliguori@us.ibm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.