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


C++ CU_FAIL函数代码示例

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


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

示例1: test_send_frame_vlan_to_vlan

static void
test_send_frame_vlan_to_vlan(void)
{
	odp_packet_t pkt = ODP_PACKET_INVALID;
	odp_event_t ev;
	uint8_t check_buf[144];
	int res;

	if (create_odp_packet_ip4(&pkt, test_frame_vlan,
				  sizeof(test_frame_vlan), 0)) {
		CU_FAIL("Fail to create packet");
		return;
	}

	memcpy(check_buf, test_frame_vlan, sizeof(test_frame_vlan));
	check_buf[15] = dev_vlan->vlan;

	res = ofp_send_frame(dev_vlan, pkt);
	CU_ASSERT_EQUAL(res, OFP_PKT_PROCESSED);

	ev = odp_queue_deq(dev->outq_def);
	CU_ASSERT_NOT_EQUAL_FATAL(ev, ODP_EVENT_INVALID);

	pkt = odp_packet_from_event(ev);
	CU_ASSERT_EQUAL_FATAL(odp_packet_len(pkt), sizeof(test_frame_vlan));

	if (memcmp(odp_packet_l2_ptr(pkt, NULL), check_buf,
		   sizeof(test_frame_vlan)))
		CU_FAIL("Frame data mismatch.");
}
开发者ID:fboudra,项目名称:ofp,代码行数:30,代码来源:ofp_test_packet_output.c

示例2: test_ofp_packet_input_to_sp

static void
test_ofp_packet_input_to_sp(void)
{
    odp_packet_t pkt;
    odp_event_t ev;
    int res;

    my_test_val = TEST_FORWARD_HOOK;
    /* Call ofp_packet_input using a pkt with destination ip
     * that does NOT match the local ip on ifnet and NO route is found.
     * The packet is forwarded to slow path queue. */
    if (create_odp_packet_ip4(&pkt, test_frame, sizeof(test_frame), 0, 0)) {
        CU_FAIL("Fail to create packet");
        return;
    }

    res = ofp_packet_input(pkt, interface_queue[port],
                           ofp_eth_vlan_processing);

    CU_ASSERT_EQUAL(res, OFP_PKT_PROCESSED);

    CU_ASSERT_NOT_EQUAL(ev = odp_queue_deq(ifnet->spq_def),
                        ODP_EVENT_INVALID);
    CU_ASSERT_EQUAL(odp_queue_deq(ifnet->spq_def), ODP_EVENT_INVALID);
    CU_ASSERT_EQUAL(odp_queue_deq(ifnet->outq_def), ODP_EVENT_INVALID);

    if (memcmp(odp_packet_data(odp_packet_from_event(ev)),
               in_pkt_data, sizeof(test_frame)))
        CU_FAIL("corrupt data sent to slow path");
    odp_packet_free(odp_packet_from_event(ev));
    CU_PASS("ofp_packet_input_to_sp");
}
开发者ID:abhinayramesh,项目名称:ofp,代码行数:32,代码来源:ofp_test_packet_input.c

示例3: check_lun_is_wiped

static void
check_lun_is_wiped(unsigned char *buf, uint64_t lba)
{
        unsigned char *rbuf = alloca(256 * block_size);

        READ16(sd, NULL, lba, 256 * block_size, block_size, 0, 0, 0, 0, 0, rbuf,
               EXPECT_STATUS_GOOD);
        if (rc16 == NULL) {
                return;
        }

        if (rc16->lbprz) {
                logging(LOG_VERBOSE, "LBPRZ==1 All blocks "
                        "should read back as 0");
                if (all_zero(rbuf, 256 * block_size) == 0) {
                        logging(LOG_NORMAL, "[FAILED] Blocks did not "
                                "read back as zero");
                        CU_FAIL("[FAILED] Blocks did not read back "
                                "as zero");
                } else {
                        logging(LOG_VERBOSE, "[SUCCESS] Blocks read "
                                "back as zero");
                }
        } else {
                logging(LOG_VERBOSE, "LBPRZ==0 Blocks should not read back as "
                        "all 'a' any more");
                if (!memcmp(buf, rbuf, 256 * block_size)) {
                        logging(LOG_NORMAL, "[FAILED] Blocks were not wiped");
                        CU_FAIL("[FAILED] Blocks were not wiped");
                } else {
                        logging(LOG_VERBOSE, "[SUCCESS] Blocks were wiped");
                }
        }
}
开发者ID:sahlberg,项目名称:libiscsi,代码行数:34,代码来源:test_sanitize_block_erase.c

