Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/40994/?format=api
http://patchwork.dpdk.org/api/patches/40994/?format=api", "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/e933ff5d55cc47a9d96c424ec7bc81825e6fc4b4.1528749451.git.anatoly.burakov@intel.com/", "project": { "id": 1, "url": "http://patchwork.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": "<e933ff5d55cc47a9d96c424ec7bc81825e6fc4b4.1528749451.git.anatoly.burakov@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/e933ff5d55cc47a9d96c424ec7bc81825e6fc4b4.1528749451.git.anatoly.burakov@intel.com", "date": "2018-06-11T20:55:41", "name": "[8/9] test: add fbarray autotests", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": true, "hash": "7ae780887efa852b3c7401b2a5e17ac5716251db", "submitter": { "id": 4, "url": "http://patchwork.dpdk.org/api/people/4/?format=api", "name": "Burakov, Anatoly", "email": "anatoly.burakov@intel.com" }, "delegate": { "id": 1, "url": "http://patchwork.dpdk.org/api/users/1/?format=api", "username": "tmonjalo", "first_name": "Thomas", "last_name": "Monjalon", "email": "thomas@monjalon.net" }, "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/e933ff5d55cc47a9d96c424ec7bc81825e6fc4b4.1528749451.git.anatoly.burakov@intel.com/mbox/", "series": [ { "id": 85, "url": "http://patchwork.dpdk.org/api/series/85/?format=api", "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=85", "date": "2018-06-11T20:55:33", "name": "mem: reduce memory fragmentation", "version": 1, "mbox": "http://patchwork.dpdk.org/series/85/mbox/" } ], "comments": "http://patchwork.dpdk.org/api/patches/40994/comments/", "check": "success", "checks": "http://patchwork.dpdk.org/api/patches/40994/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 [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 677981DEB2;\n\tMon, 11 Jun 2018 22:56:05 +0200 (CEST)", "from mga04.intel.com (mga04.intel.com [192.55.52.120])\n\tby dpdk.org (Postfix) with ESMTP id 8595A1DB16\n\tfor <dev@dpdk.org>; Mon, 11 Jun 2018 22:55:48 +0200 (CEST)", "from fmsmga007.fm.intel.com ([10.253.24.52])\n\tby fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t11 Jun 2018 13:55:45 -0700", "from irvmail001.ir.intel.com ([163.33.26.43])\n\tby fmsmga007.fm.intel.com with ESMTP; 11 Jun 2018 13:55:44 -0700", "from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com\n\t[10.237.217.45])\n\tby irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id\n\tw5BKthtK026389 for <dev@dpdk.org>; Mon, 11 Jun 2018 21:55:43 +0100", "from sivswdev01.ir.intel.com (localhost [127.0.0.1])\n\tby sivswdev01.ir.intel.com with ESMTP id w5BKthLT021624\n\tfor <dev@dpdk.org>; Mon, 11 Jun 2018 21:55:43 +0100", "(from aburakov@localhost)\n\tby sivswdev01.ir.intel.com with LOCAL id w5BKthQN021620\n\tfor dev@dpdk.org; Mon, 11 Jun 2018 21:55:43 +0100" ], "X-Amp-Result": "SKIPPED(no attachment in message)", "X-Amp-File-Uploaded": "False", "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.51,211,1526367600\"; d=\"scan'208\";a=\"46337847\"", "From": "Anatoly Burakov <anatoly.burakov@intel.com>", "To": "dev@dpdk.org", "Date": "Mon, 11 Jun 2018 21:55:41 +0100", "Message-Id": "<e933ff5d55cc47a9d96c424ec7bc81825e6fc4b4.1528749451.git.anatoly.burakov@intel.com>", "X-Mailer": "git-send-email 1.7.0.7", "In-Reply-To": [ "<cover.1528749451.git.anatoly.burakov@intel.com>", "<cover.1528749451.git.anatoly.burakov@intel.com>" ], "References": [ "<cover.1528749451.git.anatoly.burakov@intel.com>", "<cover.1528749451.git.anatoly.burakov@intel.com>" ], "Subject": "[dpdk-dev] [PATCH 8/9] test: add fbarray autotests", "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://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": "<https://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": "Introduce a suite of autotests to cover functionality of fbarray.\nThis will check for invalid parameters, check API return values and\nerrno codes, and will also do some basic functionality checks on the\nindexing code.\n\nSigned-off-by: Anatoly Burakov <anatoly.burakov@intel.com>\n---\n test/test/Makefile | 1 +\n test/test/test_fbarray.c | 576 +++++++++++++++++++++++++++++++++++++++\n 2 files changed, 577 insertions(+)\n create mode 100644 test/test/test_fbarray.c", "diff": "diff --git a/test/test/Makefile b/test/test/Makefile\nindex eccc8efcf..41eab00e7 100644\n--- a/test/test/Makefile\n+++ b/test/test/Makefile\n@@ -70,6 +70,7 @@ SRCS-y += test_memzone.c\n SRCS-y += test_bitmap.c\n SRCS-y += test_reciprocal_division.c\n SRCS-y += test_reciprocal_division_perf.c\n+SRCS-y += test_fbarray.c\n \n SRCS-y += test_ring.c\n SRCS-y += test_ring_perf.c\ndiff --git a/test/test/test_fbarray.c b/test/test/test_fbarray.c\nnew file mode 100644\nindex 000000000..8c44e2c7e\n--- /dev/null\n+++ b/test/test/test_fbarray.c\n@@ -0,0 +1,576 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2010-2014 Intel Corporation\n+ */\n+\n+#include <stdio.h>\n+#include <stdint.h>\n+#include <limits.h>\n+\n+#include <rte_common.h>\n+#include <rte_debug.h>\n+#include <rte_errno.h>\n+#include <rte_fbarray.h>\n+\n+#include \"test.h\"\n+\n+struct fbarray_testsuite_params {\n+\tstruct rte_fbarray arr;\n+\tint start;\n+\tint end;\n+};\n+\n+static struct fbarray_testsuite_params param;\n+\n+#define FBARRAY_TEST_ARR_NAME \"fbarray_autotest\"\n+#define FBARRAY_TEST_LEN 256\n+#define FBARRAY_TEST_ELT_SZ (sizeof(int))\n+\n+static int autotest_setup(void)\n+{\n+\treturn rte_fbarray_init(¶m.arr, FBARRAY_TEST_ARR_NAME,\n+\t\t\tFBARRAY_TEST_LEN, FBARRAY_TEST_ELT_SZ);\n+}\n+\n+static void autotest_teardown(void)\n+{\n+\trte_fbarray_destroy(¶m.arr);\n+}\n+\n+static int init_array(void)\n+{\n+\tint i;\n+\tfor (i = param.start; i <= param.end; i++) {\n+\t\tif (rte_fbarray_set_used(¶m.arr, i))\n+\t\t\treturn -1;\n+\t}\n+\treturn 0;\n+}\n+\n+static void reset_array(void)\n+{\n+\tint i;\n+\tfor (i = 0; i < FBARRAY_TEST_LEN; i++)\n+\t\trte_fbarray_set_free(¶m.arr, i);\n+}\n+\n+static int first_msk_test_setup(void)\n+{\n+\t/* put all within first mask */\n+\tparam.start = 3;\n+\tparam.end = 10;\n+\treturn init_array();\n+}\n+\n+static int cross_msk_test_setup(void)\n+{\n+\t/* put all within second and third mask */\n+\tparam.start = 70;\n+\tparam.end = 160;\n+\treturn init_array();\n+}\n+\n+static int multi_msk_test_setup(void)\n+{\n+\t/* put all within first and last mask */\n+\tparam.start = 3;\n+\tparam.end = FBARRAY_TEST_LEN - 20;\n+\treturn init_array();\n+}\n+\n+static int last_msk_test_setup(void)\n+{\n+\t/* put all within last mask */\n+\tparam.start = FBARRAY_TEST_LEN - 20;\n+\tparam.end = FBARRAY_TEST_LEN - 1;\n+\treturn init_array();\n+}\n+\n+static int full_msk_test_setup(void)\n+{\n+\t/* fill entire mask */\n+\tparam.start = 0;\n+\tparam.end = FBARRAY_TEST_LEN - 1;\n+\treturn init_array();\n+}\n+\n+static int empty_msk_test_setup(void)\n+{\n+\t/* do not fill anything in */\n+\treset_array();\n+\treturn 0;\n+}\n+\n+static int test_invalid(void)\n+{\n+\tstruct rte_fbarray dummy;\n+\n+\t/* invalid parameters */\n+\tTEST_ASSERT_FAIL(rte_fbarray_attach(NULL),\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\tTEST_ASSERT_FAIL(rte_fbarray_detach(NULL),\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\n+\tTEST_ASSERT_FAIL(rte_fbarray_destroy(NULL),\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno valuey\\n\");\n+\tTEST_ASSERT_FAIL(rte_fbarray_init(NULL, \"fail\", 16, 16),\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\tTEST_ASSERT_FAIL(rte_fbarray_init(&dummy, NULL, 16, 16),\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\tTEST_ASSERT_FAIL(rte_fbarray_init(&dummy, \"fail\", 0, 16),\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\tTEST_ASSERT_FAIL(rte_fbarray_init(&dummy, \"fail\", 16, 0),\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\t/* len must not be greater than INT_MAX */\n+\tTEST_ASSERT_FAIL(rte_fbarray_init(&dummy, \"fail\", INT_MAX + 1U, 16),\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\n+\tTEST_ASSERT_NULL(rte_fbarray_get(NULL, 0),\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\tTEST_ASSERT(rte_fbarray_find_idx(NULL, 0) < 0,\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\tTEST_ASSERT(rte_fbarray_set_free(NULL, 0),\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\tTEST_ASSERT(rte_fbarray_set_used(NULL, 0),\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\tTEST_ASSERT(rte_fbarray_find_contig_free(NULL, 0) < 0,\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\tTEST_ASSERT(rte_fbarray_find_contig_used(NULL, 0) < 0,\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\tTEST_ASSERT(rte_fbarray_find_rev_contig_free(NULL, 0) < 0,\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\tTEST_ASSERT(rte_fbarray_find_rev_contig_used(NULL, 0) < 0,\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\tTEST_ASSERT(rte_fbarray_find_next_free(NULL, 0) < 0,\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\tTEST_ASSERT(rte_fbarray_find_next_used(NULL, 0) < 0,\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\tTEST_ASSERT(rte_fbarray_find_prev_free(NULL, 0) < 0,\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\tTEST_ASSERT(rte_fbarray_find_prev_used(NULL, 0) < 0,\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\tTEST_ASSERT(rte_fbarray_find_next_n_free(NULL, 0, 0) < 0,\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\tTEST_ASSERT(rte_fbarray_find_next_n_used(NULL, 0, 0) < 0,\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\tTEST_ASSERT(rte_fbarray_find_prev_n_free(NULL, 0, 0) < 0,\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\tTEST_ASSERT(rte_fbarray_find_prev_n_used(NULL, 0, 0) < 0,\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\tTEST_ASSERT(rte_fbarray_is_used(NULL, 0) < 0,\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\n+\tTEST_ASSERT_SUCCESS(rte_fbarray_init(&dummy, \"success\",\n+\t\t\tFBARRAY_TEST_LEN, 8),\n+\t\t\t\"Failed to initialize valid fbarray\\n\");\n+\n+\t/* test API for handling invalid parameters with a valid fbarray */\n+\tTEST_ASSERT_NULL(rte_fbarray_get(&dummy, FBARRAY_TEST_LEN),\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\n+\tTEST_ASSERT(rte_fbarray_find_idx(&dummy, NULL) < 0,\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\n+\tTEST_ASSERT(rte_fbarray_set_free(&dummy, FBARRAY_TEST_LEN),\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\n+\tTEST_ASSERT(rte_fbarray_set_used(&dummy, FBARRAY_TEST_LEN),\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\n+\tTEST_ASSERT(rte_fbarray_find_contig_free(&dummy, FBARRAY_TEST_LEN) < 0,\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\n+\tTEST_ASSERT(rte_fbarray_find_contig_used(&dummy, FBARRAY_TEST_LEN) < 0,\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\n+\tTEST_ASSERT(rte_fbarray_find_rev_contig_free(&dummy,\n+\t\t\tFBARRAY_TEST_LEN) < 0,\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\n+\tTEST_ASSERT(rte_fbarray_find_rev_contig_used(&dummy,\n+\t\t\tFBARRAY_TEST_LEN) < 0,\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\n+\tTEST_ASSERT(rte_fbarray_find_next_free(&dummy, FBARRAY_TEST_LEN) < 0,\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\n+\tTEST_ASSERT(rte_fbarray_find_next_used(&dummy, FBARRAY_TEST_LEN) < 0,\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\n+\tTEST_ASSERT(rte_fbarray_find_prev_free(&dummy, FBARRAY_TEST_LEN) < 0,\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\n+\tTEST_ASSERT(rte_fbarray_find_prev_used(&dummy, FBARRAY_TEST_LEN) < 0,\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\n+\tTEST_ASSERT(rte_fbarray_find_next_n_free(&dummy,\n+\t\t\tFBARRAY_TEST_LEN, 1) < 0,\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\tTEST_ASSERT(rte_fbarray_find_next_n_free(&dummy, 0,\n+\t\t\tFBARRAY_TEST_LEN + 1) < 0,\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\tTEST_ASSERT(rte_fbarray_find_next_n_free(&dummy, 0, 0) < 0,\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\n+\tTEST_ASSERT(rte_fbarray_find_next_n_used(&dummy,\n+\t\t\tFBARRAY_TEST_LEN, 1) < 0,\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\tTEST_ASSERT(rte_fbarray_find_next_n_used(&dummy, 0,\n+\t\t\tFBARRAY_TEST_LEN + 1) < 0,\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\tTEST_ASSERT(rte_fbarray_find_next_n_used(&dummy, 0, 0) < 0,\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\n+\tTEST_ASSERT(rte_fbarray_find_prev_n_free(&dummy,\n+\t\t\tFBARRAY_TEST_LEN, 1) < 0,\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\tTEST_ASSERT(rte_fbarray_find_prev_n_free(&dummy, 0,\n+\t\t\tFBARRAY_TEST_LEN + 1) < 0,\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\tTEST_ASSERT(rte_fbarray_find_prev_n_free(&dummy, 0, 0) < 0,\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\n+\tTEST_ASSERT(rte_fbarray_find_prev_n_used(&dummy,\n+\t\t\tFBARRAY_TEST_LEN, 1) < 0,\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\tTEST_ASSERT(rte_fbarray_find_prev_n_used(&dummy, 0,\n+\t\t\tFBARRAY_TEST_LEN + 1) < 0,\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\tTEST_ASSERT(rte_fbarray_find_prev_n_used(&dummy, 0, 0) < 0,\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\n+\tTEST_ASSERT(rte_fbarray_is_used(&dummy, FBARRAY_TEST_LEN) < 0,\n+\t\t\t\"Call succeeded with invalid parameters\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, EINVAL, \"Wrong errno value\\n\");\n+\n+\tTEST_ASSERT_SUCCESS(rte_fbarray_destroy(&dummy),\n+\t\t\t\"Failed to destroy valid fbarray\\n\");\n+\n+\treturn TEST_SUCCESS;\n+}\n+\n+static int check_free(void)\n+{\n+\tconst int idx = 0;\n+\tconst int last_idx = FBARRAY_TEST_LEN - 1;\n+\n+\t/* ensure we can find a free spot */\n+\tTEST_ASSERT_EQUAL(rte_fbarray_find_next_free(¶m.arr, idx), idx,\n+\t\t\t\"Free space not found where expected\\n\");\n+\tTEST_ASSERT_EQUAL(rte_fbarray_find_next_n_free(¶m.arr, idx, 1), idx,\n+\t\t\t\"Free space not found where expected\\n\");\n+\tTEST_ASSERT_EQUAL(rte_fbarray_find_contig_free(¶m.arr, idx),\n+\t\t\tFBARRAY_TEST_LEN,\n+\t\t\t\"Free space not found where expected\\n\");\n+\n+\tTEST_ASSERT_EQUAL(rte_fbarray_find_prev_free(¶m.arr, idx), idx,\n+\t\t\t\"Free space not found where expected\\n\");\n+\tTEST_ASSERT_EQUAL(rte_fbarray_find_prev_n_free(¶m.arr, idx, 1), idx,\n+\t\t\t\"Free space not found where expected\\n\");\n+\tTEST_ASSERT_EQUAL(rte_fbarray_find_rev_contig_free(¶m.arr, idx), 1,\n+\t\t\t\"Free space not found where expected\\n\");\n+\n+\tTEST_ASSERT_EQUAL(rte_fbarray_find_prev_free(¶m.arr, last_idx),\n+\t\t\tlast_idx, \"Free space not found where expected\\n\");\n+\tTEST_ASSERT_EQUAL(rte_fbarray_find_prev_n_free(¶m.arr, last_idx, 1),\n+\t\t\tlast_idx, \"Free space not found where expected\\n\");\n+\tTEST_ASSERT_EQUAL(rte_fbarray_find_rev_contig_free(¶m.arr,\n+\t\t\tlast_idx), FBARRAY_TEST_LEN,\n+\t\t\t\"Free space not found where expected\\n\");\n+\n+\t/* ensure we can't find any used spots */\n+\tTEST_ASSERT(rte_fbarray_find_next_used(¶m.arr, idx) < 0,\n+\t\t\t\"Used space found where none was expected\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, ENOENT, \"Wrong errno value\\n\");\n+\tTEST_ASSERT(rte_fbarray_find_next_n_used(¶m.arr, idx, 1) < 0,\n+\t\t\t\"Used space found where none was expected\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, ENOENT, \"Wrong errno value\\n\");\n+\tTEST_ASSERT_EQUAL(rte_fbarray_find_contig_used(¶m.arr, idx), 0,\n+\t\t\t\"Used space found where none was expected\\n\");\n+\n+\tTEST_ASSERT(rte_fbarray_find_prev_used(¶m.arr, last_idx) < 0,\n+\t\t\t\"Used space found where none was expected\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, ENOENT, \"Wrong errno value\\n\");\n+\tTEST_ASSERT(rte_fbarray_find_prev_n_used(¶m.arr, last_idx, 1) < 0,\n+\t\t\t\"Used space found where none was expected\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, ENOENT, \"Wrong errno value\\n\");\n+\tTEST_ASSERT_EQUAL(rte_fbarray_find_rev_contig_used(¶m.arr,\n+\t\t\tlast_idx), 0,\n+\t\t\t\"Used space found where none was expected\\n\");\n+\n+\treturn 0;\n+}\n+\n+static int check_used_one(void)\n+{\n+\tconst int idx = 0;\n+\tconst int last_idx = FBARRAY_TEST_LEN - 1;\n+\n+\t/* check that we can find used spots now */\n+\tTEST_ASSERT_EQUAL(rte_fbarray_find_next_used(¶m.arr, idx), idx,\n+\t\t\t\"Used space not found where expected\\n\");\n+\tTEST_ASSERT_EQUAL(rte_fbarray_find_next_n_used(¶m.arr, idx, 1), idx,\n+\t\t\t\"Used space not found where expected\\n\");\n+\tTEST_ASSERT_EQUAL(rte_fbarray_find_contig_used(¶m.arr, idx), 1,\n+\t\t\t\"Used space not found where expected\\n\");\n+\n+\tTEST_ASSERT_EQUAL(rte_fbarray_find_prev_used(¶m.arr, last_idx), idx,\n+\t\t\t\"Used space not found where expected\\n\");\n+\tTEST_ASSERT_EQUAL(rte_fbarray_find_prev_n_used(¶m.arr, last_idx, 1),\n+\t\t\tidx, \"Used space not found where expected\\n\");\n+\tTEST_ASSERT_EQUAL(rte_fbarray_find_rev_contig_used(¶m.arr, idx), 1,\n+\t\t\t\"Used space not found where expected\\n\");\n+\tTEST_ASSERT_EQUAL(rte_fbarray_find_rev_contig_used(¶m.arr,\n+\t\t\tlast_idx), idx,\n+\t\t\t\"Used space not found where expected\\n\");\n+\n+\t/* check if further indices are still free */\n+\tTEST_ASSERT(rte_fbarray_find_next_used(¶m.arr, idx + 1) < 0,\n+\t\t\t\"Used space not found where none was expected\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, ENOENT, \"Wrong errno value\\n\");\n+\tTEST_ASSERT(rte_fbarray_find_next_n_used(¶m.arr, idx + 1, 1) < 0,\n+\t\t\t\"Used space not found where none was expected\\n\");\n+\tTEST_ASSERT_EQUAL(rte_errno, ENOENT, \"Wrong errno value\\n\");\n+\tTEST_ASSERT_EQUAL(rte_fbarray_find_contig_used(¶m.arr, idx + 1), 0,\n+\t\t\t\"Used space not found where none was expected\\n\");\n+\tTEST_ASSERT_EQUAL(rte_fbarray_find_contig_free(¶m.arr, idx + 1),\n+\t\t\tFBARRAY_TEST_LEN - 1,\n+\t\t\t\"Used space not found where none was expected\\n\");\n+\n+\tTEST_ASSERT_EQUAL(rte_fbarray_find_prev_used(¶m.arr, last_idx), 0,\n+\t\t\t\"Used space not found where none was expected\\n\");\n+\tTEST_ASSERT_EQUAL(rte_fbarray_find_prev_n_used(¶m.arr, last_idx, 1),\n+\t\t\t0, \"Used space not found where none was expected\\n\");\n+\tTEST_ASSERT_EQUAL(rte_fbarray_find_rev_contig_used(¶m.arr,\n+\t\t\tlast_idx), 0,\n+\t\t\t\"Used space not found where none was expected\\n\");\n+\tTEST_ASSERT_EQUAL(rte_fbarray_find_rev_contig_free(¶m.arr,\n+\t\t\tlast_idx), FBARRAY_TEST_LEN - 1,\n+\t\t\t\"Used space not found where none was expected\\n\");\n+\n+\treturn 0;\n+}\n+\n+static int test_basic(void)\n+{\n+\tconst int idx = 0;\n+\tint i;\n+\n+\t/* check array count */\n+\tTEST_ASSERT_EQUAL(param.arr.count, 0, \"Wrong element count\\n\");\n+\n+\t/* ensure we can find a free spot */\n+\tif (check_free())\n+\t\treturn TEST_FAILED;\n+\n+\t/* check if used */\n+\tTEST_ASSERT_EQUAL(rte_fbarray_is_used(¶m.arr, idx), 0,\n+\t\t\t\"Used space found where not expected\\n\");\n+\n+\t/* mark as used */\n+\tTEST_ASSERT_SUCCESS(rte_fbarray_set_used(¶m.arr, idx),\n+\t\t\t\"Failed to set as used\\n\");\n+\n+\t/* check if used again */\n+\tTEST_ASSERT_NOT_EQUAL(rte_fbarray_is_used(¶m.arr, idx), 0,\n+\t\t\t\"Used space not found where expected\\n\");\n+\n+\tif (check_used_one())\n+\t\treturn TEST_FAILED;\n+\n+\t/* check array count */\n+\tTEST_ASSERT_EQUAL(param.arr.count, 1, \"Wrong element count\\n\");\n+\n+\t/* check if getting pointers works for every element */\n+\tfor (i = 0; i < FBARRAY_TEST_LEN; i++) {\n+\t\tvoid *td = rte_fbarray_get(¶m.arr, i);\n+\t\tTEST_ASSERT_NOT_NULL(td, \"Invalid pointer returned\\n\");\n+\t\tTEST_ASSERT_EQUAL(rte_fbarray_find_idx(¶m.arr, td), i,\n+\t\t\t\t\"Wrong index returned\\n\");\n+\t}\n+\n+\t/* mark as free */\n+\tTEST_ASSERT_SUCCESS(rte_fbarray_set_free(¶m.arr, idx),\n+\t\t\t\"Failed to set as free\\n\");\n+\n+\t/* check array count */\n+\tTEST_ASSERT_EQUAL(param.arr.count, 0, \"Wrong element count\\n\");\n+\n+\t/* check if used */\n+\tTEST_ASSERT_EQUAL(rte_fbarray_is_used(¶m.arr, idx), 0,\n+\t\t\t\"Used space found where not expected\\n\");\n+\n+\tif (check_free())\n+\t\treturn TEST_FAILED;\n+\n+\treset_array();\n+\n+\treturn TEST_SUCCESS;\n+}\n+\n+static int ensure_correct(struct rte_fbarray *arr, int first, int last,\n+\t\tbool used)\n+{\n+\tint i, len = last - first + 1;\n+\tfor (i = 0; i < len; i++) {\n+\t\tint cur = first + i;\n+\t\tint cur_len = len - i;\n+\n+\t\tif (used) {\n+\t\t\tTEST_ASSERT_EQUAL(rte_fbarray_find_contig_used(arr,\n+\t\t\t\t\tcur), cur_len,\n+\t\t\t\t\t\"Used space length is wrong\\n\");\n+\t\t\tTEST_ASSERT_EQUAL(rte_fbarray_find_rev_contig_used(arr,\n+\t\t\t\t\tlast), len,\n+\t\t\t\t\t\"Used space length is wrong\\n\");\n+\t\t\tTEST_ASSERT_EQUAL(rte_fbarray_find_rev_contig_used(arr,\n+\t\t\t\t\tcur), i + 1,\n+\t\t\t\t\t\"Used space length is wrong\\n\");\n+\n+\t\t\tTEST_ASSERT_EQUAL(rte_fbarray_find_next_used(arr, cur),\n+\t\t\t\t\tcur,\n+\t\t\t\t\t\"Used space not found where expected\\n\");\n+\t\t\tTEST_ASSERT_EQUAL(rte_fbarray_find_next_n_used(arr,\n+\t\t\t\t\tcur, 1), cur,\n+\t\t\t\t\t\"Used space not found where expected\\n\");\n+\t\t\tTEST_ASSERT_EQUAL(rte_fbarray_find_next_n_used(arr, cur,\n+\t\t\t\t\tcur_len), cur,\n+\t\t\t\t\t\"Used space not found where expected\\n\");\n+\n+\t\t\tTEST_ASSERT_EQUAL(rte_fbarray_find_prev_used(arr, cur),\n+\t\t\t\t\tcur,\n+\t\t\t\t\t\"Used space not found where expected\\n\");\n+\t\t\tTEST_ASSERT_EQUAL(rte_fbarray_find_prev_n_used(arr,\n+\t\t\t\t\tlast, cur_len), cur,\n+\t\t\t\t\t\"Used space not found where expected\\n\");\n+\t\t} else {\n+\t\t\tTEST_ASSERT_EQUAL(rte_fbarray_find_contig_free(arr,\n+\t\t\t\t\tcur), cur_len,\n+\t\t\t\t\t\"Free space length is wrong\\n\");\n+\t\t\tTEST_ASSERT_EQUAL(rte_fbarray_find_rev_contig_free(arr,\n+\t\t\t\t\tlast), len,\n+\t\t\t\t\t\"Free space length is wrong\\n\");\n+\t\t\tTEST_ASSERT_EQUAL(rte_fbarray_find_rev_contig_free(arr,\n+\t\t\t\t\tcur), i + 1,\n+\t\t\t\t\t\"Free space length is wrong\\n\");\n+\n+\t\t\tTEST_ASSERT_EQUAL(rte_fbarray_find_next_free(arr, cur),\n+\t\t\t\t\tcur,\n+\t\t\t\t\t\"Free space not found where expected\\n\");\n+\t\t\tTEST_ASSERT_EQUAL(rte_fbarray_find_next_n_free(arr, cur,\n+\t\t\t\t\t1), cur,\n+\t\t\t\t\t\"Free space not found where expected\\n\");\n+\t\t\tTEST_ASSERT_EQUAL(rte_fbarray_find_next_n_free(arr, cur,\n+\t\t\t\t\tcur_len), cur,\n+\t\t\t\t\t\"Free space not found where expected\\n\");\n+\n+\t\t\tTEST_ASSERT_EQUAL(rte_fbarray_find_prev_free(arr, cur),\n+\t\t\t\t\tcur,\n+\t\t\t\t\t\"Free space not found where expected\\n\");\n+\t\t\tTEST_ASSERT_EQUAL(rte_fbarray_find_prev_n_free(arr,\n+\t\t\t\t\tlast, cur_len), cur,\n+\t\t\t\t\t\"Free space not found where expected\\n\");\n+\t\t}\n+\t}\n+\treturn 0;\n+}\n+\n+static int test_find(void)\n+{\n+\tTEST_ASSERT_EQUAL((int)param.arr.count, param.end - param.start + 1,\n+\t\t\t\"Wrong element count\\n\");\n+\t/* ensure space is free before start */\n+\tif (ensure_correct(¶m.arr, 0, param.start - 1, false))\n+\t\treturn TEST_FAILED;\n+\t/* ensure space is occupied where it's supposed to be */\n+\tif (ensure_correct(¶m.arr, param.start, param.end, true))\n+\t\treturn TEST_FAILED;\n+\t/* ensure space after end is free as well */\n+\tif (ensure_correct(¶m.arr, param.end + 1, FBARRAY_TEST_LEN - 1,\n+\t\t\tfalse))\n+\t\treturn TEST_FAILED;\n+\treturn TEST_SUCCESS;\n+}\n+\n+static int test_empty(void)\n+{\n+\tTEST_ASSERT_EQUAL((int)param.arr.count, 0, \"Wrong element count\\n\");\n+\t/* ensure space is free */\n+\tif (ensure_correct(¶m.arr, 0, FBARRAY_TEST_LEN - 1, false))\n+\t\treturn TEST_FAILED;\n+\treturn TEST_SUCCESS;\n+}\n+\n+\n+static struct unit_test_suite fbarray_test_suite = {\n+\t.suite_name = \"fbarray autotest\",\n+\t.setup = autotest_setup,\n+\t.teardown = autotest_teardown,\n+\t.unit_test_cases = {\n+\t\tTEST_CASE(test_invalid),\n+\t\tTEST_CASE(test_basic),\n+\t\tTEST_CASE_ST(first_msk_test_setup, reset_array, test_find),\n+\t\tTEST_CASE_ST(cross_msk_test_setup, reset_array, test_find),\n+\t\tTEST_CASE_ST(multi_msk_test_setup, reset_array, test_find),\n+\t\tTEST_CASE_ST(last_msk_test_setup, reset_array, test_find),\n+\t\tTEST_CASE_ST(full_msk_test_setup, reset_array, test_find),\n+\t\tTEST_CASE_ST(empty_msk_test_setup, reset_array, test_empty),\n+\t\tTEST_CASES_END()\n+\t}\n+};\n+\n+static int\n+test_fbarray(void)\n+{\n+\treturn unit_test_suite_runner(&fbarray_test_suite);\n+}\n+\n+REGISTER_TEST_COMMAND(fbarray_autotest, test_fbarray);\n", "prefixes": [ "8/9" ] }{ "id": 40994, "url": "