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

Function test_member_multimatch

dpdk/app/test/test_member.c:444–546  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

442}
443
444static int test_member_multimatch(void)
445{
446 int ret_ht, ret_vbf, ret_cache;
447 member_set_t set_ids_ht[MAX_MATCH] = {0};
448 member_set_t set_ids_vbf[MAX_MATCH] = {0};
449 member_set_t set_ids_cache[MAX_MATCH] = {0};
450
451 member_set_t set_ids_ht_m[NUM_SAMPLES][MAX_MATCH] = {{0} };
452 member_set_t set_ids_vbf_m[NUM_SAMPLES][MAX_MATCH] = {{0} };
453 member_set_t set_ids_cache_m[NUM_SAMPLES][MAX_MATCH] = {{0} };
454
455 uint32_t match_count_ht[NUM_SAMPLES];
456 uint32_t match_count_vbf[NUM_SAMPLES];
457 uint32_t match_count_cache[NUM_SAMPLES];
458
459 uint32_t num_key_ht = NUM_SAMPLES;
460 uint32_t num_key_vbf = NUM_SAMPLES;
461 uint32_t num_key_cache = NUM_SAMPLES;
462
463 const void *key_array[NUM_SAMPLES];
464
465 uint32_t i, j;
466
467 /* Same key at most inserted 2*entry_per_bucket times for HT mode */
468 for (i = M_MATCH_S; i <= M_MATCH_E; i += M_MATCH_STEP) {
469 for (j = 0; j < NUM_SAMPLES; j++) {
470 ret_ht = rte_member_add(setsum_ht, &keys[j], i);
471 ret_vbf = rte_member_add(setsum_vbf, &keys[j], i);
472 ret_cache = rte_member_add(setsum_cache, &keys[j], i);
473
474 TEST_ASSERT(ret_ht >= 0 && ret_vbf >= 0 &&
475 ret_cache >= 0,
476 "insert function error");
477 }
478 }
479
480 /* Single multimatch test */
481 for (i = 0; i < NUM_SAMPLES; i++) {
482 ret_vbf = rte_member_lookup_multi(setsum_vbf, &keys[i],
483 MAX_MATCH, set_ids_vbf);
484 ret_ht = rte_member_lookup_multi(setsum_ht, &keys[i],
485 MAX_MATCH, set_ids_ht);
486 ret_cache = rte_member_lookup_multi(setsum_cache, &keys[i],
487 MAX_MATCH, set_ids_cache);
488 /*
489 * For cache mode, keys overwrite when signature same.
490 * the multimatch should work like single match.
491 */
492 TEST_ASSERT(ret_ht == M_MATCH_CNT && ret_vbf == M_MATCH_CNT &&
493 ret_cache == 1,
494 "single lookup_multi error");
495 TEST_ASSERT(set_ids_cache[0] == M_MATCH_E,
496 "single lookup_multi cache error");
497
498 for (j = 1; j <= M_MATCH_CNT; j++) {
499 TEST_ASSERT(set_ids_ht[j-1] == j * M_MATCH_STEP - 1 &&
500 set_ids_vbf[j-1] ==
501 j * M_MATCH_STEP - 1,

Callers 1

test_memberFunction · 0.85

Calls 4

rte_member_addFunction · 0.85
rte_member_lookup_multiFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected