lagopus_result_t ofp_group_stats_reply_create_wrap(struct channel *channel, struct pbuf_list **pbuf_list, struct ofp_header *xid_header) { lagopus_result_t ret; create_data(); ret = ofp_group_stats_reply_create(channel, pbuf_list, &gstats_list, xid_header); /* after. */ group_stats_list_elem_free(&gstats_list); return ret; }
lagopus_result_t ofp_group_stats_reply_create_null_wrap(struct channel *channel, struct pbuf_list **pbuf_list, struct ofp_header *xid_header) { lagopus_result_t ret; struct group_stats_list group_stats_list; group_stats_num = 2; bucket_counter_num = 2; create_data(&group_stats_list); ret = ofp_group_stats_reply_create(NULL, pbuf_list, &group_stats_list, xid_header); TEST_ASSERT_EQUAL_MESSAGE(LAGOPUS_RESULT_INVALID_ARGS, ret, "ofp_group_stats_reply_create error."); ret = ofp_group_stats_reply_create(channel, NULL, &group_stats_list, xid_header); TEST_ASSERT_EQUAL_MESSAGE(LAGOPUS_RESULT_INVALID_ARGS, ret, "ofp_group_stats_reply_create error."); ret = ofp_group_stats_reply_create(channel, pbuf_list, NULL, xid_header); TEST_ASSERT_EQUAL_MESSAGE(LAGOPUS_RESULT_INVALID_ARGS, ret, "ofp_group_stats_reply_create error."); ret = ofp_group_stats_reply_create(channel, pbuf_list, &group_stats_list, NULL); TEST_ASSERT_EQUAL_MESSAGE(LAGOPUS_RESULT_INVALID_ARGS, ret, "ofp_group_stats_reply_create error."); /* after. */ group_stats_list_elem_free(&group_stats_list); /* Not check return value. */ return -9999; }
void test_ofp_group_stats_reply_create_02(void) { lagopus_result_t ret = LAGOPUS_RESULT_ANY_FAILURES; struct group_stats *group_stats = NULL; struct bucket_counter *bucket_counter = NULL; const char *header_data[2] = { "04 13 ff c8 00 00 00 10 00 06 00 01 00 00 00 00 ", "04 13 00 48 00 00 00 10 00 06 00 00 00 00 00 00 " }; const char *body_data[2] = { "00 38 00 00 00 00 00 01" "00 00 00 02 00 00 00 00" "00 00 00 00 00 00 00 03" "00 00 00 00 00 00 00 04" "00 00 00 05 00 00 00 06" "00 00 00 00 00 00 00 07" "00 00 00 00 00 00 00 09", "00 38 00 00 00 00 00 01" "00 00 00 02 00 00 00 00" "00 00 00 00 00 00 00 03" "00 00 00 00 00 00 00 04" "00 00 00 05 00 00 00 06" "00 00 00 00 00 00 00 07" "00 00 00 00 00 00 00 09" }; size_t nums[2] = {1169, 1}; size_t length; int i; /* data */ TAILQ_INIT(&gstats_list); for (i = 0; i < 1170; i++) { length = sizeof(struct group_stats) + sizeof(struct ofp_bucket_counter); group_stats = group_stats_alloc(length); if (group_stats != NULL) { group_stats->ofp.length = (uint16_t) length; group_stats->ofp.group_id = 0x01; group_stats->ofp.ref_count = 0x02; group_stats->ofp.packet_count = 0x03; group_stats->ofp.byte_count = 0x04; group_stats->ofp.duration_sec = 0x05; group_stats->ofp.duration_nsec = 0x06; } else { TEST_FAIL_MESSAGE("allocation error."); } TAILQ_INIT(&group_stats->bucket_counter_list); bucket_counter = bucket_counter_alloc(); if (bucket_counter != NULL) { bucket_counter->ofp.packet_count = 0x07; bucket_counter->ofp.byte_count = 0x09; } else { TEST_FAIL_MESSAGE("allocation error."); } TAILQ_INSERT_TAIL(&group_stats->bucket_counter_list, bucket_counter, entry); TAILQ_INSERT_TAIL(&gstats_list, group_stats, entry); } ret = check_pbuf_list_across_packet_create( ofp_group_stats_reply_create_wrapwith_self_data, header_data, body_data, nums, 2); TEST_ASSERT_EQUAL_MESSAGE(LAGOPUS_RESULT_OK, ret, "check_pbuf_list error."); /* free */ group_stats_list_elem_free(&gstats_list); }