From 73288cb76f1cbb68f688c4ce9869ba703d1fd882 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jaramago=20Fern=C3=A1ndez?= Date: Fri, 21 Mar 2025 15:42:26 +0100 Subject: [PATCH] Remove duplicate utils from 'test_query_rules_fast_routing_algorithm-t' --- test/tap/tap/utils.h | 22 ++++++++++++++++++ ...t_query_rules_fast_routing_algorithm-t.cpp | 23 ------------------- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/test/tap/tap/utils.h b/test/tap/tap/utils.h index bb22de272..e627a336e 100644 --- a/test/tap/tap/utils.h +++ b/test/tap/tap/utils.h @@ -21,6 +21,9 @@ template using rc_t = std::pair; +#define _S(s) ( std::string {s} ) +#define _TO_S(s) ( std::to_string(s) ) + // Improve dependency failure compilation error #ifndef DISABLE_WARNING_COUNT_LOGGING @@ -63,6 +66,12 @@ my_bool mysql_stmt_close_override(MYSQL_STMT* stmt, const char* file, int line); #endif +/** + * @brief Simple macro to use with 'mysql_query' versions. + * @details E.g: `mysql_query_ext_val(admin, SELECT_RUNTIME_VAR"'mysql-eventslog_filename'", "")`. + */ +#define SELECT_RUNTIME_VAR "SELECT variable_value FROM runtime_global_variables WHERE variable_name=" + /** * @brief Computes the binomial coefficient C(n, k) */ @@ -221,6 +230,19 @@ enum SQ3_RES_T { */ sq3_res_t sqlite3_execute_stmt(sqlite3* db, const std::string& query); +/** + * @brief Utility one-liner macro to check for query failure on a 'ext_val_t'. + * @param val The 'ext_val_t' to be checked. + * @return In case of failure, 'EXIT_FAILURE' after logging the error, continues otherwise. + */ +#define CHECK_EXT_VAL(val)\ + do {\ + if (val.err) {\ + diag("%s:%d: Query failed err=\"%s\"", __func__, __LINE__, val.str.c_str());\ + return EXIT_FAILURE;\ + }\ + } while(0) + /** * @brief Holds the result of an `mysql_query_ext_val` operation. */ diff --git a/test/tap/tests/test_query_rules_fast_routing_algorithm-t.cpp b/test/tap/tests/test_query_rules_fast_routing_algorithm-t.cpp index a69844709..1ae41d717 100644 --- a/test/tap/tests/test_query_rules_fast_routing_algorithm-t.cpp +++ b/test/tap/tests/test_query_rules_fast_routing_algorithm-t.cpp @@ -36,29 +36,6 @@ using std::vector; // Used for 'extract_module_host_port' #include "modules_server_test.h" -//////////////////////////////////////////////////////////////////////////////// -// Borrowed from test_match_eof_conn_cap.cpp - TODO: MERGE -//////////////////////////////////////////////////////////////////////////////// - -#include - -#define _S(s) ( std::string {s} ) -#define _TO_S(s) ( std::to_string(s) ) - -#define SELECT_RUNTIME_VAR "SELECT variable_value FROM runtime_global_variables WHERE variable_name=" - -#define CHECK_EXT_VAL(val)\ - do {\ - if (val.err) {\ - diag("%s:%d: Query failed err=\"%s\"", __func__, __LINE__, val.str.c_str());\ - return EXIT_FAILURE;\ - }\ - } while(0) - -const uint32_t USLEEP_SQLITE_LOCKED = 100; - -//////////////////////////////////////////////////////////////////////////////// - int get_query_int_res(MYSQL* admin, const string& q, int& val) { MYSQL_QUERY_T(admin, q.c_str()); MYSQL_RES* myres = mysql_store_result(admin);