From 70bf12735eb7fe3a5f5f6ba2df774ecc497ea9ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jaramago=20Fern=C3=A1ndez?= Date: Wed, 25 Feb 2026 16:24:14 +0100 Subject: [PATCH] fix: improve error reporting for sqlite3 TAP utils --- test/tap/tap/utils.h | 13 +++++++++++++ .../test_query_rules_fast_routing_algorithm-t.cpp | 6 +++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/test/tap/tap/utils.h b/test/tap/tap/utils.h index 5da5650cf..6d0094a51 100644 --- a/test/tap/tap/utils.h +++ b/test/tap/tap/utils.h @@ -269,6 +269,19 @@ sq3_res_t sqlite3_execute_stmt(sqlite3* db, const std::string& query); }\ } while(0) +/** + * @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 SQ3_CHECK_EXT_VAL(val)\ + do {\ + if (val.err) {\ + diag("%s:%d: Query failed err=\"%s\"", __func__, __LINE__, sq3_get_ext_val_err(val).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 6e3b4c186..2a9d3406d 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 @@ -200,7 +200,7 @@ int check_fast_routing_rules( diag("Getting last 'debug_log' entry id"); ext_val_t last_id { sq3_query_ext_val(sq3_db, SELECT_LAST_DEBUG_ID, uint32_t(0)) }; - CHECK_EXT_VAL(admin, last_id); + SQ3_CHECK_EXT_VAL(last_id); diag("Fetched last 'debug_log' entry id id=%d", last_id.val); // Check that fast_routing rules are properly working for the defined range @@ -231,7 +231,7 @@ int check_fast_routing_rules( }; ext_val_t entries { sq3_query_ext_val(sq3_db, select_count, int64_t(-1))}; if (entries.err) { - const string err { get_ext_val_err(admin, entries) }; + const string err { sq3_get_ext_val_err(entries) }; diag("%s:%d: Query failed err=\"%s\"", __func__, __LINE__, err.c_str()); return { -1, 0 }; } @@ -285,7 +285,7 @@ int threads_warmup(const CommandLine& cl, MYSQL* admin, sqlite3* sq3_db) { diag("Getting last 'debug_log' entry id"); ext_val_t last_id { sq3_query_ext_val(sq3_db, SELECT_LAST_DEBUG_ID, uint32_t(0)) }; - CHECK_EXT_VAL(admin, last_id); + SQ3_CHECK_EXT_VAL(last_id); diag("Fetched last 'debug_log' entry id id=%d", last_id.val); int conns { find_min_elems(1.0 - pow(10, -6), mysql_threads.val) /* * 2 */ };