From 17d792e9aa38c3d8a2211c7b8ee3e2d88b438922 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Tue, 4 Jan 2022 12:19:49 +1100 Subject: [PATCH] ctdb-tests: Iterate protocol tests internally Instead of repeatedly running a test binary. Run time for these tests reduces from ~90s to ~75s. When run under valgrind, the run time for protocol_test_001.sh reduces from ~390s to <1s. Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs Autobuild-User(master): Amitay Isaacs Autobuild-Date(master): Mon Feb 14 04:32:29 UTC 2022 on sn-devel-184 --- ctdb/event/event_protocol_test.c | 17 +++-- .../UNIT/cunit/event_protocol_test_001.sh | 22 +------ ctdb/tests/UNIT/cunit/protocol_test_001.sh | 4 +- ctdb/tests/UNIT/cunit/protocol_test_002.sh | 4 +- ctdb/tests/UNIT/cunit/protocol_test_012.sh | 4 +- ctdb/tests/UNIT/cunit/protocol_test_101.sh | 63 +------------------ ctdb/tests/UNIT/cunit/protocol_test_111.sh | 4 +- ctdb/tests/src/protocol_basic_test.c | 11 ++-- ctdb/tests/src/protocol_ctdb_compat_test.c | 11 ++-- ctdb/tests/src/protocol_ctdb_test.c | 32 ++++------ ctdb/tests/src/protocol_types_compat_test.c | 11 ++-- ctdb/tests/src/protocol_types_test.c | 11 ++-- 12 files changed, 47 insertions(+), 147 deletions(-) diff --git a/ctdb/event/event_protocol_test.c b/ctdb/event/event_protocol_test.c index 7f939f881cf3..8f34fa5b68d3 100644 --- a/ctdb/event/event_protocol_test.c +++ b/ctdb/event/event_protocol_test.c @@ -311,8 +311,7 @@ static void TEST_FUNC(NAME)(uint32_t cmd) \ size_t buflen, np; \ int ret; \ \ - printf("%s %u\n", #NAME, cmd); \ - fflush(stdout); \ + protocol_test_iterate_tag("%s %u\n", #NAME, cmd); \ mem_ctx = talloc_new(NULL); \ assert(mem_ctx != NULL); \ FILL_FUNC(NAME)(mem_ctx, &c1, cmd); \ @@ -340,8 +339,7 @@ static void TEST_FUNC(NAME)(uint32_t cmd) \ size_t buflen, len; \ int ret; \ \ - printf("%s %u\n", #NAME, cmd); \ - fflush(stdout); \ + protocol_test_iterate_tag("%s %u\n", #NAME, cmd); \ mem_ctx = talloc_new(NULL); \ assert(mem_ctx != NULL); \ fill_ctdb_event_header(&h1); \ @@ -379,15 +377,10 @@ EVENT_PROTOCOL1_TEST(struct ctdb_event_reply, ctdb_event_reply_data); EVENT_PROTOCOL2_TEST(struct ctdb_event_request, ctdb_event_request); EVENT_PROTOCOL2_TEST(struct ctdb_event_reply, ctdb_event_reply); -int main(int argc, const char **argv) +static void event_protocol_test(void) { uint32_t cmd; - if (argc == 2) { - int seed = atoi(argv[1]); - srandom(seed); - } - TEST_FUNC(ctdb_event_script)(); TEST_FUNC(ctdb_event_script_list)(); @@ -410,6 +403,10 @@ int main(int argc, const char **argv) for (cmd=1; cmd