]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-network: do not fail if lo has a .network file
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 4 Feb 2020 07:30:40 +0000 (08:30 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 4 Feb 2020 07:30:40 +0000 (08:30 +0100)
Fixes #9895.

src/network/test-network.c

index 7c37563ac22ae0a694b97024dd48a79af1dcbf90..b29523b3182fdd08b0a27ea7fc90084c8d50f6f6 100644 (file)
@@ -122,11 +122,18 @@ static int test_load_config(Manager *manager) {
 static void test_network_get(Manager *manager, sd_device *loopback) {
         Network *network;
         const struct ether_addr mac = ETHER_ADDR_NULL;
+        int r;
 
-        /* let's assume that the test machine does not have a .network file
-           that applies to the loopback device... */
-        assert_se(network_get(manager, loopback, "lo", NULL, &mac, &mac, 0, NULL, NULL, &network) == -ENOENT);
-        assert_se(!network);
+        /* Let's hope that the test machine does not have a .network file that applies to loopback device…
+         * But it is still possible, so let's allow that case too. */
+        r = network_get(manager, loopback, "lo", NULL, &mac, &mac, 0, NULL, NULL, &network);
+        if (r == -ENOENT)
+                /* The expected case */
+                assert_se(!network);
+        else if (r >= 0)
+                assert_se(network);
+        else
+                assert_not_reached("bad error!");
 }
 
 static void test_address_equality(void) {