示例#1
0
/*
* @brief get next hop for known destination but unsufficient size for the output
* It is expected to get no next hop and receive -ENOBUFS
*/
static void test_fib_13_get_next_hop_fail_on_buffer_size(void)
{
    size_t add_buf_size = 16; /* includes space for terminating \0 */
    char addr_dst[] = "Test address 13";
    kernel_pid_t iface_id = KERNEL_PID_UNDEF;
    uint32_t next_hop_flags = 0;
    size_t add_buf_size_nxt = 12;
    char addr_nxt[add_buf_size];

    size_t entries = 20;
    _fill_FIB_multiple(entries, 11);
    TEST_ASSERT_EQUAL_INT(20, fib_get_num_used_entries());
    TEST_ASSERT_EQUAL_INT(20, universal_address_get_num_used_entries());

    int ret = fib_get_next_hop(&iface_id,
                               (uint8_t *)addr_nxt, &add_buf_size_nxt, &next_hop_flags,
                               (uint8_t *)addr_dst, add_buf_size - 1, 0x13);

    TEST_ASSERT_EQUAL_INT(-ENOBUFS, ret);
    TEST_ASSERT_EQUAL_INT(add_buf_size_nxt, add_buf_size - 1);

#if (TEST_FIB_SHOW_OUTPUT == 1)
    fib_print_fib_table();
    puts("");
    universal_address_print_table();
    puts("");
#endif
    fib_deinit();
}
示例#2
0
/*
* @brief filling the FIB with entries and update an entry
* It is expected to have FIB entry 13 with updated lifetime of 9999
* and entry 7 with updated iface ID of 7, lifetime of 7777 and next hop "Test address 77"
*/
static void test_fib_09_update_entry(void)
{
    size_t add_buf_size = 16; /* includes space for terminating \0 */
    char addr_dst13[] = "Test address 13";
    char addr_dst07[] = "Test address 07";
    char addr_nxt2[] = "Test address 99";
    char addr_nxt77[] = "Test address 77";

    size_t entries = 20;
    _fill_FIB_multiple(entries, 11);

    TEST_ASSERT_EQUAL_INT(20, fib_get_num_used_entries());
    TEST_ASSERT_EQUAL_INT(20, universal_address_get_num_used_entries());

    fib_update_entry((uint8_t *)addr_dst13, add_buf_size - 1,
                     (uint8_t *)addr_nxt2, add_buf_size - 1, 0x99, 9999);
    fib_update_entry((uint8_t *)addr_dst07, add_buf_size - 1,
                     (uint8_t *)addr_nxt77, add_buf_size - 1, 0x77, 7777);

#if (TEST_FIB_SHOW_OUTPUT == 1)
    fib_print_fib_table();
    puts("");
    universal_address_print_table();
    puts("");
#endif
    fib_deinit();
}
示例#3
0
/*
* @brief filling the FIB with entries and removing an unknown entry
* It is expected to have 20 FIB entries and 20 universal address entries after removing
*/
static void test_fib_08_remove_unknown(void)
{
    size_t add_buf_size = 16; /* includes space for terminating \0 */
    char addr_dst[] = "Test address 99";

    size_t entries = 20;
    _fill_FIB_multiple(entries, 11);

    TEST_ASSERT_EQUAL_INT(20, fib_get_num_used_entries());
    TEST_ASSERT_EQUAL_INT(20, universal_address_get_num_used_entries());

    fib_remove_entry((uint8_t *)addr_dst, add_buf_size - 1);
    fib_remove_entry((uint8_t *)addr_dst, add_buf_size - 1);
    fib_remove_entry((uint8_t *)addr_dst, add_buf_size - 1);

#if (TEST_FIB_SHOW_OUTPUT == 1)
    fib_print_fib_table();
    puts("");
    universal_address_print_table();
    puts("");
#endif
    TEST_ASSERT_EQUAL_INT(20, fib_get_num_used_entries());
    TEST_ASSERT_EQUAL_INT(20, universal_address_get_num_used_entries());
    fib_deinit();
}
示例#4
0
/*
* @brief filling the FIB with entries and removing the upper 1/2 entries (10..19)
* It is expected to have 10 FIB entries and 10 universal address entries after remove
*/
static void test_fib_05_remove_upper_half(void)
{
    size_t add_buf_size = 16;
    char addr_dst[add_buf_size];

    size_t entries = 20;
    _fill_FIB_multiple(entries, 11);

    TEST_ASSERT_EQUAL_INT(20, fib_get_num_used_entries());
    TEST_ASSERT_EQUAL_INT(20, universal_address_get_num_used_entries());

    for (size_t i = 0; i < entries / 2; ++i) {
        /* construct "addresses" to remove */
        snprintf(addr_dst, add_buf_size, "Test address %02d", ((entries / 2) + i));
        fib_remove_entry((uint8_t *)addr_dst, add_buf_size - 1);
    }

#if (TEST_FIB_SHOW_OUTPUT == 1)
    fib_print_fib_table();
    puts("");
    universal_address_print_table();
    puts("");
#endif
    TEST_ASSERT_EQUAL_INT(10, fib_get_num_used_entries());
    TEST_ASSERT_EQUAL_INT(10, universal_address_get_num_used_entries());
    fib_deinit();
}
示例#5
0
文件: tests-fib.c 项目: daniel-k/RIOT
/*
* @brief call get next hop with invalid parameters
* It is expected to receive -EINVAL on calling get_next_hop()
*/
static void test_fib_18_get_next_hop_invalid_parameters(void)
{
    size_t add_buf_size = 16; /* includes space for terminating \0 */
    char addr_dst[] = "Test address 13";
    char addr_expect[] = "Test address 02";
    kernel_pid_t iface_id = KERNEL_PID_UNDEF;
    uint32_t next_hop_flags = 0;
    char addr_nxt[add_buf_size];

    size_t entries = 20;
    _fill_FIB_multiple(entries, 11);

    int ret = fib_get_next_hop(&test_fib_table, NULL, NULL,
                               NULL, NULL,NULL, add_buf_size - 1, 0x13);

    TEST_ASSERT_EQUAL_INT(-EINVAL, ret);

    ret = fib_get_next_hop(&test_fib_table, &iface_id,
                           (uint8_t *)addr_nxt, &add_buf_size, &next_hop_flags,
                           (uint8_t *)addr_dst, add_buf_size - 1, 0x13);

    TEST_ASSERT_EQUAL_INT(0, ret);

    ret = strncmp(addr_expect, addr_nxt, add_buf_size);
    TEST_ASSERT_EQUAL_INT(0, ret);

#if (TEST_FIB_SHOW_OUTPUT == 1)
    fib_print_fib_table(&test_fib_table);
    puts("");
    universal_address_print_table();
    puts("");
#endif
    fib_deinit(&test_fib_table);
}
示例#6
0
/*
 * @brief filling the FIB with reusable entries
 * It is expected to have 20 FIB entries and 20 universal address entries
 */
