From a3d7cbc1397bf01249b5c39dd1e285bd6aa818dc Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Thu, 6 Mar 2014 10:12:52 +0100 Subject: qdev-monitor-test: Simplify using g_assert_cmpstr() Use g_assert_cmpstr() instead of combining g_assert() and strcmp(3). This simplifies the code since we no longer have to play games to distinguish NULL from "" using "(null)". gcc extension haters will also be happy that ?: was dropped. Suggested-by: Markus Armbruster Signed-off-by: Stefan Hajnoczi Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi Signed-off-by: Andreas Färber --- tests/qdev-monitor-test.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/qdev-monitor-test.c b/tests/qdev-monitor-test.c index ba7f9cc238..eefaab823a 100644 --- a/tests/qdev-monitor-test.c +++ b/tests/qdev-monitor-test.c @@ -32,8 +32,9 @@ static void test_device_add(void) "}}"); g_assert(response); error = qdict_get_qdict(response, "error"); - g_assert(!strcmp(qdict_get_try_str(error, "desc") ?: "", - "Device needs media, but drive is empty")); + g_assert_cmpstr(qdict_get_try_str(error, "desc"), + ==, + "Device needs media, but drive is empty"); QDECREF(response); /* Delete the drive */ @@ -42,7 +43,7 @@ static void test_device_add(void) " \"command-line\": \"drive_del drive0\"" "}}"); g_assert(response); - g_assert(!strcmp(qdict_get_try_str(response, "return") ?: "(null)", "")); + g_assert_cmpstr(qdict_get_try_str(response, "return"), ==, ""); QDECREF(response); /* Try to re-add the drive. This fails with duplicate IDs if a leaked @@ -53,8 +54,7 @@ static void test_device_add(void) " \"command-line\": \"drive_add pci-addr=auto if=none,id=drive0\"" "}}"); g_assert(response); - g_assert(!strcmp(qdict_get_try_str(response, "return") ?: "", - "OK\r\n")); + g_assert_cmpstr(qdict_get_try_str(response, "return"), ==, "OK\r\n"); QDECREF(response); qtest_end(); -- cgit v1.2.3-55-g7522 From 49649f23db977137c031a21eee2f0521404f6710 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Thu, 6 Mar 2014 10:12:53 +0100 Subject: qdev-monitor-test: Don't test human-readable error message Test the error class instead. Expecting a specific message is fragile. In fact, it broke once already, in commit 75884af. Restore the test of error member "class" dropped there, and drop the test of error member "desc". There are no other tests of "desc" as far as I can tell. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi Signed-off-by: Andreas Färber --- tests/qdev-monitor-test.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/qdev-monitor-test.c b/tests/qdev-monitor-test.c index eefaab823a..e20ffd67a7 100644 --- a/tests/qdev-monitor-test.c +++ b/tests/qdev-monitor-test.c @@ -32,9 +32,7 @@ static void test_device_add(void) "}}"); g_assert(response); error = qdict_get_qdict(response, "error"); - g_assert_cmpstr(qdict_get_try_str(error, "desc"), - ==, - "Device needs media, but drive is empty"); + g_assert_cmpstr(qdict_get_try_str(error, "class"), ==, "GenericError"); QDECREF(response); /* Delete the drive */ -- cgit v1.2.3-55-g7522 From dc06cbd28611c366096fd1c9b8bba7b459a96877 Mon Sep 17 00:00:00 2001 From: Andreas Färber Date: Fri, 7 Feb 2014 15:36:16 +0100 Subject: qom-test: Test QOM properties Recursively walk all properties under /machine and try to retrieve their value. This is a regression test for link<> properties and the DeviceState::hotpluggable property. Cf. be2f78b6b062eec5170e2612299fb8953046993f and 1a37eca107cece3ed454bae29eef0bd1fac4a244 Signed-off-by: Andreas Färber --- tests/qom-test.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'tests') diff --git a/tests/qom-test.c b/tests/qom-test.c index b6671fbec3..6d9a00b448 100644 --- a/tests/qom-test.c +++ b/tests/qom-test.c @@ -10,6 +10,7 @@ #include #include +#include "qemu-common.h" #include "libqtest.h" #include "qemu/osdep.h" #include "qapi/qmp/types.h" @@ -43,6 +44,40 @@ static bool is_blacklisted(const char *arch, const char *mach) return false; } +static void test_properties(const char *path) +{ + char *child_path; + QDict *response, *tuple; + QList *list; + QListEntry *entry; + + g_test_message("Obtaining properties of %s", path); + response = qmp("{ 'execute': 'qom-list'," + " 'arguments': { 'path': '%s' } }", path); + g_assert(response); + + g_assert(qdict_haskey(response, "return")); + list = qobject_to_qlist(qdict_get(response, "return")); + QLIST_FOREACH_ENTRY(list, entry) { + tuple = qobject_to_qdict(qlist_entry_obj(entry)); + if (strstart(qdict_get_str(tuple, "type"), "child<", NULL)) { + child_path = g_strdup_printf("%s/%s", + path, qdict_get_str(tuple, "name")); + test_properties(child_path); + g_free(child_path); + } else { + const char *prop = qdict_get_str(tuple, "name"); + g_test_message("Testing property %s.%s", path, prop); + response = qmp("{ 'execute': 'qom-get'," + " 'arguments': { 'path': '%s'," + " 'property': '%s' } }", + path, prop); + /* qom-get may fail but should not, e.g., segfault. */ + g_assert(response); + } + } +} + static void test_machine(gconstpointer data) { const char *machine = data; @@ -51,8 +86,12 @@ static void test_machine(gconstpointer data) args = g_strdup_printf("-machine %s", machine); qtest_start(args); + + test_properties("/machine"); + response = qmp("{ 'execute': 'quit' }"); g_assert(qdict_haskey(response, "return")); + qtest_end(); g_free(args); } -- cgit v1.2.3-55-g7522 From 83bb0b2ffd589346c8b8f4fee9296d0a8a309cf4 Mon Sep 17 00:00:00 2001 From: Andreas Färber Date: Fri, 21 Feb 2014 16:29:17 +0100 Subject: tests: Clean up IndustryPack TPCI200 gcov paths Signed-off-by: Andreas Färber --- tests/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/Makefile b/tests/Makefile index e146f81d44..1dc24c86a0 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -87,9 +87,9 @@ gcov-files-pci-y += hw/net/ne2000.c check-qtest-pci-y += $(check-qtest-virtio-y) gcov-files-pci-y += $(gcov-files-virtio-y) hw/virtio/virtio-pci.c check-qtest-pci-y += tests/tpci200-test$(EXESUF) -gcov-files-pci-y += hw/char/tpci200.c +gcov-files-pci-y += hw/ipack/tpci200.c check-qtest-pci-y += $(check-qtest-ipack-y) -gcov-files-pci-y += $(gcov-files-ipack-y) hw/ipack/tpci200.c +gcov-files-pci-y += $(gcov-files-ipack-y) check-qtest-i386-y = tests/endianness-test$(EXESUF) check-qtest-i386-y += tests/fdc-test$(EXESUF) -- cgit v1.2.3-55-g7522 From c7a59bed62184d2d5ef5c6ed87c7ee6c23c57802 Mon Sep 17 00:00:00 2001 From: Andreas Färber Date: Sun, 9 Feb 2014 04:32:55 +0100 Subject: tests: Add virtio-blk qtest Cc: Kevin Wolf Reviewed-by: Stefan Hajnoczi Signed-off-by: Andreas Färber --- tests/Makefile | 3 +++ tests/virtio-blk-test.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 tests/virtio-blk-test.c (limited to 'tests') diff --git a/tests/Makefile b/tests/Makefile index 1dc24c86a0..d5a3f10d4d 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -72,6 +72,8 @@ gcov-files-ipack-y += hw/char/ipoctal232.c gcov-files-virtio-y += i386-softmmu/hw/virtio/virtio.c check-qtest-virtio-y += tests/virtio-net-test$(EXESUF) gcov-files-virtio-y += i386-softmmu/hw/net/virtio-net.c +check-qtest-virtio-y += tests/virtio-blk-test$(EXESUF) +gcov-files-virtio-y += i386-softmmu/hw/block/virtio-blk.c check-qtest-pci-y += tests/e1000-test$(EXESUF) gcov-files-pci-y += hw/net/e1000.c @@ -239,6 +241,7 @@ tests/pcnet-test$(EXESUF): tests/pcnet-test.o tests/eepro100-test$(EXESUF): tests/eepro100-test.o tests/vmxnet3-test$(EXESUF): tests/vmxnet3-test.o tests/ne2000-test$(EXESUF): tests/ne2000-test.o +tests/virtio-blk-test$(EXESUF): tests/virtio-blk-test.o tests/virtio-net-test$(EXESUF): tests/virtio-net-test.o tests/tpci200-test$(EXESUF): tests/tpci200-test.o tests/ipoctal232-test$(EXESUF): tests/ipoctal232-test.o diff --git a/tests/virtio-blk-test.c b/tests/virtio-blk-test.c new file mode 100644 index 0000000000..d53f875b89 --- /dev/null +++ b/tests/virtio-blk-test.c @@ -0,0 +1,34 @@ +/* + * QTest testcase for VirtIO Block Device + * + * Copyright (c) 2014 SUSE LINUX Products GmbH + * + * 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 +#include +#include "libqtest.h" +#include "qemu/osdep.h" + +/* Tests only initialization so far. TODO: Replace with functional tests */ +static void pci_nop(void) +{ +} + +int main(int argc, char **argv) +{ + int ret; + + g_test_init(&argc, &argv, NULL); + qtest_add_func("/virtio/blk/pci/nop", pci_nop); + + qtest_start("-drive id=drv0,if=none,file=/dev/null " + "-device virtio-blk-pci,drive=drv0"); + ret = g_test_run(); + + qtest_end(); + + return ret; +} -- cgit v1.2.3-55-g7522 From 02063aaa653c35291f06d58400a3349305000dd6 Mon Sep 17 00:00:00 2001 From: Andreas Färber Date: Sun, 9 Feb 2014 04:39:47 +0100 Subject: tests: Add virtio-balloon qtest Cc: Michael S. Tsirkin Reviewed-by: Stefan Hajnoczi Signed-off-by: Andreas Färber --- tests/Makefile | 3 +++ tests/virtio-balloon-test.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 tests/virtio-balloon-test.c (limited to 'tests') diff --git a/tests/Makefile b/tests/Makefile index d5a3f10d4d..d4f23dfc17 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -72,6 +72,8 @@ gcov-files-ipack-y += hw/char/ipoctal232.c gcov-files-virtio-y += i386-softmmu/hw/virtio/virtio.c check-qtest-virtio-y += tests/virtio-net-test$(EXESUF) gcov-files-virtio-y += i386-softmmu/hw/net/virtio-net.c +check-qtest-virtio-y += tests/virtio-balloon-test$(EXESUF) +gcov-files-virtio-y += i386-softmmu/hw/virtio/virtio-balloon.c check-qtest-virtio-y += tests/virtio-blk-test$(EXESUF) gcov-files-virtio-y += i386-softmmu/hw/block/virtio-blk.c @@ -241,6 +243,7 @@ tests/pcnet-test$(EXESUF): tests/pcnet-test.o tests/eepro100-test$(EXESUF): tests/eepro100-test.o tests/vmxnet3-test$(EXESUF): tests/vmxnet3-test.o tests/ne2000-test$(EXESUF): tests/ne2000-test.o +tests/virtio-balloon-test$(EXESUF): tests/virtio-balloon-test.o tests/virtio-blk-test$(EXESUF): tests/virtio-blk-test.o tests/virtio-net-test$(EXESUF): tests/virtio-net-test.o tests/tpci200-test$(EXESUF): tests/tpci200-test.o diff --git a/tests/virtio-balloon-test.c b/tests/virtio-balloon-test.c new file mode 100644 index 0000000000..becebb51a7 --- /dev/null +++ b/tests/virtio-balloon-test.c @@ -0,0 +1,33 @@ +/* + * QTest testcase for VirtIO Balloon + * + * Copyright (c) 2014 SUSE LINUX Products GmbH + * + * 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 +#include +#include "libqtest.h" +#include "qemu/osdep.h" + +/* Tests only initialization so far. TODO: Replace with functional tests */ +static void pci_nop(void) +{ +} + +int main(int argc, char **argv) +{ + int ret; + + g_test_init(&argc, &argv, NULL); + qtest_add_func("/virtio/balloon/pci/nop", pci_nop); + + qtest_start("-device virtio-balloon-pci"); + ret = g_test_run(); + + qtest_end(); + + return ret; +} -- cgit v1.2.3-55-g7522 From b6f46f02f4756d0cd6c45515c1728a899fbb1dd3 Mon Sep 17 00:00:00 2001 From: Andreas Färber Date: Sun, 9 Feb 2014 04:43:10 +0100 Subject: tests: Add virtio-rng qtest Cc: Michael S. Tsirkin Reviewed-by: Stefan Hajnoczi Signed-off-by: Andreas Färber --- tests/Makefile | 3 +++ tests/virtio-rng-test.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 tests/virtio-rng-test.c (limited to 'tests') diff --git a/tests/Makefile b/tests/Makefile index d4f23dfc17..308a5a2248 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -76,6 +76,8 @@ check-qtest-virtio-y += tests/virtio-balloon-test$(EXESUF) gcov-files-virtio-y += i386-softmmu/hw/virtio/virtio-balloon.c check-qtest-virtio-y += tests/virtio-blk-test$(EXESUF) gcov-files-virtio-y += i386-softmmu/hw/block/virtio-blk.c +check-qtest-virtio-y += tests/virtio-rng-test$(EXESUF) +gcov-files-virtio-y += hw/virtio/virtio-rng.c check-qtest-pci-y += tests/e1000-test$(EXESUF) gcov-files-pci-y += hw/net/e1000.c @@ -246,6 +248,7 @@ tests/ne2000-test$(EXESUF): tests/ne2000-test.o tests/virtio-balloon-test$(EXESUF): tests/virtio-balloon-test.o tests/virtio-blk-test$(EXESUF): tests/virtio-blk-test.o tests/virtio-net-test$(EXESUF): tests/virtio-net-test.o +tests/virtio-rng-test$(EXESUF): tests/virtio-rng-test.o tests/tpci200-test$(EXESUF): tests/tpci200-test.o tests/ipoctal232-test$(EXESUF): tests/ipoctal232-test.o tests/qom-test$(EXESUF): tests/qom-test.o diff --git a/tests/virtio-rng-test.c b/tests/virtio-rng-test.c new file mode 100644 index 0000000000..402c2060da --- /dev/null +++ b/tests/virtio-rng-test.c @@ -0,0 +1,33 @@ +/* + * QTest testcase for VirtIO RNG + * + * Copyright (c) 2014 SUSE LINUX Products GmbH + * + * 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 +#include +#include "libqtest.h" +#include "qemu/osdep.h" + +/* Tests only initialization so far. TODO: Replace with functional tests */ +static void pci_nop(void) +{ +} + +int main(int argc, char **argv) +{ + int ret; + + g_test_init(&argc, &argv, NULL); + qtest_add_func("/virtio/rng/pci/nop", pci_nop); + + qtest_start("-device virtio-rng-pci"); + ret = g_test_run(); + + qtest_end(); + + return ret; +} -- cgit v1.2.3-55-g7522 From 26c9a015ef8ad158a62690f72ee04d10545db80d Mon Sep 17 00:00:00 2001 From: Andreas Färber Date: Fri, 21 Feb 2014 16:42:15 +0100 Subject: tests: Add virtio-scsi qtest Acked-by: Paolo Bonzini Signed-off-by: Andreas Färber --- tests/Makefile | 3 +++ tests/virtio-scsi-test.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 tests/virtio-scsi-test.c (limited to 'tests') diff --git a/tests/Makefile b/tests/Makefile index 308a5a2248..75b46599f6 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -78,6 +78,8 @@ check-qtest-virtio-y += tests/virtio-blk-test$(EXESUF) gcov-files-virtio-y += i386-softmmu/hw/block/virtio-blk.c check-qtest-virtio-y += tests/virtio-rng-test$(EXESUF) gcov-files-virtio-y += hw/virtio/virtio-rng.c +check-qtest-virtio-y += tests/virtio-scsi-test$(EXESUF) +gcov-files-virtio-y += i386-softmmu/hw/scsi/virtio-scsi.c check-qtest-pci-y += tests/e1000-test$(EXESUF) gcov-files-pci-y += hw/net/e1000.c @@ -249,6 +251,7 @@ tests/virtio-balloon-test$(EXESUF): tests/virtio-balloon-test.o tests/virtio-blk-test$(EXESUF): tests/virtio-blk-test.o tests/virtio-net-test$(EXESUF): tests/virtio-net-test.o tests/virtio-rng-test$(EXESUF): tests/virtio-rng-test.o +tests/virtio-scsi-test$(EXESUF): tests/virtio-scsi-test.o tests/tpci200-test$(EXESUF): tests/tpci200-test.o tests/ipoctal232-test$(EXESUF): tests/ipoctal232-test.o tests/qom-test$(EXESUF): tests/qom-test.o diff --git a/tests/virtio-scsi-test.c b/tests/virtio-scsi-test.c new file mode 100644 index 0000000000..3230908b98 --- /dev/null +++ b/tests/virtio-scsi-test.c @@ -0,0 +1,35 @@ +/* + * QTest testcase for VirtIO SCSI + * + * Copyright (c) 2014 SUSE LINUX Products GmbH + * + * 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 +#include +#include "libqtest.h" +#include "qemu/osdep.h" + +/* Tests only initialization so far. TODO: Replace with functional tests */ +static void pci_nop(void) +{ +} + +int main(int argc, char **argv) +{ + int ret; + + g_test_init(&argc, &argv, NULL); + qtest_add_func("/virtio/scsi/pci/nop", pci_nop); + + qtest_start("-drive id=drv0,if=none,file=/dev/null " + "-device virtio-scsi-pci,id=vscsi0 " + "-device scsi-hd,bus=vscsi0.0,drive=drv0"); + ret = g_test_run(); + + qtest_end(); + + return ret; +} -- cgit v1.2.3-55-g7522 From aa97405e3289059ab614e906ce4f1141971dfd9c Mon Sep 17 00:00:00 2001 From: Andreas Färber Date: Fri, 21 Feb 2014 17:36:57 +0100 Subject: tests: Add virtio-serial qtest Signed-off-by: Andreas Färber --- tests/Makefile | 3 +++ tests/virtio-serial-test.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 tests/virtio-serial-test.c (limited to 'tests') diff --git a/tests/Makefile b/tests/Makefile index 75b46599f6..179667f31b 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -80,6 +80,8 @@ check-qtest-virtio-y += tests/virtio-rng-test$(EXESUF) gcov-files-virtio-y += hw/virtio/virtio-rng.c check-qtest-virtio-y += tests/virtio-scsi-test$(EXESUF) gcov-files-virtio-y += i386-softmmu/hw/scsi/virtio-scsi.c +check-qtest-virtio-y += tests/virtio-serial-test$(EXESUF) +gcov-files-virtio-y += i386-softmmu/hw/char/virtio-serial-bus.c check-qtest-pci-y += tests/e1000-test$(EXESUF) gcov-files-pci-y += hw/net/e1000.c @@ -252,6 +254,7 @@ tests/virtio-blk-test$(EXESUF): tests/virtio-blk-test.o tests/virtio-net-test$(EXESUF): tests/virtio-net-test.o tests/virtio-rng-test$(EXESUF): tests/virtio-rng-test.o tests/virtio-scsi-test$(EXESUF): tests/virtio-scsi-test.o +tests/virtio-serial-test$(EXESUF): tests/virtio-serial-test.o tests/tpci200-test$(EXESUF): tests/tpci200-test.o tests/ipoctal232-test$(EXESUF): tests/ipoctal232-test.o tests/qom-test$(EXESUF): tests/qom-test.o diff --git a/tests/virtio-serial-test.c b/tests/virtio-serial-test.c new file mode 100644 index 0000000000..e7438751ea --- /dev/null +++ b/tests/virtio-serial-test.c @@ -0,0 +1,33 @@ +/* + * QTest testcase for VirtIO Serial + * + * Copyright (c) 2014 SUSE LINUX Products GmbH + * + * 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 +#include +#include "libqtest.h" +#include "qemu/osdep.h" + +/* Tests only initialization so far. TODO: Replace with functional tests */ +static void pci_nop(void) +{ +} + +int main(int argc, char **argv) +{ + int ret; + + g_test_init(&argc, &argv, NULL); + qtest_add_func("/virtio/serial/pci/nop", pci_nop); + + qtest_start("-device virtio-serial-pci"); + ret = g_test_run(); + + qtest_end(); + + return ret; +} -- cgit v1.2.3-55-g7522 From 6e8114a0650e78b6476e312de59361ef11c62b59 Mon Sep 17 00:00:00 2001 From: Andreas Färber Date: Fri, 21 Feb 2014 17:49:12 +0100 Subject: tests: Add virtio-console qtest Signed-off-by: Andreas Färber --- tests/Makefile | 6 ++++++ tests/virtio-console-test.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 tests/virtio-console-test.c (limited to 'tests') diff --git a/tests/Makefile b/tests/Makefile index 179667f31b..76a2468cfa 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -69,6 +69,9 @@ gcov-files-ipack-y += hw/ipack/ipack.c check-qtest-ipack-y += tests/ipoctal232-test$(EXESUF) gcov-files-ipack-y += hw/char/ipoctal232.c +check-qtest-virtioserial-y += tests/virtio-console-test$(EXESUF) +gcov-files-virtioserial-y += hw/char/virtio-console.c + gcov-files-virtio-y += i386-softmmu/hw/virtio/virtio.c check-qtest-virtio-y += tests/virtio-net-test$(EXESUF) gcov-files-virtio-y += i386-softmmu/hw/net/virtio-net.c @@ -82,6 +85,8 @@ check-qtest-virtio-y += tests/virtio-scsi-test$(EXESUF) gcov-files-virtio-y += i386-softmmu/hw/scsi/virtio-scsi.c check-qtest-virtio-y += tests/virtio-serial-test$(EXESUF) gcov-files-virtio-y += i386-softmmu/hw/char/virtio-serial-bus.c +check-qtest-virtio-y += $(check-qtest-virtioserial-y) +gcov-files-virtio-y += $(gcov-files-virtioserial-y) check-qtest-pci-y += tests/e1000-test$(EXESUF) gcov-files-pci-y += hw/net/e1000.c @@ -255,6 +260,7 @@ tests/virtio-net-test$(EXESUF): tests/virtio-net-test.o tests/virtio-rng-test$(EXESUF): tests/virtio-rng-test.o tests/virtio-scsi-test$(EXESUF): tests/virtio-scsi-test.o tests/virtio-serial-test$(EXESUF): tests/virtio-serial-test.o +tests/virtio-console-test$(EXESUF): tests/virtio-console-test.o tests/tpci200-test$(EXESUF): tests/tpci200-test.o tests/ipoctal232-test$(EXESUF): tests/ipoctal232-test.o tests/qom-test$(EXESUF): tests/qom-test.o diff --git a/tests/virtio-console-test.c b/tests/virtio-console-test.c new file mode 100644 index 0000000000..f98f5af252 --- /dev/null +++ b/tests/virtio-console-test.c @@ -0,0 +1,34 @@ +/* + * QTest testcase for VirtIO Console + * + * Copyright (c) 2014 SUSE LINUX Products GmbH + * + * 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 +#include +#include "libqtest.h" +#include "qemu/osdep.h" + +/* Tests only initialization so far. TODO: Replace with functional tests */ +static void pci_nop(void) +{ +} + +int main(int argc, char **argv) +{ + int ret; + + g_test_init(&argc, &argv, NULL); + qtest_add_func("/virtio/console/pci/nop", pci_nop); + + qtest_start("-device virtio-serial-pci,id=vser0 " + "-device virtconsole,bus=vser0.0"); + ret = g_test_run(); + + qtest_end(); + + return ret; +} -- cgit v1.2.3-55-g7522 From 04e9a20b495f37f3132f4ada80fd925b4794b253 Mon Sep 17 00:00:00 2001 From: Alexey Kardashevskiy Date: Mon, 10 Feb 2014 14:52:56 +1100 Subject: tests: Add spapr-pci-host-bridge qtest This adds a test whether sPAPR PHB can be added via the command line. Signed-off-by: Alexey Kardashevskiy Signed-off-by: Andreas Färber --- tests/Makefile | 3 +++ tests/spapr-phb-test.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 tests/spapr-phb-test.c (limited to 'tests') diff --git a/tests/Makefile b/tests/Makefile index 76a2468cfa..7bc3999ecc 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -144,6 +144,8 @@ check-qtest-arm-y = tests/tmp105-test$(EXESUF) gcov-files-arm-y += hw/misc/tmp105.c check-qtest-ppc-y += tests/boot-order-test$(EXESUF) check-qtest-ppc64-y += tests/boot-order-test$(EXESUF) +check-qtest-ppc64-y += tests/spapr-phb-test$(EXESUF) +gcov-files-ppc64-y += ppc64-softmmu/hw/ppc/spapr_pci.c check-qtest-microblazeel-y = $(check-qtest-microblaze-y) check-qtest-xtensaeb-y = $(check-qtest-xtensa-y) @@ -240,6 +242,7 @@ libqos-omap-obj-y = $(libqos-obj-y) tests/libqos/i2c-omap.o tests/rtc-test$(EXESUF): tests/rtc-test.o tests/m48t59-test$(EXESUF): tests/m48t59-test.o tests/endianness-test$(EXESUF): tests/endianness-test.o +tests/spapr-phb-test$(EXESUF): tests/spapr-phb-test.o $(libqos-obj-y) 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 diff --git a/tests/spapr-phb-test.c b/tests/spapr-phb-test.c new file mode 100644 index 0000000000..b629de475a --- /dev/null +++ b/tests/spapr-phb-test.c @@ -0,0 +1,35 @@ +/* + * QTest testcase for SPAPR PHB + * + * Authors: + * Alexey Kardashevskiy + * + * 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 + +#include "libqtest.h" + +#define TYPE_SPAPR_PCI_HOST_BRIDGE "spapr-pci-host-bridge" + +/* Tests only initialization so far. TODO: Replace with functional tests */ +static void test_phb_device(void) +{ +} + +int main(int argc, char **argv) +{ + int ret; + + g_test_init(&argc, &argv, NULL); + qtest_add_func("/spapr-phb/device", test_phb_device); + + qtest_start("-device " TYPE_SPAPR_PCI_HOST_BRIDGE ",index=100"); + + ret = g_test_run(); + + qtest_end(); + + return ret; +} -- cgit v1.2.3-55-g7522 From f8762027a33e2f5d0915c56a904962b1481f75c1 Mon Sep 17 00:00:00 2001 From: Marcel Apfelbaum Date: Tue, 11 Mar 2014 15:00:34 +0200 Subject: libqtest: Fix possible deadlock in qtest initialization 'socket_accept' waits for QEMU to init its unix socket. If QEMU encounters an error during command line parsing, it can exit before initializing the communication channel. Using a timeout for sockets fixes the issue. Reviewed-by: Eric Blake Signed-off-by: Marcel Apfelbaum Reviewed-by: Stefan Hajnoczi Signed-off-by: Andreas Färber --- tests/libqtest.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/libqtest.c b/tests/libqtest.c index f587d36176..c9e78aa741 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -34,6 +34,7 @@ #include "qapi/qmp/json-parser.h" #define MAX_IRQ 256 +#define SOCKET_TIMEOUT 5 QTestState *global_qtest; @@ -78,12 +79,16 @@ static int socket_accept(int sock) struct sockaddr_un addr; socklen_t addrlen; int ret; + struct timeval timeout = { .tv_sec = SOCKET_TIMEOUT, + .tv_usec = 0 }; + + setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (void *)&timeout, + sizeof(timeout)); addrlen = sizeof(addr); do { ret = accept(sock, (struct sockaddr *)&addr, &addrlen); } while (ret == -1 && errno == EINTR); - g_assert_no_errno(ret); close(sock); return ret; @@ -147,12 +152,16 @@ QTestState *qtest_init(const char *extra_args) } s->fd = socket_accept(sock); - s->qmp_fd = socket_accept(qmpsock); + if (s->fd >= 0) { + s->qmp_fd = socket_accept(qmpsock); + } unlink(socket_path); unlink(qmp_socket_path); g_free(socket_path); g_free(qmp_socket_path); + g_assert(s->fd >= 0 && s->qmp_fd >= 0); + s->rx = g_string_new(""); for (i = 0; i < MAX_IRQ; i++) { s->irq_level[i] = false; -- cgit v1.2.3-55-g7522