From f62be855760ab5cd27843aea6772a8d4c15863ec Mon Sep 17 00:00:00 2001 From: Erik Ekman Date: Mon, 8 Feb 2021 19:29:33 +0100 Subject: [PATCH] netif: Add test for netif_is_flag_set() --- test/unit/core/test_netif.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/test/unit/core/test_netif.c b/test/unit/core/test_netif.c index 2f68725f..64063679 100644 --- a/test/unit/core/test_netif.c +++ b/test/unit/core/test_netif.c @@ -215,13 +215,38 @@ START_TEST(test_netif_extcallbacks) } END_TEST +START_TEST(test_netif_flag_set) +{ + ip4_addr_t addr; + ip4_addr_t netmask; + ip4_addr_t gw; + LWIP_UNUSED_ARG(_i); + + IP4_ADDR(&addr, 0, 0, 0, 0); + IP4_ADDR(&netmask, 0, 0, 0, 0); + IP4_ADDR(&gw, 0, 0, 0, 0); + + netif_add(&net_test, &addr, &netmask, &gw, &net_test, testif_init, ethernet_input); + + fail_if(netif_is_flag_set(&net_test, NETIF_FLAG_UP)); + fail_unless(netif_is_flag_set(&net_test, NETIF_FLAG_BROADCAST)); + fail_if(netif_is_flag_set(&net_test, NETIF_FLAG_LINK_UP)); + fail_unless(netif_is_flag_set(&net_test, NETIF_FLAG_ETHARP)); + fail_unless(netif_is_flag_set(&net_test, NETIF_FLAG_ETHERNET)); + fail_unless(netif_is_flag_set(&net_test, NETIF_FLAG_IGMP)); + fail_unless(netif_is_flag_set(&net_test, NETIF_FLAG_MLD6)); + + netif_remove(&net_test); +} +END_TEST /** Create the suite including all tests for this module */ Suite * netif_suite(void) { testfunc tests[] = { - TESTFUNC(test_netif_extcallbacks) + TESTFUNC(test_netif_extcallbacks), + TESTFUNC(test_netif_flag_set) }; return create_suite("NETIF", tests, sizeof(tests)/sizeof(testfunc), netif_setup, netif_teardown); }