diff --git a/maxutils/maxbase/include/maxbase/assert.h b/maxutils/maxbase/include/maxbase/assert.h index ac0391520..9f1a70ed7 100644 --- a/maxutils/maxbase/include/maxbase/assert.h +++ b/maxutils/maxbase/include/maxbase/assert.h @@ -31,9 +31,11 @@ MXB_BEGIN_DECLS fprintf(stderr, "debug assert at %s:%d failed: %s\n", (char*)__FILE__, __LINE__, debug_expr); \ raise(SIGABRT);}} while (false) -#define mxb_assert_message(exp, message) \ +#define mxb_assert_message(exp, fmt, ...) \ do {if (exp) {} else { \ const char* debug_expr = #exp; \ + char message[1024]; \ + snprintf(message, sizeof(message), fmt, ##__VA_ARGS__); \ MXB_ERROR("debug assert at %s:%d failed: %s (%s)\n", \ (char*)__FILE__, \ __LINE__, \ diff --git a/server/core/config.cc b/server/core/config.cc index c4525b01a..96f6ee25b 100644 --- a/server/core/config.cc +++ b/server/core/config.cc @@ -1966,7 +1966,8 @@ const string value = get_string(key); milliseconds duration {0}; MXB_AT_DEBUG(bool rval = ) get_suffixed_duration(value.c_str(), interpretation, &duration); - mxb_assert(rval); // When this function is called, the validity of the value should have been checked. + // When this function is called, the validity of the value should have been checked. + mxb_assert_message(rval, "Invalid value for '%s': %s", key.c_str(), value.c_str()); return duration; } diff --git a/server/core/test/test_modutil.cc b/server/core/test/test_modutil.cc index ee3df8c73..7e15a0769 100644 --- a/server/core/test/test_modutil.cc +++ b/server/core/test/test_modutil.cc @@ -285,19 +285,20 @@ void test_multiple_sql_packets1() mxb_assert_message(complete && head, "Both buffers should have data"); mxb_assert_message(gwbuf_length(complete) + gwbuf_length(head) + gwbuf_length(quarter) + gwbuf_length(half) == sizeof(resultset), - "25% of data should be available"); + "a quarter of data should be available"); quarter = gwbuf_append(gwbuf_append(complete, head), quarter); complete = modutil_get_complete_packets(&quarter); mxb_assert_message(gwbuf_length(complete) + gwbuf_length(quarter) + gwbuf_length(half) == sizeof(resultset), - "50% of data should be available"); + "half of data should be available"); half = gwbuf_append(gwbuf_append(complete, quarter), half); complete = modutil_get_complete_packets(&half); mxb_assert_message(complete, "Complete should not be NULL"); mxb_assert_message(half == NULL, "Old buffer should be NULL"); - mxb_assert_message(gwbuf_length(complete) == sizeof(resultset), "Complete should contain 100% of data"); + mxb_assert_message(gwbuf_length(complete) == sizeof(resultset), + "Complete should contain all of the data"); completelen = gwbuf_length(complete); mxb_assert_message(gwbuf_copy_data(complete, 0, completelen, databuf) == completelen,