Exemplo n.º 1
0
/*-------------------------------------------------------------------------
 * Function:	print_ref
 *
 * Purpose:	Prints the reference value
 *
 * Return:	Success:	0
 *
 *		Failure:
 *
 * Programmer:	Robb Matzke
 *		Friday, October 10, 1997
 *
 *-------------------------------------------------------------------------
 */
static void
print_ref(size_t nx, size_t ny, size_t nz)
{
    uint8_t *array;

    if(NULL != (array = (uint8_t *)HDmalloc(nx * ny * nz))) {
        printf("Reference array:\n");
        init_full(array, nx, ny, nz);
        print_array(array, nx, ny, nz);
        HDfree(array);
    } /* end if */
} /* end print_ref() */
Exemplo n.º 2
0
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;
}
Exemplo n.º 3
0
static bool init(void)
{
	if (is_error(fragdb_init()))
		goto fragdb_fail;
	if (!init_full())
		goto initfull_fail;

	if (!bib_inject_str(SERVER_ADDR6, SERVER_PORT6, NAT64_POOL4, SERVER_PORT6, L4PROTO_UDP))
		goto inject_fail;
	if (!bib_inject_str(SERVER_ADDR6, SERVER_PORT6, NAT64_POOL4, SERVER_PORT6, L4PROTO_TCP))
		goto inject_fail;
	if (!bib_inject_str(SERVER_ADDR6, SERVER_PORT6, NAT64_POOL4, SERVER_PORT6, L4PROTO_ICMP))
		goto inject_fail;

	return true;

inject_fail:
	end_full();
initfull_fail:
	fragdb_destroy();
fragdb_fail:
	return false;
}
Exemplo n.º 4
0
/*-------------------------------------------------------------------------
 * Function:	test_fill
 *
 * Purpose:	Tests the H5VM_hyper_fill() function.
 *
 * Return:	Success:	SUCCEED
 *
 *		Failure:	FAIL
 *
 * Programmer:	Robb Matzke
 *		Saturday, October 11, 1997
 *
 *-------------------------------------------------------------------------
 */
static herr_t
test_fill(size_t nx, size_t ny, size_t nz,
	  size_t di, size_t dj, size_t dk,
	  size_t ddx, size_t ddy, size_t ddz)
{
    uint8_t *dst = NULL;        /*destination array		*/
    hsize_t hs_size[3];         /*hyperslab size		*/
    hsize_t dst_size[3];        /*destination total size	*/
    hsize_t dst_offset[3];      /*offset of hyperslab in dest   */
    unsigned ref_value;         /*reference value		*/
    unsigned acc;               /*accumulator		    	*/
    size_t i, j, k, dx, dy, dz; /*counters		   	*/
    size_t u, v, w;
    unsigned ndims;             /*hyperslab dimensionality	*/
    char dim[64], s[256];       /*temp string		    	*/
    unsigned fill_value;        /*fill value		    	*/

    /*
     * Dimensionality.
     */
    if(0 == nz) {
        if(0 == ny) {
            ndims = 1;
            ny = nz = 1;
            sprintf(dim, "%lu", (unsigned long) nx);
        } /* end if */
        else {
            ndims = 2;
            nz = 1;
            sprintf(dim, "%lux%lu", (unsigned long) nx, (unsigned long) ny);
        } /* end else */
    } /* end if */
    else {
        ndims = 3;
        sprintf(dim, "%lux%lux%lu", (unsigned long) nx, (unsigned long) ny,
                (unsigned long) nz);
    } /* end else */
    sprintf(s, "Testing hyperslab fill %-11s variable hyperslab", dim);
    printf("%-70s", s);
    fflush(stdout);

    /* Allocate array */
    if(NULL == (dst = (uint8_t *)HDcalloc((size_t)1, nx * ny * nz)))
        TEST_ERROR
    
    init_full(dst, nx, ny, nz);

    for(i = 0; i < nx; i += di) {
        for(j = 0; j < ny; j += dj) {
            for(k = 0; k < nz; k += dk) {
                for(dx = 1; dx <= nx - i; dx += ddx) {
                    for(dy = 1; dy <= ny - j; dy += ddy) {
                        for(dz = 1; dz <= nz - k; dz += ddz) {

                            /* Describe the hyperslab */
                            dst_size[0] = nx;
                            dst_size[1] = ny;
                            dst_size[2] = nz;
                            dst_offset[0] = i;
                            dst_offset[1] = j;
                            dst_offset[2] = k;
                            hs_size[0] = dx;
                            hs_size[1] = dy;
                            hs_size[2] = dz;

                            for(fill_value = 0; fill_value < 256; fill_value += 64) {
                                /*
                                 * Initialize the full array, then subtract the
                                 * original * fill values and add the new ones.
                                 */
                                ref_value = init_full(dst, nx, ny, nz);
                                for(u = (size_t)dst_offset[0]; u < dst_offset[0] + dx; u++)
                                    for(v = (size_t)dst_offset[1]; v < dst_offset[1] + dy; v++)
                                        for(w = (size_t)dst_offset[2]; w < dst_offset[2] + dz; w++)
                                            ref_value -= dst[u * ny * nz + v * nz + w];
                                ref_value += fill_value * (unsigned)dx * (unsigned)dy * (unsigned)dz;

                                /* Fill the hyperslab with some value */
                                H5VM_hyper_fill(ndims, hs_size, dst_size, dst_offset, dst, fill_value);

                                /*
                                 * Sum the array and compare it to the
                                 * reference value.
                                 */
                                acc = 0;
                                for(u = 0; u < nx; u++)
                                    for(v = 0; v < ny; v++)
                                        for(w = 0; w < nz; w++)
                                            acc += dst[u * ny * nz + v * nz + w];

                                if(acc != ref_value) {
                                    H5_FAILED()
                                    if(!HDisatty(1)) {
                                        /*
                                         * Print debugging info unless output
                                         * is going directly to a terminal.
                                         */
                                        AT();
                                        printf("   acc != ref_value\n");
                                        printf("   i=%lu, j=%lu, k=%lu, "
                                            "dx=%lu, dy=%lu, dz=%lu, "
                                            "fill=%d\n", (unsigned long)i,
                                                (unsigned long)j,
                                                (unsigned long)k,
                                                (unsigned long)dx,
                                                (unsigned long)dy,
                                                (unsigned long)dz, fill_value);
                                        print_ref(nx, ny, nz);
                                        printf("\n   Result is:\n");
                                        print_array(dst, nx, ny, nz);
                                    } /* end if */
                                    goto error;
                                } /* end if */
                            } /* end for */
                        } /* end for */
                    } /* end for */
                } /* end for */
            } /* end for */
        } /* end for */
    } /* end for */