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

Function test_add_invalid_helper

dpdk/app/test/test_thash.c:438–493  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

436}
437
438static int
439test_add_invalid_helper(void)
440{
441 struct rte_thash_ctx *ctx;
442 const int key_len = 40;
443 int reta_sz = 7;
444 int ret;
445
446 ctx = rte_thash_init_ctx("test", key_len, reta_sz, NULL, 0);
447 RTE_TEST_ASSERT(ctx != NULL, "can not create thash ctx\n");
448
449 ret = rte_thash_add_helper(NULL, "test", reta_sz, 0);
450 RTE_TEST_ASSERT(ret == -EINVAL,
451 "Call succeeded with invalid parameters\n");
452
453 ret = rte_thash_add_helper(ctx, NULL, reta_sz, 0);
454 RTE_TEST_ASSERT(ret == -EINVAL,
455 "Call succeeded with invalid parameters\n");
456
457 ret = rte_thash_add_helper(ctx, "test", reta_sz - 1, 0);
458 RTE_TEST_ASSERT(ret == -EINVAL,
459 "Call succeeded with invalid parameters\n");
460
461 ret = rte_thash_add_helper(ctx, "test", reta_sz, key_len * 8);
462 RTE_TEST_ASSERT(ret == -EINVAL,
463 "Call succeeded with invalid parameters\n");
464
465 ret = rte_thash_add_helper(ctx, "first_range", reta_sz, 0);
466 RTE_TEST_ASSERT(ret == 0, "Can not create helper\n");
467
468 ret = rte_thash_add_helper(ctx, "first_range", reta_sz, 0);
469 RTE_TEST_ASSERT(ret == -EEXIST,
470 "Call succeeded with duplicated name\n");
471
472 /*
473 * Create second helper with offset 3 * reta_sz.
474 * Note first_range helper created range in key:
475 * [0, 32 + length{= reta_sz} - 1), i.e [0, 37).
476 * second range is [44, 81)
477 */
478 ret = rte_thash_add_helper(ctx, "second_range", reta_sz,
479 32 + 2 * reta_sz);
480 RTE_TEST_ASSERT(ret == 0, "Can not create helper\n");
481
482 /*
483 * Try to create overlapping with first_ and second_ ranges,
484 * i.e. [6, 49)
485 */
486 ret = rte_thash_add_helper(ctx, "third_range", 2 * reta_sz, reta_sz);
487 RTE_TEST_ASSERT(ret == -EEXIST,
488 "Call succeeded with overlapping ranges\n");
489
490 rte_thash_free_ctx(ctx);
491
492 return TEST_SUCCESS;
493}
494
495static int

Callers

nothing calls this directly

Calls 3

rte_thash_init_ctxFunction · 0.85
rte_thash_add_helperFunction · 0.85
rte_thash_free_ctxFunction · 0.85

Tested by

no test coverage detected