diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/display-vga-test.c | 6 | ||||
-rw-r--r-- | tests/endianness-test.c | 5 | ||||
-rw-r--r-- | tests/i440fx-test.c | 4 | ||||
-rw-r--r-- | tests/intel-hda-test.c | 6 | ||||
-rw-r--r-- | tests/test-filter-redirector.c | 6 | ||||
-rw-r--r-- | tests/test-logging.c | 88 | ||||
-rw-r--r-- | tests/virtio-blk-test.c | 5 | ||||
-rw-r--r-- | tests/virtio-console-test.c | 6 | ||||
-rw-r--r-- | tests/virtio-net-test.c | 6 | ||||
-rw-r--r-- | tests/virtio-scsi-test.c | 6 | ||||
-rw-r--r-- | tests/wdt_ib700-test.c | 6 |
11 files changed, 33 insertions, 111 deletions
diff --git a/tests/display-vga-test.c b/tests/display-vga-test.c index 06b244ed9a..91460215cc 100644 --- a/tests/display-vga-test.c +++ b/tests/display-vga-test.c @@ -50,8 +50,6 @@ static void pci_virtio_vga(void) int main(int argc, char **argv) { - int ret; - g_test_init(&argc, &argv, NULL); qtest_add_func("/display/pci/cirrus", pci_cirrus); @@ -62,7 +60,5 @@ int main(int argc, char **argv) #ifdef CONFIG_VIRTIO_VGA qtest_add_func("/display/pci/virtio-vga", pci_virtio_vga); #endif - ret = g_test_run(); - - return ret; + return g_test_run(); } diff --git a/tests/endianness-test.c b/tests/endianness-test.c index 2197972e55..b7a120e0a4 100644 --- a/tests/endianness-test.c +++ b/tests/endianness-test.c @@ -282,7 +282,6 @@ static void test_endianness_combine(gconstpointer data) int main(int argc, char **argv) { const char *arch = qtest_get_arch(); - int ret; int i; g_test_init(&argc, &argv, NULL); @@ -305,7 +304,5 @@ int main(int argc, char **argv) qtest_add_data_func(path, &test_cases[i], test_endianness_combine); } - ret = g_test_run(); - - return ret; + return g_test_run(); } diff --git a/tests/i440fx-test.c b/tests/i440fx-test.c index c1d9b3eb9e..3542ad114e 100644 --- a/tests/i440fx-test.c +++ b/tests/i440fx-test.c @@ -394,7 +394,6 @@ static void request_pflash(FirmwareTestFixture *fixture, int main(int argc, char **argv) { TestData data; - int ret; g_test_init(&argc, &argv, NULL); @@ -405,6 +404,5 @@ int main(int argc, char **argv) add_firmware_test("i440fx/firmware/bios", request_bios); add_firmware_test("i440fx/firmware/pflash", request_pflash); - ret = g_test_run(); - return ret; + return g_test_run(); } diff --git a/tests/intel-hda-test.c b/tests/intel-hda-test.c index b0ca7e042a..b782b2e944 100644 --- a/tests/intel-hda-test.c +++ b/tests/intel-hda-test.c @@ -31,13 +31,9 @@ static void ich9_test(void) int main(int argc, char **argv) { - int ret; - g_test_init(&argc, &argv, NULL); qtest_add_func("/intel-hda/ich6", ich6_test); qtest_add_func("/intel-hda/ich9", ich9_test); - ret = g_test_run(); - - return ret; + return g_test_run(); } diff --git a/tests/test-filter-redirector.c b/tests/test-filter-redirector.c index 280e4b68ab..c63b68f03a 100644 --- a/tests/test-filter-redirector.c +++ b/tests/test-filter-redirector.c @@ -209,12 +209,8 @@ static void test_redirector_rx(void) int main(int argc, char **argv) { - int ret; - g_test_init(&argc, &argv, NULL); qtest_add_func("/netfilter/redirector_tx", test_redirector_tx); qtest_add_func("/netfilter/redirector_rx", test_redirector_rx); - ret = g_test_run(); - - return ret; + return g_test_run(); } diff --git a/tests/test-logging.c b/tests/test-logging.c index 5ef5bb887d..440e75f5db 100644 --- a/tests/test-logging.c +++ b/tests/test-logging.c @@ -27,11 +27,14 @@ #include "qemu/osdep.h" #include "qemu-common.h" -#include "include/qemu/log.h" +#include "qapi/error.h" +#include "qemu/log.h" static void test_parse_range(void) { - qemu_set_dfilter_ranges("0x1000+0x100"); + Error *err = NULL; + + qemu_set_dfilter_ranges("0x1000+0x100", &error_abort); g_assert_false(qemu_log_in_addr_range(0xfff)); g_assert(qemu_log_in_addr_range(0x1000)); @@ -39,102 +42,57 @@ static void test_parse_range(void) g_assert(qemu_log_in_addr_range(0x10ff)); g_assert_false(qemu_log_in_addr_range(0x1100)); - qemu_set_dfilter_ranges("0x1000-0x100"); + qemu_set_dfilter_ranges("0x1000-0x100", &error_abort); g_assert_false(qemu_log_in_addr_range(0x1001)); g_assert(qemu_log_in_addr_range(0x1000)); g_assert(qemu_log_in_addr_range(0x0f01)); g_assert_false(qemu_log_in_addr_range(0x0f00)); - qemu_set_dfilter_ranges("0x1000..0x1100"); + qemu_set_dfilter_ranges("0x1000..0x1100", &error_abort); g_assert_false(qemu_log_in_addr_range(0xfff)); g_assert(qemu_log_in_addr_range(0x1000)); g_assert(qemu_log_in_addr_range(0x1100)); g_assert_false(qemu_log_in_addr_range(0x1101)); - qemu_set_dfilter_ranges("0x1000..0x1000"); + qemu_set_dfilter_ranges("0x1000..0x1000", &error_abort); g_assert_false(qemu_log_in_addr_range(0xfff)); g_assert(qemu_log_in_addr_range(0x1000)); g_assert_false(qemu_log_in_addr_range(0x1001)); - qemu_set_dfilter_ranges("0x1000+0x100,0x2100-0x100,0x3000..0x3100"); + qemu_set_dfilter_ranges("0x1000+0x100,0x2100-0x100,0x3000..0x3100", + &error_abort); g_assert(qemu_log_in_addr_range(0x1050)); g_assert(qemu_log_in_addr_range(0x2050)); g_assert(qemu_log_in_addr_range(0x3050)); -} -#ifdef CONFIG_HAS_GLIB_SUBPROCESS_TESTS -static void test_parse_invalid_range_subprocess(void) -{ - qemu_set_dfilter_ranges("0x1000+onehundred"); -} -static void test_parse_invalid_range(void) -{ - g_test_trap_subprocess("/logging/parse_invalid_range/subprocess", 0, 0); - g_test_trap_assert_failed(); - g_test_trap_assert_stdout(""); - g_test_trap_assert_stderr("*Failed to parse range in: 0x1000+onehundred\n"); -} -static void test_parse_zero_range_subprocess(void) -{ - qemu_set_dfilter_ranges("0x1000+0"); -} -static void test_parse_zero_range(void) -{ - g_test_trap_subprocess("/logging/parse_zero_range/subprocess", 0, 0); - g_test_trap_assert_failed(); - g_test_trap_assert_stdout(""); - g_test_trap_assert_stderr("*Failed to parse range in: 0x1000+0\n"); -} + qemu_set_dfilter_ranges("0x1000+onehundred", &err); + error_free_or_abort(&err); -/* As the only real failure from a bad log filename path spec is - * reporting to the user we have to use the g_test_trap_subprocess - * mechanism and check no errors reported on stderr. - */ -static void test_parse_path_subprocess(void) -{ - /* All these should work without issue */ - qemu_set_log_filename("/tmp/qemu.log"); - qemu_set_log_filename("/tmp/qemu-%d.log"); - qemu_set_log_filename("/tmp/qemu.log.%d"); + qemu_set_dfilter_ranges("0x1000+0", &err); + error_free_or_abort(&err); } + static void test_parse_path(void) { - g_test_trap_subprocess ("/logging/parse_path/subprocess", 0, 0); - g_test_trap_assert_passed(); - g_test_trap_assert_stdout(""); - g_test_trap_assert_stderr(""); -} -static void test_parse_invalid_path_subprocess(void) -{ - qemu_set_log_filename("/tmp/qemu-%d%d.log"); -} -static void test_parse_invalid_path(void) -{ - g_test_trap_subprocess ("/logging/parse_invalid_path/subprocess", 0, 0); - g_test_trap_assert_passed(); - g_test_trap_assert_stdout(""); - g_test_trap_assert_stderr("Bad logfile format: /tmp/qemu-%d%d.log\n"); + Error *err = NULL; + + qemu_set_log_filename("/tmp/qemu.log", &error_abort); + qemu_set_log_filename("/tmp/qemu-%d.log", &error_abort); + qemu_set_log_filename("/tmp/qemu.log.%d", &error_abort); + + qemu_set_log_filename("/tmp/qemu-%d%d.log", &err); + error_free_or_abort(&err); } -#endif /* CONFIG_HAS_GLIB_SUBPROCESS_TESTS */ int main(int argc, char **argv) { g_test_init(&argc, &argv, NULL); g_test_add_func("/logging/parse_range", test_parse_range); -#ifdef CONFIG_HAS_GLIB_SUBPROCESS_TESTS - g_test_add_func("/logging/parse_invalid_range/subprocess", test_parse_invalid_range_subprocess); - g_test_add_func("/logging/parse_invalid_range", test_parse_invalid_range); - g_test_add_func("/logging/parse_zero_range/subprocess", test_parse_zero_range_subprocess); - g_test_add_func("/logging/parse_zero_range", test_parse_zero_range); g_test_add_func("/logging/parse_path", test_parse_path); - g_test_add_func("/logging/parse_path/subprocess", test_parse_path_subprocess); - g_test_add_func("/logging/parse_invalid_path", test_parse_invalid_path); - g_test_add_func("/logging/parse_invalid_path/subprocess", test_parse_invalid_path_subprocess); -#endif return g_test_run(); } diff --git a/tests/virtio-blk-test.c b/tests/virtio-blk-test.c index 4ab14d5d36..811cf756c8 100644 --- a/tests/virtio-blk-test.c +++ b/tests/virtio-blk-test.c @@ -753,7 +753,6 @@ static void mmio_basic(void) int main(int argc, char **argv) { - int ret; const char *arch = qtest_get_arch(); g_test_init(&argc, &argv, NULL); @@ -769,7 +768,5 @@ int main(int argc, char **argv) qtest_add_func("/virtio/blk/mmio/basic", mmio_basic); } - ret = g_test_run(); - - return ret; + return g_test_run(); } diff --git a/tests/virtio-console-test.c b/tests/virtio-console-test.c index 6d6414dc8e..1c3de072f4 100644 --- a/tests/virtio-console-test.c +++ b/tests/virtio-console-test.c @@ -27,13 +27,9 @@ static void serialport_pci_nop(void) int main(int argc, char **argv) { - int ret; - g_test_init(&argc, &argv, NULL); qtest_add_func("/virtio/console/pci/nop", console_pci_nop); qtest_add_func("/virtio/serialport/pci/nop", serialport_pci_nop); - ret = g_test_run(); - - return ret; + return g_test_run(); } diff --git a/tests/virtio-net-test.c b/tests/virtio-net-test.c index 0d2c63f8ab..a34a9392e3 100644 --- a/tests/virtio-net-test.c +++ b/tests/virtio-net-test.c @@ -250,8 +250,6 @@ static void hotplug(void) int main(int argc, char **argv) { - int ret; - g_test_init(&argc, &argv, NULL); #ifndef _WIN32 qtest_add_data_func("/virtio/net/pci/basic", send_recv_test, pci_basic); @@ -260,7 +258,5 @@ int main(int argc, char **argv) #endif qtest_add_func("/virtio/net/pci/hotplug", hotplug); - ret = g_test_run(); - - return ret; + return g_test_run(); } diff --git a/tests/virtio-scsi-test.c b/tests/virtio-scsi-test.c index cbe5dcca24..f1489e68a0 100644 --- a/tests/virtio-scsi-test.c +++ b/tests/virtio-scsi-test.c @@ -247,15 +247,11 @@ static void test_unaligned_write_same(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_add_func("/virtio/scsi/pci/hotplug", hotplug); qtest_add_func("/virtio/scsi/pci/scsi-disk/unaligned-write-same", test_unaligned_write_same); - ret = g_test_run(); - - return ret; + return g_test_run(); } diff --git a/tests/wdt_ib700-test.c b/tests/wdt_ib700-test.c index 9c1d78b1bc..49f4f0c221 100644 --- a/tests/wdt_ib700-test.c +++ b/tests/wdt_ib700-test.c @@ -117,15 +117,11 @@ static void ib700_none(void) int main(int argc, char **argv) { - int ret; - g_test_init(&argc, &argv, NULL); qtest_add_func("/wdt_ib700/pause", ib700_pause); qtest_add_func("/wdt_ib700/reset", ib700_reset); qtest_add_func("/wdt_ib700/shutdown", ib700_shutdown); qtest_add_func("/wdt_ib700/none", ib700_none); - ret = g_test_run(); - - return ret; + return g_test_run(); } |