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

Function test_basic

dpdk/app/test/test_rib6.c:239–293  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 8

rte_rib6_createFunction · 0.85
rte_rib6_insertFunction · 0.85
rte_rib6_set_nhFunction · 0.85
rte_rib6_lookupFunction · 0.85
rte_rib6_get_nhFunction · 0.85
rte_rib6_lookup_exactFunction · 0.85
rte_rib6_removeFunction · 0.85
rte_rib6_freeFunction · 0.85

Tested by

no test coverage detected