From 44c1141770edce04bb9729d1fbb0a7b83aa73ad7 Mon Sep 17 00:00:00 2001 From: Victor Toso Date: Wed, 16 Feb 2022 09:51:34 +0100 Subject: tests: tree: Fix leaks of OsinfoTree * ==420507== 509 (48 direct, 461 indirect) bytes in 1 blocks are definitely lost in loss record 2,401 of 2,440 ==420507== at 0x48F3437: g_type_create_instance (in /usr/lib64/libgobject-2.0.so.0.7000.3) ==420507== by 0x48DAD4C: ??? (in /usr/lib64/libgobject-2.0.so.0.7000.3) ==420507== by 0x48DC2C7: g_object_new_valist (in /usr/lib64/libgobject-2.0.so.0.7000.3) ==420507== by 0x48DC7FC: g_object_new (in /usr/lib64/libgobject-2.0.so.0.7000.3) ==420507== by 0x48815F8: osinfo_tree_new (osinfo_tree.c:462) ==420507== by 0x402E99: test_create_tree.constprop.0 (test-tree.c:119) ==420507== by 0x403027: test_matching (test-tree.c:176) ==420507== by 0x4992BD5: ??? (in /usr/lib64/libglib-2.0.so.0.7000.3) ==420507== by 0x49928FA: ??? (in /usr/lib64/libglib-2.0.so.0.7000.3) ==420507== by 0x49930A9: g_test_run_suite (in /usr/lib64/libglib-2.0.so.0.7000.3) ==420507== by 0x49930D0: g_test_run (in /usr/lib64/libglib-2.0.so.0.7000.3) ==420507== by 0x4023B9: main (test-tree.c:206) ==420507== ==420507== 511 (48 direct, 463 indirect) bytes in 1 blocks are definitely lost in loss record 2,402 of 2,440 ==420507== at 0x48F3437: g_type_create_instance (in /usr/lib64/libgobject-2.0.so.0.7000.3) ==420507== by 0x48DAD4C: ??? (in /usr/lib64/libgobject-2.0.so.0.7000.3) ==420507== by 0x48DC2C7: g_object_new_valist (in /usr/lib64/libgobject-2.0.so.0.7000.3) ==420507== by 0x48DC7FC: g_object_new (in /usr/lib64/libgobject-2.0.so.0.7000.3) ==420507== by 0x48815F8: osinfo_tree_new (osinfo_tree.c:462) ==420507== by 0x402E99: test_create_tree.constprop.0 (test-tree.c:119) ==420507== by 0x402FD2: test_matching (test-tree.c:155) ==420507== by 0x4992BD5: ??? (in /usr/lib64/libglib-2.0.so.0.7000.3) ==420507== by 0x49928FA: ??? (in /usr/lib64/libglib-2.0.so.0.7000.3) ==420507== by 0x49930A9: g_test_run_suite (in /usr/lib64/libglib-2.0.so.0.7000.3) ==420507== by 0x49930D0: g_test_run (in /usr/lib64/libglib-2.0.so.0.7000.3) ==420507== by 0x4023B9: main (test-tree.c:206) ==420507== ==420507== 600 (48 direct, 552 indirect) bytes in 1 blocks are definitely lost in loss record 2,412 of 2,440 ==420507== at 0x48F3437: g_type_create_instance (in /usr/lib64/libgobject-2.0.so.0.7000.3) ==420507== by 0x48DAD4C: ??? (in /usr/lib64/libgobject-2.0.so.0.7000.3) ==420507== by 0x48DC2C7: g_object_new_valist (in /usr/lib64/libgobject-2.0.so.0.7000.3) ==420507== by 0x48DC7FC: g_object_new (in /usr/lib64/libgobject-2.0.so.0.7000.3) ==420507== by 0x48815F8: osinfo_tree_new (osinfo_tree.c:462) ==420507== by 0x402E99: test_create_tree.constprop.0 (test-tree.c:119) ==420507== by 0x402FEF: test_matching (test-tree.c:162) ==420507== by 0x4992BD5: ??? (in /usr/lib64/libglib-2.0.so.0.7000.3) ==420507== by 0x49928FA: ??? (in /usr/lib64/libglib-2.0.so.0.7000.3) ==420507== by 0x49930A9: g_test_run_suite (in /usr/lib64/libglib-2.0.so.0.7000.3) ==420507== by 0x49930D0: g_test_run (in /usr/lib64/libglib-2.0.so.0.7000.3) ==420507== by 0x4023B9: main (test-tree.c:206) ==420507== ==420507== 626 (48 direct, 578 indirect) bytes in 1 blocks are definitely lost in loss record 2,413 of 2,440 ==420507== at 0x48F3437: g_type_create_instance (in /usr/lib64/libgobject-2.0.so.0.7000.3) ==420507== by 0x48DAD4C: ??? (in /usr/lib64/libgobject-2.0.so.0.7000.3) ==420507== by 0x48DC2C7: g_object_new_valist (in /usr/lib64/libgobject-2.0.so.0.7000.3) ==420507== by 0x48DC7FC: g_object_new (in /usr/lib64/libgobject-2.0.so.0.7000.3) ==420507== by 0x48815F8: osinfo_tree_new (osinfo_tree.c:462) ==420507== by 0x402E99: test_create_tree.constprop.0 (test-tree.c:119) ==420507== by 0x40300E: test_matching (test-tree.c:169) ==420507== by 0x4992BD5: ??? (in /usr/lib64/libglib-2.0.so.0.7000.3) ==420507== by 0x49928FA: ??? (in /usr/lib64/libglib-2.0.so.0.7000.3) ==420507== by 0x49930A9: g_test_run_suite (in /usr/lib64/libglib-2.0.so.0.7000.3) ==420507== by 0x49930D0: g_test_run (in /usr/lib64/libglib-2.0.so.0.7000.3) ==420507== by 0x4023B9: main (test-tree.c:206) ==420507== ==420507== 634 (48 direct, 586 indirect) bytes in 1 blocks are definitely lost in loss record 2,414 of 2,440 ==420507== at 0x48F3437: g_type_create_instance (in /usr/lib64/libgobject-2.0.so.0.7000.3) ==420507== by 0x48DAD4C: ??? (in /usr/lib64/libgobject-2.0.so.0.7000.3) ==420507== by 0x48DC2C7: g_object_new_valist (in /usr/lib64/libgobject-2.0.so.0.7000.3) ==420507== by 0x48DC7FC: g_object_new (in /usr/lib64/libgobject-2.0.so.0.7000.3) ==420507== by 0x48815F8: osinfo_tree_new (osinfo_tree.c:462) ==420507== by 0x402E99: test_create_tree.constprop.0 (test-tree.c:119) ==420507== by 0x402FB9: test_matching (test-tree.c:148) ==420507== by 0x4992BD5: ??? (in /usr/lib64/libglib-2.0.so.0.7000.3) ==420507== by 0x49928FA: ??? (in /usr/lib64/libglib-2.0.so.0.7000.3) ==420507== by 0x49930A9: g_test_run_suite (in /usr/lib64/libglib-2.0.so.0.7000.3) ==420507== by 0x49930D0: g_test_run (in /usr/lib64/libglib-2.0.so.0.7000.3) ==420507== by 0x4023B9: main (test-tree.c:206) and ==420470== 1,007 (48 direct, 959 indirect) bytes in 1 blocks are definitely lost in loss record 2,456 of 2,477 ==420470== at 0x48F3437: g_type_create_instance (in /usr/lib64/libgobject-2.0.so.0.7000.3) ==420470== by 0x48DAD4C: ??? (in /usr/lib64/libgobject-2.0.so.0.7000.3) ==420470== by 0x48DC2C7: g_object_new_valist (in /usr/lib64/libgobject-2.0.so.0.7000.3) ==420470== by 0x48DC7FC: g_object_new (in /usr/lib64/libgobject-2.0.so.0.7000.3) ==420470== by 0x48815F8: osinfo_tree_new (osinfo_tree.c:462) ==420470== by 0x48817B2: load_keyinfo (osinfo_tree.c:618) ==420470== by 0x4031A2: test_create_from_treeinfo (test-tree.c:93) ==420470== by 0x4992BD5: ??? (in /usr/lib64/libglib-2.0.so.0.7000.3) ==420470== by 0x49928FA: ??? (in /usr/lib64/libglib-2.0.so.0.7000.3) ==420470== by 0x49930A9: g_test_run_suite (in /usr/lib64/libglib-2.0.so.0.7000.3) ==420470== by 0x49930D0: g_test_run (in /usr/lib64/libglib-2.0.so.0.7000.3) ==420470== by 0x4023B9: main (test-tree.c:206) Signed-off-by: Victor Toso --- tests/test-tree.c | 62 +++++++++++++++++++++++++++---------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/tests/test-tree.c b/tests/test-tree.c index 79d6e74..ce207ba 100644 --- a/tests/test-tree.c +++ b/tests/test-tree.c @@ -104,7 +104,7 @@ test_create_from_treeinfo(void) os = osinfo_tree_get_os(tree); g_assert_cmpstr(osinfo_entity_get_id(OSINFO_ENTITY(os)), ==, "http://libosinfo.org/test/tree"); g_object_unref(os); - + g_object_unref(tree); g_object_unref(loader); } @@ -145,40 +145,40 @@ test_create_tree(const char *id, static void test_matching(void) { - OsinfoTree *unknown = test_create_tree("https://libosinfo.org/test/", - "x86_64", - "Fedora", - "Server", - "35", - "x86_64"); + g_autoptr(OsinfoTree) unknown = test_create_tree("https://libosinfo.org/test/", + "x86_64", + "Fedora", + "Server", + "35", + "x86_64"); /* Match with several optional fields */ - OsinfoTree *reference1 = test_create_tree("https://fedoraproject.org/fedora/35/tree1", - "x86_64", - "Fedora", - NULL, - NULL, - NULL); + g_autoptr(OsinfoTree) reference1 = test_create_tree("https://fedoraproject.org/fedora/35/tree1", + "x86_64", + "Fedora", + NULL, + NULL, + NULL); /* Mis-match on version */ - OsinfoTree *reference2 = test_create_tree("https://fedoraproject.org/fedora/34/tree2", - "x86_64", - "Fedora", - NULL, - "34", - "x86_64"); + g_autoptr(OsinfoTree) reference2 = test_create_tree("https://fedoraproject.org/fedora/34/tree2", + "x86_64", + "Fedora", + NULL, + "34", + "x86_64"); /* Match with all fields with some regexes */ - OsinfoTree *reference3 = test_create_tree("https://fedoraproject.org/fedora/unknown/tree3", - "x86_64", - "Fedora", - "(Server|Workstation)", - "3[0-9]", - NULL); + g_autoptr(OsinfoTree) reference3 = test_create_tree("https://fedoraproject.org/fedora/unknown/tree3", + "x86_64", + "Fedora", + "(Server|Workstation)", + "3[0-9]", + NULL); /* Mis-match on arch */ - OsinfoTree *reference4 = test_create_tree("https://fedoraproject.org/fedora/35/tree1", - "i686", - "Fedora", - NULL, - NULL, - NULL); + g_autoptr(OsinfoTree) reference4 = test_create_tree("https://fedoraproject.org/fedora/35/tree1", + "i686", + "Fedora", + NULL, + NULL, + NULL); g_assert(osinfo_tree_matches(unknown, reference1)); g_assert(!osinfo_tree_matches(unknown, reference2)); g_assert(osinfo_tree_matches(unknown, reference3)); -- cgit v1.2.1