当前位置: 首页>>代码示例>>C++>>正文


C++ CU_ASSERT_FATAL函数代码示例

本文整理汇总了C++中CU_ASSERT_FATAL函数的典型用法代码示例。如果您正苦于以下问题:C++ CU_ASSERT_FATAL函数的具体用法?C++ CU_ASSERT_FATAL怎么用?C++ CU_ASSERT_FATAL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了CU_ASSERT_FATAL函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: vector_2

static void vector_2(void) {
    vector_t v;

    CU_ASSERT(vector_init(&v, "my_vector.bin", 1) == 0);
    CU_ASSERT(vector_size(&v) == 0);
    CU_ASSERT(vector_pages(&v) == 0);
    CU_ASSERT(vector_capacity(&v) == 0);
    CU_ASSERT(vector_elem_size(&v) == 1);

    CU_ASSERT(vector_size(&v, COUNT) == COUNT);
    CU_ASSERT(COUNT <= vector_capacity(&v));
    CU_ASSERT(COUNT <= vector_size(&v));
    CU_ASSERT(3 <= vector_pages(&v));

    for (int i=0; i<COUNT; i++) {
        unsigned char c = (unsigned char)i;
        crc2 = clib_crc32(c, crc2);
        CU_ASSERT(vector_put(&v, i, &c) == 0);
    }
    CU_ASSERT_FATAL(crc2 != 0);

    FILE * f = fopen(v.hdr.name, "w");
    CU_ASSERT_FATAL(f != NULL);
    CU_ASSERT(COUNT < vector_save(&v, f));
    fclose(f), f = NULL;

    CU_ASSERT(vector_delete(&v) == 0);
}
开发者ID:eddiejames,项目名称:ffs,代码行数:28,代码来源:vector.c

示例2: reset_queues

static void reset_queues(thread_args_t *args)
{
	int i, j, k;
	int num_prio = args->num_prio;
	int num_queues = args->num_queues;
	char name[32];

	for (i = 0; i < num_prio; i++) {
		for (j = 0; j < num_queues; j++) {
			odp_queue_t queue;

			snprintf(name, sizeof(name),
				 "sched_%d_%d_o", i, j);
			queue = odp_queue_lookup(name);
			CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID);

			for (k = 0; k < args->num_bufs; k++) {
				queue_context *qctx =
					odp_queue_context(queue);
				int ndx;
				int ndx_max;

				ndx_max = odp_queue_lock_count(queue);
				CU_ASSERT_FATAL(ndx_max >= 0);
				qctx->sequence = 0;
				for (ndx = 0; ndx < ndx_max; ndx++)
					qctx->lock_sequence[ndx] = 0;
			}
		}
	}
}
开发者ID:nmorey,项目名称:odp,代码行数:31,代码来源:scheduler.c

示例3: pktio_test_send_on_ronly

void pktio_test_send_on_ronly(void)
{
	odp_pktio_t pktio;
	odp_packet_t pkt;
	int ret;

	pktio = create_pktio(0, ODP_PKTIN_MODE_RECV,
			     ODP_PKTOUT_MODE_DISABLED);

	if (pktio == ODP_PKTIO_INVALID) {
		CU_FAIL("failed to open pktio");
		return;
	}

	ret = odp_pktio_start(pktio);
	CU_ASSERT_FATAL(ret == 0);

	pkt = odp_packet_alloc(default_pkt_pool, packet_len);
	CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID)

	pktio_init_packet(pkt);

	ret = odp_pktio_send(pktio, &pkt, 1);
	CU_ASSERT(ret < 0);

	if (ret <= 0)
		odp_packet_free(pkt);

	ret = odp_pktio_stop(pktio);
	CU_ASSERT_FATAL(ret == 0);

	ret = odp_pktio_close(pktio);
	CU_ASSERT_FATAL(ret == 0);
}
开发者ID:kalray,项目名称:odp-mppa,代码行数:34,代码来源:pktio.c

示例4: mmapAndParse

static void
mmapAndParse(char *path, int expected)
{
	int					fd, ret;
	struct toml_node	*root;
	void				*m;
	struct stat			st;

	toml_init(&root);

	fd = open(path, O_RDONLY);
	CU_ASSERT_FATAL(fd != -1);

	ret = fstat(fd, &st);
	CU_ASSERT_FATAL(ret != -1);

	m = mmap(NULL, st.st_size, PROT_READ, MAP_FILE|MAP_PRIVATE, fd, 0);
	CU_ASSERT_FATAL(m != NULL);

	ret = toml_parse(root, m, st.st_size);
	CU_ASSERT(ret == expected);

	munmap(m, st.st_size);
	close(fd);
	toml_free(root);
}
开发者ID:medcat,项目名称:libtoml,代码行数:26,代码来源:test.c

