From patchwork Thu Apr 30 01:56:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honnappa Nagarahalli X-Patchwork-Id: 185850 Delivered-To: patch@linaro.org Received: by 2002:a92:3d9a:0:0:0:0:0 with SMTP id k26csp1488851ilf; Wed, 29 Apr 2020 18:57:07 -0700 (PDT) X-Google-Smtp-Source: APiQypIxAfnvQGa+EJ6PAiFbOli/AweKnZr0eQqe8XDjDiDV7z7FTi54WfkUTSf/vmuzmRngDO2Z X-Received: by 2002:a17:906:1490:: with SMTP id x16mr514922ejc.323.1588211827723; Wed, 29 Apr 2020 18:57:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588211827; cv=none; d=google.com; s=arc-20160816; b=n3c3ExIYcPbEPyKiA7RXHQi8GBBMirresjdQinW+cfMhBLGtLb3JVkm/rAjSYDL6/g /R/LB1vnba6I6erMAkEPJYlObCH92HsrCS9blhWBas/+xJkIMLWNhf/bVNL8wgiGnIKK Jnb4N9gwlNLuYWUi4AFDuVfbcoVGTPKnLBMaSfPhj9SeM6glo5lPOfcriYNGQl7goMgL rBkndzHtOLpd4k0KAnWxU+kSc/oWz916bHKOaI3RVcnYQw3p44ZEvlLvtj8pLCsXM9V3 bnxhCxH19+l8QsDL9mqnHooEVL1kmoiY8TCpUsG1bOluq12Ckv2oMPeGqk0xa+ERvNEp Lr6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:message-id:date:cc:to :from; bh=1SyrrVjc3/rTxDlmavgvcTfHxf1i1vWwVhD6Kgu1qvE=; b=zO7gvmSXWZMmURyXcw2ugiNfSwa7/Qu868p/+BHTkgglrscGYVtLdmQ4b34fSpGhiX ZfGe5A2z1iLAWjN4dLGBBk8TVDXYs/RmgYhPyrxTi1FnJ6cTG1QKphdVL3xNRNsukTJY xi40aWuS0sR1YDm9RLgVgnJDA76rX0nk3TfzcAQuX56SVfwuMsAqXpnruZYL/0Cq2RHv POKzg0FY0ultreQmEWXvWfy17DMjkekXUz10vm2YR+EeP5AcgH6kEuU8rRdocUSQvG/e +Ww9J0/bGPNTsj6puovVQKc2YDbTlCsRMQlh6LG4xgTwvpgz/bfb1IRKxcFUvQ/yJFNk CleQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org Return-Path: Received: from dpdk.org (dpdk.org. [92.243.14.124]) by mx.google.com with ESMTP id dk9si4236773edb.403.2020.04.29.18.57.07; Wed, 29 Apr 2020 18:57:07 -0700 (PDT) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) client-ip=92.243.14.124; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8F9281D9BB; Thu, 30 Apr 2020 03:57:06 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by dpdk.org (Postfix) with ESMTP id A78201D9B6 for ; Thu, 30 Apr 2020 03:57:05 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E72031063; Wed, 29 Apr 2020 18:57:04 -0700 (PDT) Received: from qc2400f-1.austin.arm.com (qc2400f-1.austin.arm.com [10.118.14.48]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D714F3F68F; Wed, 29 Apr 2020 18:57:04 -0700 (PDT) From: Honnappa Nagarahalli To: dev@dpdk.org, konstantin.ananyev@intel.com, thomas@monjalon.net, aconole@redhat.com, honnappa.nagarahalli@arm.com Cc: ruifeng.wang@arm.com, nd@arm.com Date: Wed, 29 Apr 2020 20:56:50 -0500 Message-Id: <20200430015650.18243-1-honnappa.nagarahalli@arm.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH] test/ring: fix long compilation time X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" test_ring.c takes lot of time to compile with clang. It is reproducable with compiler version 8.0 on Ubuntu 18.04. Amount of testing is reduced, but attempt is made to keep the same coverage. Reported-by: Aaron Conole Reported-by: Thomas Monjalon Signed-off-by: Honnappa Nagarahalli Reviewed-by: Ruifeng Wang --- app/test/test_ring.c | 588 +++++++++++++++++++++---------------------- 1 file changed, 283 insertions(+), 305 deletions(-) -- 2.17.1 diff --git a/app/test/test_ring.c b/app/test/test_ring.c index e21557cd9..82148566a 100644 --- a/app/test/test_ring.c +++ b/app/test/test_ring.c @@ -203,83 +203,77 @@ test_ring_negative_tests(void) * Random number of elements are enqueued and dequeued. */ static int -test_ring_burst_bulk_tests1(unsigned int api_type, unsigned int create_flags, - const char *tname) +test_ring_burst_bulk_tests1(unsigned int api_type, const unsigned int esize, + unsigned int create_flags, const char *tname) { struct rte_ring *r; void **src = NULL, **cur_src = NULL, **dst = NULL, **cur_dst = NULL; int ret; - unsigned int i, j; + unsigned int j; int rand; const unsigned int rsz = RING_SIZE - 1; - for (i = 0; i < RTE_DIM(esize); i++) { - test_ring_print_test_string(tname, api_type, esize[i]); - - /* Create the ring */ - r = test_ring_create("test_ring_burst_bulk_tests", esize[i], - RING_SIZE, SOCKET_ID_ANY, create_flags); - - /* alloc dummy object pointers */ - src = test_ring_calloc(RING_SIZE * 2, esize[i]); - if (src == NULL) - goto fail; - test_ring_mem_init(src, RING_SIZE * 2, esize[i]); - cur_src = src; - - /* alloc some room for copied objects */ - dst = test_ring_calloc(RING_SIZE * 2, esize[i]); - if (dst == NULL) - goto fail; - cur_dst = dst; - - printf("Random full/empty test\n"); - - for (j = 0; j != TEST_RING_FULL_EMTPY_ITER; j++) { - /* random shift in the ring */ - rand = RTE_MAX(rte_rand() % RING_SIZE, 1UL); - printf("%s: iteration %u, random shift: %u;\n", - __func__, i, rand); - ret = test_ring_enqueue(r, cur_src, esize[i], rand, - api_type); - TEST_RING_VERIFY(ret != 0); - - ret = test_ring_dequeue(r, cur_dst, esize[i], rand, - api_type); - TEST_RING_VERIFY(ret == rand); - - /* fill the ring */ - ret = test_ring_enqueue(r, cur_src, esize[i], rsz, - api_type); - TEST_RING_VERIFY(ret != 0); - - TEST_RING_VERIFY(rte_ring_free_count(r) == 0); - TEST_RING_VERIFY(rsz == rte_ring_count(r)); - TEST_RING_VERIFY(rte_ring_full(r)); - TEST_RING_VERIFY(rte_ring_empty(r) == 0); - - /* empty the ring */ - ret = test_ring_dequeue(r, cur_dst, esize[i], rsz, - api_type); - TEST_RING_VERIFY(ret == (int)rsz); - TEST_RING_VERIFY(rsz == rte_ring_free_count(r)); - TEST_RING_VERIFY(rte_ring_count(r) == 0); - TEST_RING_VERIFY(rte_ring_full(r) == 0); - TEST_RING_VERIFY(rte_ring_empty(r)); - - /* check data */ - TEST_RING_VERIFY(memcmp(src, dst, rsz) == 0); - } + test_ring_print_test_string(tname, api_type, esize); + + /* Create the ring */ + r = test_ring_create("test_ring_burst_bulk_tests", esize, + RING_SIZE, SOCKET_ID_ANY, create_flags); + + /* alloc dummy object pointers */ + src = test_ring_calloc(RING_SIZE * 2, esize); + if (src == NULL) + goto fail; + test_ring_mem_init(src, RING_SIZE * 2, esize); + cur_src = src; + + /* alloc some room for copied objects */ + dst = test_ring_calloc(RING_SIZE * 2, esize); + if (dst == NULL) + goto fail; + cur_dst = dst; + + printf("Random full/empty test\n"); + + for (j = 0; j != TEST_RING_FULL_EMTPY_ITER; j++) { + /* random shift in the ring */ + rand = RTE_MAX(rte_rand() % RING_SIZE, 1UL); + printf("%s: iteration %u, random shift: %u;\n", + __func__, j, rand); + ret = test_ring_enqueue(r, cur_src, esize, rand, api_type); + TEST_RING_VERIFY(ret != 0); + + ret = test_ring_dequeue(r, cur_dst, esize, rand, api_type); + TEST_RING_VERIFY(ret == rand); + + /* fill the ring */ + ret = test_ring_enqueue(r, cur_src, esize, rsz, api_type); + TEST_RING_VERIFY(ret != 0); + + TEST_RING_VERIFY(rte_ring_free_count(r) == 0); + TEST_RING_VERIFY(rsz == rte_ring_count(r)); + TEST_RING_VERIFY(rte_ring_full(r)); + TEST_RING_VERIFY(rte_ring_empty(r) == 0); + + /* empty the ring */ + ret = test_ring_dequeue(r, cur_dst, esize, rsz, api_type); + TEST_RING_VERIFY(ret == (int)rsz); + TEST_RING_VERIFY(rsz == rte_ring_free_count(r)); + TEST_RING_VERIFY(rte_ring_count(r) == 0); + TEST_RING_VERIFY(rte_ring_full(r) == 0); + TEST_RING_VERIFY(rte_ring_empty(r)); - /* Free memory before test completed */ - rte_ring_free(r); - rte_free(src); - rte_free(dst); - r = NULL; - src = NULL; - dst = NULL; + /* check data */ + TEST_RING_VERIFY(memcmp(src, dst, rsz) == 0); } + /* Free memory before test completed */ + rte_ring_free(r); + rte_free(src); + rte_free(dst); + r = NULL; + src = NULL; + dst = NULL; + return 0; fail: rte_ring_free(r); @@ -294,89 +288,84 @@ test_ring_burst_bulk_tests1(unsigned int api_type, unsigned int create_flags, * dequeued data. */ static int -test_ring_burst_bulk_tests2(unsigned int api_type, unsigned int create_flags, - const char *tname) +test_ring_burst_bulk_tests2(unsigned int api_type, const unsigned int esize, + unsigned int create_flags, const char *tname) { struct rte_ring *r; void **src = NULL, **cur_src = NULL, **dst = NULL, **cur_dst = NULL; int ret; - unsigned int i; - - for (i = 0; i < RTE_DIM(esize); i++) { - test_ring_print_test_string(tname, api_type, esize[i]); - - /* Create the ring */ - r = test_ring_create("test_ring_burst_bulk_tests", esize[i], - RING_SIZE, SOCKET_ID_ANY, create_flags); - - /* alloc dummy object pointers */ - src = test_ring_calloc(RING_SIZE * 2, esize[i]); - if (src == NULL) - goto fail; - test_ring_mem_init(src, RING_SIZE * 2, esize[i]); - cur_src = src; - - /* alloc some room for copied objects */ - dst = test_ring_calloc(RING_SIZE * 2, esize[i]); - if (dst == NULL) - goto fail; - cur_dst = dst; - - printf("enqueue 1 obj\n"); - ret = test_ring_enqueue(r, cur_src, esize[i], 1, api_type); - if (ret != 1) - goto fail; - cur_src = test_ring_inc_ptr(cur_src, esize[i], 1); - printf("enqueue 2 objs\n"); - ret = test_ring_enqueue(r, cur_src, esize[i], 2, api_type); - if (ret != 2) - goto fail; - cur_src = test_ring_inc_ptr(cur_src, esize[i], 2); - - printf("enqueue MAX_BULK objs\n"); - ret = test_ring_enqueue(r, cur_src, esize[i], MAX_BULK, - api_type); - if (ret != MAX_BULK) - goto fail; - cur_src = test_ring_inc_ptr(cur_src, esize[i], MAX_BULK); - - printf("dequeue 1 obj\n"); - ret = test_ring_dequeue(r, cur_dst, esize[i], 1, api_type); - if (ret != 1) - goto fail; - cur_dst = test_ring_inc_ptr(cur_dst, esize[i], 1); - - printf("dequeue 2 objs\n"); - ret = test_ring_dequeue(r, cur_dst, esize[i], 2, api_type); - if (ret != 2) - goto fail; - cur_dst = test_ring_inc_ptr(cur_dst, esize[i], 2); - - printf("dequeue MAX_BULK objs\n"); - ret = test_ring_dequeue(r, cur_dst, esize[i], MAX_BULK, - api_type); - if (ret != MAX_BULK) - goto fail; - cur_dst = test_ring_inc_ptr(cur_dst, esize[i], MAX_BULK); - - /* check data */ - if (memcmp(src, dst, cur_dst - dst)) { - rte_hexdump(stdout, "src", src, cur_src - src); - rte_hexdump(stdout, "dst", dst, cur_dst - dst); - printf("data after dequeue is not the same\n"); - goto fail; - } - - /* Free memory before test completed */ - rte_ring_free(r); - rte_free(src); - rte_free(dst); - r = NULL; - src = NULL; - dst = NULL; + test_ring_print_test_string(tname, api_type, esize); + + /* Create the ring */ + r = test_ring_create("test_ring_burst_bulk_tests", esize, + RING_SIZE, SOCKET_ID_ANY, create_flags); + + /* alloc dummy object pointers */ + src = test_ring_calloc(RING_SIZE * 2, esize); + if (src == NULL) + goto fail; + test_ring_mem_init(src, RING_SIZE * 2, esize); + cur_src = src; + + /* alloc some room for copied objects */ + dst = test_ring_calloc(RING_SIZE * 2, esize); + if (dst == NULL) + goto fail; + cur_dst = dst; + + printf("enqueue 1 obj\n"); + ret = test_ring_enqueue(r, cur_src, esize, 1, api_type); + if (ret != 1) + goto fail; + cur_src = test_ring_inc_ptr(cur_src, esize, 1); + + printf("enqueue 2 objs\n"); + ret = test_ring_enqueue(r, cur_src, esize, 2, api_type); + if (ret != 2) + goto fail; + cur_src = test_ring_inc_ptr(cur_src, esize, 2); + + printf("enqueue MAX_BULK objs\n"); + ret = test_ring_enqueue(r, cur_src, esize, MAX_BULK, api_type); + if (ret != MAX_BULK) + goto fail; + cur_src = test_ring_inc_ptr(cur_src, esize, MAX_BULK); + + printf("dequeue 1 obj\n"); + ret = test_ring_dequeue(r, cur_dst, esize, 1, api_type); + if (ret != 1) + goto fail; + cur_dst = test_ring_inc_ptr(cur_dst, esize, 1); + + printf("dequeue 2 objs\n"); + ret = test_ring_dequeue(r, cur_dst, esize, 2, api_type); + if (ret != 2) + goto fail; + cur_dst = test_ring_inc_ptr(cur_dst, esize, 2); + + printf("dequeue MAX_BULK objs\n"); + ret = test_ring_dequeue(r, cur_dst, esize, MAX_BULK, api_type); + if (ret != MAX_BULK) + goto fail; + cur_dst = test_ring_inc_ptr(cur_dst, esize, MAX_BULK); + + /* check data */ + if (memcmp(src, dst, cur_dst - dst)) { + rte_hexdump(stdout, "src", src, cur_src - src); + rte_hexdump(stdout, "dst", dst, cur_dst - dst); + printf("data after dequeue is not the same\n"); + goto fail; } + /* Free memory before test completed */ + rte_ring_free(r); + rte_free(src); + rte_free(dst); + r = NULL; + src = NULL; + dst = NULL; + return 0; fail: rte_ring_free(r); @@ -390,68 +379,62 @@ test_ring_burst_bulk_tests2(unsigned int api_type, unsigned int create_flags, * Enqueue and dequeue to cover the entire ring length. */ static int -test_ring_burst_bulk_tests3(unsigned int api_type, unsigned int create_flags, - const char *tname) +test_ring_burst_bulk_tests3(unsigned int api_type, const unsigned int esize, + unsigned int create_flags, const char *tname) { struct rte_ring *r; void **src = NULL, **cur_src = NULL, **dst = NULL, **cur_dst = NULL; int ret; - unsigned int i, j; - - for (i = 0; i < RTE_DIM(esize); i++) { - test_ring_print_test_string(tname, api_type, esize[i]); - - /* Create the ring */ - r = test_ring_create("test_ring_burst_bulk_tests", esize[i], - RING_SIZE, SOCKET_ID_ANY, create_flags); - - /* alloc dummy object pointers */ - src = test_ring_calloc(RING_SIZE * 2, esize[i]); - if (src == NULL) + unsigned int j; + + test_ring_print_test_string(tname, api_type, esize); + + /* Create the ring */ + r = test_ring_create("test_ring_burst_bulk_tests", esize, + RING_SIZE, SOCKET_ID_ANY, create_flags); + + /* alloc dummy object pointers */ + src = test_ring_calloc(RING_SIZE * 2, esize); + if (src == NULL) + goto fail; + test_ring_mem_init(src, RING_SIZE * 2, esize); + cur_src = src; + + /* alloc some room for copied objects */ + dst = test_ring_calloc(RING_SIZE * 2, esize); + if (dst == NULL) + goto fail; + cur_dst = dst; + + printf("fill and empty the ring\n"); + for (j = 0; j < RING_SIZE / MAX_BULK; j++) { + ret = test_ring_enqueue(r, cur_src, esize, MAX_BULK, api_type); + if (ret != MAX_BULK) goto fail; - test_ring_mem_init(src, RING_SIZE * 2, esize[i]); - cur_src = src; + cur_src = test_ring_inc_ptr(cur_src, esize, MAX_BULK); - /* alloc some room for copied objects */ - dst = test_ring_calloc(RING_SIZE * 2, esize[i]); - if (dst == NULL) - goto fail; - cur_dst = dst; - - printf("fill and empty the ring\n"); - for (j = 0; j < RING_SIZE / MAX_BULK; j++) { - ret = test_ring_enqueue(r, cur_src, esize[i], MAX_BULK, - api_type); - if (ret != MAX_BULK) - goto fail; - cur_src = test_ring_inc_ptr(cur_src, esize[i], - MAX_BULK); - - ret = test_ring_dequeue(r, cur_dst, esize[i], MAX_BULK, - api_type); - if (ret != MAX_BULK) - goto fail; - cur_dst = test_ring_inc_ptr(cur_dst, esize[i], - MAX_BULK); - } - - /* check data */ - if (memcmp(src, dst, cur_dst - dst)) { - rte_hexdump(stdout, "src", src, cur_src - src); - rte_hexdump(stdout, "dst", dst, cur_dst - dst); - printf("data after dequeue is not the same\n"); + ret = test_ring_dequeue(r, cur_dst, esize, MAX_BULK, api_type); + if (ret != MAX_BULK) goto fail; - } + cur_dst = test_ring_inc_ptr(cur_dst, esize, MAX_BULK); + } - /* Free memory before test completed */ - rte_ring_free(r); - rte_free(src); - rte_free(dst); - r = NULL; - src = NULL; - dst = NULL; + /* check data */ + if (memcmp(src, dst, cur_dst - dst)) { + rte_hexdump(stdout, "src", src, cur_src - src); + rte_hexdump(stdout, "dst", dst, cur_dst - dst); + printf("data after dequeue is not the same\n"); + goto fail; } + /* Free memory before test completed */ + rte_ring_free(r); + rte_free(src); + rte_free(dst); + r = NULL; + src = NULL; + dst = NULL; + return 0; fail: rte_ring_free(r); @@ -465,123 +448,116 @@ test_ring_burst_bulk_tests3(unsigned int api_type, unsigned int create_flags, * Enqueue till the ring is full and dequeue till the ring becomes empty. */ static int -test_ring_burst_bulk_tests4(unsigned int api_type, unsigned int create_flags, - const char *tname) +test_ring_burst_bulk_tests4(unsigned int api_type, const unsigned int esize, + unsigned int create_flags, const char *tname) { struct rte_ring *r; void **src = NULL, **cur_src = NULL, **dst = NULL, **cur_dst = NULL; int ret; - unsigned int i, j; + unsigned int j; unsigned int num_elems; - for (i = 0; i < RTE_DIM(esize); i++) { - test_ring_print_test_string(tname, api_type, esize[i]); + test_ring_print_test_string(tname, api_type, esize); - /* Create the ring */ - r = test_ring_create("test_ring_burst_bulk_tests", esize[i], - RING_SIZE, SOCKET_ID_ANY, create_flags); - - /* alloc dummy object pointers */ - src = test_ring_calloc(RING_SIZE * 2, esize[i]); - if (src == NULL) - goto fail; - test_ring_mem_init(src, RING_SIZE * 2, esize[i]); - cur_src = src; - - /* alloc some room for copied objects */ - dst = test_ring_calloc(RING_SIZE * 2, esize[i]); - if (dst == NULL) - goto fail; - cur_dst = dst; - - printf("Test enqueue without enough memory space\n"); - for (j = 0; j < (RING_SIZE/MAX_BULK - 1); j++) { - ret = test_ring_enqueue(r, cur_src, esize[i], MAX_BULK, - api_type); - if (ret != MAX_BULK) - goto fail; - cur_src = test_ring_inc_ptr(cur_src, esize[i], - MAX_BULK); - } + /* Create the ring */ + r = test_ring_create("test_ring_burst_bulk_tests", esize, + RING_SIZE, SOCKET_ID_ANY, create_flags); - printf("Enqueue 2 objects, free entries = MAX_BULK - 2\n"); - ret = test_ring_enqueue(r, cur_src, esize[i], 2, api_type); - if (ret != 2) - goto fail; - cur_src = test_ring_inc_ptr(cur_src, esize[i], 2); - - printf("Enqueue the remaining entries = MAX_BULK - 3\n"); - /* Bulk APIs enqueue exact number of elements */ - if ((api_type & TEST_RING_ELEM_BULK) == TEST_RING_ELEM_BULK) - num_elems = MAX_BULK - 3; - else - num_elems = MAX_BULK; - /* Always one free entry left */ - ret = test_ring_enqueue(r, cur_src, esize[i], num_elems, - api_type); - if (ret != MAX_BULK - 3) - goto fail; - cur_src = test_ring_inc_ptr(cur_src, esize[i], MAX_BULK - 3); + /* alloc dummy object pointers */ + src = test_ring_calloc(RING_SIZE * 2, esize); + if (src == NULL) + goto fail; + test_ring_mem_init(src, RING_SIZE * 2, esize); + cur_src = src; - printf("Test if ring is full\n"); - if (rte_ring_full(r) != 1) - goto fail; + /* alloc some room for copied objects */ + dst = test_ring_calloc(RING_SIZE * 2, esize); + if (dst == NULL) + goto fail; + cur_dst = dst; - printf("Test enqueue for a full entry\n"); - ret = test_ring_enqueue(r, cur_src, esize[i], MAX_BULK, - api_type); - if (ret != 0) + printf("Test enqueue without enough memory space\n"); + for (j = 0; j < (RING_SIZE/MAX_BULK - 1); j++) { + ret = test_ring_enqueue(r, cur_src, esize, MAX_BULK, api_type); + if (ret != MAX_BULK) goto fail; + cur_src = test_ring_inc_ptr(cur_src, esize, MAX_BULK); + } - printf("Test dequeue without enough objects\n"); - for (j = 0; j < RING_SIZE / MAX_BULK - 1; j++) { - ret = test_ring_dequeue(r, cur_dst, esize[i], MAX_BULK, - api_type); - if (ret != MAX_BULK) - goto fail; - cur_dst = test_ring_inc_ptr(cur_dst, esize[i], - MAX_BULK); - } - - /* Available memory space for the exact MAX_BULK entries */ - ret = test_ring_dequeue(r, cur_dst, esize[i], 2, api_type); - if (ret != 2) - goto fail; - cur_dst = test_ring_inc_ptr(cur_dst, esize[i], 2); - - /* Bulk APIs enqueue exact number of elements */ - if ((api_type & TEST_RING_ELEM_BULK) == TEST_RING_ELEM_BULK) - num_elems = MAX_BULK - 3; - else - num_elems = MAX_BULK; - ret = test_ring_dequeue(r, cur_dst, esize[i], num_elems, - api_type); - if (ret != MAX_BULK - 3) - goto fail; - cur_dst = test_ring_inc_ptr(cur_dst, esize[i], MAX_BULK - 3); + printf("Enqueue 2 objects, free entries = MAX_BULK - 2\n"); + ret = test_ring_enqueue(r, cur_src, esize, 2, api_type); + if (ret != 2) + goto fail; + cur_src = test_ring_inc_ptr(cur_src, esize, 2); - printf("Test if ring is empty\n"); - /* Check if ring is empty */ - if (rte_ring_empty(r) != 1) + printf("Enqueue the remaining entries = MAX_BULK - 3\n"); + /* Bulk APIs enqueue exact number of elements */ + if ((api_type & TEST_RING_ELEM_BULK) == TEST_RING_ELEM_BULK) + num_elems = MAX_BULK - 3; + else + num_elems = MAX_BULK; + /* Always one free entry left */ + ret = test_ring_enqueue(r, cur_src, esize, num_elems, api_type); + if (ret != MAX_BULK - 3) + goto fail; + cur_src = test_ring_inc_ptr(cur_src, esize, MAX_BULK - 3); + + printf("Test if ring is full\n"); + if (rte_ring_full(r) != 1) + goto fail; + + printf("Test enqueue for a full entry\n"); + ret = test_ring_enqueue(r, cur_src, esize, MAX_BULK, + api_type); + if (ret != 0) + goto fail; + + printf("Test dequeue without enough objects\n"); + for (j = 0; j < RING_SIZE / MAX_BULK - 1; j++) { + ret = test_ring_dequeue(r, cur_dst, esize, MAX_BULK, api_type); + if (ret != MAX_BULK) goto fail; + cur_dst = test_ring_inc_ptr(cur_dst, esize, MAX_BULK); + } - /* check data */ - if (memcmp(src, dst, cur_dst - dst)) { - rte_hexdump(stdout, "src", src, cur_src - src); - rte_hexdump(stdout, "dst", dst, cur_dst - dst); - printf("data after dequeue is not the same\n"); - goto fail; - } + /* Available memory space for the exact MAX_BULK entries */ + ret = test_ring_dequeue(r, cur_dst, esize, 2, api_type); + if (ret != 2) + goto fail; + cur_dst = test_ring_inc_ptr(cur_dst, esize, 2); - /* Free memory before test completed */ - rte_ring_free(r); - rte_free(src); - rte_free(dst); - r = NULL; - src = NULL; - dst = NULL; + /* Bulk APIs enqueue exact number of elements */ + if ((api_type & TEST_RING_ELEM_BULK) == TEST_RING_ELEM_BULK) + num_elems = MAX_BULK - 3; + else + num_elems = MAX_BULK; + ret = test_ring_dequeue(r, cur_dst, esize, num_elems, + api_type); + if (ret != MAX_BULK - 3) + goto fail; + cur_dst = test_ring_inc_ptr(cur_dst, esize, MAX_BULK - 3); + + printf("Test if ring is empty\n"); + /* Check if ring is empty */ + if (rte_ring_empty(r) != 1) + goto fail; + + /* check data */ + if (memcmp(src, dst, cur_dst - dst)) { + rte_hexdump(stdout, "src", src, cur_src - src); + rte_hexdump(stdout, "dst", dst, cur_dst - dst); + printf("data after dequeue is not the same\n"); + goto fail; } + /* Free memory before test completed */ + rte_ring_free(r); + rte_free(src); + rte_free(dst); + r = NULL; + src = NULL; + dst = NULL; + return 0; fail: rte_ring_free(r); @@ -853,55 +829,57 @@ test_ring(void) for (j = TEST_RING_ELEM_BULK; j <= TEST_RING_ELEM_BURST; j <<= 1) for (i = TEST_RING_THREAD_DEF; i <= TEST_RING_THREAD_MPMC; i <<= 1) - if (test_ring_burst_bulk_tests1(i | j, 0, tname) < 0) + if (test_ring_burst_bulk_tests1(i | j, + -1, 0, tname) < 0) goto test_fail; for (j = TEST_RING_ELEM_BULK; j <= TEST_RING_ELEM_BURST; j <<= 1) for (i = TEST_RING_THREAD_DEF; i <= TEST_RING_THREAD_MPMC; i <<= 1) - if (test_ring_burst_bulk_tests2(i | j, 0, tname) < 0) + if (test_ring_burst_bulk_tests2(i | j, 4, 0, tname) < 0) goto test_fail; for (j = TEST_RING_ELEM_BULK; j <= TEST_RING_ELEM_BURST; j <<= 1) for (i = TEST_RING_THREAD_DEF; i <= TEST_RING_THREAD_MPMC; i <<= 1) - if (test_ring_burst_bulk_tests3(i | j, 0, tname) < 0) + if (test_ring_burst_bulk_tests3(i | j, 8, 0, tname) < 0) goto test_fail; - for (j = TEST_RING_ELEM_BULK; j <= TEST_RING_ELEM_BURST; j <<= 1) + for (j = TEST_RING_ELEM_BULK; j < TEST_RING_ELEM_BURST; j <<= 1) for (i = TEST_RING_THREAD_DEF; i <= TEST_RING_THREAD_MPMC; i <<= 1) - if (test_ring_burst_bulk_tests4(i | j, 0, tname) < 0) + if (test_ring_burst_bulk_tests4(i | j, + 16, 0, tname) < 0) goto test_fail; /* Burst and bulk operations with MT_RTS and MT_HTS sync modes */ for (i = 0; i != RTE_DIM(test_sync_modes); i++) { - for (j = TEST_RING_ELEM_BULK; j <= TEST_RING_ELEM_BURST; + for (j = TEST_RING_ELEM_BULK; j < TEST_RING_ELEM_BURST; j <<= 1) { rc = test_ring_burst_bulk_tests1( - TEST_RING_THREAD_DEF | j, + TEST_RING_THREAD_DEF | j, -1, test_sync_modes[i].create_flags, test_sync_modes[i].name); if (rc < 0) goto test_fail; rc = test_ring_burst_bulk_tests2( - TEST_RING_THREAD_DEF | j, + TEST_RING_THREAD_DEF | j, 4, test_sync_modes[i].create_flags, test_sync_modes[i].name); if (rc < 0) goto test_fail; rc = test_ring_burst_bulk_tests3( - TEST_RING_THREAD_DEF | j, + TEST_RING_THREAD_DEF | j, 8, test_sync_modes[i].create_flags, test_sync_modes[i].name); if (rc < 0) goto test_fail; - rc = test_ring_burst_bulk_tests3( - TEST_RING_THREAD_DEF | j, + rc = test_ring_burst_bulk_tests4( + TEST_RING_THREAD_DEF | j, 16, test_sync_modes[i].create_flags, test_sync_modes[i].name); if (rc < 0)