MCPcopy Create free account
hub / github.com/F-Stack/f-stack / test_basic

Function test_basic

dpdk/app/test/test_rib.c:238–291  ·  view source on GitHub ↗

* Call insert, lookup/lookup_exact and delete for a single rule */

Source from the content-addressed store, hash-verified

236 * Call insert, lookup/lookup_exact and delete for a single rule
237 */
238int32_t
239test_basic(void)
240{
241 struct rte_rib *rib = NULL;
242 struct rte_rib_node *node;
243 struct rte_rib_conf config;
244
245 uint32_t ip = RTE_IPV4(192, 0, 2, 0);
246 uint64_t next_hop_add = 10;
247 uint64_t next_hop_return;
248 uint8_t depth = 24;
249 int ret;
250
251 config.max_nodes = MAX_RULES;
252 config.ext_sz = 0;
253
254 rib = rte_rib_create(__func__, SOCKET_ID_ANY, &config);
255 RTE_TEST_ASSERT(rib != NULL, "Failed to create RIB\n");
256
257 node = rte_rib_insert(rib, ip, depth);
258 RTE_TEST_ASSERT(node != NULL, "Failed to insert rule\n");
259
260 ret = rte_rib_set_nh(node, next_hop_add);
261 RTE_TEST_ASSERT(ret == 0,
262 "Failed to set rte_rib_node field\n");
263
264 node = rte_rib_lookup(rib, ip);
265 RTE_TEST_ASSERT(node != NULL, "Failed to lookup\n");
266
267 ret = rte_rib_get_nh(node, &next_hop_return);
268 RTE_TEST_ASSERT((ret == 0) && (next_hop_add == next_hop_return),
269 "Failed to get proper nexthop\n");
270
271 node = rte_rib_lookup_exact(rib, ip, depth);
272 RTE_TEST_ASSERT(node != NULL,
273 "Failed to lookup\n");
274
275 ret = rte_rib_get_nh(node, &next_hop_return);
276 RTE_TEST_ASSERT((ret == 0) && (next_hop_add == next_hop_return),
277 "Failed to get proper nexthop\n");
278
279 rte_rib_remove(rib, ip, depth);
280
281 node = rte_rib_lookup(rib, ip);
282 RTE_TEST_ASSERT(node == NULL,
283 "Lookup returns non existent rule\n");
284 node = rte_rib_lookup_exact(rib, ip, depth);
285 RTE_TEST_ASSERT(node == NULL,
286 "Lookup returns non existent rule\n");
287
288 rte_rib_free(rib);
289
290 return TEST_SUCCESS;
291}
292
293int32_t
294test_tree_traversal(void)

Callers

nothing calls this directly

Calls 8

rte_rib_createFunction · 0.85
rte_rib_insertFunction · 0.85
rte_rib_set_nhFunction · 0.85
rte_rib_lookupFunction · 0.85
rte_rib_get_nhFunction · 0.85
rte_rib_lookup_exactFunction · 0.85
rte_rib_removeFunction · 0.85
rte_rib_freeFunction · 0.85

Tested by

no test coverage detected