示例5: timer_test_timeout_pool_free

void timer_test_timeout_pool_free(void)
{
	odp_pool_t pool;
	odp_timeout_t tmo;
	odp_pool_param_t params;

	odp_pool_param_init(&params);
	params.type    = ODP_POOL_TIMEOUT;
	params.tmo.num = 1;

	pool = odp_pool_create("timeout_pool_free", &params);
	CU_ASSERT_FATAL(pool != ODP_POOL_INVALID);
	odp_pool_print(pool);

	/* Allocate the only timeout from the pool */
	tmo = odp_timeout_alloc(pool);
	CU_ASSERT_FATAL(tmo != ODP_TIMEOUT_INVALID);

	/* Pool should have only one timeout */
	CU_ASSERT_FATAL(odp_timeout_alloc(pool) == ODP_TIMEOUT_INVALID)

	odp_timeout_free(tmo);

	/* Check that the timeout was returned back to the pool */
	tmo = odp_timeout_alloc(pool);
	CU_ASSERT_FATAL(tmo != ODP_TIMEOUT_INVALID);

	odp_timeout_free(tmo);
	CU_ASSERT(odp_pool_destroy(pool) == 0);
}
开发者ID:nmorey,项目名称:odp,代码行数:30,代码来源:timer.c

示例6: classification_test_destroy_cos

void classification_test_destroy_cos(void)
{
	odp_cos_t cos;
	char name[ODP_COS_NAME_LEN];
	odp_pool_t pool;
	odp_queue_t queue;
	odp_cls_cos_param_t cls_param;
	int retval;

	pool = pool_create("cls_basic_pool");
	CU_ASSERT_FATAL(pool != ODP_POOL_INVALID);

	queue = queue_create("cls_basic_queue", true);
	CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID);

	sprintf(name, "ClassOfService");
	odp_cls_cos_param_init(&cls_param);
	cls_param.pool = pool;
	cls_param.queue = queue;
	cls_param.drop_policy = ODP_COS_DROP_POOL;

	cos = odp_cls_cos_create(name, &cls_param);
	CU_ASSERT_FATAL(cos != ODP_COS_INVALID);
	retval = odp_cos_destroy(cos);
	CU_ASSERT(retval == 0);
	retval = odp_cos_destroy(ODP_COS_INVALID);
	CU_ASSERT(retval < 0);

	odp_pool_destroy(pool);
	odp_queue_destroy(queue);
}
开发者ID:guanhe0,项目名称:packages,代码行数:31,代码来源:odp_classification_basic.c

示例7: vector_3

static void vector_3(void) {
    vector_t v;
    vector_init(&v, __func__, 1);

    CU_ASSERT(vector_size(&v) == 0);
    CU_ASSERT(vector_pages(&v) == 0);
    CU_ASSERT(vector_capacity(&v) == 0);
    CU_ASSERT(vector_elem_size(&v) == 1);

    FILE * f = fopen("my_vector.bin", "r");
    CU_ASSERT_FATAL(f != NULL);
    CU_ASSERT(COUNT < vector_load(&v, f));
    fclose(f), f = NULL;

    crc3 = 0;

    for (int i=0; i<COUNT; i++) {
        unsigned char c;
        vector_get(&v, i, &c);
        crc3 = clib_crc32(c, crc3);
    }
    CU_ASSERT_FATAL(crc3 != 0);

    CU_ASSERT_FATAL(crc2 == crc3);

    vector_delete(&v);
}
开发者ID:eddiejames,项目名称:ffs,代码行数:27,代码来源:vector.c

示例8: list_test_queue

