Beispiel #1
0
/**
 * Main function for this unit test
 *
 *
 * @return 0 if test passed
 */
int main()
{
	int i;
	t_sched *cur;
	t_sched *sched;

	memset(checker, 0, sizeof(*checker) * NBSPAWNS);
	sched = rinoo_sched();
	XTEST(sched != NULL);
	XTEST(rinoo_spawn(sched, NBSPAWNS) == 0);
	for (i = 0; i <= NBSPAWNS; i++) {
		cur = rinoo_spawn_get(sched, i);
		XTEST(cur != NULL);
		if (i == 0) {
			XTEST(cur == sched);
		}
		XTEST(rinoo_task_start(cur, task, sched) == 0);
	}
	rinoo_sched_loop(sched);
	rinoo_sched_destroy(sched);
	for (i = 0; i <= NBSPAWNS; i++) {
		XTEST(checker[i] == 1);
	}
	XPASS();
}
Beispiel #2
0
/**
 * Main function for this unit test
 *
 *
 * @return 0 if test passed
 */
int main()
{
	XTEST(rinoo_task_self() == NULL);
	sched = rinoo_sched();
	XTEST(sched != NULL);
	XTEST(rinoo_task_run(sched, task1, sched) == 0);
	rinoo_sched_destroy(sched);
	XPASS();
}
Beispiel #3
0
int main()
{
	t_sched *sched;

	sched = rinoo_sched();
	rinoo_task_start(sched, task_server, sched);
	rinoo_sched_loop(sched);
	rinoo_sched_destroy(sched);
	return 0;
}
Beispiel #4
0
/**
 * Main function for this unit test
 *
 *
 * @return 0 if test passed
 */
int main()
{
	t_sched *sched;

	sched = rinoo_sched();
	XTEST(sched != NULL);
	XTEST(rinoo_task_run(sched, task1, sched) == 0);
	rinoo_sched_destroy(sched);
	XTEST(checker == 3);
	XPASS();
}
Beispiel #5
0
/**
 * Main function for this unit test
 *
 *
 * @return 0 if test passed
 */
int main()
{
	t_sched *sched;

	sched = rinoo_sched();
	XTEST(sched != NULL);
	XTEST(rinoo_task_start(sched, task_func, sched) == 0);
	rinoo_sched_loop(sched);
	rinoo_sched_destroy(sched);
	XPASS();
}
Beispiel #6
0
/**
 * Main function for this unit test.
 *
 *
 * @return 0 if test passed
 */
int main()
{
	t_sched *sched;

	sched = rinoo_sched();
	XTEST(sched != NULL);
	XTEST(rinoo_task_start(sched, server_func, NULL) == 0);
	XTEST(rinoo_task_start(sched, client_func, NULL) == 0);
	rinoo_sched_loop(sched);
	rinoo_sched_destroy(sched);
	XPASS();
}
Beispiel #7
0
/**
 * Main function for this unit test.
 *
 *
 * @return 0 if test passed
 */
int main()
{
	t_sched *sched;

	sched = rinoo_sched();
	XTEST(sched != NULL);
	XTEST(rinoo_task_start(sched, http_server, sched) == 0);
	XTEST(rinoo_task_start(sched, http_client, sched) == 0);
	rinoo_sched_loop(sched);
	rinoo_sched_destroy(sched);
	XPASS();
}
Beispiel #8
0
/**
 * Main function for this unit test.
 *
 *
 * @return 0 if test passed
 */
int main()
{
	t_sched *sched;

	mkdir(TEST_DIRECTORY, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
	sched = rinoo_sched();
	XTEST(sched != NULL);
	XTEST(rinoo_task_start(sched, check_file, sched) == 0);
	XTEST(rinoo_task_start(sched, event_generator, sched) == 0);
	rinoo_sched_loop(sched);
	rinoo_sched_destroy(sched);
	rmdir(TEST_DIRECTORY);
	XPASS();
}
/**
 * Main function for this unit test.
 *
 * @return 0 if test passed
 */
int main()
{
	t_rinoosched *sched;

	big_buffer = malloc(sizeof(*big_buffer) * BUFFER_SIZE);
	XTEST(big_buffer != NULL);
	memset(big_buffer, 'x', sizeof(*big_buffer) * BUFFER_SIZE);
	sched = rinoo_sched();
	XTEST(sched != NULL);
	XTEST(rinoo_task_start(sched, server_func, sched) == 0);
	XTEST(rinoo_task_start(sched, client_func, sched) == 0);
	rinoo_sched_loop(sched);
	rinoo_sched_destroy(sched);
	free(big_buffer);
	XPASS();
}
void *server_thread(void *unused(arg))
{
	char b;
	t_rinoosched *sched;
	t_rinoosocket *server;
	t_rinoosocket *client;
	struct sockaddr_in addr;

	sched = rinoo_sched();
	XTEST(sched != NULL);
	server = rinoo_socket(sched, &socket_class_tcp);
	XTEST(server != NULL);
	addr.sin_port = htons(4242);
	addr.sin_family = AF_INET;
	addr.sin_addr.s_addr = 0;
	XTEST(rinoo_socket_bind(server, (struct sockaddr *) &addr, sizeof(addr), 42) == 0);
	rinoo_log("server listening...");
	client = rinoo_socket_accept(server, (struct sockaddr *) &addr, (socklen_t *)(int[]){(sizeof(struct sockaddr))});
Beispiel #11
0
int main(int argc, char **argv)
{
    sched = rinoo_sched();
    if (sched == NULL) {
        return -1;
    }
    config = rsc_config_create();
    if (config == NULL) {
        rinoo_log("could not create configuration");
        rinoo_sched_destroy(sched);
        return -1;
    }
    if (rsc_config_parse_options(argc, argv, config) != 0) {
        rsc_config_destroy(config);
        rinoo_sched_destroy(sched);
        return -1;
    }
    if (signal(SIGINT, sig_handler) == SIG_ERR) {
        rsc_config_destroy(config);
        rinoo_sched_destroy(sched);
        return -1;
    }
    if (config->gui) {
        if (rsc_ui_start(sched) != 0) {
            rinoo_log("could not start web server");
            rsc_config_destroy(config);
            rinoo_sched_destroy(sched);
            return -1;
        }
        thread_counter++;
    }
    if (rsc_start(sched) != 0) {
        rinoo_log("could not create threads");
        rsc_config_destroy(config);
        rinoo_sched_destroy(sched);
        return -1;
    }
    rinoo_sched_loop(sched);
    rinoo_sched_destroy(sched);
    rsc_stats();
    rsc_log(config, RSC_LOG_REPORT, "Report - Sent: %d Failed: %d Total: %d", config->stats.all.sent, config->stats.all.failed, config->stats.all.sent + config->stats.all.failed);
    rsc_config_destroy(config);
    return 0;
}