static void test_fib_02_fill_multiple_entries(void)
{
    size_t entries = 20;
    _fill_FIB_multiple(entries, 11);

#if (TEST_FIB_SHOW_OUTPUT == 1)
    fib_print_fib_table();
    puts("");
    universal_address_print_table();
    puts("");
#endif
    TEST_ASSERT_EQUAL_INT(20, fib_get_num_used_entries());
    TEST_ASSERT_EQUAL_INT(20, universal_address_get_num_used_entries());
    fib_deinit();
}
示例#7
0
/*
* @brief filling the FIB with entries and removing one entry
* It is expected to have 19 FIB entries and still 20 universal address entries
* after removing 02
* (the use count for 02 is reduced to 1 after remove)
*/
static void test_fib_06_remove_one_entry(void)
{
    size_t add_buf_size = 16;
    char addr_dst[] = "Test address 02";

    size_t entries = 20;
    _fill_FIB_multiple(entries, 11);

    TEST_ASSERT_EQUAL_INT(20, fib_get_num_used_entries());
    TEST_ASSERT_EQUAL_INT(20, universal_address_get_num_used_entries());

    fib_remove_entry((uint8_t *)addr_dst, add_buf_size - 1);

#if (TEST_FIB_SHOW_OUTPUT == 1)
    fib_print_fib_table();
    puts("");
    universal_address_print_table();
    puts("");
#endif
    TEST_ASSERT_EQUAL_INT(19, fib_get_num_used_entries());
    TEST_ASSERT_EQUAL_INT(20, universal_address_get_num_used_entries());
    fib_deinit();
}