From 95c953a156af37cf47b7837e9a9f5163f2d39f9e Mon Sep 17 00:00:00 2001 From: Xavier Simonart Date: Thu, 29 Aug 2024 12:32:26 +0200 Subject: [PATCH] tests: Add test for IDL memory leak. Multiple leaks detected for memory allocated by ovsdb_idl_txn_add_map_op. For instance: Direct leak of 24 byte(s) in 1 object(s) allocated from: 0 0x4e60a7 in calloc (./tests/test-ovsdb+0x4e60a7) 1 0x5f9b32 in xcalloc__ ./lib/util.c:125:31 2 0x5f9b60 in xzalloc__ ./lib/util.c:135:12 3 0x5f9c25 in xzalloc ./ovs/lib/util.c:169:12 4 0x5d4899 in ovsdb_idl_txn_add_map_op ./lib/ovsdb-idl.c:4175:29 5 0x5d4758 in ovsdb_idl_txn_write_partial_map ./lib/ovsdb-idl.c:4332:5 6 0x53cbe8 in idltest_simple2_update_smap_setkey ./tests/idltest.c:4701:5 7 0x526fe2 in do_idl_partial_update_map_column ./tests/test-ovsdb.c:3027:5 8 0x59d99c in ovs_cmdl_run_command__ ./lib/command-line.c:247:17 9 0x59d79a in ovs_cmdl_run_command ./lib/command-line.c:278:5 10 0x51d458 in main ./tests/test-ovsdb.c:80:5 11 0x7f0a20a79b74 in __libc_start_main (/lib64/libc.so.6+0x27b74) Signed-off-by: Xavier Simonart --- tests/ovsdb-idl.at | 5 ++++- tests/test-ovsdb.c | 13 +++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/ovsdb-idl.at b/tests/ovsdb-idl.at index 9070ea051a6..f39db33462d 100644 --- a/tests/ovsdb-idl.at +++ b/tests/ovsdb-idl.at @@ -1881,7 +1881,10 @@ OVSDB_CHECK_IDL_PARTIAL_UPDATE_MAP_COLUMN([map, simple2 idl-partial-update-map-c 007: name=String2 smap=[[key2 : value2]] imap=[[3 : myids2]] 008: After trying to delete a deleted element 009: name=String2 smap=[[key2 : value2]] imap=[[3 : myids2]] -010: End test +010: After Create and Delete element +011: name=String2 smap=[[key2 : value2]] imap=[[3 : myids2]] +012: End test + ]]) OVSDB_CHECK_IDL_PY([partial-map idl], diff --git a/tests/test-ovsdb.c b/tests/test-ovsdb.c index 41c1525f451..3ae8a94563e 100644 --- a/tests/test-ovsdb.c +++ b/tests/test-ovsdb.c @@ -3020,6 +3020,19 @@ do_idl_partial_update_map_column(struct ovs_cmdl_context *ctx) printf("%03d: After trying to delete a deleted element\n", step++); dump_simple2(idl, myRow, step++); + myTxn = ovsdb_idl_txn_create(idl); + myRow = idltest_simple2_insert(myTxn); + idltest_simple2_get_smap(myRow, OVSDB_TYPE_STRING, + OVSDB_TYPE_STRING); + idltest_simple2_update_smap_setkey(myRow, "key3", "myList3"); + idltest_simple2_set_name(myRow, "String2"); + idltest_simple2_delete(myRow); + ovsdb_idl_txn_commit_block(myTxn); + ovsdb_idl_txn_destroy(myTxn); + ovsdb_idl_get_initial_snapshot(idl); + printf("%03d: After Create and Delete element\n", step++); + dump_simple2(idl, myRow, step++); + ovsdb_idl_destroy(idl); printf("%03d: End test\n", step); }