Exemplo n.º 1
0
Handle testStringLessOrEqual(TaskData *mdTaskData, Handle y, Handle x)
{
    return mdTaskData->saveVec.push(string_test(DEREFWORD(x), DEREFWORD(y)) <= 0 ? TAGGED(1) : TAGGED(0));
}
Exemplo n.º 2
0
Handle compareStrings(TaskData *mdTaskData, Handle y, Handle x)
{
    return mdTaskData->saveVec.push(TAGGED(string_test(DEREFWORD(x), DEREFWORD(y))));
}
Exemplo n.º 3
0
Handle testStringGreater(TaskData *mdTaskData, Handle y, Handle x)
{
    return mdTaskData->saveVec.push(string_test(DEREFWORD(x), DEREFWORD(y)) > 0 ? TAGGED(1) : TAGGED(0));
}
Exemplo n.º 4
0
int test_inner(void)
{
    pj_caching_pool caching_pool;
    const char *filename;
    int line;
    int rc = 0;

    mem = &caching_pool.factory;

    pj_log_set_level(3);
    pj_log_set_decor(param_log_decor);

    rc = pj_init();
    if (rc != 0) {
	app_perror("pj_init() error!!", rc);
	return rc;
    }
    
    //pj_dump_config();
    pj_caching_pool_init( &caching_pool, NULL, 0 );

#if INCLUDE_ERRNO_TEST
    DO_TEST( errno_test() );
#endif

#if INCLUDE_EXCEPTION_TEST
    DO_TEST( exception_test() );
#endif

#if INCLUDE_OS_TEST
    DO_TEST( os_test() );
#endif

#if INCLUDE_RAND_TEST
    DO_TEST( rand_test() );
#endif

#if INCLUDE_LIST_TEST
    DO_TEST( list_test() );
#endif

#if INCLUDE_POOL_TEST
    DO_TEST( pool_test() );
#endif

#if INCLUDE_POOL_PERF_TEST
    DO_TEST( pool_perf_test() );
#endif

#if INCLUDE_STRING_TEST
    DO_TEST( string_test() );
#endif
    
#if INCLUDE_FIFOBUF_TEST
    DO_TEST( fifobuf_test() );
#endif

#if INCLUDE_RBTREE_TEST
    DO_TEST( rbtree_test() );
#endif

#if INCLUDE_HASH_TEST
    DO_TEST( hash_test() );
#endif

#if INCLUDE_TIMESTAMP_TEST
    DO_TEST( timestamp_test() );
#endif

#if INCLUDE_ATOMIC_TEST
    DO_TEST( atomic_test() );
#endif

#if INCLUDE_MUTEX_TEST
    DO_TEST( mutex_test() );
#endif

#if INCLUDE_TIMER_TEST
    DO_TEST( timer_test() );
#endif

#if INCLUDE_SLEEP_TEST
    DO_TEST( sleep_test() );
#endif

#if INCLUDE_THREAD_TEST
    DO_TEST( thread_test() );
#endif

#if INCLUDE_SOCK_TEST
    DO_TEST( sock_test() );
#endif

#if INCLUDE_SOCK_PERF_TEST
    DO_TEST( sock_perf_test() );
#endif

#if INCLUDE_SELECT_TEST
    DO_TEST( select_test() );
#endif

#if INCLUDE_UDP_IOQUEUE_TEST
    DO_TEST( udp_ioqueue_test() );
#endif

#if PJ_HAS_TCP && INCLUDE_TCP_IOQUEUE_TEST
    DO_TEST( tcp_ioqueue_test() );
#endif

#if INCLUDE_IOQUEUE_PERF_TEST
    DO_TEST( ioqueue_perf_test() );
#endif

#if INCLUDE_IOQUEUE_UNREG_TEST
    DO_TEST( udp_ioqueue_unreg_test() );
#endif

#if INCLUDE_ACTIVESOCK_TEST
    DO_TEST( activesock_test() );
#endif

#if INCLUDE_FILE_TEST
    DO_TEST( file_test() );
#endif

#if INCLUDE_SSLSOCK_TEST
    DO_TEST( ssl_sock_test() );
#endif

#if INCLUDE_ECHO_SERVER
    //echo_server();
    //echo_srv_sync();
    udp_echo_srv_ioqueue();

#elif INCLUDE_ECHO_CLIENT
    if (param_echo_sock_type == 0)
        param_echo_sock_type = pj_SOCK_DGRAM();

    echo_client( param_echo_sock_type, 
                 param_echo_server, 
                 param_echo_port);
#endif

    goto on_return;

on_return:

    pj_caching_pool_destroy( &caching_pool );

    PJ_LOG(3,("test", ""));
 
    pj_thread_get_stack_info(pj_thread_this(), &filename, &line);
    PJ_LOG(3,("test", "Stack max usage: %u, deepest: %s:%u", 
	              pj_thread_get_stack_max_usage(pj_thread_this()),
		      filename, line));
    if (rc == 0)
	PJ_LOG(3,("test", "Looks like everything is okay!.."));
    else
	PJ_LOG(3,("test", "Test completed with error(s)"));
    
    pj_shutdown();
    
    return 0;
}
Exemplo n.º 5
0
int main()
{
    int flag;
    char  input[3];
    //creating 3 node type variables new_node current and head
    node *new_node,*current;
    printf("\nEnter data to First linked list\n");
    //Dynamic initializtion
    new_node=(node *)malloc(sizeof(node));
    printf("\nEnter data to the node: ");
    //Storing some data
    scanf("%d",&new_node->data);
    //head pointing to the new node
    head=new_node;
    new_node->next=NULL;
    length_1++;
    current=new_node;
    printf("\nDo you want to enter new node(yes/no):");
    scanf("%s",input);
    flag=string_test(input);
    //Iterate itself until flag is 1 i. the string entered is yes
    while(flag==1)
    {
        length_1++;
        //calling create_node function to create new node and link it
        current=create_node(current);
        printf("\nDo you want to enter new node(yes/no):");
        scanf("%s",input);
        //calling string_test fuction to check whether the input is yes or no
        flag=string_test(input);
    }
    //Calling the display function and passing head as the value
    display(head);
    printf("\nEnter the data to Second linked list");
    //Dynamic initializtion
    new_node=(node *)malloc(sizeof(node));
    printf("\nEnter data to the node:  ");
    //Storing some data
    scanf("%d",&new_node->data);
    //head pointing to the new node
    new_head=new_node;
    new_node->next=NULL;
    length_2++;
    current=new_node;
    printf("\nDo you want to enter new node(yes/no):");
    scanf("%s",input);
    flag=string_test(input);
    //Iterate itself until flag is 1 i. the string entered is yes
    while(flag==1)
    {
        length_2++;
        //calling create_node function to create new node and link it
        current=create_node(current);
        printf("\nDo you want to enter new node(yes/no):");
        scanf("%s",input);
        //calling string_test fuction to check whether the input is yes or no
        flag=string_test(input);
    }
    //Calling the display function and passing head as the value
    display(new_head);
    merger();

    return 0;
}
Exemplo n.º 6
0
int
main(int argc, char *argv[])
{
    grpc_error_t result;
    char *config_file, *program_name;
    int ch;
    int ret, exit_code;

    program_name = argv[0];

    while ((ch = getopt(argc, argv, "v")) != -1) {
        switch (ch) {
        case 'v' :
            verbose = 1;
            break;
        default :
            fprintf(stderr, "Usage: %s [-v] config\n", program_name);
            exit(2);
        }
    }
    argc -= optind;
    argv += optind;

    if (argc < 1) {
        fprintf(stderr, "Usage: %s [-v] config\n", program_name);
        exit(2);
    }

    config_file = argv[0];
    exit_code = 0;

    setbuf(stdout, NULL);

    result = grpc_initialize(config_file);
    if (result != GRPC_NO_ERROR) {
        fprintf(stderr, 
            "grpc_initialize() error. (%s)\n", grpc_error_string(result));
        exit(2);
    }

    printf("char_testing: ");
    ret = char_test();
    printf(ret ? "\tOK\n" : "\tfailed\n");
    exit_code = ((ret && (exit_code == 0)) ? 0 : 1);

    printf("short_testing: ");
    ret = short_test();
    printf(ret ? "\tOK\n" : "\tfailed\n");
    exit_code = ((ret && (exit_code == 0)) ? 0 : 1);

    printf("int_testing: ");
    ret = int_test();
    printf(ret ? "\tOK\n" : "\tfailed\n");
    exit_code = ((ret && (exit_code == 0)) ? 0 : 1);

    printf("long_testing: ");
    ret = long_test();
    printf(ret ? "\tOK\n" : "\tfailed\n");
    exit_code = ((ret && (exit_code == 0)) ? 0 : 1);

    printf("float_testing: ");
    ret = float_test();
    printf(ret ? "\tOK\n" : "\tfailed\n");
    exit_code = ((ret && (exit_code == 0)) ? 0 : 1);

    printf("double_testing: ");
    ret = double_test();
    printf(ret ? "\tOK\n" : "\tfailed\n");
    exit_code = ((ret && (exit_code == 0)) ? 0 : 1);

    printf("string_testing: ");
    ret = string_test();
    printf(ret ? "\tOK\n" : "\tfailed\n");
    exit_code = ((ret && (exit_code == 0)) ? 0 : 1);

    printf("string_array_testing: ");
    ret = string_array_test();
    printf(ret ? "\tOK\n" : "\tfailed\n");
    exit_code = ((ret && (exit_code == 0)) ? 0 : 1);

    printf("scomplex_testing: ");
    ret = scomplex_test();
    printf(ret ? "\tOK\n" : "\tfailed\n");
    exit_code = ((ret && (exit_code == 0)) ? 0 : 1);

    printf("dcomplex_testing: ");
    ret = dcomplex_test();
    printf(ret ? "\tOK\n" : "\tfailed\n");
    exit_code = ((ret && (exit_code == 0)) ? 0 : 1);

    printf("work_testing: ");
    ret = work_test();
    printf(ret ? "\tOK\n" : "\tfailed\n");
    exit_code = ((ret && (exit_code == 0)) ? 0 : 1);

    result = grpc_finalize();
    if (result != GRPC_NO_ERROR) {
        fprintf(stderr, 
            "grpc_finalize() error. (%s)\n", grpc_error_string(result));
        exit(2);
    }
 
    return exit_code;
}
Exemplo n.º 7
0
// --------------------------------------------------------------------
int BenchMark:: start_custom_run()
{
	cout << message[starting_test_msg] << endl;
	cout << endl;

	set_block_limits(16);
	set_report_limits(16);

	unsigned i = 0;

	cout << message[int_add_msg] << " \n";
	for (i = 0; i < block_loop; i++)
	{
		addtion_test_list[i] = sum_int_test();
		average_int_sum += addtion_test_list[i];
	}
	average_int_sum = average_int_sum / block_loop;

	cout << message[int_sub_msg] << " \n";
	for (i = 0; i < block_loop; i++)
	{
		substrac_test_list[i] = sub_int_test();
		average_int_sub += substrac_test_list[i];
	}
	average_int_sub = average_int_sub / block_loop;

	cout << message[int_div_msg] << " \n";
	for (i = 0; i < block_loop; i++)
	{
		division_test_list[i] = div_int_test();
		average_int_div += division_test_list[i];
	}
	average_int_div = average_int_div / block_loop;

	cout << message[int_mul_msg] << " \n";
	for (i = 0; i < block_loop; i++)
	{
		mult_test_list[i] = mul_int_test();
		average_int_mul += mult_test_list[i];
	}
	average_int_sub = average_int_sub / block_loop;

	// Start of floating point tests
	cout << message[dec_add_msg] << " \n";
	for (i = 0; i < block_loop; i++)
	{
		add_float_list[i] = sum_decimal_test();
		average_decimal_sum += add_float_list[i];
	}
	average_decimal_sum = average_decimal_sum / block_loop;

	cout << message[dec_sub_msg] << " \n";
	for (i = 0; i < block_loop; i++)
	{
		sub_float_list[i] = sub_decimal_test();
		average_decimal_sub += sub_float_list[i];
	}
	average_decimal_sub = average_decimal_sub / block_loop;

	cout << message[dec_div_msg] << " \n";
	for (i = 0; i < block_loop; i++)
	{
		div_float_list[i] = div_decimal_test();
		average_decimal_div += div_float_list[i];
	}
	average_decimal_div = average_decimal_div / block_loop;

	cout << message[dec_mul_msg] << " \n";
	for (i = 0; i < block_loop; i++)
	{
		mul_float_list[i] = mul_decimal_test();
		average_decimal_mul += mul_float_list[i];
	}
	average_decimal_mul = average_decimal_mul / block_loop;

	// Start of misc tests
	cout << message[str_msg] << " \n";
	for (i = 0; i < block_loop; i++)
	{
		string_result_list[i] = string_test();
		average_string += string_result_list[i];
	}
	average_string = average_string / block_loop;

	cout << message[func_msg] << " \n";
	for (i = 0; i < block_loop; i++)
	{
		function_result_list[i] = function_call_test();
		average_func += function_result_list[i];
	}
	average_func = average_func / block_loop;

	cout << message[prime_msg] << " \n";
	for (i = 0; i < block_loop; i++)
	{
		prime_result_list[i] = prime_number_test();
		average_prime += prime_result_list[i];
	}
	average_prime = average_prime / block_loop;

	is_test_done = true;

	display_report(all);

	return 0;
}
Exemplo n.º 8
0
int
main(int argc, char *argv[])
{
    if (argc < 2)
	fail("To few arguments for test case");

    {
	char *testcase;
	int save_xres = 0;
	int i;

	send_my_pid();

	testcase = argv[1];
#ifdef THREAD_SAFE
	{
	    int res = ethr_init(NULL);
	    if (res != 0)
		fail("Failed to initialize the ethread library");
	}
#endif

	for (i = 2; i < argc; i++) {
	    if (strcmp(argv[i], "save_expected_result") == 0) {
		save_xres = 1;
		break;
	    }
	}

	if (save_xres) {
	    char filename[100];
	    sprintf(filename,
		    "%s%s_test.h",
		    testcase,
		    sizeof(void *) == 8 ? "_64" : "");
	    printf("Saving expected result to %s\n", filename);
	    outfile = fopen(filename, "w");
	    ASSERT(outfile);
	    fprintf(outfile,
		    "/*\n"
		    " * %%CopyrightBegin%%\n"
		    " * Copyright Ericsson AB 1996-2009. All Rights Reserved.\n"
		    " * \n"
		    " * The contents of this file are subject to the Erlang Public License,\n"
		    " * Version 1.1, (the \"License\"); you may not use this file except in\n"
		    " * compliance with the License. You should have received a copy of the\n"
		    " * Erlang Public License along with this software. If not, it can be\n"
		    " * retrieved online at http://www.erlang.org/.\n"
		    " * \n"
		    " * Software distributed under the License is distributed on an \"AS IS\"\n"
		    " * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See\n"
		    " * the License for the specific language governing rights and limitations\n"
		    " * under the License.\n"
		    " * %%CopyrightEnd%%\n"
		    " */\n"
		    "\n");
	    fprintf(outfile,
		    "/* \n"
		    " * This file has been automatically generated. Do NOT edit it; instead,\n"
		    " * run '%s %s save_expected_result'%s.\n"
		    " */\n"
		    "\n",
		    argv[0],
		    testcase,
		    sizeof(void *) == 8 ? " on a 64-bit machine" : "");
	    fprintf(outfile,
		    "char *%s%s_expected_result[] = {\n",
		    testcase,
		    sizeof(void *) == 8 ? "_64" : "");
	}

	if (strcmp("integer", testcase) == 0)
	    integer_test();
	else if (strcmp("float", testcase) == 0)
	    float_test();
	else if (strcmp("string", testcase) == 0)
	    string_test();
	else if (strcmp("character", testcase) == 0)
	    character_test();
	else if (strcmp("snprintf", testcase) == 0)
	    snprintf_test();
	else if (strcmp("quote", testcase) == 0)
	    quote_test();
	else if (!save_xres)
	    skip("Test case \"%s\" not implemented yet", testcase);

	if (save_xres) {
	    fprintf(outfile, "\tNULL};\n");
	    fclose(outfile);
	}

	succeed(NULL);
    }

    return 0;
}