From 36ccbcc550a981688eee6a83bfc55324cdd0c874 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 7 Oct 2020 09:00:41 +0200 Subject: [PATCH] platform/tests: print details about test failure for test_platform_ip_address_pretty_sort_cmp() When the test is about to fail, print the wrong data to help debugging the test failure. (cherry picked from commit 3576f541003106fb4ba7b41138a57f8e4a6e7d18) --- src/platform/tests/test-platform-general.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/platform/tests/test-platform-general.c b/src/platform/tests/test-platform-general.c index aca4413fad..ee1e247753 100644 --- a/src/platform/tests/test-platform-general.c +++ b/src/platform/tests/test-platform-general.c @@ -715,6 +715,19 @@ test_platform_ip_address_pretty_sort_cmp(gconstpointer test_data) NULL, 0, &bin_len); + + if (bin_len != ELM_SIZE * N_ADDRESSES || memcmp(addresses, bin_arr, bin_len) != 0) { + char *addresses_str = nm_utils_bin2hexstr(addresses, ELM_SIZE * N_ADDRESSES, -1); + + g_error(">>> test_platform_ip_address_pretty_sort_cmp() will fail:\n" + ">>> addresses[%zu]: %s\n" + ">>> expected [%zu]: %s\n", + ELM_SIZE * N_ADDRESSES, + addresses_str, + bin_len, + EXPECTED_BUFFER[TEST_DATA_I]); + } + g_assert_cmpmem(addresses, ELM_SIZE * N_ADDRESSES, bin_arr, bin_len); } }