From 96db641250e2692836badcf8eeb5e32fd7e189d4 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Fri, 1 Mar 2019 17:39:45 +0900 Subject: [PATCH] test: make network_verify() public and use it in test-networkd-conf --- src/network/networkd-network.c | 9 +++++---- src/network/networkd-network.h | 1 + src/network/test-networkd-conf.c | 3 +++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c index 027e076c346..22b240c1bec 100644 --- a/src/network/networkd-network.c +++ b/src/network/networkd-network.c @@ -70,14 +70,15 @@ static int network_resolve_netdev_one(Network *network, const char *name, NetDev NetDev *netdev; int r; + /* For test-networkd-conf, the check must be earlier than the assertions. */ + if (!name) + return 0; + assert(network); assert(network->manager); assert(network->filename); assert(ret_netdev); - if (!name) - return 0; - if (kind == _NETDEV_KIND_TUNNEL) kind_string = "tunnel"; else { @@ -159,7 +160,7 @@ static uint32_t network_get_stacked_netdevs_mtu(Network *network) { return mtu; } -static int network_verify(Network *network) { +int network_verify(Network *network) { Address *address, *address_next; Route *route, *route_next; FdbEntry *fdb, *fdb_next; diff --git a/src/network/networkd-network.h b/src/network/networkd-network.h index 38f3b7decb3..8b65fd16bde 100644 --- a/src/network/networkd-network.h +++ b/src/network/networkd-network.h @@ -285,6 +285,7 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(Network*, network_free); int network_load(Manager *manager); int network_load_one(Manager *manager, const char *filename); +int network_verify(Network *network); int network_get_by_name(Manager *manager, const char *name, Network **ret); int network_get(Manager *manager, sd_device *device, const char *ifname, const struct ether_addr *mac, Network **ret); diff --git a/src/network/test-networkd-conf.c b/src/network/test-networkd-conf.c index 3adfdab2bf8..6408719d15a 100644 --- a/src/network/test-networkd-conf.c +++ b/src/network/test-networkd-conf.c @@ -172,8 +172,11 @@ static void test_config_parse_address_one(const char *rvalue, int family, unsign _cleanup_(network_freep) Network *network = NULL; assert_se(network = new0(Network, 1)); + assert_se(network->filename = strdup("hogehoge.network")); assert_se(config_parse_address("network", "filename", 1, "section", 1, "Address", 0, rvalue, network, network) == 0); assert_se(network->n_static_addresses == 1); + assert_se(network_verify(network) >= 0); + assert_se(network->n_static_addresses == n_addresses); if (n_addresses > 0) { assert_se(network->static_addresses); assert_se(network->static_addresses->prefixlen == prefixlen);