示例4: handle_tmo

/* @private Handle a received (timeout) event */
static void handle_tmo(odp_event_t ev, bool stale, uint64_t prev_tick)
{
	CU_ASSERT_FATAL(ev != ODP_EVENT_INVALID); /* Internal error */
	if (odp_event_type(ev) != ODP_EVENT_TIMEOUT) {
		/* Not a timeout event */
		CU_FAIL("Unexpected event type received");
		return;
	}
	/* Read the metadata from the timeout */
	odp_timeout_t tmo = odp_timeout_from_event(ev);
	odp_timer_t tim = odp_timeout_timer(tmo);
	uint64_t tick = odp_timeout_tick(tmo);
	struct test_timer *ttp = odp_timeout_user_ptr(tmo);

	if (tim == ODP_TIMER_INVALID)
		CU_FAIL("odp_timeout_timer() invalid timer");
	if (!ttp)
		CU_FAIL("odp_timeout_user_ptr() null user ptr");

	if (ttp && ttp->ev2 != ev)
		CU_FAIL("odp_timeout_user_ptr() wrong user ptr");
	if (ttp && ttp->tim != tim)
		CU_FAIL("odp_timeout_timer() wrong timer");
	if (stale) {
		if (odp_timeout_fresh(tmo))
			CU_FAIL("Wrong status (fresh) for stale timeout");
		/* Stale timeout => local timer must have invalid tick */
		if (ttp && ttp->tick != TICK_INVALID)
			CU_FAIL("Stale timeout for active timer");
	} else {
		if (!odp_timeout_fresh(tmo))
			CU_FAIL("Wrong status (stale) for fresh timeout");
		/* Fresh timeout => local timer must have matching tick */
		if (ttp && ttp->tick != tick) {
			LOG_DBG("Wrong tick: expected %" PRIu64
				" actual %" PRIu64 "\n",
				ttp->tick, tick);
			CU_FAIL("odp_timeout_tick() wrong tick");
		}
		/* Check that timeout was delivered 'timely' */
		if (tick > odp_timer_current_tick(tp))
			CU_FAIL("Timeout delivered early");
		if (tick < prev_tick) {
			LOG_DBG("Too late tick: %" PRIu64
				" prev_tick %" PRIu64"\n",
				tick, prev_tick);
			/* We don't report late timeouts using CU_FAIL */
			odp_atomic_inc_u32(&ndelivtoolate);
		}
	}

	if (ttp) {
		/* Internal error */
		CU_ASSERT_FATAL(ttp->ev == ODP_EVENT_INVALID);
		ttp->ev = ev;
	}
}
开发者ID:nmorey,项目名称:odp,代码行数:58,代码来源:timer.c

示例5: test_packet_output_gre

/*
 * Tests
 */