void list_test_queue(void) {
    /* Reject invalid inputs */
    CU_ASSERT(dslist_enqueue(NULL, "Non-null value") == false);
    CU_ASSERT(dslist_enqueue(list_test, NULL) == false);
    CU_ASSERT(dslist_dequeue(NULL) == NULL);

    /* Queue up a bunch of strings */
    for (int i = 0; i < 10; i++) {
        char *fmt = "Str %d";
        char *val = malloc(strlen(fmt) + 1);
        CU_ASSERT_FATAL(val != NULL);
        sprintf(val, fmt, i);
        CU_ASSERT(dslist_enqueue(list_test, val) == true);
        CU_ASSERT(dslist_len(list_test) == i+1);
    }

    /* Dequeue the previous strings */
    for (int i = 0; i < 10; i++) {
        char *fmt = "Str %d";
        char *val = malloc(strlen(fmt) + 1);
        CU_ASSERT_FATAL(val != NULL);
        sprintf(val, fmt, i);

        char *tmp = dslist_dequeue(list_test);
        CU_ASSERT(tmp != NULL);
        CU_ASSERT(dslist_len(list_test) == (9-i));
        CU_ASSERT(strcmp(tmp, val) == 0);
        free(tmp);
        free(val);
    }
}
开发者ID:chrisrink10,项目名称:libds,代码行数:31,代码来源:list_test.c

示例9: classification_test_cos_set_drop

void classification_test_cos_set_drop(void)
{
	int retval;
	char cosname[ODP_COS_NAME_LEN];
	odp_cos_t cos_drop;
	odp_queue_t queue;
	odp_pool_t pool;
	odp_cls_cos_param_t cls_param;

	pool = pool_create("cls_basic_pool");
	CU_ASSERT_FATAL(pool != ODP_POOL_INVALID);

	queue = queue_create("cls_basic_queue", true);
	CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID);

	sprintf(cosname, "CoSDrop");
	odp_cls_cos_param_init(&cls_param);
	cls_param.pool = pool;
	cls_param.queue = queue;
	cls_param.drop_policy = ODP_COS_DROP_POOL;
	cos_drop = odp_cls_cos_create(cosname, &cls_param);
	CU_ASSERT_FATAL(cos_drop != ODP_COS_INVALID);

	retval = odp_cos_drop_set(cos_drop, ODP_COS_DROP_POOL);
	CU_ASSERT(retval == 0);
	retval = odp_cos_drop_set(cos_drop, ODP_COS_DROP_NEVER);
	CU_ASSERT(retval == 0);
	odp_cos_destroy(cos_drop);
	odp_pool_destroy(pool);
	odp_queue_destroy(queue);
}
开发者ID:guanhe0,项目名称:packages,代码行数:31,代码来源:odp_classification_basic.c

示例10: configure_pktio_default_cos

void configure_pktio_default_cos(void)
{
	int retval;
	odp_queue_param_t qparam;
	char cosname[ODP_COS_NAME_LEN];
	char queuename[ODP_QUEUE_NAME_LEN];

	sprintf(cosname, "DefaultCoS");
	cos_list[CLS_DEFAULT] = odp_cos_create(cosname);
	CU_ASSERT_FATAL(cos_list[CLS_DEFAULT] != ODP_COS_INVALID);

	qparam.sched.prio = ODP_SCHED_PRIO_DEFAULT;
	qparam.sched.sync = ODP_SCHED_SYNC_NONE;
	qparam.sched.group = ODP_SCHED_GROUP_ALL;
	sprintf(queuename, "%s", "DefaultQueue");
	queue_list[CLS_DEFAULT] = odp_queue_create(queuename,
					 ODP_QUEUE_TYPE_SCHED, &qparam);
	CU_ASSERT_FATAL(queue_list[CLS_DEFAULT] != ODP_QUEUE_INVALID);

	retval = odp_cos_set_queue(cos_list[CLS_DEFAULT],
				   queue_list[CLS_DEFAULT]);
	CU_ASSERT(retval == 0);

	retval = odp_pktio_default_cos_set(pktio_loop, cos_list[CLS_DEFAULT]);
	CU_ASSERT(retval == 0);
}
开发者ID:weixiaohui,项目名称:packages,代码行数:26,代码来源:odp_classification_tests.c

示例11: configure_pktio_error_cos

