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 3576f54100)
This commit is contained in:
Thomas Haller 2020-10-07 09:00:41 +02:00
parent 07868a535f
commit 36ccbcc550
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -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);
}
}