コード例 #1
0
ファイル: abts.c プロジェクト: KunZheng/mosbench
static int report(abts_suite *suite)
{
    int count = 0;
    sub_suite *dptr;

    if (suite && suite->tail &&!suite->tail->not_run) {
        end_suite(suite);
    }

    for (dptr = suite->head; dptr; dptr = dptr->next) {
        count += dptr->failed;
    }

    if (list_tests) {
        return 0;
    }

    if (count == 0) {
        printf("All tests passed.\n");
        return 0;
    }

    dptr = suite->head;
    fprintf(stdout, "%-15s\t\tTotal\tFail\tFailed %%\n", "Failed Tests");
    fprintf(stdout, "===================================================\n");
    while (dptr != NULL) {
        if (dptr->failed != 0) {
            float percent = ((float)dptr->failed / (float)dptr->num_test);
            fprintf(stdout, "%-15s\t\t%5d\t%4d\t%6.2f%%\n", dptr->name, 
                    dptr->num_test, dptr->failed, percent * 100);
        }
        dptr = dptr->next;
    }
    return 1;
}
コード例 #2
0
ファイル: abts.c プロジェクト: vicallee/abts
/* return the tail pointer */
abts_suite *abts_add_suite(abts_suite *suite, const char *suite_name_full)
{
    abts_suite *newsuite;
    char *p;
    const char *suite_name;
    curr_char = 0;
    
    /* Only end the suite if we actually ran it */
    if (suite && !suite->not_run) {
        end_suite(suite);
    }

    newsuite = malloc(sizeof(*newsuite));
    newsuite->num_test = 0;
    newsuite->num_failed = 0;
    newsuite->next = newsuite;
    /* suite_name_full may be an absolute path depending on __FILE__ expansion */
    suite_name = strrchr(suite_name_full, DELIMITER);
    if (suite_name) {
        suite_name++;
    } else {
	    suite_name = suite_name_full;
    }
    p = strrchr(suite_name, '.');
    if (p) {
        newsuite->name = memcpy(calloc(p - suite_name + 1, 1),
                                suite_name, p - suite_name);
    }
    else {
        newsuite->name = strdup(suite_name);
    }

    if (list_tests) {
        fprintf(outfp, "%s\n", newsuite->name);
    }
    
    newsuite->not_run = 0;

	/* append to tail */
    if (suite) {
    	newsuite->next = suite->next;
    	suite->next = newsuite;
    }    
	suite = newsuite;

    if (!should_test_run(newsuite->name)) {
        newsuite->not_run = 1;
        return suite;
    }

    reset_status();
    fprintf(outfp, "%-20s:  ", newsuite->name);
    update_status();
    fflush(outfp);

    return suite;
}
コード例 #3
0
int main(int argc, char* argv[]) {
    MPI_Init(&argc, &argv);

    start_suite("MPI_Actor_create");
    run_test(comm_actor_creation, "Creation, getting, deleting");
    run_test(comm_actor_duplication, "Communicator duplication");
    run_test(
        comm_actor_null_arguments,
        "Communicator creation with minimal arguments"
    );
    end_suite();

    MPI_Finalize();
    return mpitest_exit_status();
}
コード例 #4
0
ファイル: socket_main.c プロジェクト: charloco/ofp
/** main() Application entry point
 *
 * @param argc int
 * @param argv[] char*
 * @return int
 *
 */
