aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorThomas Huth <thuth@redhat.com>2018-11-12 19:46:20 +0100
committerThomas Huth <thuth@redhat.com>2018-12-17 15:36:39 +0100
commitac16ab753ae2ee240fddb9c69400782c18ae3bc1 (patch)
tree748759cf18c7edcc8f9a0ae637db6ab234632c41 /tests
parent273e3d92cfa26ae07a72657b75b4b76105a0fbc4 (diff)
tests/vmgenid: Make test independent of global_qtest
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. Acked-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/vmgenid-test.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/tests/vmgenid-test.c b/tests/vmgenid-test.c
index c9c4f8c375..84449ce8ae 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)