void test_ofp_barrier_request_handle_normal_pattern(void) { lagopus_result_t ret = LAGOPUS_RESULT_ANY_FAILURES; struct eventq_data *eventq_data = NULL; struct barrier *barrier = NULL; struct pbuf *req_data; uint8_t type = OFPT_BARRIER_REQUEST; uint32_t xid = 0x12345678; uint32_t channel_id = 0x00; char req[] = "04 14 00 08 12 34 56 78"; create_packet(req, &req_data); ret = check_packet_parse_with_dequeue( ofp_barrier_request_handle_wrap, req, (void **)&eventq_data); /* get result */ TEST_ASSERT_EQUAL_MESSAGE(LAGOPUS_RESULT_OK, ret, "ofp_barrier_request_handle(normal) error."); /* check queue_data. */ barrier = &(eventq_data->barrier); TEST_ASSERT_EQUAL_MESSAGE(LAGOPUS_EVENTQ_BARRIER_REQUEST, eventq_data->type, "type error."); /* check barrier. */ TEST_ASSERT_EQUAL_MESSAGE(type, barrier->type, "type error."); TEST_ASSERT_EQUAL_MESSAGE(xid, barrier->xid, "xid error."); TEST_ASSERT_EQUAL_MESSAGE(channel_id, barrier->channel_id, "channel_id error."); TEST_ASSERT_EQUAL_MESSAGE(0, memcmp(req_data->data, barrier->req->data, req_data->plen), "request data error."); pbuf_free(req_data); ofp_barrier_free(eventq_data); }
static lagopus_result_t ofp_barrier_reply_send_wrap(struct channel *channel, struct ofp_header *xid_header) { lagopus_result_t ret; struct eventq_data *ed; uint64_t dpid = 0x10; (void) xid_header; ed = create_data(OFPT_BARRIER_REPLY); ret = ofp_barrier_reply_send(channel, &ed->barrier, dpid); /* after. */ ofp_barrier_free(ed); return ret; }
static lagopus_result_t ofp_barrier_reply_create_wrap(struct channel *channel, struct pbuf **pbuf, struct ofp_header *xid_header) { lagopus_result_t ret; struct eventq_data *ed; (void) xid_header; ed = create_data(OFPT_BARRIER_REPLY); /* Call func. */ ret = ofp_barrier_reply_create(channel, &ed->barrier, pbuf); /* after. */ ofp_barrier_free(ed); return ret; }
void test_ofp_barrier_reply_send_null(void) { lagopus_result_t ret; struct eventq_data *ed; uint64_t dpid = 0x10; struct channel *channel = channel_alloc_ip4addr("127.0.0.1", "1000", 0x01); ed = create_data(OFPT_BARRIER_REPLY); ret = ofp_barrier_reply_send(NULL, &ed->barrier, dpid); TEST_ASSERT_EQUAL_MESSAGE(ret, LAGOPUS_RESULT_INVALID_ARGS, "ofp_barrier_reply_send error."); ret = ofp_barrier_reply_send(channel, NULL, dpid); TEST_ASSERT_EQUAL_MESSAGE(ret, LAGOPUS_RESULT_INVALID_ARGS, "ofp_barrier_reply_send error."); /* after. */ ofp_barrier_free(ed); channel_free(channel); }