int main(int argc, char *argv[])
{
	odph_linux_pthread_t thread_tbl[MAX_WORKERS];
	appl_args_t params;
	int core_count, num_workers;
	odp_cpumask_t cpumask;
	char cpumaskstr[64];

	/* Parse and store the application arguments */
	parse_args(argc, argv, &params);

	/* Print both system and application information */
	print_info(NO_PATH(argv[0]), &params);

	if (odp_init_global(NULL, NULL)) {
		OFP_ERR("Error: ODP global init failed.\n");
		exit(EXIT_FAILURE);
	}
	if (odp_init_local(ODP_THREAD_CONTROL)) {
		OFP_ERR("Error: ODP local init failed.\n");
		exit(EXIT_FAILURE);
	}

	core_count = odp_cpu_count();
	num_workers = core_count;

	if (params.core_count)
		num_workers = params.core_count;
	if (num_workers > MAX_WORKERS)
		num_workers = MAX_WORKERS;

	if (core_count > 1)
		num_workers--;

	num_workers = odp_cpumask_default_worker(&cpumask, num_workers);
	odp_cpumask_to_str(&cpumask, cpumaskstr, sizeof(cpumaskstr));

	printf("Num worker threads: %i\n", num_workers);
	printf("first CPU:          %i\n", odp_cpumask_first(&cpumask));
	printf("cpu mask:           %s\n", cpumaskstr);

	memset(&app_init_params, 0, sizeof(app_init_params));
	app_init_params.linux_core_id = 0;
	app_init_params.if_count = params.if_count;
	app_init_params.if_names = params.if_names;

	if (ofp_init_global(&app_init_params)) {
		OFP_ERR("Error: OFP global init failed.\n");
		exit(EXIT_FAILURE);
	}

	memset(thread_tbl, 0, sizeof(thread_tbl));
	/* Start dataplane dispatcher worker threads */
	ofp_linux_pthread_create(thread_tbl,
				  &cpumask,
				  default_event_dispatcher,
				  ofp_eth_vlan_processing,
				  ODP_THREAD_CONTROL
				);

	/* other app code here.*/
	/* Start CLI */
	ofp_start_cli_thread(app_init_params.linux_core_id, params.conf_file);

	sleep(5);

	ofp_loglevel = OFP_LOG_INFO;

	config_suite_framework(app_init_params.linux_core_id);

	OFP_INFO("\n\nSuite: IPv4 UDP socket: create and close.\n\n");
	if (!init_suite(NULL))
		run_suite(create_close_udp, create_close_udp_noproto);
	end_suite();
	OFP_INFO("Test ended.\n");

	OFP_INFO("\n\nSuite: IPv4 TCP socket: create and close.\n\n");
	if (!init_suite(NULL))
		run_suite(create_close_tcp, create_close_tcp_noproto);
	end_suite();
	OFP_INFO("Test ended.\n");

#ifdef INET6
	OFP_INFO("\n\nSuite: IPv6 UDP socket: create and close.\n\n");
	if (!init_suite(NULL))
		run_suite(create_close_udp6, create_close_udp6_noproto);
	end_suite();
	OFP_INFO("Test ended.\n");

	OFP_INFO("\n\nSuite: IPv6 TCP socket: create and close.\n\n");
	if (!init_suite(NULL))
		run_suite(create_close_tcp6, create_close_tcp6_noproto);
	end_suite();
	OFP_INFO("Test ended.\n");
#endif /* INET6 */

	OFP_INFO("\n\nSuite: IPv4 UDP socket: bind.\n\n");
	if (!init_suite(init_udp_create_socket))
		run_suite(bind_ip4_local_ip, bind_ip4_any);
	end_suite();
	OFP_INFO("Test ended.\n");

	OFP_INFO("\n\nSuite: IPv4 TCP socket: bind.\n\n");
	if (!init_suite(init_tcp_create_socket))
		run_suite(bind_ip4_local_ip, bind_ip4_any);
	end_suite();
	OFP_INFO("Test ended.\n");

#ifdef INET6
	OFP_INFO("\n\nSuite: IPv6 UDP socket: bind.\n\n");
	if (!init_suite(init_udp6_create_socket))
		run_suite(bind_ip6_local_ip, bind_ip6_any);
	end_suite();
	OFP_INFO("Test ended.\n");

	OFP_INFO("\n\nSuite: IPv6 TCP socket: bind.\n\n");
	if (!init_suite(init_tcp6_create_socket))
		run_suite(bind_ip6_local_ip, bind_ip6_any);
	end_suite();
	OFP_INFO("Test ended.\n");
#endif /* INET6 */

	OFP_INFO("\n\nSuite: IPv4 UDP socket: shutdown.\n\n");
	if (!init_suite(init_udp_create_socket))
		run_suite(shutdown_socket, shutdown_socket);
	end_suite();
	OFP_INFO("Test ended.\n");

	OFP_INFO("\n\nSuite: IPv4 TCP socket: shutdown (no connection).\n\n");
	if (!init_suite(init_tcp_create_socket))
		run_suite(shutdown_socket, shutdown_socket);
	end_suite();
	OFP_INFO("Test ended.\n");

#ifdef INET6
	OFP_INFO("\n\nSuite: IPv6 UDP socket: shutdown.\n\n");
	if (!init_suite(init_udp6_create_socket))
		run_suite(shutdown_socket, shutdown_socket);
	end_suite();
	OFP_INFO("Test ended.\n");

	OFP_INFO("\n\nSuite: IPv6 TCP socket: shutdown (no connection).\n\n");
	if (!init_suite(init_tcp6_create_socket))
		run_suite(shutdown_socket, shutdown_socket);
	end_suite();
	OFP_INFO("Test ended.\n");
#endif /* INET6 */

	OFP_INFO("\n\nSuite: IPv4 UDP socket: connect.\n\n");
	if (!init_suite(init_udp_create_socket))
		run_suite(connect_udp4, connect_bind_udp4);
	end_suite();
	OFP_INFO("Test ended.\n");

	OFP_INFO("\n\nSuite: IPv4 UDP socket: connect + shutdown.\n\n");
	if (!init_suite(init_udp_create_socket))
		run_suite(connect_shutdown_udp4, connect_shutdown_bind_udp4);
	end_suite();
	OFP_INFO("Test ended.\n");

#ifdef INET6
	OFP_INFO("\n\nSuite: IPv6 UDP socket: connect.\n\n");
	if (!init_suite(init_udp6_create_socket))
		run_suite(connect_udp6, connect_bind_udp6);
	end_suite();
	OFP_INFO("Test ended.\n");

	OFP_INFO("\n\nSuite: IPv6 UDP socket: connect + shutdown.\n\n");
	if (!init_suite(init_udp6_create_socket))
		run_suite(connect_shutdown_udp6, connect_shutdown_bind_udp6);
	end_suite();
	OFP_INFO("Test ended.\n");

	OFP_INFO("\n\nSuite: IPv6 UDP socket: connect + shutdown + any.\n\n");
	if (!init_suite(init_udp6_create_socket))
		run_suite(connect_shutdown_udp6_any,
				connect_shutdown_bind_udp6_any);
	end_suite();
	OFP_INFO("Test ended.\n");
#endif /* INET6 */

	OFP_INFO("\n\nSuite: IPv4 UDP socket BIND local address: send + sendto\n\n");
	if (!init_suite(init_udp_bind_local_ip))
		run_suite(send_ip4_udp_local_ip, sendto_ip4_udp_local_ip);
	end_suite();
	OFP_INFO("Test ended.\n");

	OFP_INFO("\n\nSuite: IPv4 UDP socket bind any address: send + sendto\n\n");
	if (!init_suite(init_udp_bind_any))
		run_suite(send_ip4_udp_any, sendto_ip4_udp_any);
	end_suite();
	OFP_INFO("Test ended.\n");

#ifdef INET6
	OFP_INFO("\n\nSuite: IPv6 UDP socket BIND local address: send + sendto\n\n");
	if (!init_suite(init_udp6_bind_local_ip))
		run_suite(send_ip6_udp_local_ip, sendto_ip6_udp_local_ip);
	end_suite();
	OFP_INFO("Test ended.\n");

	OFP_INFO("\n\nSuite: IPv6 UDP socket bind any address: send + sendto\n\n");
	if (!init_suite(init_udp6_bind_any))
		run_suite(send_ip6_udp_any, sendto_ip6_udp_any);
	end_suite();
	OFP_INFO("Test ended.\n");
#endif /* INET6 */

	OFP_INFO("\n\nSuite: IPv4 UDP bind local IP: sendto + recv.\n\n");
	if (!init_suite(init_udp_local_ip))
		run_suite(send_udp_local_ip, recv_udp);
	end_suite();
	OFP_INFO("Test ended.\n");

	OFP_INFO("\n\nSuite: IPv4 UDP bind local IP: sendto + recvfrom.\n\n");
	if (!init_suite(init_udp_bind_local_ip))
		run_suite(send_udp_local_ip, recvfrom_udp);
	end_suite();
	OFP_INFO("Test ended.\n");

	OFP_INFO("\n\nSuite: IPv4 UDP bind any address: sendto + recv.\n\n");
	if (!init_suite(init_udp_any))
		run_suite(send_udp_any, recv_udp);
	end_suite();

	OFP_INFO("\n\nSuite: IPv4 UDP bind any address: sendto + recvfrom.\n\n");
	if (!init_suite(init_udp_bind_any))
		run_suite(send_udp_any, recvfrom_udp);
	end_suite();
	OFP_INFO("Test ended.\n");

	OFP_INFO("\n\nSuite: IPv4 UDP bind any address: sendto + recvfrom(NULL addr).\n\n");
	if (!init_suite(init_udp_bind_any))
		run_suite(send_udp_any, recvfrom_udp_null_addr);
	end_suite();
	OFP_INFO("Test ended.\n");

#ifdef INET6
	OFP_INFO("\n\nSuite: IPv6 UDP bind local IP: sendto + recv.\n\n");
	if (!init_suite(init_udp6_bind_local_ip))
		run_suite(send_udp6_local_ip, recv_udp);
	end_suite();
	OFP_INFO("Test ended.\n");

	OFP_INFO("\n\nSuite: IPv6 UDP bind local IP: sendto + recvfrom.\n\n");
	if (!init_suite(init_udp6_bind_local_ip))
		run_suite(send_udp6_local_ip, recvfrom_udp6);
	end_suite();
	OFP_INFO("Test ended.\n");

	OFP_INFO("\n\nSuite: IPv6 UDP bind any IP: sendto + recv.\n\n");
	if (!init_suite(init_udp6_bind_any))
		run_suite(send_udp6_any, recv_udp);
	end_suite();
	OFP_INFO("Test ended.\n");

	OFP_INFO("\n\nSuite: IPv6 UDP bind any IP: sendto + recvfrom.\n\n");
	if (!init_suite(init_udp6_bind_any))
		run_suite(send_udp6_any, recvfrom_udp6);
	end_suite();
	OFP_INFO("Test ended.\n");

	OFP_INFO("\n\nSuite: IPv6 UDP bind any IP: sendto + recvfrom(NULL addr).\n\n");
	if (!init_suite(init_udp6_bind_any))
		run_suite(send_udp6_any, recvfrom_udp_null_addr);
	end_suite();
	OFP_INFO("Test ended.\n");
#endif /*INET6*/

	OFP_INFO("\n\nSuite: IPv4 TCP socket local IP: listen.\n\n");
	if (!init_suite(init_tcp_bind_local_ip))
		run_suite(listen_tcp, listen_tcp);
	end_suite();
	OFP_INFO("Test ended.\n");

#ifdef INET6
	OFP_INFO("\n\nSuite: IPv6 TCP socket local IP: listen.\n\n");
	if (!init_suite(init_tcp6_bind_local_ip))
		run_suite(listen_tcp, listen_tcp);
	end_suite();
	OFP_INFO("Test ended.\n");
#endif /*INET6*/

	OFP_INFO("\n\nSuite: IPv4 TCP socket local IP: connect + accept.\n\n");
	if (!init_suite(init_tcp_bind_listen_local_ip))
		run_suite(connect_tcp4_local_ip, accept_tcp4);
	end_suite();
	OFP_INFO("Test ended.\n");

	OFP_INFO("\n\nSuite: IPv4 TCP socket any IP: connect + accept.\n\n");
	if (!init_suite(init_tcp_bind_listen_any))
		run_suite(connect_tcp4_any, accept_tcp4);
	end_suite();
	OFP_INFO("Test ended.\n");

	OFP_INFO("\n\nSuite: IPv4 TCP socket local IP: connect + accept null address.\n\n");
	if (!init_suite(init_tcp_bind_listen_local_ip))
		run_suite(connect_tcp4_local_ip, accept_tcp4_null_addr);
	end_suite();
	OFP_INFO("Test ended.\n");

#ifdef INET6
	OFP_INFO("\n\nSuite: IPv6 TCP socket local IP: connect + accept.\n\n");
	if (!init_suite(init_tcp6_bind_listen_local_ip))
		run_suite(connect_tcp6_local_ip, accept_tcp6);
	end_suite();
	OFP_INFO("Test ended.\n");

	OFP_INFO("\n\nSuite: IPv6 TCP socket any IP: connect + accept.\n\n");
	if (!init_suite(init_tcp6_bind_listen_any))
		run_suite(connect_tcp6_any, accept_tcp6);
	end_suite();
	OFP_INFO("Test ended.\n");


	OFP_INFO("\n\nSuite: IPv6 TCP socket local IP: connect + accept null address.\n\n");
	if (!init_suite(init_tcp6_bind_listen_local_ip))
		run_suite(connect_tcp6_local_ip, accept_tcp6_null_addr);
	end_suite();
	OFP_INFO("Test ended.\n");
#endif /*INET6*/

	OFP_INFO("\n\nSuite: IPv4 TCP socket local IP: send + recv.\n\n");
	if (!init_suite(init_tcp_bind_listen_local_ip))
		run_suite(send_tcp4_local_ip, receive_tcp);
	end_suite();
	OFP_INFO("Test ended.\n");

	OFP_INFO("\n\nSuite: IPv4 TCP socket any IP: send + recv.\n\n");
	if (!init_suite(init_tcp_bind_listen_any))
		run_suite(send_tcp4_any, receive_tcp);
	end_suite();
	OFP_INFO("Test ended.\n");

#ifdef INET6
	OFP_INFO("\n\nSuite: IPv6 TCP socket local IP: send + recv.\n\n");
	if (!init_suite(init_tcp6_bind_listen_local_ip))
		run_suite(send_tcp6_local_ip, receive_tcp);
	end_suite();
	OFP_INFO("Test ended.\n");

	OFP_INFO("\n\nSuite: IPv6 TCP socket any IP: send + recv.\n\n");
	if (!init_suite(init_tcp6_bind_listen_any))
		run_suite(send_tcp6_any, receive_tcp);
	end_suite();
	OFP_INFO("Test ended.\n");
#endif /*INET6*/

	OFP_INFO("\n\nSuite: IPv4 UDP bind local IP: select + recv.\n\n");
	if (!init_suite(init_udp_bind_local_ip))
		run_suite(send_udp_local_ip, select_recv_udp);
	end_suite();
	OFP_INFO("Test ended.\n");

	OFP_INFO("\n\nSuite: IPv4 TCP bind local IP: select + accept + recv.\n\n");
	if (!init_suite(init_tcp_bind_listen_local_ip))
		run_suite(send_tcp4_local_ip, select_recv_tcp);
	end_suite();
	OFP_INFO("Test ended.\n");

#ifdef INET6
	OFP_INFO("\n\nSuite: IPv6 UDP bind local IP: select + recv.\n\n");
	if (!init_suite(init_udp6_bind_local_ip))
		run_suite(send_udp6_local_ip, select_recv_udp);
	end_suite();
	OFP_INFO("Test ended.\n");

	OFP_INFO("\n\nSuite: IPv6 TCP bind local IP: select + accept + recv.\n\n");
	if (!init_suite(init_tcp6_bind_listen_local_ip))
		run_suite(send_tcp6_local_ip, select_recv_tcp);
	end_suite();
	OFP_INFO("Test ended.\n");
#endif /*INET6*/

	OFP_INFO("\n\nSuite: IPv4 UDP bindlocal IP: select + recv x2.\n\n");
	if (!init_suite(init_udp_bind_local_ip))
		run_suite(send_udp_local_ip, select_recv_udp_2);
	end_suite();
	OFP_INFO("Test ended.\n");

	OFP_INFO("\n\nSuite: IPv4 UDP bind local IP: socket_sigevent rcv.\n\n");
	if (!init_suite(init_udp_bind_local_ip))
		run_suite(recv_send_udp_local_ip, socket_sigevent_udp4);
	end_suite();
	OFP_INFO("Test ended.\n");

#ifdef INET6
	OFP_INFO("\n\nSuite: IPv6 UDP bind local IP: socket_sigevent rcv.\n\n");
	if (!init_suite(init_udp6_bind_local_ip))
		run_suite(recv_send_udp6_local_ip, socket_sigevent_udp6);
	end_suite();
	OFP_INFO("Test ended.\n");
#endif /*INET6*/

	OFP_INFO("\n\nSuite: IPv4 TCP bind local IP: socket_sigevent rcv.\n\n");
	if (!init_suite(init_tcp_bind_listen_local_ip))
		run_suite(connect_recv_send_tcp_local_ip, socket_sigevent_tcp_rcv);
	end_suite();
	OFP_INFO("Test ended.\n");

#ifdef INET6
	OFP_INFO("\n\nSuite: IPv6 TCP bind local IP: socket_sigevent rcv.\n\n");
	if (!init_suite(init_tcp6_bind_listen_local_ip))
		run_suite(connect_recv_send_tcp6_local_ip, socket_sigevent_tcp_rcv);
	end_suite();
	OFP_INFO("Test ended.\n");
#endif /*INET6*/

	OFP_INFO("\n\nSuite: IPv4 TCP bind local IP: socket_sigevent accept.\n\n");
	if (!init_suite(init_tcp_bind_listen_local_ip))
		run_suite(connect_tcp_delayed_local_ip, socket_sigevent_tcp_accept);
	end_suite();
	OFP_INFO("Test ended.\n");

#ifdef INET6
	OFP_INFO("\n\nSuite: IPv6 TCP bind local IP: socket_sigevent accept.\n\n");
	if (!init_suite(init_tcp6_bind_listen_local_ip))
		run_suite(connect_tcp6_delayed_local_ip,
			socket_sigevent_tcp_accept);
	end_suite();
	OFP_INFO("Test ended.\n");
#endif /*INET6*/

	odph_linux_pthread_join(thread_tbl, num_workers);
	printf("End Main()\n");
	return 0;
}
コード例 #5
0
ファイル: abts.c プロジェクト: KunZheng/mosbench
abts_suite *abts_add_suite(abts_suite *suite, const char *suite_name_full)
{
    sub_suite *subsuite;
    char *p;
    const char *suite_name;
    curr_char = 0;
    
    /* Only end the suite if we actually ran it */
    if (suite && suite->tail &&!suite->tail->not_run) {
        end_suite(suite);
    }

    subsuite = malloc(sizeof(*subsuite));
    subsuite->num_test = 0;
    subsuite->failed = 0;
    subsuite->next = NULL;
    /* suite_name_full may be an absolute path depending on __FILE__ 
     * expansion */
    suite_name = strrchr(suite_name_full, '/');
    if (suite_name) {
        suite_name++;
    } else {
        suite_name = suite_name_full;
    }
    p = strrchr(suite_name, '.');
    if (p) {
        subsuite->name = memcpy(calloc(p - suite_name + 1, 1),
                                suite_name, p - suite_name);
    }
    else {
        subsuite->name = suite_name;
    }

    if (list_tests) {
        fprintf(stdout, "%s\n", subsuite->name);
    }
    
    subsuite->not_run = 0;

    if (suite == NULL) {
        suite = malloc(sizeof(*suite));
        suite->head = subsuite;
        suite->tail = subsuite;
    }
    else {
        suite->tail->next = subsuite;
        suite->tail = subsuite;
    }

    if (!should_test_run(subsuite->name)) {
        subsuite->not_run = 1;
        return suite;
    }

    reset_status();
    fprintf(stdout, "%-20s:  ", subsuite->name);
    update_status();
    fflush(stdout);

    return suite;
}