get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/64049/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 64049,
    "url": "http://patches.dpdk.org/api/patches/64049/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20191220044524.32910-4-honnappa.nagarahalli@arm.com/",
    "project": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<20191220044524.32910-4-honnappa.nagarahalli@arm.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20191220044524.32910-4-honnappa.nagarahalli@arm.com",
    "date": "2019-12-20T04:45:10",
    "name": "[v7,03/17] test/ring: add functional tests for rte_ring_xxx_elem APIs",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "31fec632caef6791f5c3bb14eadf22164851f3b8",
    "submitter": {
        "id": 1045,
        "url": "http://patches.dpdk.org/api/people/1045/?format=api",
        "name": "Honnappa Nagarahalli",
        "email": "honnappa.nagarahalli@arm.com"
    },
    "delegate": {
        "id": 24651,
        "url": "http://patches.dpdk.org/api/users/24651/?format=api",
        "username": "dmarchand",
        "first_name": "David",
        "last_name": "Marchand",
        "email": "david.marchand@redhat.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20191220044524.32910-4-honnappa.nagarahalli@arm.com/mbox/",
    "series": [
        {
            "id": 7903,
            "url": "http://patches.dpdk.org/api/series/7903/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=7903",
            "date": "2019-12-20T04:45:07",
            "name": "lib/ring: APIs to support custom element size",
            "version": 7,
            "mbox": "http://patches.dpdk.org/series/7903/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/64049/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/64049/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 1CDFEA04F3;\n\tFri, 20 Dec 2019 05:46:08 +0100 (CET)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id AD9F91BF78;\n\tFri, 20 Dec 2019 05:46:02 +0100 (CET)",
            "from foss.arm.com (foss.arm.com [217.140.110.172])\n by dpdk.org (Postfix) with ESMTP id 2A2AC1BF73\n for <dev@dpdk.org>; Fri, 20 Dec 2019 05:45:58 +0100 (CET)",
            "from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14])\n by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0EEAA106F;\n Thu, 19 Dec 2019 20:45:57 -0800 (PST)",
            "from qc2400f-1.austin.arm.com (qc2400f-1.austin.arm.com\n [10.118.14.48])\n by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E821D3F86C;\n Thu, 19 Dec 2019 20:45:56 -0800 (PST)"
        ],
        "From": "Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>",
        "To": "olivier.matz@6wind.com, sthemmin@microsoft.com, jerinj@marvell.com,\n bruce.richardson@intel.com, david.marchand@redhat.com,\n pbhagavatula@marvell.com, konstantin.ananyev@intel.com,\n honnappa.nagarahalli@arm.com",
        "Cc": "dev@dpdk.org, dharmik.thakkar@arm.com, ruifeng.wang@arm.com,\n gavin.hu@arm.com, nd@arm.com",
        "Date": "Thu, 19 Dec 2019 22:45:10 -0600",
        "Message-Id": "<20191220044524.32910-4-honnappa.nagarahalli@arm.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<20191220044524.32910-1-honnappa.nagarahalli@arm.com>",
        "References": "<20190906190510.11146-1-honnappa.nagarahalli@arm.com>\n <20191220044524.32910-1-honnappa.nagarahalli@arm.com>",
        "Subject": "[dpdk-dev] [PATCH v7 03/17] test/ring: add functional tests for\n\trte_ring_xxx_elem APIs",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "Add basic infrastructure to test rte_ring_xxx_elem APIs. Add\ntest cases for testing burst and bulk tests.\n\nSigned-off-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>\nReviewed-by: Gavin Hu <gavin.hu@arm.com>\n---\n app/test/test_ring.c | 466 ++++++++++++++++++++-----------------------\n app/test/test_ring.h | 203 +++++++++++++++++++\n 2 files changed, 419 insertions(+), 250 deletions(-)\n create mode 100644 app/test/test_ring.h",
    "diff": "diff --git a/app/test/test_ring.c b/app/test/test_ring.c\nindex aaf1e70ad..e7a8b468b 100644\n--- a/app/test/test_ring.c\n+++ b/app/test/test_ring.c\n@@ -23,11 +23,13 @@\n #include <rte_branch_prediction.h>\n #include <rte_malloc.h>\n #include <rte_ring.h>\n+#include <rte_ring_elem.h>\n #include <rte_random.h>\n #include <rte_errno.h>\n #include <rte_hexdump.h>\n \n #include \"test.h\"\n+#include \"test_ring.h\"\n \n /*\n  * Ring\n@@ -67,6 +69,50 @@ static rte_atomic32_t synchro;\n \n #define\tTEST_RING_FULL_EMTPY_ITER\t8\n \n+static int esize[] = {-1, 4, 8, 16};\n+\n+static void\n+test_ring_mem_init(void *obj, unsigned int count, int esize)\n+{\n+\tunsigned int i;\n+\n+\t/* Legacy queue APIs? */\n+\tif (esize == -1)\n+\t\tfor (i = 0; i < count; i++)\n+\t\t\t((void **)obj)[i] = (void *)(unsigned long)i;\n+\telse\n+\t\tfor (i = 0; i < (count * esize / sizeof(uint32_t)); i++)\n+\t\t\t((uint32_t *)obj)[i] = i;\n+}\n+\n+static void\n+test_ring_print_test_string(const char *istr, unsigned int api_type, int esize)\n+{\n+\tprintf(\"\\n%s: \", istr);\n+\n+\tif (esize == -1)\n+\t\tprintf(\"legacy APIs: \");\n+\telse\n+\t\tprintf(\"elem APIs: element size %dB \", esize);\n+\n+\tif (api_type == TEST_RING_IGNORE_API_TYPE)\n+\t\treturn;\n+\n+\tif ((api_type & TEST_RING_N) == TEST_RING_N)\n+\t\tprintf(\": default enqueue/dequeue: \");\n+\telse if ((api_type & TEST_RING_S) == TEST_RING_S)\n+\t\tprintf(\": SP/SC: \");\n+\telse if ((api_type & TEST_RING_M) == TEST_RING_M)\n+\t\tprintf(\": MP/MC: \");\n+\n+\tif ((api_type & TEST_RING_SL) == TEST_RING_SL)\n+\t\tprintf(\"single\\n\");\n+\telse if ((api_type & TEST_RING_BL) == TEST_RING_BL)\n+\t\tprintf(\"bulk\\n\");\n+\telse if ((api_type & TEST_RING_BR) == TEST_RING_BR)\n+\t\tprintf(\"burst\\n\");\n+}\n+\n /*\n  * helper routine for test_ring_basic\n  */\n@@ -314,286 +360,203 @@ test_ring_basic(struct rte_ring *r)\n \treturn -1;\n }\n \n+/*\n+ * Burst and bulk operations with sp/sc, mp/mc and default (during creation)\n+ */\n static int\n-test_ring_burst_basic(struct rte_ring *r)\n+test_ring_burst_bulk_tests(unsigned int api_type)\n {\n+\tstruct rte_ring *r;\n \tvoid **src = NULL, **cur_src = NULL, **dst = NULL, **cur_dst = NULL;\n \tint ret;\n-\tunsigned i;\n+\tunsigned int i, j;\n+\tunsigned int num_elems;\n \n-\t/* alloc dummy object pointers */\n-\tsrc = malloc(RING_SIZE*2*sizeof(void *));\n-\tif (src == NULL)\n-\t\tgoto fail;\n-\n-\tfor (i = 0; i < RING_SIZE*2 ; i++) {\n-\t\tsrc[i] = (void *)(unsigned long)i;\n-\t}\n-\tcur_src = src;\n+\tfor (i = 0; i < RTE_DIM(esize); i++) {\n+\t\ttest_ring_print_test_string(\"Test standard ring\", api_type,\n+\t\t\t\t\t\tesize[i]);\n \n-\t/* alloc some room for copied objects */\n-\tdst = malloc(RING_SIZE*2*sizeof(void *));\n-\tif (dst == NULL)\n-\t\tgoto fail;\n+\t\t/* Create the ring */\n+\t\tTEST_RING_CREATE(\"test_ring_burst_bulk_tests\", esize[i],\n+\t\t\t\t\tRING_SIZE, SOCKET_ID_ANY, 0, r);\n \n-\tmemset(dst, 0, RING_SIZE*2*sizeof(void *));\n-\tcur_dst = dst;\n-\n-\tprintf(\"Test SP & SC basic functions \\n\");\n-\tprintf(\"enqueue 1 obj\\n\");\n-\tret = rte_ring_sp_enqueue_burst(r, cur_src, 1, NULL);\n-\tcur_src += 1;\n-\tif (ret != 1)\n-\t\tgoto fail;\n-\n-\tprintf(\"enqueue 2 objs\\n\");\n-\tret = rte_ring_sp_enqueue_burst(r, cur_src, 2, NULL);\n-\tcur_src += 2;\n-\tif (ret != 2)\n-\t\tgoto fail;\n-\n-\tprintf(\"enqueue MAX_BULK objs\\n\");\n-\tret = rte_ring_sp_enqueue_burst(r, cur_src, MAX_BULK, NULL);\n-\tcur_src += MAX_BULK;\n-\tif (ret != MAX_BULK)\n-\t\tgoto fail;\n-\n-\tprintf(\"dequeue 1 obj\\n\");\n-\tret = rte_ring_sc_dequeue_burst(r, cur_dst, 1, NULL);\n-\tcur_dst += 1;\n-\tif (ret != 1)\n-\t\tgoto fail;\n-\n-\tprintf(\"dequeue 2 objs\\n\");\n-\tret = rte_ring_sc_dequeue_burst(r, cur_dst, 2, NULL);\n-\tcur_dst += 2;\n-\tif (ret != 2)\n-\t\tgoto fail;\n+\t\t/* alloc dummy object pointers */\n+\t\tsrc = test_ring_calloc(RING_SIZE * 2, esize[i]);\n+\t\tif (src == NULL)\n+\t\t\tgoto fail;\n+\t\ttest_ring_mem_init(src, RING_SIZE * 2, esize[i]);\n+\t\tcur_src = src;\n \n-\tprintf(\"dequeue MAX_BULK objs\\n\");\n-\tret = rte_ring_sc_dequeue_burst(r, cur_dst, MAX_BULK, NULL);\n-\tcur_dst += MAX_BULK;\n-\tif (ret != MAX_BULK)\n-\t\tgoto fail;\n+\t\t/* alloc some room for copied objects */\n+\t\tdst = test_ring_calloc(RING_SIZE * 2, esize[i]);\n+\t\tif (dst == NULL)\n+\t\t\tgoto fail;\n+\t\tcur_dst = dst;\n \n-\t/* check data */\n-\tif (memcmp(src, dst, cur_dst - dst)) {\n-\t\trte_hexdump(stdout, \"src\", src, cur_src - src);\n-\t\trte_hexdump(stdout, \"dst\", dst, cur_dst - dst);\n-\t\tprintf(\"data after dequeue is not the same\\n\");\n-\t\tgoto fail;\n-\t}\n+\t\tprintf(\"enqueue 1 obj\\n\");\n+\t\tTEST_RING_ENQUEUE(r, cur_src, esize[i], 1, ret, api_type);\n+\t\tif (ret != 1)\n+\t\t\tgoto fail;\n+\t\tTEST_RING_INCP(cur_src, esize[i], 1);\n \n-\tcur_src = src;\n-\tcur_dst = dst;\n+\t\tprintf(\"enqueue 2 objs\\n\");\n+\t\tTEST_RING_ENQUEUE(r, cur_src, esize[i], 2, ret, api_type);\n+\t\tif (ret != 2)\n+\t\t\tgoto fail;\n+\t\tTEST_RING_INCP(cur_src, esize[i], 2);\n \n-\tprintf(\"Test enqueue without enough memory space \\n\");\n-\tfor (i = 0; i< (RING_SIZE/MAX_BULK - 1); i++) {\n-\t\tret = rte_ring_sp_enqueue_burst(r, cur_src, MAX_BULK, NULL);\n-\t\tcur_src += MAX_BULK;\n+\t\tprintf(\"enqueue MAX_BULK objs\\n\");\n+\t\tTEST_RING_ENQUEUE(r, cur_src, esize[i], MAX_BULK, ret,\n+\t\t\t\t\t\tapi_type);\n \t\tif (ret != MAX_BULK)\n \t\t\tgoto fail;\n-\t}\n-\n-\tprintf(\"Enqueue 2 objects, free entries = MAX_BULK - 2  \\n\");\n-\tret = rte_ring_sp_enqueue_burst(r, cur_src, 2, NULL);\n-\tcur_src += 2;\n-\tif (ret != 2)\n-\t\tgoto fail;\n+\t\tTEST_RING_INCP(cur_src, esize[i], MAX_BULK);\n \n-\tprintf(\"Enqueue the remaining entries = MAX_BULK - 2  \\n\");\n-\t/* Always one free entry left */\n-\tret = rte_ring_sp_enqueue_burst(r, cur_src, MAX_BULK, NULL);\n-\tcur_src += MAX_BULK - 3;\n-\tif (ret != MAX_BULK - 3)\n-\t\tgoto fail;\n-\n-\tprintf(\"Test if ring is full  \\n\");\n-\tif (rte_ring_full(r) != 1)\n-\t\tgoto fail;\n+\t\tprintf(\"dequeue 1 obj\\n\");\n+\t\tTEST_RING_DEQUEUE(r, cur_dst, esize[i], 1, ret, api_type);\n+\t\tif (ret != 1)\n+\t\t\tgoto fail;\n+\t\tTEST_RING_INCP(cur_dst, esize[i], 1);\n \n-\tprintf(\"Test enqueue for a full entry  \\n\");\n-\tret = rte_ring_sp_enqueue_burst(r, cur_src, MAX_BULK, NULL);\n-\tif (ret != 0)\n-\t\tgoto fail;\n+\t\tprintf(\"dequeue 2 objs\\n\");\n+\t\tTEST_RING_DEQUEUE(r, cur_dst, esize[i], 2, ret, api_type);\n+\t\tif (ret != 2)\n+\t\t\tgoto fail;\n+\t\tTEST_RING_INCP(cur_dst, esize[i], 2);\n \n-\tprintf(\"Test dequeue without enough objects \\n\");\n-\tfor (i = 0; i<RING_SIZE/MAX_BULK - 1; i++) {\n-\t\tret = rte_ring_sc_dequeue_burst(r, cur_dst, MAX_BULK, NULL);\n-\t\tcur_dst += MAX_BULK;\n+\t\tprintf(\"dequeue MAX_BULK objs\\n\");\n+\t\tTEST_RING_DEQUEUE(r, cur_dst, esize[i], MAX_BULK, ret,\n+\t\t\t\t\t\tapi_type);\n \t\tif (ret != MAX_BULK)\n \t\t\tgoto fail;\n-\t}\n-\n-\t/* Available memory space for the exact MAX_BULK entries */\n-\tret = rte_ring_sc_dequeue_burst(r, cur_dst, 2, NULL);\n-\tcur_dst += 2;\n-\tif (ret != 2)\n-\t\tgoto fail;\n-\n-\tret = rte_ring_sc_dequeue_burst(r, cur_dst, MAX_BULK, NULL);\n-\tcur_dst += MAX_BULK - 3;\n-\tif (ret != MAX_BULK - 3)\n-\t\tgoto fail;\n-\n-\tprintf(\"Test if ring is empty \\n\");\n-\t/* Check if ring is empty */\n-\tif (1 != rte_ring_empty(r))\n-\t\tgoto fail;\n-\n-\t/* check data */\n-\tif (memcmp(src, dst, cur_dst - dst)) {\n-\t\trte_hexdump(stdout, \"src\", src, cur_src - src);\n-\t\trte_hexdump(stdout, \"dst\", dst, cur_dst - dst);\n-\t\tprintf(\"data after dequeue is not the same\\n\");\n-\t\tgoto fail;\n-\t}\n+\t\tTEST_RING_INCP(cur_dst, esize[i], MAX_BULK);\n \n-\tcur_src = src;\n-\tcur_dst = dst;\n-\n-\tprintf(\"Test MP & MC basic functions \\n\");\n-\n-\tprintf(\"enqueue 1 obj\\n\");\n-\tret = rte_ring_mp_enqueue_burst(r, cur_src, 1, NULL);\n-\tcur_src += 1;\n-\tif (ret != 1)\n-\t\tgoto fail;\n-\n-\tprintf(\"enqueue 2 objs\\n\");\n-\tret = rte_ring_mp_enqueue_burst(r, cur_src, 2, NULL);\n-\tcur_src += 2;\n-\tif (ret != 2)\n-\t\tgoto fail;\n-\n-\tprintf(\"enqueue MAX_BULK objs\\n\");\n-\tret = rte_ring_mp_enqueue_burst(r, cur_src, MAX_BULK, NULL);\n-\tcur_src += MAX_BULK;\n-\tif (ret != MAX_BULK)\n-\t\tgoto fail;\n-\n-\tprintf(\"dequeue 1 obj\\n\");\n-\tret = rte_ring_mc_dequeue_burst(r, cur_dst, 1, NULL);\n-\tcur_dst += 1;\n-\tif (ret != 1)\n-\t\tgoto fail;\n-\n-\tprintf(\"dequeue 2 objs\\n\");\n-\tret = rte_ring_mc_dequeue_burst(r, cur_dst, 2, NULL);\n-\tcur_dst += 2;\n-\tif (ret != 2)\n-\t\tgoto fail;\n-\n-\tprintf(\"dequeue MAX_BULK objs\\n\");\n-\tret = rte_ring_mc_dequeue_burst(r, cur_dst, MAX_BULK, NULL);\n-\tcur_dst += MAX_BULK;\n-\tif (ret != MAX_BULK)\n-\t\tgoto fail;\n-\n-\t/* check data */\n-\tif (memcmp(src, dst, cur_dst - dst)) {\n-\t\trte_hexdump(stdout, \"src\", src, cur_src - src);\n-\t\trte_hexdump(stdout, \"dst\", dst, cur_dst - dst);\n-\t\tprintf(\"data after dequeue is not the same\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tcur_src = src;\n-\tcur_dst = dst;\n+\t\t/* check data */\n+\t\tif (memcmp(src, dst, cur_dst - dst)) {\n+\t\t\trte_hexdump(stdout, \"src\", src, cur_src - src);\n+\t\t\trte_hexdump(stdout, \"dst\", dst, cur_dst - dst);\n+\t\t\tprintf(\"data after dequeue is not the same\\n\");\n+\t\t\tgoto fail;\n+\t\t}\n+\n+\t\tcur_src = src;\n+\t\tcur_dst = dst;\n+\n+\t\tprintf(\"fill and empty the ring\\n\");\n+\t\tfor (j = 0; j < RING_SIZE / MAX_BULK; j++) {\n+\t\t\tTEST_RING_ENQUEUE(r, cur_src, esize[i], MAX_BULK,\n+\t\t\t\t\t\t\tret, api_type);\n+\t\t\tif (ret != MAX_BULK)\n+\t\t\t\tgoto fail;\n+\t\t\tTEST_RING_INCP(cur_src, esize[i], MAX_BULK);\n+\n+\t\t\tTEST_RING_DEQUEUE(r, cur_dst, esize[i], MAX_BULK,\n+\t\t\t\t\t\t\tret, api_type);\n+\t\t\tif (ret != MAX_BULK)\n+\t\t\t\tgoto fail;\n+\t\t\tTEST_RING_INCP(cur_dst, esize[i], MAX_BULK);\n+\t\t}\n \n-\tprintf(\"fill and empty the ring\\n\");\n-\tfor (i = 0; i<RING_SIZE/MAX_BULK; i++) {\n-\t\tret = rte_ring_mp_enqueue_burst(r, cur_src, MAX_BULK, NULL);\n-\t\tcur_src += MAX_BULK;\n-\t\tif (ret != MAX_BULK)\n+\t\t/* check data */\n+\t\tif (memcmp(src, dst, cur_dst - dst)) {\n+\t\t\trte_hexdump(stdout, \"src\", src, cur_src - src);\n+\t\t\trte_hexdump(stdout, \"dst\", dst, cur_dst - dst);\n+\t\t\tprintf(\"data after dequeue is not the same\\n\");\n \t\t\tgoto fail;\n-\t\tret = rte_ring_mc_dequeue_burst(r, cur_dst, MAX_BULK, NULL);\n-\t\tcur_dst += MAX_BULK;\n-\t\tif (ret != MAX_BULK)\n+\t\t}\n+\n+\t\tcur_src = src;\n+\t\tcur_dst = dst;\n+\n+\t\tprintf(\"Test enqueue without enough memory space\\n\");\n+\t\tfor (j = 0; j < (RING_SIZE/MAX_BULK - 1); j++) {\n+\t\t\tTEST_RING_ENQUEUE(r, cur_src, esize[i], MAX_BULK,\n+\t\t\t\t\t\t\tret, api_type);\n+\t\t\tif (ret != MAX_BULK)\n+\t\t\t\tgoto fail;\n+\t\t\tTEST_RING_INCP(cur_src, esize[i], MAX_BULK);\n+\t\t}\n+\n+\t\tprintf(\"Enqueue 2 objects, free entries = MAX_BULK - 2\\n\");\n+\t\tTEST_RING_ENQUEUE(r, cur_src, esize[i], 2, ret, api_type);\n+\t\tif (ret != 2)\n \t\t\tgoto fail;\n-\t}\n-\n-\t/* check data */\n-\tif (memcmp(src, dst, cur_dst - dst)) {\n-\t\trte_hexdump(stdout, \"src\", src, cur_src - src);\n-\t\trte_hexdump(stdout, \"dst\", dst, cur_dst - dst);\n-\t\tprintf(\"data after dequeue is not the same\\n\");\n-\t\tgoto fail;\n-\t}\n-\n-\tcur_src = src;\n-\tcur_dst = dst;\n-\n-\tprintf(\"Test enqueue without enough memory space \\n\");\n-\tfor (i = 0; i<RING_SIZE/MAX_BULK - 1; i++) {\n-\t\tret = rte_ring_mp_enqueue_burst(r, cur_src, MAX_BULK, NULL);\n-\t\tcur_src += MAX_BULK;\n-\t\tif (ret != MAX_BULK)\n+\t\tTEST_RING_INCP(cur_src, esize[i], 2);\n+\n+\n+\t\tprintf(\"Enqueue the remaining entries = MAX_BULK - 3\\n\");\n+\t\t/* Bulk APIs enqueue exact number of elements */\n+\t\tif ((api_type & TEST_RING_BL) == TEST_RING_BL)\n+\t\t\tnum_elems = MAX_BULK - 3;\n+\t\telse\n+\t\t\tnum_elems = MAX_BULK;\n+\t\t/* Always one free entry left */\n+\t\tTEST_RING_ENQUEUE(r, cur_src, esize[i], num_elems,\n+\t\t\t\t\t\tret, api_type);\n+\t\tif (ret != MAX_BULK - 3)\n \t\t\tgoto fail;\n-\t}\n-\n-\t/* Available memory space for the exact MAX_BULK objects */\n-\tret = rte_ring_mp_enqueue_burst(r, cur_src, 2, NULL);\n-\tcur_src += 2;\n-\tif (ret != 2)\n-\t\tgoto fail;\n+\t\tTEST_RING_INCP(cur_src, esize[i], MAX_BULK - 3);\n \n-\tret = rte_ring_mp_enqueue_burst(r, cur_src, MAX_BULK, NULL);\n-\tcur_src += MAX_BULK - 3;\n-\tif (ret != MAX_BULK - 3)\n-\t\tgoto fail;\n+\t\tprintf(\"Test if ring is full\\n\");\n+\t\tif (rte_ring_full(r) != 1)\n+\t\t\tgoto fail;\n \n+\t\tprintf(\"Test enqueue for a full entry\\n\");\n+\t\tTEST_RING_ENQUEUE(r, cur_src, esize[i], MAX_BULK,\n+\t\t\t\t\t\tret, api_type);\n+\t\tif (ret != 0)\n+\t\t\tgoto fail;\n \n-\tprintf(\"Test dequeue without enough objects \\n\");\n-\tfor (i = 0; i<RING_SIZE/MAX_BULK - 1; i++) {\n-\t\tret = rte_ring_mc_dequeue_burst(r, cur_dst, MAX_BULK, NULL);\n-\t\tcur_dst += MAX_BULK;\n-\t\tif (ret != MAX_BULK)\n+\t\tprintf(\"Test dequeue without enough objects\\n\");\n+\t\tfor (j = 0; j < RING_SIZE / MAX_BULK - 1; j++) {\n+\t\t\tTEST_RING_DEQUEUE(r, cur_dst, esize[i], MAX_BULK,\n+\t\t\t\t\t\t\tret, api_type);\n+\t\t\tif (ret != MAX_BULK)\n+\t\t\t\tgoto fail;\n+\t\t\tTEST_RING_INCP(cur_dst, esize[i], MAX_BULK);\n+\t\t}\n+\n+\t\t/* Available memory space for the exact MAX_BULK entries */\n+\t\tTEST_RING_DEQUEUE(r, cur_dst, esize[i], 2, ret, api_type);\n+\t\tif (ret != 2)\n \t\t\tgoto fail;\n-\t}\n+\t\tTEST_RING_INCP(cur_dst, esize[i], 2);\n+\n+\t\t/* Bulk APIs enqueue exact number of elements */\n+\t\tif ((api_type & TEST_RING_BL) == TEST_RING_BL)\n+\t\t\tnum_elems = MAX_BULK - 3;\n+\t\telse\n+\t\t\tnum_elems = MAX_BULK;\n+\t\tTEST_RING_DEQUEUE(r, cur_dst, esize[i], num_elems,\n+\t\t\t\t\t\tret, api_type);\n+\t\tif (ret != MAX_BULK - 3)\n+\t\t\tgoto fail;\n+\t\tTEST_RING_INCP(cur_dst, esize[i], MAX_BULK - 3);\n \n-\t/* Available objects - the exact MAX_BULK */\n-\tret = rte_ring_mc_dequeue_burst(r, cur_dst, 2, NULL);\n-\tcur_dst += 2;\n-\tif (ret != 2)\n-\t\tgoto fail;\n+\t\tprintf(\"Test if ring is empty\\n\");\n+\t\t/* Check if ring is empty */\n+\t\tif (rte_ring_empty(r) != 1)\n+\t\t\tgoto fail;\n \n-\tret = rte_ring_mc_dequeue_burst(r, cur_dst, MAX_BULK, NULL);\n-\tcur_dst += MAX_BULK - 3;\n-\tif (ret != MAX_BULK - 3)\n-\t\tgoto fail;\n+\t\t/* check data */\n+\t\tif (memcmp(src, dst, cur_dst - dst)) {\n+\t\t\trte_hexdump(stdout, \"src\", src, cur_src - src);\n+\t\t\trte_hexdump(stdout, \"dst\", dst, cur_dst - dst);\n+\t\t\tprintf(\"data after dequeue is not the same\\n\");\n+\t\t\tgoto fail;\n+\t\t}\n \n-\t/* check data */\n-\tif (memcmp(src, dst, cur_dst - dst)) {\n-\t\trte_hexdump(stdout, \"src\", src, cur_src - src);\n-\t\trte_hexdump(stdout, \"dst\", dst, cur_dst - dst);\n-\t\tprintf(\"data after dequeue is not the same\\n\");\n-\t\tgoto fail;\n+\t\t/* Free memory before test completed */\n+\t\trte_ring_free(r);\n+\t\trte_free(src);\n+\t\trte_free(dst);\n \t}\n \n-\tcur_src = src;\n-\tcur_dst = dst;\n-\n-\tprintf(\"Covering rte_ring_enqueue_burst functions \\n\");\n-\n-\tret = rte_ring_enqueue_burst(r, cur_src, 2, NULL);\n-\tcur_src += 2;\n-\tif (ret != 2)\n-\t\tgoto fail;\n-\n-\tret = rte_ring_dequeue_burst(r, cur_dst, 2, NULL);\n-\tcur_dst += 2;\n-\tif (ret != 2)\n-\t\tgoto fail;\n-\n-\t/* Free memory before test completed */\n-\tfree(src);\n-\tfree(dst);\n \treturn 0;\n-\n- fail:\n-\tfree(src);\n-\tfree(dst);\n+fail:\n+\trte_ring_free(r);\n+\trte_free(src);\n+\trte_free(dst);\n \treturn -1;\n }\n \n@@ -810,6 +773,7 @@ test_ring_with_exact_size(void)\n static int\n test_ring(void)\n {\n+\tunsigned int i, j;\n \tstruct rte_ring *r = NULL;\n \n \t/* some more basic operations */\n@@ -828,9 +792,11 @@ test_ring(void)\n \t\tgoto test_fail;\n \t}\n \n-\t/* burst operations */\n-\tif (test_ring_burst_basic(r) < 0)\n-\t\tgoto test_fail;\n+\t/* Burst and bulk operations with sp/sc, mp/mc and default */\n+\tfor (j = TEST_RING_BL; j <= TEST_RING_BR; j <<= 1)\n+\t\tfor (i = TEST_RING_N; i <= TEST_RING_M; i <<= 1)\n+\t\t\tif (test_ring_burst_bulk_tests(i | j) < 0)\n+\t\t\t\tgoto test_fail;\n \n \t/* basic operations */\n \tif (test_ring_basic(r) < 0)\ndiff --git a/app/test/test_ring.h b/app/test/test_ring.h\nnew file mode 100644\nindex 000000000..19ef1b399\n--- /dev/null\n+++ b/app/test/test_ring.h\n@@ -0,0 +1,203 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2019 Arm Limited\n+ */\n+\n+#include <rte_malloc.h>\n+#include <rte_ring.h>\n+#include <rte_ring_elem.h>\n+\n+/* API type to call\n+ * N - Calls default APIs\n+ * S - Calls SP or SC API\n+ * M - Calls MP or MC API\n+ */\n+#define TEST_RING_N 1\n+#define TEST_RING_S 2\n+#define TEST_RING_M 4\n+\n+/* API type to call\n+ * SL - Calls single element APIs\n+ * BL - Calls bulk APIs\n+ * BR - Calls burst APIs\n+ */\n+#define TEST_RING_SL 8\n+#define TEST_RING_BL 16\n+#define TEST_RING_BR 32\n+\n+#define TEST_RING_IGNORE_API_TYPE ~0U\n+\n+#define TEST_RING_INCP(obj, esize, n) do { \\\n+\t/* Legacy queue APIs? */ \\\n+\tif ((esize) == -1) \\\n+\t\tobj = ((void **)obj) + n; \\\n+\telse \\\n+\t\tobj = (void **)(((uint32_t *)obj) + \\\n+\t\t\t\t\t(n * esize / sizeof(uint32_t))); \\\n+} while (0)\n+\n+#define TEST_RING_CREATE(name, esize, count, socket_id, flags, r) do { \\\n+\t/* Legacy queue APIs? */ \\\n+\tif ((esize) == -1) \\\n+\t\tr = rte_ring_create((name), (count), (socket_id), (flags)); \\\n+\telse \\\n+\t\tr = rte_ring_create_elem((name), (esize), (count), \\\n+\t\t\t\t\t\t(socket_id), (flags)); \\\n+} while (0)\n+\n+#define TEST_RING_ENQUEUE(r, obj, esize, n, ret, api_type) do { \\\n+\t/* Legacy queue APIs? */ \\\n+\tif ((esize) == -1) \\\n+\t\tswitch (api_type) { \\\n+\t\tcase (TEST_RING_N | TEST_RING_SL): \\\n+\t\t\tret = rte_ring_enqueue(r, obj); \\\n+\t\t\tbreak; \\\n+\t\tcase (TEST_RING_S | TEST_RING_SL): \\\n+\t\t\tret = rte_ring_sp_enqueue(r, obj); \\\n+\t\t\tbreak; \\\n+\t\tcase (TEST_RING_M | TEST_RING_SL): \\\n+\t\t\tret = rte_ring_mp_enqueue(r, obj); \\\n+\t\t\tbreak; \\\n+\t\tcase (TEST_RING_N | TEST_RING_BL): \\\n+\t\t\tret = rte_ring_enqueue_bulk(r, obj, n, NULL); \\\n+\t\t\tbreak; \\\n+\t\tcase (TEST_RING_S | TEST_RING_BL): \\\n+\t\t\tret = rte_ring_sp_enqueue_bulk(r, obj, n, NULL); \\\n+\t\t\tbreak; \\\n+\t\tcase (TEST_RING_M | TEST_RING_BL): \\\n+\t\t\tret = rte_ring_mp_enqueue_bulk(r, obj, n, NULL); \\\n+\t\t\tbreak; \\\n+\t\tcase (TEST_RING_N | TEST_RING_BR): \\\n+\t\t\tret = rte_ring_enqueue_burst(r, obj, n, NULL); \\\n+\t\t\tbreak; \\\n+\t\tcase (TEST_RING_S | TEST_RING_BR): \\\n+\t\t\tret = rte_ring_sp_enqueue_burst(r, obj, n, NULL); \\\n+\t\t\tbreak; \\\n+\t\tcase (TEST_RING_M | TEST_RING_BR): \\\n+\t\t\tret = rte_ring_mp_enqueue_burst(r, obj, n, NULL); \\\n+\t\t} \\\n+\telse \\\n+\t\tswitch (api_type) { \\\n+\t\tcase (TEST_RING_N | TEST_RING_SL): \\\n+\t\t\tret = rte_ring_enqueue_elem(r, obj, esize); \\\n+\t\t\tbreak; \\\n+\t\tcase (TEST_RING_S | TEST_RING_SL): \\\n+\t\t\tret = rte_ring_sp_enqueue_elem(r, obj, esize); \\\n+\t\t\tbreak; \\\n+\t\tcase (TEST_RING_M | TEST_RING_SL): \\\n+\t\t\tret = rte_ring_mp_enqueue_elem(r, obj, esize); \\\n+\t\t\tbreak; \\\n+\t\tcase (TEST_RING_N | TEST_RING_BL): \\\n+\t\t\tret = rte_ring_enqueue_bulk_elem(r, obj, esize, n, \\\n+\t\t\t\t\t\t\t\tNULL); \\\n+\t\t\tbreak; \\\n+\t\tcase (TEST_RING_S | TEST_RING_BL): \\\n+\t\t\tret = rte_ring_sp_enqueue_bulk_elem(r, obj, esize, n, \\\n+\t\t\t\t\t\t\t\tNULL); \\\n+\t\t\tbreak; \\\n+\t\tcase (TEST_RING_M | TEST_RING_BL): \\\n+\t\t\tret = rte_ring_mp_enqueue_bulk_elem(r, obj, esize, n, \\\n+\t\t\t\t\t\t\t\tNULL); \\\n+\t\t\tbreak; \\\n+\t\tcase (TEST_RING_N | TEST_RING_BR): \\\n+\t\t\tret = rte_ring_enqueue_burst_elem(r, obj, esize, n, \\\n+\t\t\t\t\t\t\t\tNULL); \\\n+\t\t\tbreak; \\\n+\t\tcase (TEST_RING_S | TEST_RING_BR): \\\n+\t\t\tret = rte_ring_sp_enqueue_burst_elem(r, obj, esize, n, \\\n+\t\t\t\t\t\t\t\tNULL); \\\n+\t\t\tbreak; \\\n+\t\tcase (TEST_RING_M | TEST_RING_BR): \\\n+\t\t\tret = rte_ring_mp_enqueue_burst_elem(r, obj, esize, n, \\\n+\t\t\t\t\t\t\t\tNULL); \\\n+\t\t} \\\n+} while (0)\n+\n+#define TEST_RING_DEQUEUE(r, obj, esize, n, ret, api_type) do { \\\n+\t/* Legacy queue APIs? */ \\\n+\tif ((esize) == -1) \\\n+\t\tswitch (api_type) { \\\n+\t\tcase (TEST_RING_N | TEST_RING_SL): \\\n+\t\t\tret = rte_ring_dequeue(r, obj); \\\n+\t\t\tbreak; \\\n+\t\tcase (TEST_RING_S | TEST_RING_SL): \\\n+\t\t\tret = rte_ring_sc_dequeue(r, obj); \\\n+\t\t\tbreak; \\\n+\t\tcase (TEST_RING_M | TEST_RING_SL): \\\n+\t\t\tret = rte_ring_mc_dequeue(r, obj); \\\n+\t\t\tbreak; \\\n+\t\tcase (TEST_RING_N | TEST_RING_BL): \\\n+\t\t\tret = rte_ring_dequeue_bulk(r, obj, n, NULL); \\\n+\t\t\tbreak; \\\n+\t\tcase (TEST_RING_S | TEST_RING_BL): \\\n+\t\t\tret = rte_ring_sc_dequeue_bulk(r, obj, n, NULL); \\\n+\t\t\tbreak; \\\n+\t\tcase (TEST_RING_M | TEST_RING_BL): \\\n+\t\t\tret = rte_ring_mc_dequeue_bulk(r, obj, n, NULL); \\\n+\t\t\tbreak; \\\n+\t\tcase (TEST_RING_N | TEST_RING_BR): \\\n+\t\t\tret = rte_ring_dequeue_burst(r, obj, n, NULL); \\\n+\t\t\tbreak; \\\n+\t\tcase (TEST_RING_S | TEST_RING_BR): \\\n+\t\t\tret = rte_ring_sc_dequeue_burst(r, obj, n, NULL); \\\n+\t\t\tbreak; \\\n+\t\tcase (TEST_RING_M | TEST_RING_BR): \\\n+\t\t\tret = rte_ring_mc_dequeue_burst(r, obj, n, NULL); \\\n+\t\t} \\\n+\telse \\\n+\t\tswitch (api_type) { \\\n+\t\tcase (TEST_RING_N | TEST_RING_SL): \\\n+\t\t\tret = rte_ring_dequeue_elem(r, obj, esize); \\\n+\t\t\tbreak; \\\n+\t\tcase (TEST_RING_S | TEST_RING_SL): \\\n+\t\t\tret = rte_ring_sc_dequeue_elem(r, obj, esize); \\\n+\t\t\tbreak; \\\n+\t\tcase (TEST_RING_M | TEST_RING_SL): \\\n+\t\t\tret = rte_ring_mc_dequeue_elem(r, obj, esize); \\\n+\t\t\tbreak; \\\n+\t\tcase (TEST_RING_N | TEST_RING_BL): \\\n+\t\t\tret = rte_ring_dequeue_bulk_elem(r, obj, esize, n, \\\n+\t\t\t\t\t\t\t\tNULL); \\\n+\t\t\tbreak; \\\n+\t\tcase (TEST_RING_S | TEST_RING_BL): \\\n+\t\t\tret = rte_ring_sc_dequeue_bulk_elem(r, obj, esize, n, \\\n+\t\t\t\t\t\t\t\tNULL); \\\n+\t\t\tbreak; \\\n+\t\tcase (TEST_RING_M | TEST_RING_BL): \\\n+\t\t\tret = rte_ring_mc_dequeue_bulk_elem(r, obj, esize, n, \\\n+\t\t\t\t\t\t\t\tNULL); \\\n+\t\t\tbreak; \\\n+\t\tcase (TEST_RING_N | TEST_RING_BR): \\\n+\t\t\tret = rte_ring_dequeue_burst_elem(r, obj, esize, n, \\\n+\t\t\t\t\t\t\t\tNULL); \\\n+\t\t\tbreak; \\\n+\t\tcase (TEST_RING_S | TEST_RING_BR): \\\n+\t\t\tret = rte_ring_sc_dequeue_burst_elem(r, obj, esize, n, \\\n+\t\t\t\t\t\t\t\tNULL); \\\n+\t\t\tbreak; \\\n+\t\tcase (TEST_RING_M | TEST_RING_BR): \\\n+\t\t\tret = rte_ring_mc_dequeue_burst_elem(r, obj, esize, n, \\\n+\t\t\t\t\t\t\t\tNULL); \\\n+\t\t} \\\n+} while (0)\n+\n+/* This function is placed here as it is required for both\n+ * performance and functional tests.\n+ */\n+static __rte_always_inline void *\n+test_ring_calloc(unsigned int rsize, int esize)\n+{\n+\tunsigned int sz;\n+\tvoid *p;\n+\n+\t/* Legacy queue APIs? */\n+\tif (esize == -1)\n+\t\tsz = sizeof(void *);\n+\telse\n+\t\tsz = esize;\n+\n+\tp = rte_zmalloc(NULL, rsize * sz, RTE_CACHE_LINE_SIZE);\n+\tif (p == NULL)\n+\t\tprintf(\"Failed to allocate memory\\n\");\n+\n+\treturn p;\n+}\n",
    "prefixes": [
        "v7",
        "03/17"
    ]
}