Skip to content

Commit

Permalink
Adding some clean up to test_digest_umap_aux-t
Browse files Browse the repository at this point in the history
Also modified tap to return the number of completed test
  • Loading branch information
renecannao committed Apr 22, 2024
1 parent dad6f0f commit 4cdb1ac
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
4 changes: 4 additions & 0 deletions test/tap/tap/tap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions test/tap/tap/tap.h
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,12 @@ void todo_end();

int tests_failed();

/**
* @brief Return the number of tests that have passed.
*/

int tests_last();

/** @} */

#ifdef __cplusplus
Expand Down
9 changes: 8 additions & 1 deletion test/tap/tests/test_digest_umap_aux-t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 4cdb1ac

Please sign in to comment.