Example #1
0
int init_module(void)
{
	START_TESTS("BIB");

	INIT_CALL_END(init(), simple_bib(), end(), "Single BIB");
	INIT_CALL_END(init(), test_allocate_ipv4_transport_address(), end(), "Allocate function.");
	INIT_CALL_END(init(), test_compare_addr6(), end(), "compare_addr6");
	INIT_CALL_END(init(), test_compare_full6(), end(), "compare_full6");
	INIT_CALL_END(init(), test_compare_addr4(), end(), "compare_addr4");

	END_TESTS;
}
int __init filtering_test_init(void)
{
    START_TESTS("Filtering and Updating");
    
    log_debug("\n\n\n");
    log_debug("\n\nNAT64 %s TEST module inserted!", "filtering_test");

    // Initialize the NAT configuration for the tests.
    if ( !config_init() )
		return -EINVAL;

    /*      UDP & ICMP      */
    CALL_TEST(test_transport_address_ipv4(), "test_transport_address_ipv4");
    CALL_TEST(test_transport_address_ipv6(), "test_transport_address_ipv6");
    CALL_TEST(test_extract_ipv4_from_ipv6(), "test_extract_ipv4_from_ipv6");
    CALL_TEST(test_embed_ipv4_in_ipv6(), "test_embed_ipv4_in_ipv6");
    CALL_TEST(test_allocate_ipv4_transport_address(), "test_allocate_ipv4_transport_address");
    CALL_TEST(test_allocate_ipv4_transport_address_digger(), "test_allocate_ipv4_transport_address_digger");
    INIT_CALL_END(init_full(), test_ipv6_udp(), end_full(), "test_ipv6_udp");
    INIT_CALL_END(init_full(), test_ipv4_udp(), end_full(), "test_ipv4_udp");
    INIT_CALL_END(init_full(), test_ipv6_icmp6(), end_full(), "test_ipv6_icmp6");
    INIT_CALL_END(init_full(), test_ipv4_icmp4(), end_full(), "test_ipv4_icmp4");
    //~ CALL_TEST(test_send_icmp_error_message(), "test_send_icmp_error_message"); // Not implemented yet!
    INIT_CALL_END(init_full(), test_filtering_and_updating(), end_full(), "test_filtering_and_updating");

    /*      TCP      */
    CALL_TEST(test_packet_is_ipv4(), "test_packet_is_ipv4");
    CALL_TEST(test_packet_is_ipv6(), "test_packet_is_ipv6");
    CALL_TEST(test_packet_is_v4_syn(), "test_packet_is_v4_syn");
    CALL_TEST(test_packet_is_v6_syn(), "test_packet_is_v6_syn");
    CALL_TEST(test_packet_is_v4_fin(), "test_packet_is_v4_fin");
    CALL_TEST(test_packet_is_v6_fin(), "test_packet_is_v6_fin");
    CALL_TEST(test_packet_is_v4_rst(), "test_packet_is_v4_rst");
    CALL_TEST(test_packet_is_v6_rst(), "test_packet_is_v6_rst");
    CALL_TEST(test_send_probe_packet(), "test_send_probe_packet");
    INIT_CALL_END(init_full(), test_tcp_closed_state_handle_6(), end_full(), "test_tcp_closed_state_handle_6");
    INIT_CALL_END(init_full(), test_tcp_closed_state_handle_4(), end_full(), "test_tcp_closed_state_handle_4");
    CALL_TEST(test_tcp_v4_init_state_handle(), "test_tcp_v4_init_state_handle");
    CALL_TEST(test_tcp_v6_init_state_handle(), "test_tcp_v6_init_state_handle");
    CALL_TEST(test_tcp_established_state_handle(), "test_tcp_established_state_handle");
    CALL_TEST(test_tcp_v4_fin_rcv_state_handle(), "test_tcp_v4_fin_rcv_state_handle");
    CALL_TEST(test_tcp_v6_fin_rcv_state_handle(), "test_tcp_v6_fin_rcv_state_handle");
    CALL_TEST(test_tcp_trans_state_handle(), "test_tcp_trans_state_handle");
    INIT_CALL_END(init_full(), test_tcp(), end_full(), "test_tcp");

	config_destroy();
    /* A non 0 return means a test failed; module can't be loaded. */
    END_TESTS;
}