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

Function test_ring_negative_tests

dpdk/app/test/test_ring.c:501–580  ·  view source on GitHub ↗

* Various negative test cases. */

Source from the content-addressed store, hash-verified

499 * Various negative test cases.
500 */
501static int
502test_ring_negative_tests(void)
503{
504 struct rte_ring *rp = NULL;
505 struct rte_ring *rt = NULL;
506 unsigned int i;
507
508 /* Test with esize not a multiple of 4 */
509 rp = test_ring_create("test_bad_element_size", 23,
510 RING_SIZE + 1, SOCKET_ID_ANY, 0);
511 if (rp != NULL) {
512 printf("Test failed to detect invalid element size\n");
513 goto test_fail;
514 }
515
516
517 for (i = 0; i < RTE_DIM(esize); i++) {
518 /* Test if ring size is not power of 2 */
519 rp = test_ring_create("test_bad_ring_size", esize[i],
520 RING_SIZE + 1, SOCKET_ID_ANY, 0);
521 if (rp != NULL) {
522 printf("Test failed to detect odd count\n");
523 goto test_fail;
524 }
525
526 /* Test if ring size is exceeding the limit */
527 rp = test_ring_create("test_bad_ring_size", esize[i],
528 RTE_RING_SZ_MASK + 1, SOCKET_ID_ANY, 0);
529 if (rp != NULL) {
530 printf("Test failed to detect limits\n");
531 goto test_fail;
532 }
533
534 /* Tests if lookup returns NULL on non-existing ring */
535 rp = rte_ring_lookup("ring_not_found");
536 if (rp != NULL && rte_errno != ENOENT) {
537 printf("Test failed to detect NULL ring lookup\n");
538 goto test_fail;
539 }
540
541 /* Test to if a non-power of 2 count causes the create
542 * function to fail correctly
543 */
544 rp = test_ring_create("test_ring_count", esize[i], 4097,
545 SOCKET_ID_ANY, 0);
546 if (rp != NULL)
547 goto test_fail;
548
549 rp = test_ring_create("test_ring_negative", esize[i], RING_SIZE,
550 SOCKET_ID_ANY,
551 RING_F_SP_ENQ | RING_F_SC_DEQ);
552 if (rp == NULL) {
553 printf("test_ring_negative fail to create ring\n");
554 goto test_fail;
555 }
556
557 TEST_RING_VERIFY(rte_ring_lookup("test_ring_negative") == rp,
558 rp, goto test_fail);

Callers 1

test_ringFunction · 0.85

Calls 5

test_ring_createFunction · 0.85
rte_ring_lookupFunction · 0.85
rte_ring_emptyFunction · 0.85
rte_ring_freeFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected