From 610618ff61a87ae652116d2e0b58fa556b3c66ba Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Thu, 3 Sep 2020 12:58:30 +0200 Subject: [PATCH] test-socket-netlink: print the proper expected string We would use the return value from the tested function to decide what to print as "expected", which is confusing when something is wrong with the tested function. --- src/test/test-socket-netlink.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/test/test-socket-netlink.c b/src/test/test-socket-netlink.c index f86f1237827..f03e455d0ee 100644 --- a/src/test/test-socket-netlink.c +++ b/src/test/test-socket-netlink.c @@ -12,11 +12,19 @@ static void test_socket_address_parse_one(const char *in, int ret, int family, c int r; r = socket_address_parse(&a, in); - if (r >= 0) - assert_se(socket_address_print(&a, &out) >= 0); + if (r >= 0) { + r = socket_address_print(&a, &out); + if (r < 0) + log_error_errno(r, "Printing failed for \"%s\": %m", in); + assert(r >= 0); + } - log_info("\"%s\" → %s → \"%s\" (expect \"%s\")", in, - r >= 0 ? "✓" : "✗", empty_to_dash(out), r >= 0 ? expected ?: in : "-"); + log_info("\"%s\" → %s %d → \"%s\" (expect %d / \"%s\")", + in, + r >= 0 ? "✓" : "✗", r, + empty_to_dash(out), + ret, + ret >= 0 ? expected ?: in : "-"); assert_se(r == ret); if (r >= 0) { assert_se(a.sockaddr.sa.sa_family == family); -- 2.47.3