static int test_stats_entry_setup_from_add(void) { of_flow_add_t *add; of_flow_stats_entry_t *entry; of_match_t m1, m2; of_list_action_t *list; of_list_action_t list_out; TEST_ASSERT((add = of_flow_add_new(OF_VERSION_1_0)) != NULL); TEST_ASSERT((entry = of_flow_stats_entry_new(OF_VERSION_1_0)) != NULL); TEST_ASSERT(of_flow_add_OF_VERSION_1_0_populate(add, 1) != 0); TEST_ASSERT(of_flow_add_match_get(add, &m1) == 0); TEST_ASSERT(of_flow_stats_entry_setup_from_flow_add(entry, add, NULL) == 0); TEST_ASSERT(of_flow_stats_entry_match_get(entry, &m2) == 0); TEST_ASSERT(memcmp(&m1, &m2, sizeof(m1)) == 0); of_flow_add_delete(add); of_flow_stats_entry_delete(entry); /* @todo check action lists agree */ /* Same with an external action list */ TEST_ASSERT((add = of_flow_add_new(OF_VERSION_1_0)) != NULL); TEST_ASSERT((entry = of_flow_stats_entry_new(OF_VERSION_1_0)) != NULL); TEST_ASSERT(of_flow_add_OF_VERSION_1_0_populate(add, 1) != 0); TEST_ASSERT(of_flow_add_match_get(add, &m1) == 0); list = of_list_action_new(OF_VERSION_1_0); TEST_ASSERT(list != NULL); TEST_ASSERT(of_list_action_OF_VERSION_1_0_populate(list, 1) != 0); /* Verify matches agree */ TEST_ASSERT(of_flow_stats_entry_setup_from_flow_add(entry, add, list) == 0); TEST_ASSERT(of_flow_stats_entry_match_get(entry, &m2) == 0); TEST_ASSERT(memcmp(&m1, &m2, sizeof(m1)) == 0); of_list_action_init(&list_out, OF_VERSION_1_0, 0, 1); of_flow_stats_entry_actions_bind(entry, &list_out); /* Verify lists agree */ TEST_ASSERT(list->length == list_out.length); TEST_ASSERT(memcmp(WBUF_BUF(list->wire_object.wbuf), WBUF_BUF(list_out.wire_object.wbuf), list->length)); of_flow_add_delete(add); of_list_action_delete(list); of_flow_stats_entry_delete(entry); return TEST_PASS; }
static int test_list_limits(void) { of_flow_stats_reply_t *obj = of_flow_stats_reply_new(OF_VERSION_1_0); of_list_flow_stats_entry_t list; of_flow_stats_entry_t *element = of_flow_stats_entry_new(OF_VERSION_1_0); int i = 0; of_flow_stats_reply_entries_bind(obj, &list); ASSERT(element != NULL); while (1) { int rv = of_list_flow_stats_entry_append(&list, element); ASSERT(rv == OF_ERROR_NONE || rv == OF_ERROR_RESOURCE); if (rv != OF_ERROR_NONE) { break; } i++; } ASSERT(i == 744); of_flow_stats_entry_delete(element); of_flow_stats_reply_delete(obj); return TEST_PASS; }