static int populate_table(ft_instance_t ft, int count, of_match_t *match) { int idx; of_flow_add_t *flow_add_base; of_flow_add_t *flow_add; ft_entry_t *entry; flow_add_base = of_flow_add_new(OF_VERSION_1_0); TEST_ASSERT(of_flow_add_OF_VERSION_1_0_populate(flow_add_base, 1) != 0); of_flow_add_flags_set(flow_add_base, 0); TEST_OK(of_flow_add_match_get(flow_add_base, match)); for (idx = 0; idx < count; ++idx) { TEST_ASSERT((flow_add = of_object_dup((of_object_t *)flow_add_base)) != NULL); match->fields.eth_type = TEST_ETH_TYPE(idx); TEST_OK(of_flow_add_match_set(flow_add, match)); TEST_INDIGO_OK(FT_ADD(ft, TEST_KEY(idx), flow_add, &entry)); TEST_ASSERT(check_table_entry_states(ft) == 0); } CHECK_FLOW_COUNT(&ft->status, TEST_FLOW_COUNT); of_flow_add_delete(flow_add_base); return 0; }
/** * Undo above */ static int depopulate_table(ft_instance_t ft) { int idx; ft_entry_t *entry; int count; count = ft->status.current_count; for (idx = 0; idx < count; ++idx) { entry = ft_id_lookup(ft, TEST_KEY(idx)); TEST_ASSERT(entry != NULL); TEST_ASSERT(entry->match.fields.eth_type == TEST_ETH_TYPE(idx)); FT_DELETE_ID(ft, TEST_KEY(idx), 1); /* Does callback */ TEST_ASSERT(check_table_entry_states(ft) == 0); } return 0; }
void test_flowinfo_eth_type_adddel(void) { size_t s; TEST_ASSERT_OBJECTS(); /* Add Ethernet type matches. */ for (s = 0; s < ARRAY_LEN(test_flow); s++) { FLOW_ADD_ETH_TYPE_MATCH(test_flow[s], TEST_ETH_TYPE(s)); } /* Run the sideeffect-prone scenario. */ TEST_SCENARIO_FLOWINFO_SEP(flowinfo); /* Delete the matches. */ for (s = 0; s < ARRAY_LEN(test_flow); s++) { TAILQ_INIT(&test_flow[s]->match_list); } }