From a60e1544b515e5205489141fc76cdf26de3a5f1b Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Fri, 25 Jul 2025 15:50:31 +0200 Subject: qtest/qom-test: Shallow testing of qom-list / qom-get This test traverses the QOM sub-tree rooted at /machine with a combination of qom-list and qom-get. In my x86_64 testing, it runs almost 12000 QMP commands in 34 seconds. With -m slow, we test more machines, and it takes almost 84000 commands in almost four minutes. Since commit 3dd93992ffb (tests/qtest/qom-test: unit test for qom-list-get), the test traverses this tree a second time, with qom-list-get. In my x86_64 testing, this takes some 200 QMP commands and around two seconds, and some 1100 in just under 12s with -m slow. Traversing the entire tree is useful, because it exercise the QOM property getters. Traversing it twice not so much. Make the qom-list / qom-get test shallow unless -m slow is given: don't recurse. Cuts the number of commands to around 600, and run time to under 5s for me. Signed-off-by: Markus Armbruster Message-ID: <20250725135034.2280477-3-armbru@redhat.com> Reviewed-by: Steve Sistare --- tests/qtest/qom-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/qtest') diff --git a/tests/qtest/qom-test.c b/tests/qtest/qom-test.c index 4ade1c7..7dea0d8 100644 --- a/tests/qtest/qom-test.c +++ b/tests/qtest/qom-test.c @@ -180,7 +180,7 @@ static void test_properties(QTestState *qts, const char *path, bool recurse) links = g_slist_delete_link(links, links); } while (children) { - test_properties(qts, children->data, true); + test_properties(qts, children->data, g_test_slow()); g_free(children->data); children = g_slist_delete_link(children, children); } -- cgit v1.1 From 67a392f7cf2b1662c21fb609b25bd745d25a2d05 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Fri, 25 Jul 2025 15:50:32 +0200 Subject: qtest/qom-test: Traverse entire QOM tree This test traverses the QOM sub-tree rooted at /machine. Traverse the entire tree instead. The x86_64 test runs some 40 additional QMP commands, and stays under 5s for me. Signed-off-by: Markus Armbruster Message-ID: <20250725135034.2280477-4-armbru@redhat.com> Reviewed-by: Steve Sistare --- tests/qtest/qom-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/qtest') diff --git a/tests/qtest/qom-test.c b/tests/qtest/qom-test.c index 7dea0d8..a2db56b 100644 --- a/tests/qtest/qom-test.c +++ b/tests/qtest/qom-test.c @@ -211,7 +211,7 @@ static void test_machine(gconstpointer data) test_properties(qts, "/machine", true); - qlist_append_str(paths, "/machine"); + qlist_append_str(paths, "/"); test_list_get(qts, paths); test_list_get_value(qts); -- cgit v1.1 From c4c3ee8c1de5f04b4a34b53c2f3d6e85f5a2fe6f Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Fri, 25 Jul 2025 15:50:33 +0200 Subject: qtest/qom-test: Don't bother to execute QMP command quit Signed-off-by: Markus Armbruster Message-ID: <20250725135034.2280477-5-armbru@redhat.com> Reviewed-by: Steve Sistare --- tests/qtest/qom-test.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'tests/qtest') diff --git a/tests/qtest/qom-test.c b/tests/qtest/qom-test.c index a2db56b..2da9918 100644 --- a/tests/qtest/qom-test.c +++ b/tests/qtest/qom-test.c @@ -215,10 +215,6 @@ static void test_machine(gconstpointer data) test_list_get(qts, paths); test_list_get_value(qts); - response = qtest_qmp(qts, "{ 'execute': 'quit' }"); - g_assert(qdict_haskey(response, "return")); - qobject_unref(response); - qtest_quit(qts); g_free((void *)machine); } -- cgit v1.1 From c9a1ea9c52e6462ad5c7814f3abd65baa69dc4ce Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 28 Jul 2025 16:57:47 +0200 Subject: Revert "tests/qtest: use qos_printf instead of g_test_message" This reverts commit 30ea13e9d97dcbd4ea541ddf9e8857fa1d5cb30f. Also rewrites qos_printf() calls added later. "make check" prints many lines like stdout: 138: UNKNOWN: # # qos_test running single test in subprocess stdout: 139: UNKNOWN: # # set_protocol_features: 0x42 stdout: 140: UNKNOWN: # # set_owner: start of session stdout: 141: UNKNOWN: # # vhost-user: un-handled message: 14 stdout: 142: UNKNOWN: # # vhost-user: un-handled message: 14 stdout: 143: UNKNOWN: # # set_vring(0)=enabled stdout: 144: UNKNOWN: # # set_vring(1)=enabled stdout: 145: UNKNOWN: # # set_vring(0)=enabled stdout: 146: UNKNOWN: # # set_vring(1)=enabled stdout: 147: UNKNOWN: # # set_vring(0)=enabled stdout: 148: UNKNOWN: # # set_vring(1)=enabled stdout: 149: UNKNOWN: # # set_vring(0)=enabled stdout: 150: UNKNOWN: # # set_vring(1)=enabled stdout: 151: UNKNOWN: # # set_vring(0)=enabled stdout: 152: UNKNOWN: # # set_vring(1)=enabled stdout: 153: UNKNOWN: # # set_vring_num: 0/256 stdout: 154: UNKNOWN: # # set_vring_addr: 0x7f9060000000/0x7f905ffff000/0x7f9060001000 Turns out this is qos-test, and the culprit is a commit meant to ease debugging. Revert it until a better solution is found. Signed-off-by: Markus Armbruster Message-ID: <20250728145747.3165315-1-armbru@redhat.com> [Commit message clarified] --- tests/qtest/qos-test.c | 5 ----- tests/qtest/vhost-user-test.c | 27 +++++++++++++-------------- 2 files changed, 13 insertions(+), 19 deletions(-) (limited to 'tests/qtest') diff --git a/tests/qtest/qos-test.c b/tests/qtest/qos-test.c index abfd4b9..00f39f3 100644 --- a/tests/qtest/qos-test.c +++ b/tests/qtest/qos-test.c @@ -328,11 +328,6 @@ static void walk_path(QOSGraphNode *orig_path, int len) int main(int argc, char **argv, char** envp) { g_test_init(&argc, &argv, NULL); - - if (g_test_subprocess()) { - qos_printf("qos_test running single test in subprocess\n"); - } - if (g_test_verbose()) { qos_printf("ENVIRONMENT VARIABLES: {\n"); for (char **env = envp; *env != 0; env++) { diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c index 75cb3e4..56472ca 100644 --- a/tests/qtest/vhost-user-test.c +++ b/tests/qtest/vhost-user-test.c @@ -26,7 +26,6 @@ #include "libqos/virtio-pci.h" #include "libqos/malloc-pc.h" -#include "libqos/qgraph_internal.h" #include "hw/virtio/virtio-net.h" #include "standard-headers/linux/vhost_types.h" @@ -345,7 +344,7 @@ static void chr_read(void *opaque, const uint8_t *buf, int size) } if (size != VHOST_USER_HDR_SIZE) { - qos_printf("%s: Wrong message size received %d\n", __func__, size); + g_test_message("Wrong message size received %d", size); return; } @@ -356,8 +355,8 @@ static void chr_read(void *opaque, const uint8_t *buf, int size) p += VHOST_USER_HDR_SIZE; size = qemu_chr_fe_read_all(chr, p, msg.size); if (size != msg.size) { - qos_printf("%s: Wrong message size received %d != %d\n", - __func__, size, msg.size); + g_test_message("Wrong message size received %d != %d", + size, msg.size); goto out; } } @@ -393,7 +392,7 @@ static void chr_read(void *opaque, const uint8_t *buf, int size) * We don't need to do anything here, the remote is just * letting us know it is in charge. Just log it. */ - qos_printf("set_owner: start of session\n"); + g_test_message("set_owner: start of session\n"); break; case VHOST_USER_GET_PROTOCOL_FEATURES: @@ -419,7 +418,7 @@ static void chr_read(void *opaque, const uint8_t *buf, int size) * the remote end to send this. There is no handshake reply so * just log the details for debugging. */ - qos_printf("set_protocol_features: 0x%"PRIx64 "\n", msg.payload.u64); + g_test_message("set_protocol_features: 0x%"PRIx64 "\n", msg.payload.u64); break; /* @@ -427,11 +426,11 @@ static void chr_read(void *opaque, const uint8_t *buf, int size) * address of the vrings but we can simply report them. */ case VHOST_USER_SET_VRING_NUM: - qos_printf("set_vring_num: %d/%d\n", + g_test_message("set_vring_num: %d/%d\n", msg.payload.state.index, msg.payload.state.num); break; case VHOST_USER_SET_VRING_ADDR: - qos_printf("set_vring_addr: 0x%"PRIx64"/0x%"PRIx64"/0x%"PRIx64"\n", + g_test_message("set_vring_addr: 0x%"PRIx64"/0x%"PRIx64"/0x%"PRIx64"\n", msg.payload.addr.avail_user_addr, msg.payload.addr.desc_user_addr, msg.payload.addr.used_user_addr); @@ -464,7 +463,7 @@ static void chr_read(void *opaque, const uint8_t *buf, int size) case VHOST_USER_SET_VRING_CALL: /* consume the fd */ if (!qemu_chr_fe_get_msgfds(chr, &fd, 1) && fd < 0) { - qos_printf("call fd: %d, do not set non-blocking\n", fd); + g_test_message("call fd: %d, do not set non-blocking\n", fd); break; } /* @@ -510,12 +509,12 @@ static void chr_read(void *opaque, const uint8_t *buf, int size) * fully functioning vhost-user we would enable/disable the * vring monitoring. */ - qos_printf("set_vring(%d)=%s\n", msg.payload.state.index, + g_test_message("set_vring(%d)=%s\n", msg.payload.state.index, msg.payload.state.num ? "enabled" : "disabled"); break; default: - qos_printf("vhost-user: un-handled message: %d\n", msg.request); + g_test_message("vhost-user: un-handled message: %d\n", msg.request); break; } @@ -539,7 +538,7 @@ static const char *init_hugepagefs(void) } if (access(path, R_OK | W_OK | X_OK)) { - qos_printf("access on path (%s): %s", path, strerror(errno)); + g_test_message("access on path (%s): %s", path, strerror(errno)); g_test_fail(); return NULL; } @@ -549,13 +548,13 @@ static const char *init_hugepagefs(void) } while (ret != 0 && errno == EINTR); if (ret != 0) { - qos_printf("statfs on path (%s): %s", path, strerror(errno)); + g_test_message("statfs on path (%s): %s", path, strerror(errno)); g_test_fail(); return NULL; } if (fs.f_type != HUGETLBFS_MAGIC) { - qos_printf("Warning: path not on HugeTLBFS: %s", path); + g_test_message("Warning: path not on HugeTLBFS: %s", path); g_test_fail(); return NULL; } -- cgit v1.1