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

Function test9

dpdk/app/test/test_lpm6.c:439–478  ·  view source on GitHub ↗

* Call add, lookup and delete for a single rule with depth < 24. * Check all the combinations for the first three bytes that result in a hit. * Delete the rule and check that the same test returns a miss. */

Source from the content-addressed store, hash-verified

437 * Delete the rule and check that the same test returns a miss.
438 */
439int32_t
440test9(void)
441{
442 struct rte_lpm6 *lpm = NULL;
443 struct rte_lpm6_config config;
444 uint8_t ip[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
445 uint8_t depth = 16;
446 uint32_t next_hop_add = 100, next_hop_return = 0;
447 int32_t status = 0;
448 uint8_t i;
449
450 config.max_rules = MAX_RULES;
451 config.number_tbl8s = NUMBER_TBL8S;
452 config.flags = 0;
453
454 lpm = rte_lpm6_create(__func__, SOCKET_ID_ANY, &config);
455 TEST_LPM_ASSERT(lpm != NULL);
456
457 status = rte_lpm6_add(lpm, ip, depth, next_hop_add);
458 TEST_LPM_ASSERT(status == 0);
459
460 for (i = 0; i < UINT8_MAX; i++) {
461 ip[2] = i;
462 status = rte_lpm6_lookup(lpm, ip, &next_hop_return);
463 TEST_LPM_ASSERT((status == 0) && (next_hop_return == next_hop_add));
464 }
465
466 status = rte_lpm6_delete(lpm, ip, depth);
467 TEST_LPM_ASSERT(status == 0);
468
469 for (i = 0; i < UINT8_MAX; i++) {
470 ip[2] = i;
471 status = rte_lpm6_lookup(lpm, ip, &next_hop_return);
472 TEST_LPM_ASSERT(status == -ENOENT);
473 }
474
475 rte_lpm6_free(lpm);
476
477 return PASS;
478}
479
480/*
481 * Adds max_rules + 1 and expects a failure. Deletes a rule, then adds

Callers

nothing calls this directly

Calls 5

rte_lpm6_createFunction · 0.50
rte_lpm6_addFunction · 0.50
rte_lpm6_lookupFunction · 0.50
rte_lpm6_deleteFunction · 0.50
rte_lpm6_freeFunction · 0.50

Tested by

no test coverage detected