void configure_pktio_error_cos(void)
{
	int retval;
	odp_queue_param_t qparam;
	char queuename[ODP_QUEUE_NAME_LEN];
	char cosname[ODP_COS_NAME_LEN];

	qparam.sched.prio = ODP_SCHED_PRIO_LOWEST;
	qparam.sched.sync = ODP_SCHED_SYNC_NONE;
	qparam.sched.group = ODP_SCHED_GROUP_ALL;
	sprintf(queuename, "%s", "ErrorCos");

	queue_list[CLS_ERROR] = odp_queue_create(queuename,
						 ODP_QUEUE_TYPE_SCHED,
						 &qparam);
	CU_ASSERT_FATAL(queue_list[CLS_ERROR] != ODP_QUEUE_INVALID);

	sprintf(cosname, "%s", "ErrorCos");
	cos_list[CLS_ERROR] = odp_cos_create(cosname);
	CU_ASSERT_FATAL(cos_list[CLS_ERROR] != ODP_COS_INVALID);

	retval = odp_cos_set_queue(cos_list[CLS_ERROR], queue_list[CLS_ERROR]);
	CU_ASSERT(retval == 0);

	retval = odp_pktio_error_cos_set(pktio_loop, cos_list[CLS_ERROR]);
	CU_ASSERT(retval == 0);
}
开发者ID:weixiaohui,项目名称:packages,代码行数:27,代码来源:odp_classification_tests.c

示例12: list_test_iter

void list_test_iter(void) {
    int num_iters = 0;
    DSList *list = dslist_new((dslist_compare_fn) dsbuf_compare,
                               (dslist_free_fn) dsbuf_destroy);
    CU_ASSERT_FATAL(list != NULL);

    for (int i = 0; i < 6; i++) {
        char *some = "Test %d";
        char *next = malloc(strlen(some) + 1);
        CU_ASSERT_FATAL(next != NULL);
        sprintf(next, some, i);

        DSBuffer *buf = dsbuf_new(next);
        CU_ASSERT_FATAL(buf != NULL);
        free(next);
        CU_ASSERT(dslist_append(list, buf) == true);
        num_iters++;
    }

    DSIter *iter = dslist_iter(list);
    CU_ASSERT_FATAL(iter != NULL);
    CU_ASSERT(dsiter_has_next(iter) == true);

    int count_iters = 0;
    while(dsiter_next(iter)) {
        CU_ASSERT(dsiter_key(iter) == NULL);    // Always NULL for lists
        CU_ASSERT(dsiter_value(iter) != NULL);
        count_iters++;
    }

    CU_ASSERT(count_iters == num_iters);
    CU_ASSERT(dsiter_has_next(iter) == false);
    dsiter_destroy(iter);
    dslist_destroy(list);
}
开发者ID:chrisrink10,项目名称:libds,代码行数:35,代码来源:list_test.c

示例13: test_class_db_result_list

void test_class_db_result_list(void) {
    db_result_t* local_result = result;
    db_result_t* local_result2 = result2;

    CU_ASSERT_PTR_NOT_NULL_FATAL((result_list = db_result_list_new()));

    CU_ASSERT_FATAL(!db_result_list_add(result_list, result));
    result = NULL;
    CU_ASSERT_FATAL(!db_result_list_add(result_list, result2));
    result2 = NULL;

    CU_ASSERT(db_result_list_size(result_list) == 2);
    CU_ASSERT(db_result_list_begin(result_list) == local_result);
    CU_ASSERT(db_result_list_next(result_list) == local_result2);

    db_result_list_free(result_list);
    result_list = NULL;
    CU_PASS("db_result_list_free");
    CU_PASS("db_result_free");

    CU_ASSERT_PTR_NOT_NULL_FATAL((result_list = db_result_list_new()));

    CU_ASSERT_FATAL(!db_result_list_set_next(result_list, __db_result_list_next, &fake_pointer, 2));

    CU_ASSERT(db_result_list_size(result_list) == 2);
    CU_ASSERT_PTR_NOT_NULL(db_result_list_begin(result_list));
    CU_ASSERT_PTR_NOT_NULL(db_result_list_next(result_list));

    db_result_list_free(result_list);
    result_list = NULL;
    CU_PASS("db_result_list_free");
    CU_PASS("db_result_free");
}
开发者ID:jelu,项目名称:dbo,代码行数:33,代码来源:test_classes.c

示例14: test_class_db_backend_meta_data_list

