From 0c45a60f8e36f8c0e3785084a739837e2317ee53 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Tue, 29 Jun 2021 15:33:58 +0900 Subject: [PATCH] test: add usual log messages in test-netlink --- src/libsystemd/sd-netlink/test-netlink.c | 38 +++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/src/libsystemd/sd-netlink/test-netlink.c b/src/libsystemd/sd-netlink/test-netlink.c index 41a7280477..76a567ec4d 100644 --- a/src/libsystemd/sd-netlink/test-netlink.c +++ b/src/libsystemd/sd-netlink/test-netlink.c @@ -14,12 +14,14 @@ #include "stdio-util.h" #include "string-util.h" #include "strv.h" -#include "util.h" +#include "tests.h" static void test_message_link_bridge(sd_netlink *rtnl) { _cleanup_(sd_netlink_message_unrefp) sd_netlink_message *message = NULL; uint32_t cost; + log_debug("/* %s */", __func__); + assert_se(sd_rtnl_message_new_link(rtnl, &message, RTM_NEWLINK, 1) >= 0); assert_se(sd_rtnl_message_link_set_family(message, AF_BRIDGE) >= 0); assert_se(sd_netlink_message_open_container(message, IFLA_PROTINFO) >= 0); @@ -40,6 +42,8 @@ static void test_link_configure(sd_netlink *rtnl, int ifindex) { const char *name_out; struct ether_addr mac_out; + log_debug("/* %s */", __func__); + /* we'd really like to test NEWLINK, but let's not mess with the running kernel */ assert_se(sd_rtnl_message_new_link(rtnl, &message, RTM_GETLINK, ifindex) >= 0); @@ -57,6 +61,8 @@ static void test_link_get(sd_netlink *rtnl, int ifindex) { uint32_t u32_data; struct ether_addr eth_data; + log_debug("/* %s */", __func__); + assert_se(sd_rtnl_message_new_link(rtnl, &m, RTM_GETLINK, ifindex) >= 0); assert_se(m); @@ -83,6 +89,8 @@ static void test_address_get(sd_netlink *rtnl, int ifindex) { struct ifa_cacheinfo cache; const char *label; + log_debug("/* %s */", __func__); + assert_se(sd_rtnl_message_new_addr(rtnl, &m, RTM_GETADDR, ifindex, AF_INET) >= 0); assert_se(m); assert_se(sd_netlink_message_request_dump(m, true) >= 0); @@ -100,6 +108,8 @@ static void test_route(sd_netlink *rtnl) { uint32_t index = 2, u32_data; int r; + log_debug("/* %s */", __func__); + r = sd_rtnl_message_new_route(rtnl, &req, RTM_NEWROUTE, AF_INET, RTPROT_STATIC); if (r < 0) { log_error_errno(r, "Could not create RTM_NEWROUTE message: %m"); @@ -134,6 +144,8 @@ static void test_route(sd_netlink *rtnl) { static void test_multiple(void) { sd_netlink *rtnl1, *rtnl2; + log_debug("/* %s */", __func__); + assert_se(sd_netlink_open(&rtnl1) >= 0); assert_se(sd_netlink_open(&rtnl2) >= 0); @@ -164,6 +176,8 @@ static void test_event_loop(int ifindex) { _cleanup_(sd_netlink_message_unrefp) sd_netlink_message *m = NULL; char *ifname; + log_debug("/* %s */", __func__); + ifname = strdup("lo2"); assert_se(ifname); @@ -194,6 +208,8 @@ static void test_async(int ifindex) { const char *description; char *ifname; + log_debug("/* %s */", __func__); + ifname = strdup("lo"); assert_se(ifname); @@ -225,6 +241,8 @@ static void test_slot_set(int ifindex) { const char *description; char *ifname; + log_debug("/* %s */", __func__); + ifname = strdup("lo"); assert_se(ifname); @@ -303,6 +321,8 @@ static void test_async_destroy_callback(int ifindex) { _cleanup_(sd_netlink_slot_unrefp) sd_netlink_slot *slot = NULL; char *ifname; + log_debug("/* %s */", __func__); + assert_se(t = new(struct test_async_object, 1)); assert_se(ifname = strdup("lo")); *t = (struct test_async_object) { @@ -371,6 +391,8 @@ static void test_pipe(int ifindex) { _cleanup_(sd_netlink_message_unrefp) sd_netlink_message *m1 = NULL, *m2 = NULL; int counter = 0; + log_debug("/* %s */", __func__); + assert_se(sd_netlink_open(&rtnl) >= 0); assert_se(sd_rtnl_message_new_link(rtnl, &m1, RTM_GETLINK, ifindex) >= 0); @@ -396,6 +418,8 @@ static void test_container(sd_netlink *rtnl) { uint32_t u32_data; const char *string_data; + log_debug("/* %s */", __func__); + assert_se(sd_rtnl_message_new_link(rtnl, &m, RTM_NEWLINK, 0) >= 0); assert_se(sd_netlink_message_open_container(m, IFLA_LINKINFO) >= 0); @@ -429,6 +453,8 @@ static void test_match(void) { _cleanup_(sd_netlink_slot_unrefp) sd_netlink_slot *s1 = NULL, *s2 = NULL; _cleanup_(sd_netlink_unrefp) sd_netlink *rtnl = NULL; + log_debug("/* %s */", __func__); + assert_se(sd_netlink_open(&rtnl) >= 0); assert_se(sd_netlink_add_match(rtnl, &s1, RTM_NEWLINK, link_handler, NULL, NULL, NULL) >= 0); @@ -445,6 +471,8 @@ static void test_get_addresses(sd_netlink *rtnl) { _cleanup_(sd_netlink_message_unrefp) sd_netlink_message *req = NULL, *reply = NULL; sd_netlink_message *m; + log_debug("/* %s */", __func__); + assert_se(sd_rtnl_message_new_addr(rtnl, &req, RTM_GETADDR, 0, AF_UNSPEC) >= 0); assert_se(sd_netlink_message_request_dump(req, true) >= 0); assert_se(sd_netlink_call(rtnl, req, 0, &reply) >= 0); @@ -472,6 +500,8 @@ static void test_get_addresses(sd_netlink *rtnl) { static void test_message(sd_netlink *rtnl) { _cleanup_(sd_netlink_message_unrefp) sd_netlink_message *m = NULL; + log_debug("/* %s */", __func__); + assert_se(rtnl_message_new_synthetic_error(rtnl, -ETIMEDOUT, 1, &m) >= 0); assert_se(sd_netlink_message_get_errno(m) == -ETIMEDOUT); } @@ -480,6 +510,8 @@ static void test_array(void) { _cleanup_(sd_netlink_unrefp) sd_netlink *genl = NULL; _cleanup_(sd_netlink_message_unrefp) sd_netlink_message *m = NULL; + log_debug("/* %s */", __func__); + assert_se(sd_genl_socket_open(&genl) >= 0); assert_se(sd_genl_message_new(genl, SD_GENL_ID_CTRL, CTRL_CMD_GETFAMILY, &m) >= 0); @@ -522,6 +554,8 @@ static void test_strv(sd_netlink *rtnl) { _cleanup_strv_free_ char **names_in = NULL, **names_out; const char *p; + log_debug("/* %s */", __func__); + assert_se(sd_rtnl_message_new_link(rtnl, &m, RTM_NEWLINKPROP, 1) >= 0); for (unsigned i = 0; i < 10; i++) { @@ -555,6 +589,8 @@ int main(void) { int if_loopback; uint16_t type; + test_setup_logging(LOG_DEBUG); + test_match(); test_multiple();