static void
test_packet_output_gre(void)
{
	odp_packet_t pkt = ODP_PACKET_INVALID;
	odp_event_t ev;
	int res;
	struct ofp_ether_header *eth;
	struct ofp_ip *ip;
	struct ofp_ip *ip_orig;
	struct ofp_greip *greip;

	if (create_odp_packet_ip4(&pkt, test_frame, sizeof(test_frame),
				  tun_p2p)) {
		CU_FAIL("Fail to create packet");
		return;
	}

	/*
	 * Packet's destination is GRE tunnel's p2p address, next hop is GRE
	 * interface. GRE+IP header is prepended. Packet's new destination is
	 * link local. Packet is put into output queue.
	 */
	res = ofp_ip_output(pkt, NULL);
	CU_ASSERT_EQUAL(res, OFP_PKT_PROCESSED);

	res = ofp_send_pending_pkt();
	CU_ASSERT_EQUAL(res, OFP_PKT_PROCESSED);

	ev = odp_queue_deq(dev->outq_def);
	CU_ASSERT_NOT_EQUAL_FATAL(ev, ODP_EVENT_INVALID);

	pkt = odp_packet_from_event(ev);
	CU_ASSERT_EQUAL_FATAL(odp_packet_len(pkt),
			      sizeof(test_frame) + 20 + 4);

	eth = odp_packet_l2_ptr(pkt, NULL);
	if (memcmp(eth->ether_dhost, tun_rem_mac, OFP_ETHER_ADDR_LEN))
		CU_FAIL("Bad destination mac address.");
	if (memcmp(eth->ether_shost, dev->mac, OFP_ETHER_ADDR_LEN))
		CU_FAIL("Bad source mac address.");

	ip = odp_packet_l3_ptr(pkt, NULL);
	CU_ASSERT_EQUAL(ip->ip_src.s_addr, dev_ip);
	CU_ASSERT_EQUAL(ip->ip_dst.s_addr, tun_rem_ip);
	CU_ASSERT_EQUAL(ip->ip_p, OFP_IPPROTO_GRE);

	greip = (struct ofp_greip *)ip;
	CU_ASSERT_EQUAL(greip->gi_g.flags, 0);
	CU_ASSERT_EQUAL(greip->gi_g.ptype,
			odp_cpu_to_be_16(OFP_ETHERTYPE_IP));

	/* inner ip */
	ip = (struct ofp_ip *)(greip + 1);
	ip_orig = (struct ofp_ip *)(&orig_pkt_data[OFP_ETHER_HDR_LEN]);
	if (memcmp(ip, ip_orig, odp_be_to_cpu_16(ip_orig->ip_len)))
		CU_FAIL("Inner IP packet error.");
}
开发者ID:fboudra,项目名称:ofp,代码行数:60,代码来源:ofp_test_packet_output.c

示例6: test_writesame10_unmap_vpd

void
test_writesame10_unmap_vpd(void)
{
	int ret;
	unsigned char *buf = alloca(block_size);

	logging(LOG_VERBOSE, LOG_BLANK_LINE);
	logging(LOG_VERBOSE, "Test WRITESAME10 UNMAP availability is "
		"consistent with VPD settings");

	CHECK_FOR_DATALOSS;
	CHECK_FOR_SBC;

	logging(LOG_VERBOSE, "Check if WRITESAME10 can be used for UNMAP.");
	logging(LOG_VERBOSE, "Unmap 1 block using WRITESAME10");
	memset(buf, 0, block_size);
	ret = writesame10(sd, 0,
			  block_size, 1, 0, 1, 0, 0, buf,
			  EXPECT_STATUS_GOOD);
	if (ret != 0) {
		logging(LOG_VERBOSE, "WRITESAME10 UNMAP is not available. "
			"Verify that VPD settings reflect this.");

		logging(LOG_VERBOSE, "Verify that LBPWS10 is clear.");
		if (inq_lbp && inq_lbp->lbpws10) {
			logging(LOG_NORMAL, "[FAILED] WRITESAME10 UNMAP is not "
				"implemented but LBPWS10 is set");
			CU_FAIL("[FAILED] WRITESAME10 UNMAP is unavailable but "
				"LBPWS10==1");
		} else {
			logging(LOG_VERBOSE, "[SUCCESS] LBPWS10 is clear.");
		}
	} else {
		logging(LOG_VERBOSE, "WRITESAME10 UNMAP is available. Verify "
			"that VPD settings reflect this.");

		logging(LOG_VERBOSE, "Verify that LBPME is set.");
		if (rc16 && rc16->lbpme) {
			logging(LOG_VERBOSE, "[SUCCESS] LBPME is set.");
		} else {
			logging(LOG_NORMAL, "[FAILED] WRITESAME10 UNMAP is "
				"implemented but LBPME is not set");
			CU_FAIL("[FAILED] UNMAP is available but LBPME==0");
		}

		logging(LOG_VERBOSE, "Verify that LBPWS10 is set.");
		if (inq_lbp && inq_lbp->lbpws10) {
			logging(LOG_VERBOSE, "[SUCCESS] LBPWS10 is set.");
		} else {
			logging(LOG_NORMAL, "[FAILED] WRITESAME10 UNMAP is "
				"implemented but LBPWS10 is not set");
			CU_FAIL("[FAILED] UNMAP is available but LBPWS10==0");
		}
	}
}
开发者ID:agrare,项目名称:libiscsi,代码行数:55,代码来源:test_writesame10_unmap_vpd.c