void test_class_db_backend_meta_data_list(void) {
    db_backend_meta_data_t* local_backend_meta_data = backend_meta_data;
    db_backend_meta_data_t* local_backend_meta_data2 = backend_meta_data2;
    db_backend_meta_data_t* local_backend_meta_data3 = backend_meta_data3;
    db_backend_meta_data_t* local_backend_meta_data4 = backend_meta_data4;

    CU_ASSERT_PTR_NOT_NULL_FATAL((backend_meta_data_list = db_backend_meta_data_list_new()));
    CU_ASSERT_FATAL(!db_backend_meta_data_list_add(backend_meta_data_list, backend_meta_data));
    backend_meta_data = NULL;
    CU_ASSERT_FATAL(!db_backend_meta_data_list_add(backend_meta_data_list, backend_meta_data2));
    backend_meta_data2 = NULL;
    CU_ASSERT(db_backend_meta_data_list_find(backend_meta_data_list, "name1") == local_backend_meta_data);
    CU_ASSERT(db_backend_meta_data_list_find(backend_meta_data_list, "name2") == local_backend_meta_data2);

    CU_ASSERT_PTR_NOT_NULL_FATAL((backend_meta_data_list2 = db_backend_meta_data_list_new()));
    CU_ASSERT_FATAL(!db_backend_meta_data_list_copy(backend_meta_data_list2, backend_meta_data_list));
    CU_ASSERT_PTR_NOT_NULL(db_backend_meta_data_list_find(backend_meta_data_list2, "name1"));
    CU_ASSERT_PTR_NOT_NULL(db_backend_meta_data_list_find(backend_meta_data_list2, "name2"));
    db_backend_meta_data_list_free(backend_meta_data_list2);
    backend_meta_data_list2 = NULL;
    CU_PASS("db_backend_meta_data_list_free");

    CU_ASSERT_PTR_NOT_NULL_FATAL((backend_meta_data_list2 = db_backend_meta_data_list_new()));
    CU_ASSERT_FATAL(!db_backend_meta_data_list_add(backend_meta_data_list2, backend_meta_data3));
    backend_meta_data3 = NULL;
    CU_ASSERT_FATAL(!db_backend_meta_data_list_add(backend_meta_data_list2, backend_meta_data4));
    backend_meta_data4 = NULL;
    CU_ASSERT(db_backend_meta_data_list_find(backend_meta_data_list2, "name3") == local_backend_meta_data3);
    CU_ASSERT(db_backend_meta_data_list_find(backend_meta_data_list2, "name4") == local_backend_meta_data4);
}
开发者ID:jelu,项目名称:dbo,代码行数:30,代码来源:test_classes.c

示例15: chaos_thread

static int chaos_thread(void *arg)
{
	uint64_t i, wait;
	int rc;
	chaos_buf *cbuf;
	odp_event_t ev;
	odp_queue_t from;
	thread_args_t *args = (thread_args_t *)arg;
	test_globals_t *globals = args->globals;
	int me = odp_thread_id();
	odp_time_t start_time, end_time, diff;

	if (CHAOS_DEBUG)
		printf("Chaos thread %d starting...\n", me);

	/* Wait for all threads to start */
	odp_barrier_wait(&globals->barrier);
	start_time = odp_time_local();

	/* Run the test */
	wait = odp_schedule_wait_time(5 * ODP_TIME_MSEC_IN_NS);
	for (i = 0; i < CHAOS_NUM_ROUNDS; i++) {
		ev = odp_schedule(&from, wait);
		if (ev == ODP_EVENT_INVALID)
			continue;

		cbuf = odp_buffer_addr(odp_buffer_from_event(ev));
		CU_ASSERT_FATAL(cbuf != NULL);
		if (CHAOS_DEBUG)
			printf("Thread %d received event %" PRIu64
			       " seq %" PRIu64
			       " from Q %s, sending to Q %s\n",
			       me, cbuf->evno, cbuf->seqno,
			       globals->
			       chaos_q
			       [CHAOS_PTR_TO_NDX(odp_queue_context(from))].name,
			       globals->
			       chaos_q[cbuf->seqno % CHAOS_NUM_QUEUES].name);

		rc = odp_queue_enq(
			globals->
			chaos_q[cbuf->seqno++ % CHAOS_NUM_QUEUES].handle,
			ev);
		CU_ASSERT_FATAL(rc == 0);
	}

	if (CHAOS_DEBUG)
		printf("Thread %d completed %d rounds...terminating\n",
		       odp_thread_id(), CHAOS_NUM_EVENTS);

	exit_schedule_loop();

	end_time = odp_time_local();
	diff = odp_time_diff(end_time, start_time);

	printf("Thread %d ends, elapsed time = %" PRIu64 "us\n",
	       odp_thread_id(), odp_time_to_ns(diff) / 1000);

	return 0;
}
开发者ID:nmorey,项目名称:odp,代码行数:60,代码来源:scheduler.c


注:本文中的CU_ASSERT_FATAL函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。