From: Igor Mammedov <imammedo@redhat.com>
To: Thomas Huth <thuth@redhat.com>
Cc: Eric Blake <eblake@redhat.com>,
qemu-devel@nongnu.org, John Snow <jsnow@redhat.com>,
Laurent Vivier <lvivier@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Ben Warren <ben@skyportsystems.com>
Subject: Re: [Qemu-devel] [PATCH for-3.2 6/7] tests/vmgenid: Make test independent of global_qtest
Date: Tue, 27 Nov 2018 15:38:09 +0100 [thread overview]
Message-ID: <20181127153809.3fae7754@redhat.com> (raw)
In-Reply-To: <1542049690-12826-7-git-send-email-thuth@redhat.com>
On Mon, 12 Nov 2018 20:08:09 +0100
Thomas Huth <thuth@redhat.com> wrote:
> The biggest part has already been done in the previous patch, we now
> only have to replace some few qmp() and readb() calls with the
> corresponding qtest_*() functions to get there.
>
> Signed-off-by: Thomas Huth <thuth@redhat.com>
Acked-by: Igor Mammedov <imammedo@redhat.com>
> ---
> tests/vmgenid-test.c | 31 +++++++++++++++++--------------
> 1 file changed, 17 insertions(+), 14 deletions(-)
>
> diff --git a/tests/vmgenid-test.c b/tests/vmgenid-test.c
> index c9c4f8c..84449ce 100644
> --- a/tests/vmgenid-test.c
> +++ b/tests/vmgenid-test.c
> @@ -95,17 +95,17 @@ static uint32_t acpi_find_vgia(QTestState *qts)
> return guid_offset;
> }
>
> -static void read_guid_from_memory(QemuUUID *guid)
> +static void read_guid_from_memory(QTestState *qts, QemuUUID *guid)
> {
> uint32_t vmgenid_addr;
> int i;
>
> - vmgenid_addr = acpi_find_vgia(global_qtest);
> + vmgenid_addr = acpi_find_vgia(qts);
> g_assert(vmgenid_addr);
>
> /* Read the GUID directly from guest memory */
> for (i = 0; i < 16; i++) {
> - guid->data[i] = readb(vmgenid_addr + i);
> + guid->data[i] = qtest_readb(qts, vmgenid_addr + i);
> }
> /* The GUID is in little-endian format in the guest, while QEMU
> * uses big-endian. Swap after reading.
> @@ -113,12 +113,12 @@ static void read_guid_from_memory(QemuUUID *guid)
> qemu_uuid_bswap(guid);
> }
>
> -static void read_guid_from_monitor(QemuUUID *guid)
> +static void read_guid_from_monitor(QTestState *qts, QemuUUID *guid)
> {
> QDict *rsp, *rsp_ret;
> const char *guid_str;
>
> - rsp = qmp("{ 'execute': 'query-vm-generation-id' }");
> + rsp = qtest_qmp(qts, "{ 'execute': 'query-vm-generation-id' }");
> if (qdict_haskey(rsp, "return")) {
> rsp_ret = qdict_get_qdict(rsp, "return");
> g_assert(qdict_haskey(rsp_ret, "guid"));
> @@ -139,45 +139,48 @@ static char disk[] = "tests/vmgenid-test-disk-XXXXXX";
> static void vmgenid_set_guid_test(void)
> {
> QemuUUID expected, measured;
> + QTestState *qts;
>
> g_assert(qemu_uuid_parse(VGID_GUID, &expected) == 0);
>
> - global_qtest = qtest_initf(GUID_CMD(VGID_GUID));
> + qts = qtest_initf(GUID_CMD(VGID_GUID));
>
> /* Read the GUID from accessing guest memory */
> - read_guid_from_memory(&measured);
> + read_guid_from_memory(qts, &measured);
> g_assert(memcmp(measured.data, expected.data, sizeof(measured.data)) == 0);
>
> - qtest_quit(global_qtest);
> + qtest_quit(qts);
> }
>
> static void vmgenid_set_guid_auto_test(void)
> {
> QemuUUID measured;
> + QTestState *qts;
>
> - global_qtest = qtest_initf(GUID_CMD("auto"));
> + qts = qtest_initf(GUID_CMD("auto"));
>
> - read_guid_from_memory(&measured);
> + read_guid_from_memory(qts, &measured);
>
> /* Just check that the GUID is non-null */
> g_assert(!qemu_uuid_is_null(&measured));
>
> - qtest_quit(global_qtest);
> + qtest_quit(qts);
> }
>
> static void vmgenid_query_monitor_test(void)
> {
> QemuUUID expected, measured;
> + QTestState *qts;
>
> g_assert(qemu_uuid_parse(VGID_GUID, &expected) == 0);
>
> - global_qtest = qtest_initf(GUID_CMD(VGID_GUID));
> + qts = qtest_initf(GUID_CMD(VGID_GUID));
>
> /* Read the GUID via the monitor */
> - read_guid_from_monitor(&measured);
> + read_guid_from_monitor(qts, &measured);
> g_assert(memcmp(measured.data, expected.data, sizeof(measured.data)) == 0);
>
> - qtest_quit(global_qtest);
> + qtest_quit(qts);
> }
>
> int main(int argc, char **argv)
next prev parent reply other threads:[~2018-11-27 14:38 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-12 19:08 [Qemu-devel] [PATCH v1 for-3.2 0/7] Get rid of global_qtest in some of the qtests Thomas Huth
2018-11-12 19:08 ` [Qemu-devel] [PATCH for-3.2 1/7] tests/pvpanic: Make the pvpanic test independent of global_qtest Thomas Huth
2018-11-13 0:47 ` Eric Blake
2018-11-12 19:08 ` [Qemu-devel] [PATCH for-3.2 2/7] tests/libqos/pci: Make PCI access functions " Thomas Huth
2018-11-12 19:33 ` Paolo Bonzini
2018-11-12 19:08 ` [Qemu-devel] [PATCH for-3.2 3/7] ahci-test: Drop dependence on global_qtest Thomas Huth
2018-11-14 0:10 ` John Snow
2018-11-27 14:55 ` Eric Blake
2018-11-12 19:08 ` [Qemu-devel] [PATCH for-3.2 4/7] ivshmem-test: " Thomas Huth
2018-11-12 19:08 ` [Qemu-devel] [PATCH for-3.2 5/7] tests/acpi-utils: " Thomas Huth
2018-11-27 14:30 ` Igor Mammedov
2018-11-12 19:08 ` [Qemu-devel] [PATCH for-3.2 6/7] tests/vmgenid: Make test independent of global_qtest Thomas Huth
2018-11-27 14:38 ` Igor Mammedov [this message]
2018-11-12 19:08 ` [Qemu-devel] [PATCH for-3.2 7/7] tests/boot-serial: Get rid of global_qtest variable Thomas Huth
2018-11-13 11:38 ` [Qemu-devel] [PATCH v1 for-3.2 0/7] Get rid of global_qtest in some of the qtests no-reply
2018-11-13 12:31 ` Thomas Huth
2018-11-13 13:36 ` Laurent Vivier
2018-11-13 14:28 ` Thomas Huth
2018-11-13 15:11 ` [Qemu-devel] [PATCH] tests/ide: Free pcibus when finishing a test Thomas Huth
2018-11-13 15:54 ` Eric Blake
2018-11-13 16:34 ` Philippe Mathieu-Daudé
2018-11-14 0:56 ` John Snow
2018-11-14 13:05 ` [Qemu-devel] [PATCH v1 for-3.2 0/7] Get rid of global_qtest in some of the qtests no-reply
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=20181127153809.3fae7754@redhat.com \
--to=imammedo@redhat.com \
--cc=ben@skyportsystems.com \
--cc=eblake@redhat.com \
--cc=jsnow@redhat.com \
--cc=lvivier@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=thuth@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).