示例7: test_report_supported_opcodes_servactv

void
test_report_supported_opcodes_servactv(void)
{
	int i, ret;
	struct scsi_task *rso_task;
	struct scsi_report_supported_op_codes *rsoc;

	logging(LOG_VERBOSE, LOG_BLANK_LINE);
	logging(LOG_VERBOSE, "Test READ_SUPPORTED_OPCODES SERVACTV flag");


	ret = report_supported_opcodes(
		sd, &rso_task,
		0, SCSI_REPORT_SUPPORTING_OPS_ALL, 0, 0,
		65535,
		EXPECT_STATUS_GOOD);
	if (ret == -2) {
		logging(LOG_NORMAL, "[SKIPPED] READ_SUPPORTED_OPCODES is not "
			"implemented.");
		CU_PASS("READ_SUPPORTED_OPCODES is not implemented.");
		scsi_free_scsi_task(rso_task);
		return;
	}
	CU_ASSERT_EQUAL(ret, 0);
	if (ret != 0) {
		scsi_free_scsi_task(rso_task);
		return;
	}
	
	logging(LOG_VERBOSE, "Unmarshall the DATA-IN buffer");
	rsoc = scsi_datain_unmarshall(rso_task);
	CU_ASSERT_NOT_EQUAL(rsoc, NULL);
	if (!rsoc) {
		logging(LOG_NORMAL, "[FAILED] Target did not return any data "
			"for ReportSupportedOpcodes\n");
		CU_FAIL("Target did not return any data for "
			"ReportSupportedOpcodes");
		return;
	}


	logging(LOG_VERBOSE, "Verify that when SERVACTV is clear then "
		"ServiceAction must be zero.");
	for (i = 0; i < rsoc->num_descriptors; i++) {
		if (!rsoc->descriptors[i].servactv && rsoc->descriptors[i].sa) {
			logging(LOG_NORMAL, "[FAILED] ServiceAction is "
				"non-zero but SERVACTV is clear");
			CU_FAIL("[FAILED] ServiceAction is "
				"non-zero but SERVACTV is clear");
		}
	}

	scsi_free_scsi_task(rso_task);
}
开发者ID:daodewang,项目名称:libiscsi,代码行数:54,代码来源:test_report_supported_opcodes_servactv.c

示例8: test_conf_parse_file

