]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-socket-netlink: print the proper expected string
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 3 Sep 2020 10:58:30 +0000 (12:58 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 9 Sep 2020 22:46:44 +0000 (00:46 +0200)
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

index f86f1237827c01f7c58f0b1ace9e1346117f842f..f03e455d0ee8c3c4c109fcad74b70234013d3774 100644 (file)
@@ -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);