static void create_data(struct bucket_counter_list *bucket_counter_list) { struct bucket_counter *bucket_counter; int i; TAILQ_INIT(bucket_counter_list); /* data. */ for (i = 0; i < bucket_cnt_num; i++) { bucket_counter = bucket_counter_alloc(); if (bucket_counter != NULL) { TAILQ_INSERT_TAIL(bucket_counter_list, bucket_counter, entry); bucket_counter->ofp.packet_count = (uint64_t) (0x01 + i); bucket_counter->ofp.byte_count = (uint64_t) (0x02 + i); } else { TEST_FAIL_MESSAGE("bucket_counter is NULL."); } } }
void test_bucket_counter_alloc_list_free(void) { struct bucket_counter_list bucket_counter_list; struct bucket_counter *bucket_counter; uint64_t packet_counts[] = {0x01, 0x03}; uint64_t byte_counts[] = {0x02, 0x04}; int test_num = 2; int i; TAILQ_INIT(&bucket_counter_list); for (i = 0; i < test_num; i++) { bucket_counter = bucket_counter_alloc(); if (bucket_counter != NULL) { bucket_counter->ofp.packet_count = packet_counts[i]; bucket_counter->ofp.byte_count = byte_counts[i]; TAILQ_INSERT_TAIL(&bucket_counter_list, bucket_counter, entry); } else { TEST_FAIL_MESSAGE("bucket_counter is NULL."); } } bucket_counter_list_elem_free(&bucket_counter_list); }
static void create_data(void) { struct group_stats *group_stats; struct bucket_counter *bucket_counter; size_t length; int i; int j; TAILQ_INIT(&gstats_list); for (i = 0; i < group_stats_num; i++) { length = sizeof(struct group_stats) + (sizeof(struct ofp_bucket_counter) * 2); group_stats = group_stats_alloc(length); group_stats->ofp.length = (uint16_t) length; group_stats->ofp.group_id = (uint32_t) (0x01 + i); group_stats->ofp.ref_count = (uint32_t) (0x02 + i); group_stats->ofp.packet_count = (uint64_t) (0x03 + i); group_stats->ofp.byte_count = (uint64_t) (0x04 + i); group_stats->ofp.duration_sec = (uint32_t) (0x05 + i); group_stats->ofp.duration_nsec = (uint32_t) (0x06 + i); TAILQ_INIT(&group_stats->bucket_counter_list); for (j = 0; j < bucket_counter_num; j++) { bucket_counter = bucket_counter_alloc(); bucket_counter->ofp.packet_count = (uint64_t) (0x07 + i + j); bucket_counter->ofp.byte_count = (uint64_t) (0x09 + i + j); TAILQ_INSERT_TAIL(&group_stats->bucket_counter_list, bucket_counter, entry); } TAILQ_INSERT_TAIL(&gstats_list, group_stats, entry); } }
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); }