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();