/* Allocate datapath manager. */ struct dpmgr * dpmgr_alloc(void) { struct dpmgr *dpmgr; dpmgr = (struct dpmgr *)calloc(1, sizeof(struct dpmgr)); if (dpmgr == NULL) { return NULL; } dpmgr->ports = ports_alloc(); if (dpmgr->ports == NULL) { return NULL; } TAILQ_INIT(&dpmgr->bridge_list); #if defined(HAVE_DPDK) rte_rwlock_init(&dpmgr_lock); #endif /* HAVE_DPDK */ init_flow_timer(); dpmgr_singleton = dpmgr; return dpmgr; }
void test_ports_alloc(void) { struct vector *ports; ports = ports_alloc(); TEST_ASSERT_NOT_NULL_MESSAGE(ports, "ports_alloc error"); ports_free(ports); }
void setUp(void) { TEST_ASSERT_NULL(dpmgr); TEST_ASSERT_NULL(bridge); TEST_ASSERT_NULL(flowdb); TEST_ASSERT_NULL(ports); TEST_ASSERT_NULL(group_table); TEST_ASSERT_NOT_NULL(dpmgr = dpmgr_alloc()); TEST_ASSERT_TRUE(LAGOPUS_RESULT_OK == dpmgr_bridge_add(dpmgr, bridge_name, dpid)); TEST_ASSERT_NOT_NULL(bridge = dpmgr_bridge_lookup(dpmgr, bridge_name)); TEST_ASSERT_NOT_NULL(flowdb = bridge->flowdb); TEST_ASSERT_NOT_NULL(ports = ports_alloc()); TEST_ASSERT_NOT_NULL(group_table = group_table_alloc(bridge)); }
void test_port_add(void) { struct vector *ports; struct port port; lagopus_result_t rv; ports = ports_alloc(); TEST_ASSERT_NOT_NULL_MESSAGE(ports, "ports_alloc error"); strncpy(port.ofp_port.name, "port1", sizeof(port.ofp_port.name)); port.ofp_port.port_no = 1; port.ifindex = 120; port.type = LAGOPUS_PORT_TYPE_NULL; rv = port_add(ports, &port); TEST_ASSERT_EQUAL_MESSAGE(rv, LAGOPUS_RESULT_OK, "port_add error"); }