コード例 #1
0
ファイル: rinoo_spawn.c プロジェクト: dyu/librinoo
/**
 * 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();
}
コード例 #2
0
ファイル: rbtree_head.c プロジェクト: kastnerkyle/librinoo
int main()
{
	int i;
	int min;
	tmytest *head;
	t_rinoorbtree tree;
	t_rinoorbtree_node *node;
	tmytest tab[RINOO_HEADTEST_NB_ELEM];

	XTEST(rinoorbtree(&tree, cmp_func, NULL) == 0);
	for (i = 0; i < RINOO_HEADTEST_NB_ELEM; i++) {
		tab[i].val = random();
		if (i == 0 || min > tab[i].val) {
			min = tab[i].val;
		}
		XTEST(rinoorbtree_put(&tree, &tab[i].node) == 0);
		XTEST(tree.head != NULL);
		head = container_of(tree.head, tmytest, node);
		XTEST(head->val == min);
	}
	rinoorbtree_flush(&tree);
	for (i = 0; i < RINOO_HEADTEST_NB_ELEM; i++) {
		tab[i].val = i;
		XTEST(rinoorbtree_put(&tree, &tab[i].node) == 0);
		XTEST(tree.head != NULL);
	}
	for (i = 0; i < RINOO_HEADTEST_NB_ELEM; i++) {
		node = rinoorbtree_head(&tree);
		XTEST(node != NULL);
		head = container_of(node, tmytest, node);
		XTEST(head->val == i);
		rinoorbtree_remove(&tree, node);
	}
	XPASS();
}
コード例 #3
0
int main()
{
	int i;
	int last;
	tmytest *head;
	t_rinoohtable htable;
	t_rinoohtable_node *node;
	tmytest tab[RINOO_HTABLETEST_NB_ELEM];

	XTEST(rinoohtable(&htable, 42, hash_func, cmp_func) == 0);
	for (i = 0; i < RINOO_HTABLETEST_NB_ELEM; i++) {
		tab[i].val = random();
		rinoohtable_put(&htable, &tab[i].node);
		XTEST(htable.table[tab[i].node.hash % htable.table_size] != NULL);
	}
	XTEST(rinoohtable_size(&htable) == RINOO_HTABLETEST_NB_ELEM);
	for (i = 0; i < RINOO_HTABLETEST_SIZE; i++) {
		node = htable.table[i];
		if (node != NULL) {
			head = container_of(node, tmytest, node);
			last = head->val;
		}
		while((node = htable.table[i]) != NULL) {
			head = container_of(node, tmytest, node);
			XTEST(head->val >= last);
			last = head->val;
			rinoohtable_remove(&htable, node);
		}
	}
	rinoohtable_destroy(&htable);
	XPASS();
}
コード例 #4
0
ファイル: buffer_tolong.c プロジェクト: dyu/librinoo
/**
 * Main function for this unit test
 *
 *
 * @return 0 if test passed
 */
int main()
{
	t_buffer *buffer;
	t_buffer buffer2;

	buffer = buffer_create(NULL);
	XTEST(buffer != NULL);
	XTEST(buffer_add(buffer, "123456789", 9) == 9);
	check_buf(buffer, 123456789);
	buffer_erase(buffer, buffer_size(buffer));
	XTEST(buffer_add(buffer, "1", 1) == 1);
	check_buf(buffer, 1);
	buffer_erase(buffer, buffer_size(buffer));
	XTEST(buffer_add(buffer, "-12345678", 9) == 9);
	check_buf(buffer, -12345678);
	buffer_erase(buffer, buffer_size(buffer));
	buffer_destroy(buffer);
	strtobuffer(&buffer2, "987654321");
	check_buf(&buffer2, 987654321);
	strtobuffer(&buffer2, "0");
	check_buf(&buffer2, 0);
	strtobuffer(&buffer2, "-987654321");
	check_buf(&buffer2, -987654321);
	XPASS();
}
コード例 #5
0
ファイル: rinoo_fs_browse.c プロジェクト: dyu/librinoo
/**
 * Main function for this unit test.
 *
 *
 * @return 0 if test passed
 */
int main()
{
	t_fs_entry *entry = NULL;

	while (rinoo_fs_browse(".", &entry) == 0 && entry != NULL) {
		rinoo_log("%s", buffer_ptr(entry->path));
	}
	XPASS();
}
コード例 #6
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();
}
コード例 #7
0
ファイル: rinoo_ssl_gen.c プロジェクト: kastnerkyle/librinoo
/**
 * Main function for this unit test.
 *
 * @return 0 if test passed
 */
int main()
{
	t_rinoossl_ctx *ssl;

	ssl = rinoo_ssl_context();
	XTEST(ssl != NULL);
	rinoo_ssl_context_destroy(ssl);
	XPASS();
}
コード例 #8
0
ファイル: rinoo_task.c プロジェクト: dyu/librinoo
/**
 * 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();
}
コード例 #9
0
ファイル: rinoo_task_wait.c プロジェクト: dyu/librinoo
/**
 * 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();
}
コード例 #10
0
ファイル: rinoo_socket_readb.c プロジェクト: dyu/librinoo
/**
 * 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();
}
コード例 #11
0
ファイル: http.c プロジェクト: dyu/librinoo
/**
 * 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();
}
コード例 #12
0
ファイル: rinoo_inotify.c プロジェクト: dyu/librinoo
/**
 * 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();
}
コード例 #13
0
ファイル: buffer_strcasecmp.c プロジェクト: dyu/librinoo
/**
 * Main function for this unit test
 *
 *
 * @return 0 if test passed
 */
int main()
{
	uint32_t i;
	t_buffer *buffer1;

	buffer1 = buffer_create(NULL);
	XTEST(buffer1 != NULL);
	for (i = 0; i < ARRAY_SIZE(strings) - 1; i++) {
		buffer_add(buffer1, strings[i], strlen(strings[i]));
		XTEST(buffer_strcasecmp(buffer1, strings[i + 1]) < 0);
		buffer_erase(buffer1, buffer_size(buffer1));
	}
	buffer_destroy(buffer1);
	XPASS();
}
コード例 #14
0
/**
 * 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();
}
コード例 #15
0
ファイル: vector_add.c プロジェクト: reginaldl/librinoo
/**
 * Main function for this unit test
 *
 *
 * @return 0 if test passed
 */
int main()
{
    int i;
    size_t prev = 4;
    t_vector vector = { 0 };

    for (i = 0; i < 1000; i++) {
        XTEST(vector_add(&vector, INT_TO_PTR(i)) == 0);
        XTEST(vector.size == (size_t) i + 1);
        XTEST(vector.msize == prev * 2);
        if ((size_t) (i + 1) >= vector.msize) {
            prev = vector.msize;
        }
    }
    for (i = 0; i < 1000; i++) {
        XTEST(vector_get(&vector, (uint32_t) i) == INT_TO_PTR(i));
    }
    XTEST(vector_get(&vector, 1000) == NULL);
    vector_destroy(&vector);
    XPASS();
}