Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/26109/?format=api
http://patches.dpdk.org/api/patches/26109/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/20170630150621.156365-5-bruce.richardson@intel.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": "<20170630150621.156365-5-bruce.richardson@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20170630150621.156365-5-bruce.richardson@intel.com", "date": "2017-06-30T15:06:20", "name": "[dpdk-dev,v2,4/5] test/test: add auto-tests for event ring functions", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": true, "hash": "ac1841cb35675765856f33cd9536f68aa2f25334", "submitter": { "id": 20, "url": "http://patches.dpdk.org/api/people/20/?format=api", "name": "Bruce Richardson", "email": "bruce.richardson@intel.com" }, "delegate": { "id": 310, "url": "http://patches.dpdk.org/api/users/310/?format=api", "username": "jerin", "first_name": "Jerin", "last_name": "Jacob", "email": "jerinj@marvell.com" }, "mbox": "http://patches.dpdk.org/project/dpdk/patch/20170630150621.156365-5-bruce.richardson@intel.com/mbox/", "series": [], "comments": "http://patches.dpdk.org/api/patches/26109/comments/", "check": "success", "checks": "http://patches.dpdk.org/api/patches/26109/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@dpdk.org", "Delivered-To": "patchwork@dpdk.org", "Received": [ "from [92.243.14.124] (localhost [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id 768A77CBA;\n\tFri, 30 Jun 2017 17:07:06 +0200 (CEST)", "from mga11.intel.com (mga11.intel.com [192.55.52.93])\n\tby dpdk.org (Postfix) with ESMTP id 2E95D7CAE\n\tfor <dev@dpdk.org>; Fri, 30 Jun 2017 17:06:51 +0200 (CEST)", "from fmsmga003.fm.intel.com ([10.253.24.29])\n\tby fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t30 Jun 2017 08:06:51 -0700", "from silpixa00399126.ir.intel.com (HELO\n\tsilpixa00399126.ger.corp.intel.com) ([10.237.223.223])\n\tby FMSMGA003.fm.intel.com with ESMTP; 30 Jun 2017 08:06:50 -0700" ], "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.40,287,1496127600\"; d=\"scan'208\";a=\"873507553\"", "From": "Bruce Richardson <bruce.richardson@intel.com>", "To": "dev@dpdk.org", "Cc": "olivier.matz@6wind.com, jerin.jacob@caviumnetworks.com,\n\tBruce Richardson <bruce.richardson@intel.com>", "Date": "Fri, 30 Jun 2017 16:06:20 +0100", "Message-Id": "<20170630150621.156365-5-bruce.richardson@intel.com>", "X-Mailer": "git-send-email 2.13.0", "In-Reply-To": "<20170630150621.156365-1-bruce.richardson@intel.com>", "References": "<20170607133620.275801-1-bruce.richardson@intel.com>\n\t<20170630150621.156365-1-bruce.richardson@intel.com>", "Subject": "[dpdk-dev] [PATCH v2 4/5] test/test: add auto-tests for event ring\n\tfunctions", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "Precedence": "list", "List-Id": "DPDK patches and discussions <dev.dpdk.org>", "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://dpdk.org/ml/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "Add some basic tests for the event ring functions. Not everything needs\ntesting as there is so much code re-use from the rte_ring code.\n\nSigned-off-by: Bruce Richardson <bruce.richardson@intel.com>\n\n---\nV2: change name of static ring to avoid conflict with ring_autotest\n---\n test/test/Makefile | 1 +\n test/test/test_event_ring.c | 276 ++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 277 insertions(+)\n create mode 100644 test/test/test_event_ring.c", "diff": "diff --git a/test/test/Makefile b/test/test/Makefile\nindex ee240be46..e797c2094 100644\n--- a/test/test/Makefile\n+++ b/test/test/Makefile\n@@ -201,6 +201,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += test_cryptodev.c\n \n ifeq ($(CONFIG_RTE_LIBRTE_EVENTDEV),y)\n SRCS-y += test_eventdev.c\n+SRCS-y += test_event_ring.c\n SRCS-$(CONFIG_RTE_LIBRTE_PMD_SW_EVENTDEV) += test_eventdev_sw.c\n SRCS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX_SSOVF) += test_eventdev_octeontx.c\n endif\ndiff --git a/test/test/test_event_ring.c b/test/test/test_event_ring.c\nnew file mode 100644\nindex 000000000..c158c9b09\n--- /dev/null\n+++ b/test/test/test_event_ring.c\n@@ -0,0 +1,276 @@\n+/*-\n+ * BSD LICENSE\n+ *\n+ * Copyright(c) 2010-2017 Intel Corporation. All rights reserved.\n+ * All rights reserved.\n+ *\n+ * Redistribution and use in source and binary forms, with or without\n+ * modification, are permitted provided that the following conditions\n+ * are met:\n+ *\n+ * * Redistributions of source code must retain the above copyright\n+ * notice, this list of conditions and the following disclaimer.\n+ * * Redistributions in binary form must reproduce the above copyright\n+ * notice, this list of conditions and the following disclaimer in\n+ * the documentation and/or other materials provided with the\n+ * distribution.\n+ * * Neither the name of Intel Corporation nor the names of its\n+ * contributors may be used to endorse or promote products derived\n+ * from this software without specific prior written permission.\n+ *\n+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+ * \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+ */\n+\n+#include <string.h>\n+\n+#include <rte_event_ring.h>\n+\n+#include \"test.h\"\n+\n+/*\n+ * Event Ring\n+ * ===========\n+ *\n+ * Test some basic ops for the event rings.\n+ * Does not fully test everything, since most code is reused from rte_ring\n+ * library and tested as part of the normal ring autotests.\n+ */\n+\n+#define RING_SIZE 4096\n+#define MAX_BULK 32\n+\n+static struct rte_event_ring *r;\n+\n+/*\n+ * ensure failure to create ring with a bad ring size\n+ */\n+static int\n+test_event_ring_creation_with_wrong_size(void)\n+{\n+\tstruct rte_event_ring *rp = NULL;\n+\n+\t/* Test if ring size is not power of 2 */\n+\trp = rte_event_ring_create(\"test_bad_ring_size\", RING_SIZE + 1,\n+\t\t\tSOCKET_ID_ANY, 0);\n+\tif (rp != NULL)\n+\t\treturn -1;\n+\n+\t/* Test if ring size is exceeding the limit */\n+\trp = rte_event_ring_create(\"test_bad_ring_size\", (RTE_RING_SZ_MASK + 1),\n+\t\t\tSOCKET_ID_ANY, 0);\n+\tif (rp != NULL)\n+\t\treturn -1;\n+\treturn 0;\n+}\n+\n+/*\n+ * Test to check if a non-power-of-2 count causes the create\n+ * function to fail correctly\n+ */\n+static int\n+test_create_count_odd(void)\n+{\n+\tstruct rte_event_ring *r = rte_event_ring_create(\"test_event_ring_count\",\n+\t\t\t4097, SOCKET_ID_ANY, 0);\n+\tif (r != NULL)\n+\t\treturn -1;\n+\treturn 0;\n+}\n+\n+static int\n+test_lookup_null(void)\n+{\n+\tstruct rte_event_ring *rlp = rte_event_ring_lookup(\"ring_not_found\");\n+\tif (rlp == NULL && rte_errno != ENOENT) {\n+\t\tprintf(\"test failed to return error on null pointer\\n\");\n+\t\treturn -1;\n+\t}\n+\treturn 0;\n+}\n+\n+static int\n+test_basic_event_enqueue_dequeue(void)\n+{\n+\tstruct rte_event_ring *sr = NULL;\n+\tstruct rte_event evs[16];\n+\tuint16_t ret, free_count, used_count;\n+\n+\tmemset(evs, 0, sizeof(evs));\n+\tsr = rte_event_ring_create(\"spsc_ring\", 32, rte_socket_id(),\n+\t\t\tRING_F_SP_ENQ | RING_F_SC_DEQ);\n+\tif (sr == NULL) {\n+\t\tprintf(\"Failed to create sp/sc ring\\n\");\n+\t\treturn -1;\n+\t}\n+\tif (rte_event_ring_get_capacity(sr) != 31) {\n+\t\tprintf(\"Error, invalid capacity\\n\");\n+\t\tgoto error;\n+\t}\n+\n+\t/* test sp/sc ring */\n+\tif (rte_event_ring_count(sr) != 0) {\n+\t\tprintf(\"Error, ring not empty as expected\\n\");\n+\t\tgoto error;\n+\t}\n+\tif (rte_event_ring_free_count(sr) != rte_event_ring_get_capacity(sr)) {\n+\t\tprintf(\"Error, ring free count not as expected\\n\");\n+\t\tgoto error;\n+\t}\n+\n+\tret = rte_event_ring_enqueue_burst(sr, evs, RTE_DIM(evs), &free_count);\n+\tif (ret != RTE_DIM(evs) ||\n+\t\t\tfree_count != rte_event_ring_get_capacity(sr) - ret) {\n+\t\tprintf(\"Error, status after enqueue is unexpected\\n\");\n+\t\tgoto error;\n+\t}\n+\n+\tret = rte_event_ring_enqueue_burst(sr, evs, RTE_DIM(evs), &free_count);\n+\tif (ret != RTE_DIM(evs) - 1 ||\n+\t\t\tfree_count != 0) {\n+\t\tprintf(\"Error, status after enqueue is unexpected\\n\");\n+\t\tgoto error;\n+\t}\n+\n+\tret = rte_event_ring_dequeue_burst(sr, evs, RTE_DIM(evs), &used_count);\n+\tif (ret != RTE_DIM(evs) ||\n+\t\t\tused_count != rte_event_ring_get_capacity(sr) - ret) {\n+\t\tprintf(\"Error, status after enqueue is unexpected\\n\");\n+\t\tgoto error;\n+\t}\n+\tret = rte_event_ring_dequeue_burst(sr, evs, RTE_DIM(evs), &used_count);\n+\tif (ret != RTE_DIM(evs) - 1 ||\n+\t\t\tused_count != 0) {\n+\t\tprintf(\"Error, status after enqueue is unexpected\\n\");\n+\t\tgoto error;\n+\t}\n+\n+\trte_event_ring_free(sr);\n+\treturn 0;\n+error:\n+\trte_event_ring_free(sr);\n+\treturn -1;\n+}\n+\n+static int\n+test_event_ring_with_exact_size(void)\n+{\n+\tstruct rte_event_ring *std_ring, *exact_sz_ring;\n+\tstruct rte_event ev = { .mbuf = NULL };\n+\tstruct rte_event ev_array[16];\n+\tstatic const unsigned int ring_sz = RTE_DIM(ev_array);\n+\tunsigned int i;\n+\n+\tstd_ring = rte_event_ring_create(\"std\", ring_sz, rte_socket_id(),\n+\t\t\tRING_F_SP_ENQ | RING_F_SC_DEQ);\n+\tif (std_ring == NULL) {\n+\t\tprintf(\"%s: error, can't create std ring\\n\", __func__);\n+\t\treturn -1;\n+\t}\n+\texact_sz_ring = rte_event_ring_create(\"exact sz\",\n+\t\t\tring_sz, rte_socket_id(),\n+\t\t\tRING_F_SP_ENQ | RING_F_SC_DEQ | RING_F_EXACT_SZ);\n+\tif (exact_sz_ring == NULL) {\n+\t\tprintf(\"%s: error, can't create exact size ring\\n\", __func__);\n+\t\treturn -1;\n+\t}\n+\n+\t/*\n+\t * Check that the exact size ring is bigger than the standard ring\n+\t */\n+\tif (rte_event_ring_get_size(std_ring) >=\n+\t\t\trte_event_ring_get_size(exact_sz_ring)) {\n+\t\tprintf(\"%s: error, std ring (size: %u) is not smaller than exact size one (size %u)\\n\",\n+\t\t\t\t__func__,\n+\t\t\t\trte_event_ring_get_size(std_ring),\n+\t\t\t\trte_event_ring_get_size(exact_sz_ring));\n+\t\treturn -1;\n+\t}\n+\t/*\n+\t * check that the exact_sz_ring can hold one more element than the\n+\t * standard ring. (16 vs 15 elements)\n+\t */\n+\tfor (i = 0; i < ring_sz - 1; i++) {\n+\t\trte_event_ring_enqueue_burst(std_ring, &ev, 1, NULL);\n+\t\trte_event_ring_enqueue_burst(exact_sz_ring, &ev, 1, NULL);\n+\t}\n+\tif (rte_event_ring_enqueue_burst(std_ring, &ev, 1, NULL) != 0) {\n+\t\tprintf(\"%s: error, unexpected successful enqueue\\n\", __func__);\n+\t\treturn -1;\n+\t}\n+\tif (rte_event_ring_enqueue_burst(exact_sz_ring, &ev, 1, NULL) != 1) {\n+\t\tprintf(\"%s: error, enqueue failed\\n\", __func__);\n+\t\treturn -1;\n+\t}\n+\n+\t/* check that dequeue returns the expected number of elements */\n+\tif (rte_event_ring_dequeue_burst(exact_sz_ring, ev_array,\n+\t\t\tRTE_DIM(ev_array), NULL) != ring_sz) {\n+\t\tprintf(\"%s: error, failed to dequeue expected nb of elements\\n\",\n+\t\t\t\t__func__);\n+\t\treturn -1;\n+\t}\n+\n+\t/* check that the capacity function returns expected value */\n+\tif (rte_event_ring_get_capacity(exact_sz_ring) != ring_sz) {\n+\t\tprintf(\"%s: error, incorrect ring capacity reported\\n\",\n+\t\t\t\t__func__);\n+\t\treturn -1;\n+\t}\n+\n+\trte_event_ring_free(std_ring);\n+\trte_event_ring_free(exact_sz_ring);\n+\treturn 0;\n+}\n+\n+static int\n+test_event_ring(void)\n+{\n+\tif (r == NULL)\n+\t\tr = rte_event_ring_create(\"ev_test\", RING_SIZE,\n+\t\t\t\tSOCKET_ID_ANY, 0);\n+\tif (r == NULL)\n+\t\treturn -1;\n+\n+\t/* retrieve the ring from its name */\n+\tif (rte_event_ring_lookup(\"ev_test\") != r) {\n+\t\tprintf(\"Cannot lookup ring from its name\\n\");\n+\t\treturn -1;\n+\t}\n+\n+\t/* basic operations */\n+\tif (test_create_count_odd() < 0) {\n+\t\tprintf(\"Test failed to detect odd count\\n\");\n+\t\treturn -1;\n+\t}\n+\tprintf(\"Test detected odd count\\n\");\n+\n+\tif (test_lookup_null() < 0) {\n+\t\tprintf(\"Test failed to detect NULL ring lookup\\n\");\n+\t\treturn -1;\n+\t}\n+\tprintf(\"Test detected NULL ring lookup\\n\");\n+\n+\t/* test of creating ring with wrong size */\n+\tif (test_event_ring_creation_with_wrong_size() < 0)\n+\t\treturn -1;\n+\n+\tif (test_basic_event_enqueue_dequeue() < 0)\n+\t\treturn -1;\n+\n+\tif (test_event_ring_with_exact_size() < 0)\n+\t\treturn -1;\n+\n+\treturn 0;\n+}\n+\n+REGISTER_TEST_COMMAND(event_ring_autotest, test_event_ring);\n", "prefixes": [ "dpdk-dev", "v2", "4/5" ] }{ "id": 26109, "url": "