void test_conf_parse_file(void) {
	/* Writes test content in test configuration file */
	char path[256] = CONF_TEST_PATH;
	// printf("%s", __FILE__);
	// sprintf(path, "%s/../%s", dirname(__FILE__), CONF_TEST_PATH);
	// sprintf(path, "%s/../%s", dirname(__FILE__), CONF_TEST_PATH);

	FILE *fp = fopen(path, "w");

	if (NULL == fp) {
		perror("fopen()");
		CU_FAIL("could not create test config file");
		return;
	}

	int octets = fprintf(fp, "%s", CONF_TEST_FILE);

	if (octets != strlen(CONF_TEST_FILE)) {
		CU_FAIL("test content could not be copied in test file");
		return;
	}
	fclose(fp);

	/* Tests parsed configuration */
	service_list_t* list = conf_parse_file(path);

	CU_ASSERT_PTR_NOT_NULL_FATAL(list);
	CU_ASSERT_EQUAL(list->count, 4);

	service_t* srv = service_list_lookup(list, "SRV12");
	CU_ASSERT_PTR_NOT_NULL_FATAL(srv);
	CU_ASSERT_STRING_EQUAL(srv->warn, "1");
	CU_ASSERT_STRING_EQUAL(srv->crit, "2");

	srv = service_list_lookup(list, "SRV34");
	CU_ASSERT_PTR_NOT_NULL_FATAL(srv);
	CU_ASSERT_PTR_NOT_NULL(srv);
	CU_ASSERT_STRING_EQUAL(srv->warn, "3");
	CU_ASSERT_STRING_EQUAL(srv->crit, "4");

	srv = service_list_lookup(list, "SRV56");
	CU_ASSERT_PTR_NOT_NULL_FATAL(srv);
	CU_ASSERT_STRING_EQUAL(srv->warn, "5");
	CU_ASSERT_STRING_EQUAL(srv->crit, "6");

	srv = service_list_lookup(list, "SRV78");
	CU_ASSERT_PTR_NOT_NULL_FATAL(srv);
	CU_ASSERT_STRING_EQUAL(srv->warn, "a");
	CU_ASSERT_STRING_EQUAL(srv->crit, "-1");

	service_list_free(list);
}
开发者ID:geektophe,项目名称:ndcwrap,代码行数:52,代码来源:test_conf.c

示例9: test_filter_index_2

// @filter_index:test_filter_index_2 => [filter_index ne libère pas la mémoire des éléments qu'elle supprime.]
void test_filter_index_2(void)
{
	Entry *ent1 = (Entry*) malloc(sizeof(Entry));
	Entry *ent2 = (Entry*) malloc(sizeof(Entry));
	Entry *ent3 = (Entry*) malloc(sizeof(Entry));
	Entry *ent4 = (Entry*) malloc(sizeof(Entry));
	Entry *ent5 = (Entry*) malloc(sizeof(Entry));

    if (ent1 == NULL || ent2 == NULL || ent3 == NULL || ent4 == NULL || ent5 == NULL) {
        CU_FAIL("La mémoire n'a pas pu être allouée pour le test test_filter_index_2.");
        return;
    }

    *ent1 = (Entry){"lorem", 2, ent2};
	*ent2 = (Entry){"ipsum", 2, ent3};
	*ent3 = (Entry){"dolor", 1, ent4};
	*ent4 = (Entry){"sit", 1, ent5};
	*ent5 = (Entry){"amet", 1, NULL};
	
	free_count = 0;
	filter_index(&ent1,2);
	
	CU_ASSERT_EQUAL(free_count,3);
	free(ent1);
	free(ent2);
}
开发者ID:DamJos,项目名称:SINF1252-1,代码行数:27,代码来源:tests.c

示例10: pktio_test_inq_remdef

