From 4776a3ef79a9d757d8ce8c1997b95ac9bb674ec8 Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Fri, 14 Nov 2014 08:12:12 +0100 Subject: [PATCH] [SQUASH ME] ipv6.if: tests and fixes --- sys/net/include/ipv6/if.h | 47 ++- sys/net/network_layer/ipv6/if/if.c | 34 +- tests/unittests/tests-ipv6_if/Makefile | 3 + .../unittests/tests-ipv6_if/Makefile.include | 1 + tests/unittests/tests-ipv6_if/tests-ipv6_if.c | 368 ++++++++++++++++++ tests/unittests/tests-ipv6_if/tests-ipv6_if.h | 37 ++ 6 files changed, 467 insertions(+), 23 deletions(-) create mode 100644 tests/unittests/tests-ipv6_if/Makefile create mode 100644 tests/unittests/tests-ipv6_if/Makefile.include create mode 100644 tests/unittests/tests-ipv6_if/tests-ipv6_if.c create mode 100644 tests/unittests/tests-ipv6_if/tests-ipv6_if.h diff --git a/sys/net/include/ipv6/if.h b/sys/net/include/ipv6/if.h index e11496a7c58be..fd26f7e502151 100644 --- a/sys/net/include/ipv6/if.h +++ b/sys/net/include/ipv6/if.h @@ -56,7 +56,7 @@ extern "C" { /** * @brief ID of the loopback interface. */ -#define IPV6_IF_LOOPBACK_IF (IPV6_IF_NUM) +#define IPV6_IF_LOOPBACK_ID (IPV6_IF_NUM) /** * @brief Flags and scope for an address registered to and interface @@ -65,8 +65,7 @@ extern "C" { * RFC 4291 * */ -typedef enum __attribute__((packed)) -{ +typedef enum __attribute__((packed)) { /** * @brief Identifies address as a unicast address. * @@ -96,8 +95,7 @@ typedef enum __attribute__((packed)) * @brief Identifies address as a link-local address. */ IPV6_IF_ADDR_FLAGS_LINK_LOCAL = 0x04 -} -ipv6_if_addr_flags_t; +} ipv6_if_addr_flags_t; /** * @brief Type to represent an address registered to an interface @@ -138,6 +136,8 @@ typedef struct { extern ipv6_if_t ipv6_ifs[IPV6_IF_NUM]; +extern const ipv6_if_t ipv6_if_loopback; + /** * @brief Initializes the module. */ @@ -149,6 +149,8 @@ void ipv6_if_init(void); * @param[in] mac_pid A MAC layer's PID * * @return The new interface's ID on success. + * @return -EINVAL if *mac_pid* is KERNEL_PID_UNDEF + * @return -EISCONN if *mac_pid* is already connected to the interface * @return -ENOBUFS if no space for a new interface is left. */ int ipv6_if_init_if(kernel_pid_t mac_pid); @@ -170,8 +172,8 @@ void ipv6_if_reset_if(int if_id); */ static inline bool ipv6_if_initialized(int if_id) { - return (if_id >= 0) && (if_id < IPV6_IF_NUM) && - (ipv6_ifs[if_id].mac_pid != KERNEL_PID_UNDEF); + return (if_id == IPV6_IF_LOOPBACK_ID) || + ((if_id >= 0) && (if_id < IPV6_IF_NUM) && (ipv6_ifs[if_id].mac_pid != KERNEL_PID_UNDEF)); } /** @@ -184,7 +186,15 @@ static inline bool ipv6_if_initialized(int if_id) */ static inline ipv6_if_t *ipv6_if_get_by_id(int if_id) { - return (ipv6_if_initialized(if_id)) ? (&(ipv6_ifs[if_id])) : NULL; + if (if_id == IPV6_IF_LOOPBACK_ID) { + return (ipv6_if_t *)(&ipv6_if_loopback); + } + else if (ipv6_if_initialized(if_id)) { + return &(ipv6_ifs[if_id]); + } + else { + return NULL; + } } /** @@ -214,9 +224,7 @@ static inline ipv6_if_t *ipv6_if_get_by_mac(kernel_pid_t mac_pid) /** * @brief Adds an address to an interface * - * @param[in] if_id An interface's ID - * @param[in] addr An IPv6 address - * @param[in] anycast Identifies *addr* as anycast address if true. + * @details Duplicate addresses are ignored * * @see * RFC 4291, section 2.6 @@ -225,6 +233,10 @@ static inline ipv6_if_t *ipv6_if_get_by_mac(kernel_pid_t mac_pid) * RFC 4291, section 2.5 * on address syntax. * + * @param[in] if_id An interface's ID + * @param[in] addr An IPv6 address + * @param[in] anycast Identifies *addr* as anycast address if true. + * * @return 0, on success * @return -EINVAL, if *addr* is syntactically no unicast address, but *anycast* * is set or if *addr* is the unspecified or loopback address. @@ -252,7 +264,9 @@ int ipv6_if_rem_addr(int if_id, const ipv6_addr_t *addr); * @param[in] addr An IPv6 address * * @return Pointer to the address on the interface, if it is is registered - * @return NULL, if the address is not registered to this interface + * @return NULL, if the address is not registered to this interface or if + * there is no interface identified by *if_id* + */ ipv6_addr_t *ipv6_if_find_addr_on_if(int if_id, const ipv6_addr_t *addr); @@ -277,8 +291,8 @@ ipv6_if_addr_search_res_t *ipv6_if_find_addr(ipv6_if_addr_search_res_t *res, * @param[in] addr An IPv6 address * * @return Pointer to the found address on the interface, if it is is registered - * @return NULL, if there is no address registered to this interface or on - * error + * @return NULL, if there is no address registered to this interface or if + * there is no interface identified by *if_id* */ ipv6_addr_t *ipv6_if_find_prefix_match_on_if(int if_id, const ipv6_addr_t *addr); @@ -310,8 +324,9 @@ ipv6_if_addr_search_res_t *ipv6_if_find_prefix_match(ipv6_if_addr_search_res_t * * @param[in] addr A destination address for a packet we search the source * address for. * - * @return The best source address for the interface, on success - * @return NULL, if no suitable address could be found. + * @return The best source address for the interface, on success + * @return NULL, if no suitable address could be found or if there is no + * interface identified by *if_id*. */ ipv6_addr_t *ipv6_if_get_best_src_addr_on_if(int if_id, const ipv6_addr_t *addr); diff --git a/sys/net/network_layer/ipv6/if/if.c b/sys/net/network_layer/ipv6/if/if.c index df1153693a676..818ef1c0f061e 100644 --- a/sys/net/network_layer/ipv6/if/if.c +++ b/sys/net/network_layer/ipv6/if/if.c @@ -21,15 +21,16 @@ #include "ipv6/if.h" #define _CHECK(if_id, err_ret) \ - if (ipv6_if_initialized(if_id)) { \ + if (!ipv6_if_initialized(if_id)) { \ err_ret; \ }; ipv6_if_t ipv6_ifs[IPV6_IF_NUM]; -static const ipv6_if_addr_t _loopback = { - IPV6_ADDR_LOOPBACK, - IPV6_IF_ADDR_FLAGS_UNICAST +const ipv6_if_t ipv6_if_loopback = { + { { IPV6_ADDR_LOOPBACK, IPV6_IF_ADDR_FLAGS_UNICAST } }, + MUTEX_INIT, + KERNEL_PID_UNDEF, }; static inline void _reset_addr(ipv6_if_addr_t *a) @@ -62,7 +63,15 @@ void ipv6_if_init(void) int ipv6_if_init_if(kernel_pid_t mac_pid) { + if(mac_pid == KERNEL_PID_UNDEF) { + return -EINVAL; + } + for (int if_id = 0; if_id < IPV6_IF_NUM; if_id++) { + if (ipv6_ifs[if_id].mac_pid == mac_pid) { + return -EISCONN; + } + if (ipv6_ifs[if_id].mac_pid == KERNEL_PID_UNDEF) { mutex_lock(&(ipv6_ifs[if_id].mutex)); @@ -106,6 +115,8 @@ int ipv6_if_get_id_by_mac(kernel_pid_t mac_pid) int ipv6_if_add_addr(int if_id, const ipv6_addr_t *addr, bool anycast) { + int res = -ENOBUFS; + _CHECK(if_id, return -ENOENT); if (ipv6_addr_is_unspecified(addr) || ipv6_addr_is_loopback(addr) || @@ -131,12 +142,21 @@ int ipv6_if_add_addr(int if_id, const ipv6_addr_t *addr, bool anycast) if (ipv6_addr_is_link_local(addr)) { ipv6_ifs[if_id].addrs[i].flags |= IPV6_IF_ADDR_FLAGS_LINK_LOCAL; } + + res = 0; + + break; + } + else if (ipv6_addr_is_equal(&(ipv6_ifs[if_id].addrs[i].addr), addr)) { + res = 0; + + break; } } mutex_unlock(&(ipv6_ifs[if_id].mutex)); - return -ENOBUFS; + return res; } static ipv6_addr_t *_ipv6_if_find_addr_on_if(ipv6_if_t *ipv6_if, @@ -194,8 +214,8 @@ ipv6_if_addr_search_res_t *ipv6_if_find_addr(ipv6_if_addr_search_res_t *res, } if (ipv6_addr_is_loopback(addr)) { - res->if_id = IPV6_IF_LOOPBACK_IF; - res->addr = (ipv6_addr_t *)&_loopback.addr; /* _loopback is const */ + res->if_id = IPV6_IF_LOOPBACK_ID; + res->addr = (ipv6_addr_t *)&ipv6_if_loopback.addrs[0].addr; /* ipv6_if_loopback is const */ return res; } diff --git a/tests/unittests/tests-ipv6_if/Makefile b/tests/unittests/tests-ipv6_if/Makefile new file mode 100644 index 0000000000000..a55911d648218 --- /dev/null +++ b/tests/unittests/tests-ipv6_if/Makefile @@ -0,0 +1,3 @@ +MODULE = tests-ipv6_if + +include $(RIOTBASE)/Makefile.base diff --git a/tests/unittests/tests-ipv6_if/Makefile.include b/tests/unittests/tests-ipv6_if/Makefile.include new file mode 100644 index 0000000000000..33eb1701c9544 --- /dev/null +++ b/tests/unittests/tests-ipv6_if/Makefile.include @@ -0,0 +1 @@ +USEMODULE += ipv6_if diff --git a/tests/unittests/tests-ipv6_if/tests-ipv6_if.c b/tests/unittests/tests-ipv6_if/tests-ipv6_if.c new file mode 100644 index 0000000000000..59d834abf665d --- /dev/null +++ b/tests/unittests/tests-ipv6_if/tests-ipv6_if.c @@ -0,0 +1,368 @@ +/* + * Copyright (C) 2014 Martine Lenders + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @{ + * + * @file tests-ipv6_if.c + */ +#include +#include + +#include "embUnit/embUnit.h" + +#include "byteorder.h" +#include "kernel_types.h" +#include "ipv6/addr.h" +#include "ipv6/if.h" + +#include "tests-ipv6_if.h" + +#define TEST_MAC_PID (KERNEL_PID_FIRST) + +static int if_id = -1; + +static void set_up(void) +{ + kernel_pid_t mac_pid = TEST_MAC_PID; + + ipv6_if_init(); + + if_id = ipv6_if_init_if(mac_pid); +} + +static void test_ipv6_if_init_if_EINVAL(void) +{ + kernel_pid_t mac_pid = KERNEL_PID_UNDEF; + + ipv6_if_init(); + + TEST_ASSERT_EQUAL_INT(-EINVAL, ipv6_if_init_if(mac_pid)); +} + +static void test_ipv6_if_init_if_EISCONN(void) +{ + kernel_pid_t mac_pid = TEST_MAC_PID; + + ipv6_if_init(); + + TEST_ASSERT(ipv6_if_init_if(mac_pid) >= 0); + TEST_ASSERT_EQUAL_INT(-EISCONN, ipv6_if_init_if(mac_pid)); +} + +static void test_ipv6_if_init_if_ENOBUFS(void) +{ + kernel_pid_t mac_pid = TEST_MAC_PID; + + ipv6_if_init(); + + for (if_id = 0; if_id < IPV6_IF_NUM; if_id++) { + TEST_ASSERT(ipv6_if_init_if(mac_pid++) >= 0); + } + + TEST_ASSERT_EQUAL_INT(-ENOBUFS, ipv6_if_init_if(mac_pid)); +} + +static void test_ipv6_if_reset_if_and_test_if_initialized(void) +{ + ipv6_if_reset_if(if_id); + + TEST_ASSERT_EQUAL_INT(false, ipv6_if_initialized(if_id)); +} + +static void test_ipv6_if_initialized(void) +{ + TEST_ASSERT_EQUAL_INT(true, ipv6_if_initialized(if_id)); +} + +static void test_ipv6_if_get_by_id_uninitialized(void) +{ + TEST_ASSERT_NULL(ipv6_if_get_by_id(INT_MAX)); +} + +static void test_ipv6_if_get_by_id_negative(void) +{ + TEST_ASSERT_NULL(ipv6_if_get_by_id(INT_MIN)); +} + +static void test_ipv6_if_get_by_id(void) +{ + TEST_ASSERT_NOT_NULL(ipv6_if_get_by_id(if_id)); +} + +static void test_ipv6_if_get_id_by_mac_KERNEL_PID_UNDEF(void) +{ + TEST_ASSERT_EQUAL_INT(-ENOENT, ipv6_if_get_id_by_mac(KERNEL_PID_UNDEF)); +} + +static void test_ipv6_if_get_id_by_mac_KERNEL_PID_LAST(void) +{ + TEST_ASSERT_EQUAL_INT(-ENOENT, ipv6_if_get_id_by_mac(KERNEL_PID_LAST)); +} + +static void test_ipv6_if_get_id_by_mac(void) +{ + TEST_ASSERT_EQUAL_INT(if_id, ipv6_if_get_id_by_mac(TEST_MAC_PID)); +} + +static void test_ipv6_if_get_by_mac_KERNEL_PID_UNDEF(void) +{ + TEST_ASSERT_NULL(ipv6_if_get_by_mac(KERNEL_PID_UNDEF)); +} + +static void test_ipv6_if_get_by_mac_KERNEL_PID_LAST(void) +{ + TEST_ASSERT_NULL(ipv6_if_get_by_mac(KERNEL_PID_LAST)); +} + +static void test_ipv6_if_get_by_mac(void) +{ + TEST_ASSERT_NOT_NULL(ipv6_if_get_by_mac(TEST_MAC_PID)); +} + +static void test_ipv6_if_add_addr_wrong_interface_with_anycast(void) +{ + ipv6_addr_t addr = { { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f } }; + + TEST_ASSERT_EQUAL_INT(-ENOENT, ipv6_if_add_addr(INT_MAX, &addr, true)); +} + +static void test_ipv6_if_add_addr_wrong_interface_without_anycast(void) +{ + ipv6_addr_t addr = { { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f } }; + + TEST_ASSERT_EQUAL_INT(-ENOENT, ipv6_if_add_addr(INT_MAX, &addr, false)); +} + +static void test_ipv6_if_add_unspecified_addr_with_anycast(void) +{ + ipv6_addr_t addr = IPV6_ADDR_UNSPECIFIED; + + TEST_ASSERT_EQUAL_INT(-EINVAL, ipv6_if_add_addr(if_id, &addr, true)); +} + +static void test_ipv6_if_add_unspecified_addr_without_anycast(void) +{ + ipv6_addr_t addr = IPV6_ADDR_UNSPECIFIED; + + TEST_ASSERT_EQUAL_INT(-EINVAL, ipv6_if_add_addr(if_id, &addr, false)); +} + +static void test_ipv6_if_add_loopback_addr_with_anycast(void) +{ + ipv6_addr_t addr = IPV6_ADDR_LOOPBACK; + + TEST_ASSERT_EQUAL_INT(-EINVAL, ipv6_if_add_addr(if_id, &addr, true)); +} + +static void test_ipv6_if_add_loopback_addr_without_anycast(void) +{ + ipv6_addr_t addr = IPV6_ADDR_LOOPBACK; + + TEST_ASSERT_EQUAL_INT(-EINVAL, ipv6_if_add_addr(if_id, &addr, false)); +} + +static void test_ipv6_if_add_multicast_addr_with_anycast(void) +{ + ipv6_addr_t addr = IPV6_ADDR_ALL_NODES_LINK_LOCAL; + + TEST_ASSERT_EQUAL_INT(-EINVAL, ipv6_if_add_addr(if_id, &addr, true)); +} + +static void test_ipv6_if_add_addr_too_many(void) +{ + ipv6_addr_t addr = { { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f } }; + + for (uint32_t i = 0; i < IPV6_IF_ADDR_NUM; i++) { + addr.u32[3].u32 = i; + TEST_ASSERT_EQUAL_INT(0, ipv6_if_add_addr(if_id, &addr, false)); + } + + addr.u32[2].u32 = 0; + TEST_ASSERT_EQUAL_INT(-ENOBUFS, ipv6_if_add_addr(if_id, &addr, false)); +} + +static void test_ipv6_if_add_addr_two_times_same(void) +{ + ipv6_addr_t addr = { { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f } }; + + TEST_ASSERT_EQUAL_INT(true, ipv6_addr_is_unspecified(&(ipv6_if_get_by_id(if_id)->addrs[0].addr))); + + TEST_ASSERT_EQUAL_INT(0, ipv6_if_add_addr(if_id, &addr, false)); + + TEST_ASSERT_EQUAL_INT(false, ipv6_addr_is_unspecified(&(ipv6_if_get_by_id(if_id)->addrs[0].addr))); + TEST_ASSERT_EQUAL_INT(true, ipv6_addr_is_unspecified(&(ipv6_if_get_by_id(if_id)->addrs[1].addr))); + + TEST_ASSERT_EQUAL_INT(0, ipv6_if_add_addr(if_id, &addr, false)); + + TEST_ASSERT_EQUAL_INT(false, ipv6_addr_is_unspecified(&(ipv6_if_get_by_id(if_id)->addrs[0].addr))); + TEST_ASSERT_EQUAL_INT(true, ipv6_addr_is_unspecified(&(ipv6_if_get_by_id(if_id)->addrs[1].addr))); +} + +static void test_ipv6_if_add_unicast_addr(void) +{ + ipv6_addr_t addr = { { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f } }; + ipv6_addr_t *internal = NULL; + + TEST_ASSERT_EQUAL_INT(0, ipv6_if_add_addr(if_id, &addr, false)); + + internal = ipv6_if_find_addr_on_if(if_id, &addr); + + TEST_ASSERT_NOT_NULL(internal); + TEST_ASSERT(&addr != internal); + + TEST_ASSERT_EQUAL_INT(true, ipv6_if_addr_is_unicast(internal)); +} + +static void test_ipv6_if_add_anycast_addr(void) +{ + ipv6_addr_t addr = { { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f } }; + ipv6_addr_t *internal = NULL; + + TEST_ASSERT_EQUAL_INT(0, ipv6_if_add_addr(if_id, &addr, true)); + + internal = ipv6_if_find_addr_on_if(if_id, &addr); + + TEST_ASSERT_NOT_NULL(internal); + TEST_ASSERT(&addr != internal); + + TEST_ASSERT_EQUAL_INT(true, ipv6_if_addr_is_anycast(internal)); +} + +static void test_ipv6_if_add_multicast_addr(void) +{ + ipv6_addr_t addr = IPV6_ADDR_ALL_NODES_IF_LOCAL; + ipv6_addr_t *internal = NULL; + + TEST_ASSERT_EQUAL_INT(0, ipv6_if_add_addr(if_id, &addr, false)); + + internal = ipv6_if_find_addr_on_if(if_id, &addr); + + TEST_ASSERT_NOT_NULL(internal); + TEST_ASSERT(&addr != internal); + + TEST_ASSERT_EQUAL_INT(true, ipv6_if_addr_is_multicast(internal)); +} + +static void test_ipv6_if_add_link_local_unicast_addr(void) +{ + ipv6_addr_t addr = { { 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f } }; + ipv6_addr_t *internal = NULL; + + TEST_ASSERT_EQUAL_INT(0, ipv6_if_add_addr(if_id, &addr, false)); + + internal = ipv6_if_find_addr_on_if(if_id, &addr); + + TEST_ASSERT_NOT_NULL(internal); + TEST_ASSERT(&addr != internal); + + TEST_ASSERT_EQUAL_INT(true, ipv6_if_addr_is_link_local(internal)); +} + +static void test_ipv6_if_add_link_local_multicast_addr(void) +{ + ipv6_addr_t addr = IPV6_ADDR_ALL_NODES_LINK_LOCAL; + ipv6_addr_t *internal = NULL; + + TEST_ASSERT_EQUAL_INT(0, ipv6_if_add_addr(if_id, &addr, false)); + + internal = ipv6_if_find_addr_on_if(if_id, &addr); + + TEST_ASSERT_NOT_NULL(internal); + TEST_ASSERT(&addr != internal); + + TEST_ASSERT_EQUAL_INT(true, ipv6_if_addr_is_link_local(internal)); +} + +Test *tests_ipv6_if_uninit_tests(void) +{ + EMB_UNIT_TESTFIXTURES(uninit_fixtures) { + new_TestFixture(test_ipv6_if_init_if_EINVAL), + new_TestFixture(test_ipv6_if_init_if_EISCONN), + new_TestFixture(test_ipv6_if_init_if_ENOBUFS), + }; + + EMB_UNIT_TESTCALLER(ipv6_if_tests, NULL, NULL, uninit_fixtures); + + return (Test *)&ipv6_if_tests; +} + +static void test_ipv6_if_rem_addr_wrong_interface(void) +{ + ipv6_addr_t addr = { { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f } }; + + TEST_ASSERT_EQUAL_INT(-ENOENT, ipv6_if_rem_addr(INT_MAX, &addr)); +} + +static void test_ipv6_if_rem_addr(void) +{ + ipv6_addr_t addr = { { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f } }; + + TEST_ASSERT_EQUAL_INT(true, ipv6_addr_is_unspecified(&(ipv6_if_get_by_id(if_id)->addrs[0].addr))); + + TEST_ASSERT_EQUAL_INT(0, ipv6_if_add_addr(if_id, &addr, false)); + + TEST_ASSERT_EQUAL_INT(false, ipv6_addr_is_unspecified(&(ipv6_if_get_by_id(if_id)->addrs[0].addr))); + + TEST_ASSERT_EQUAL_INT(0, ipv6_if_rem_addr(if_id, &addr)); + + TEST_ASSERT_EQUAL_INT(true, ipv6_addr_is_unspecified(&(ipv6_if_get_by_id(if_id)->addrs[0].addr))); +} + +Test *tests_ipv6_if_init_tests(void) +{ + EMB_UNIT_TESTFIXTURES(init_fixtures) { + new_TestFixture(test_ipv6_if_reset_if_and_test_if_initialized), + new_TestFixture(test_ipv6_if_initialized), + new_TestFixture(test_ipv6_if_get_by_id_uninitialized), + new_TestFixture(test_ipv6_if_get_by_id_negative), + new_TestFixture(test_ipv6_if_get_by_id), + new_TestFixture(test_ipv6_if_get_id_by_mac_KERNEL_PID_UNDEF), + new_TestFixture(test_ipv6_if_get_id_by_mac_KERNEL_PID_LAST), + new_TestFixture(test_ipv6_if_get_id_by_mac), + new_TestFixture(test_ipv6_if_get_by_mac_KERNEL_PID_UNDEF), + new_TestFixture(test_ipv6_if_get_by_mac_KERNEL_PID_LAST), + new_TestFixture(test_ipv6_if_get_by_mac), + new_TestFixture(test_ipv6_if_add_addr_wrong_interface_with_anycast), + new_TestFixture(test_ipv6_if_add_addr_wrong_interface_without_anycast), + new_TestFixture(test_ipv6_if_add_unspecified_addr_with_anycast), + new_TestFixture(test_ipv6_if_add_unspecified_addr_without_anycast), + new_TestFixture(test_ipv6_if_add_loopback_addr_with_anycast), + new_TestFixture(test_ipv6_if_add_loopback_addr_without_anycast), + new_TestFixture(test_ipv6_if_add_multicast_addr_with_anycast), + new_TestFixture(test_ipv6_if_add_addr_too_many), + new_TestFixture(test_ipv6_if_add_addr_two_times_same), + new_TestFixture(test_ipv6_if_add_anycast_addr), + new_TestFixture(test_ipv6_if_add_unicast_addr), + new_TestFixture(test_ipv6_if_add_multicast_addr), + new_TestFixture(test_ipv6_if_add_link_local_unicast_addr), + new_TestFixture(test_ipv6_if_add_link_local_multicast_addr), + new_TestFixture(test_ipv6_if_rem_addr_wrong_interface), + new_TestFixture(test_ipv6_if_rem_addr), + }; + + EMB_UNIT_TESTCALLER(ipv6_if_tests, set_up, NULL, init_fixtures); + + return (Test *)&ipv6_if_tests; +} + +void tests_ipv6_if(void) +{ + TESTS_RUN(tests_ipv6_if_uninit_tests()); + TESTS_RUN(tests_ipv6_if_init_tests()); +} +/** @} */ diff --git a/tests/unittests/tests-ipv6_if/tests-ipv6_if.h b/tests/unittests/tests-ipv6_if/tests-ipv6_if.h new file mode 100644 index 0000000000000..f3ebf9d43b1cb --- /dev/null +++ b/tests/unittests/tests-ipv6_if/tests-ipv6_if.h @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2014 Martin Lenders + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @addtogroup unittests + * @{ + * + * @file tests-ipv6_if.h + * @brief Unittests for the ``ipv6_if`` module + * + * @author Martine Lenders + */ +#ifndef __TESTS_PKTBUF_H_ +#define __TESTS_PKTBUF_H_ + +#include "../unittests.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief The entry point of this test suite. + */ +void tests_ipv6_if(void); + +#ifdef __cplusplus +} +#endif + +#endif /* __TESTS_PKTBUF_H_ */ +/** @} */