From 4cdb1acb8c0f2b8bd8a8e25169ee8c6ac51515c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Mon, 22 Apr 2024 02:02:24 +0000 Subject: [PATCH] Adding some clean up to test_digest_umap_aux-t Also modified tap to return the number of completed test --- test/tap/tap/tap.cpp | 4 ++++ test/tap/tap/tap.h | 6 ++++++ test/tap/tests/test_digest_umap_aux-t.cpp | 9 ++++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/test/tap/tap/tap.cpp b/test/tap/tap/tap.cpp index 8afb7939cd..b067432a2d 100644 --- a/test/tap/tap/tap.cpp +++ b/test/tap/tap/tap.cpp @@ -415,6 +415,10 @@ int tests_failed() { return g_test.failed; } +int tests_last() { + return g_test.last; +} + /** @mainpage Testing C and C++ using MyTAP diff --git a/test/tap/tap/tap.h b/test/tap/tap/tap.h index 4b7e76354a..7678c1a390 100644 --- a/test/tap/tap/tap.h +++ b/test/tap/tap/tap.h @@ -311,6 +311,12 @@ void todo_end(); int tests_failed(); +/** + * @brief Return the number of tests that have passed. + */ + +int tests_last(); + /** @} */ #ifdef __cplusplus diff --git a/test/tap/tests/test_digest_umap_aux-t.cpp b/test/tap/tests/test_digest_umap_aux-t.cpp index 227f5af08d..22391e05b8 100644 --- a/test/tap/tests/test_digest_umap_aux-t.cpp +++ b/test/tap/tests/test_digest_umap_aux-t.cpp @@ -178,7 +178,8 @@ int main(int argc, char** argv) { return EXIT_FAILURE; } - plan(1 + DUMMY_QUERIES.size() * 5); // always specify the number of tests that are going to be performed + int nplan = (1 + DUMMY_QUERIES.size() * 5); // always specify the number of tests that are going to be performed + plan(nplan); MYSQL *proxy_admin = mysql_init(NULL); if (!mysql_real_connect(proxy_admin, cl.host, cl.admin_username, cl.admin_password, NULL, cl.admin_port, NULL, 0)) { @@ -314,6 +315,12 @@ int main(int argc, char** argv) { ); } + if (tests_last() == nplan && tests_failed == 0) { + string q = "TRUNCATE TABLE stats.stats_mysql_query_digest"; + diag("Running %s", q.c_str()); + MYSQL_QUERY(proxy_admin, q.c_str()); + } + mysql_close(proxy_admin); return exit_status();