void pktio_test_inq_remdef(void)
{
	odp_pktio_t pktio;
	odp_queue_t inq;
	odp_event_t ev;
	uint64_t wait;
	int i;

	pktio = create_pktio(0, ODP_PKTIN_MODE_SCHED,
			     ODP_PKTOUT_MODE_SEND);
	CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
	CU_ASSERT(create_inq(pktio, ODP_QUEUE_TYPE_POLL) == 0);
	inq = odp_pktio_inq_getdef(pktio);
	CU_ASSERT(inq != ODP_QUEUE_INVALID);
	CU_ASSERT(odp_pktio_inq_remdef(pktio) == 0);

	wait = odp_schedule_wait_time(ODP_TIME_MSEC_IN_NS);
	for (i = 0; i < 100; i++) {
		ev = odp_schedule(NULL, wait);
		if (ev != ODP_EVENT_INVALID) {
			odp_event_free(ev);
			CU_FAIL("received unexpected event");
		}
	}

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

示例11: test_ofp_packet_input_local_UDPv4_hook

static void
test_ofp_packet_input_local_UDPv4_hook(void)
{
    odp_packet_t pkt;
    int res;

    /* Call ofp_packet_input with a pkt with destination ip
     * that matches the local ip on ifnet.
     * The packet is terminated in local UDPv4 hook */
    my_test_val = TEST_LOCAL_UDPv4_HOOK;
    ifnet->ip_addr = dst_ipaddr;
    if (create_odp_packet_ip4(&pkt, test_frame, sizeof(test_frame),
                              dst_ipaddr, 0)) {
        CU_FAIL("Fail to create packet");
        return;
    }

    res = ofp_packet_input(pkt, interface_queue[port],
                           ofp_eth_vlan_processing);
    CU_ASSERT_EQUAL(res, OFP_TEST_LOCAL_UDPv4_HOOK);
#ifdef SP
    CU_ASSERT_EQUAL(odp_queue_deq(ifnet->spq_def), ODP_EVENT_INVALID);
#endif /* SP */
    CU_ASSERT_EQUAL(odp_queue_deq(ifnet->outq_def), ODP_EVENT_INVALID);
    ifnet->ip_addr = 0;
    CU_PASS("ofp_packet_input_local_UDPv4_hook");
}
开发者ID:abhinayramesh,项目名称:ofp,代码行数:27,代码来源:ofp_test_packet_input.c

示例12: destroy_inq

static int destroy_inq(odp_pktio_t pktio)
{
	odp_queue_t inq;
	odp_event_t ev;
	odp_queue_type_t q_type;

	inq = odp_pktio_inq_getdef(pktio);

	if (inq == ODP_QUEUE_INVALID) {
		CU_FAIL("attempting to destroy invalid inq");
		return -1;
	}

	CU_ASSERT(odp_pktio_inq_remdef(pktio) == 0);

	q_type = odp_queue_type(inq);

	/* flush any pending events */
	while (1) {
		if (q_type == ODP_QUEUE_TYPE_POLL)
			ev = odp_queue_deq(inq);
		else
			ev = odp_schedule(NULL, ODP_SCHED_NO_WAIT);

		if (ev != ODP_EVENT_INVALID)
			odp_event_free(ev);
		else
			break;
	}

	return odp_queue_destroy(inq);
}
开发者ID:kalray,项目名称:odp-mppa,代码行数:32,代码来源:pktio.c

示例13: 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

示例14: test_calloc2_3

// @calloc2:test_calloc2_3 => [Votre fonction calloc ne prend pas en compte le fait que malloc puisse échouer.]
void test_calloc2_3(void) {
    let_malloc_fail = 1; //On indique qu'on veut que malloc utilisé par calloc2 échoue


    // Pour plus de détails sur le fonctionnement des signaux et l'interception des segfaults,
    // voir mini-projet-string/tests.c
    if (signal(SIGSEGV, sig_handler) == SIG_ERR) {
        CU_FAIL("Impossible d'enregistrer un signal handler.");
        return;
    }

    if(setjmp(label_test_calloc2_3)==0) {
        calloc2(42, 42);
    }
    else if {
        /* IMPORTANT ! On remet let_malloc_fail à 0 pour que CUnit puisse réutiliser malloc par la suite.
         * Ici, si on ne pense pas à remettre cette variable à 0, CUnit ne prend pas en compte l'échec du test. */
        let_malloc_fail = 0; 
        CU_ASSERT_TRUE(0);
    }
    
    /* IMPORTANT ! On remet let_malloc_fail à 0 pour que CUnit puisse réutiliser malloc par la suite. */
    let_malloc_fail = 0; 
    signal(SIGSEGV, SIG_DFL);
}
开发者ID:CharlyBVo,项目名称:SINF1252,代码行数:26,代码来源:tests.c

示例15: pktio_test_recv_on_wonly

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

	pktio = create_pktio(0, ODP_PKTIN_MODE_DISABLED,
			     ODP_PKTOUT_MODE_SEND);

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

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

	ret = odp_pktio_recv(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,代码行数:29,代码来源:pktio.c


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