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

Function setup_keys_and_data

dpdk/app/test/test_member.c:553–587  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

551}
552
553static void
554setup_keys_and_data(void)
555{
556 unsigned int i, j;
557 int num_duplicates;
558
559 /* Reset all arrays */
560 for (i = 0; i < KEY_SIZE; i++)
561 generated_keys[0][i] = 0;
562
563 /* Generate a list of keys, some of which may be duplicates */
564 for (i = 0; i < MAX_ENTRIES; i++) {
565 for (j = 0; j < KEY_SIZE; j++)
566 generated_keys[i][j] = rte_rand() & 0xFF;
567 }
568
569 /* Remove duplicates from the keys array */
570 do {
571 num_duplicates = 0;
572 /* Sort the list of keys to make it easier to find duplicates */
573 qsort(generated_keys, MAX_ENTRIES, KEY_SIZE, key_compare);
574
575 /* Sift through the list of keys and look for duplicates */
576 for (i = 0; i < MAX_ENTRIES - 1; i++) {
577 if (memcmp(generated_keys[i], generated_keys[i + 1],
578 KEY_SIZE) == 0) {
579 /* This key already exists, try again */
580 num_duplicates++;
581 for (j = 0; j < KEY_SIZE; j++)
582 generated_keys[i][j] =
583 rte_rand() & 0xFF;
584 }
585 }
586 } while (num_duplicates != 0);
587}
588
589static inline int
590add_generated_keys(struct rte_member_setsum *setsum, unsigned int *added_keys)

Callers 1

test_member_loadfactorFunction · 0.70

Calls 2

rte_randFunction · 0.85
qsortFunction · 0.85

Tested by

no test coverage detected