get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 68069,
    "url": "http://patches.dpdk.org/api/patches/68069/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20200409172502.1693-6-l.wojciechow@partner.samsung.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": "<20200409172502.1693-6-l.wojciechow@partner.samsung.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20200409172502.1693-6-l.wojciechow@partner.samsung.com",
    "date": "2020-04-09T17:24:54",
    "name": "[v3,05/13] app/test: introduce librte security tests",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "41b4ac8d9891c0b6a6cd168b7820f3fe0ffe40b6",
    "submitter": {
        "id": 1628,
        "url": "http://patches.dpdk.org/api/people/1628/?format=api",
        "name": "Lukasz Wojciechowski",
        "email": "l.wojciechow@partner.samsung.com"
    },
    "delegate": {
        "id": 6690,
        "url": "http://patches.dpdk.org/api/users/6690/?format=api",
        "username": "akhil",
        "first_name": "akhil",
        "last_name": "goyal",
        "email": "gakhil@marvell.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20200409172502.1693-6-l.wojciechow@partner.samsung.com/mbox/",
    "series": [
        {
            "id": 9272,
            "url": "http://patches.dpdk.org/api/series/9272/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=9272",
            "date": "2020-04-09T17:24:49",
            "name": "Fixes and unit tests for librte_security",
            "version": 3,
            "mbox": "http://patches.dpdk.org/series/9272/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/68069/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/68069/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 3B9DEA0597;\n\tThu,  9 Apr 2020 19:26:36 +0200 (CEST)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 6121F1D40B;\n\tThu,  9 Apr 2020 19:25:43 +0200 (CEST)",
            "from mailout1.w1.samsung.com (mailout1.w1.samsung.com\n [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id 117F81C437\n for <dev@dpdk.org>; Thu,  9 Apr 2020 19:25:34 +0200 (CEST)",
            "from eucas1p1.samsung.com (unknown [182.198.249.206])\n by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id\n 20200409172534euoutp01311465a95bffb69d26b4693103ad1844~ENrh6WQud0978309783euoutp01t\n for <dev@dpdk.org>; Thu,  9 Apr 2020 17:25:34 +0000 (GMT)",
            "from eusmges1new.samsung.com (unknown [203.254.199.242]) by\n eucas1p2.samsung.com (KnoxPortal) with ESMTP id\n 20200409172534eucas1p2099daf82245f993879db947d5d79fc62~ENrhyEc711612816128eucas1p2E\n for <dev@dpdk.org>; Thu,  9 Apr 2020 17:25:34 +0000 (GMT)",
            "from eucas1p1.samsung.com ( [182.198.249.206]) by\n eusmges1new.samsung.com (EUCPMTA) with SMTP id D3.F2.61286.E8A5F8E5; Thu,  9\n Apr 2020 18:25:34 +0100 (BST)",
            "from eusmtrp1.samsung.com (unknown [182.198.249.138]) by\n eucas1p1.samsung.com (KnoxPortal) with ESMTPA id\n 20200409172533eucas1p1f4363aa89cfbda87e5d20da1006e21c0~ENrgyXlqu0987109871eucas1p1o\n for <dev@dpdk.org>; Thu,  9 Apr 2020 17:25:33 +0000 (GMT)",
            "from eusmgms1.samsung.com (unknown [182.198.249.179]) by\n eusmtrp1.samsung.com (KnoxPortal) with ESMTP id\n 20200409172533eusmtrp11239e15c2ef2d6275bc55cb5b6292c88~ENrgx4gFP2463624636eusmtrp1H\n for <dev@dpdk.org>; Thu,  9 Apr 2020 17:25:33 +0000 (GMT)",
            "from eusmtip1.samsung.com ( [203.254.199.221]) by\n eusmgms1.samsung.com (EUCPMTA) with SMTP id CC.B9.08375.D8A5F8E5; Thu,  9\n Apr 2020 18:25:33 +0100 (BST)",
            "from localhost.localdomain (unknown [106.210.88.70]) by\n eusmtip1.samsung.com (KnoxPortal) with ESMTPA id\n 20200409172532eusmtip1e2d21e889fa9bb6326009d6211ecce29~ENrft6aOi1096110961eusmtip1q\n for <dev@dpdk.org>; Thu,  9 Apr 2020 17:25:32 +0000 (GMT)"
        ],
        "DKIM-Filter": "OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com\n 20200409172534euoutp01311465a95bffb69d26b4693103ad1844~ENrh6WQud0978309783euoutp01t",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com;\n s=mail20170921; t=1586453134;\n bh=WrcdDMMRND8v2u1ONiKug0Uemv1+AJ6IvTjxmpvaYco=;\n h=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n b=Lq9Pef6qMslK4PkHv8v0o6ZK0x3B5/bZUz/iOqwdaXKVKwo1Cuebu1/BBhQBo3Ctr\n x9LguAlpsz0a4M56hbRmpIV+FkcaG8v0hbRZYrjRPLUQKXmbWfO14VHzIUCX/oNfK7\n iu7f2rWTjwsQmUHoSsdbErvOZf4eNydJPgW7Pkzg=",
        "X-AuditID": "cbfec7f2-f0bff7000001ef66-34-5e8f5a8ef17b",
        "From": "Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>",
        "To": "",
        "Cc": "dev@dpdk.org",
        "Date": "Thu,  9 Apr 2020 19:24:54 +0200",
        "Message-Id": "<20200409172502.1693-6-l.wojciechow@partner.samsung.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<20200409172502.1693-1-l.wojciechow@partner.samsung.com>",
        "X-Brightmail-Tracker": [
            "\n H4sIAAAAAAAAA+NgFjrDIsWRmVeSWpSXmKPExsWy7djPc7p9Uf1xBrc/yFm8+7SdyYHR49eC\n pawBjFFcNimpOZllqUX6dglcGSumihQ82s9YsWBxL3sD4+T5jF2MnBwSAiYST54+Yuti5OIQ\n EljBKPHpwmxWCKedSWLS26NQThuTxMTJD1hgWubP/QrWLiSwnFHi21IPuKLWyffBEmwCthJH\n Zn5lBbFFBFgkVn7/DtbMLCAg8fjeM7C4sICzxJ2528DiLAKqEpevTWEDsXkFXCR2bGpghlgm\n L7F6wwEwm1PAVeLW8UvMIMskBFawScz8PIkNoshFom3KLyYIW1ji1fEt7BC2jMTpyT0sEA3b\n GCWu/v7JCOHsZ5S43rsCqspa4vC/30CTOIDO05RYv0sfIuwo8e31TiaQsIQAn8SNt4IQD/BJ\n TNo2nRkizCvR0SYEUa0n8bRnKiPM2j9rn0ADy0Oi/cV/dkgAXWaU+DvnCdsERvlZCMsWMDKu\n YhRPLS3OTU8tNsxLLdcrTswtLs1L10vOz93ECIzj0/+Of9rB+PVS0iFGAQ5GJR5eA4b+OCHW\n xLLiytxDjBIczEoivN5NvXFCvCmJlVWpRfnxRaU5qcWHGKU5WJTEeY0XvYwVEkhPLEnNTk0t\n SC2CyTJxcEo1MG7T6fy2acF+119LCnwMZh4MmW//I/zMOpPeL346B2zPeHXnrRGe9kr82b6V\n v5cEpTIWF97dkrjvqtf2ZzEP5JO1xHS2tG/aHNx46/OtT/y9V02bT/4/FS5g3rZ8bcXOrzU/\n Ksyz7PlfLGBcK9Q6lev8jF3Tj6bKfLWTcW0U8tT8WvTu2NtNm0OUWIozEg21mIuKEwFO4sKt\n 3wIAAA==",
            "\n H4sIAAAAAAAAA+NgFlrDLMWRmVeSWpSXmKPExsVy+t/xu7q9Uf1xBrfPSVm8+7SdyYHR49eC\n pawBjFF6NkX5pSWpChn5xSW2StGGFkZ6hpYWekYmlnqGxuaxVkamSvp2NimpOZllqUX6dgl6\n GSumihQ82s9YsWBxL3sD4+T5jF2MnBwSAiYS8+d+BbK5OIQEljJKzDzbx9TFyAGUkJH4cEkA\n okZY4s+1LjaImhYmicPfrzCBJNgEbCWOzPzKCmKLCLBIrPz+nQXEZhYQkHh87xlYXFjAWeLO\n 3G1gcRYBVYnL16awgdi8Ai4SOzY1MEMskJdYveEAmM0p4Cpx6/glMFtIoF7idtcfxgmMfAsY\n GVYxiqSWFuem5xYb6hUn5haX5qXrJefnbmIEhtS2Yz8372C8tDH4EKMAB6MSD68BQ3+cEGti\n WXFl7iFGCQ5mJRFe76beOCHelMTKqtSi/Pii0pzU4kOMpkBHTWSWEk3OB4Z7Xkm8oamhuYWl\n obmxubGZhZI4b4fAwRghgfTEktTs1NSC1CKYPiYOTqkGRs4N1x63stR8VDGWMLdJ4vl4KkB5\n 6hqpXeIidZa69YsZPkb87/ZgXnxocdTPYq1QxnoPPfaNO+bPF8u/ErvuU7PKt/1KXRltsr4i\n 66YGf/28kVc44PqzjZMDlOzfGpiUspmY5p54nl0WcyT5UZ3SPcYvc3Yc+1ySonnkdte2by4m\n Allcf9MclViKMxINtZiLihMBQtaUMj8CAAA="
        ],
        "X-CMS-MailID": "20200409172533eucas1p1f4363aa89cfbda87e5d20da1006e21c0",
        "X-Msg-Generator": "CA",
        "Content-Type": "text/plain; charset=\"utf-8\"",
        "X-RootMTR": "20200409172533eucas1p1f4363aa89cfbda87e5d20da1006e21c0",
        "X-EPHeader": "CA",
        "CMS-TYPE": "201P",
        "X-CMS-RootMailID": "20200409172533eucas1p1f4363aa89cfbda87e5d20da1006e21c0",
        "References": "<20200408031351.4288-1-l.wojciechow@partner.samsung.com>\n <20200409172502.1693-1-l.wojciechow@partner.samsung.com>\n <CGME20200409172533eucas1p1f4363aa89cfbda87e5d20da1006e21c0@eucas1p1.samsung.com>",
        "Subject": "[dpdk-dev] [PATCH v3 05/13] app/test: introduce librte security\n\ttests",
        "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": "This patch introduces set of unit tests of librte_security API functions.\nTests are added to dpdk-test application and can be run with\n\"security_autotest\" runtime command.\n\nThis is the first patch in the series of patches as adding all test cases\nfor all API functions in a single patch would make it unreadable.\n\nThis patch defines structure of the file and necessary test framework\ninitialization. It also contains first subset of unit tests for\nrte_security_session_create API function.\n\nStructure of the tests file is following:\n- macros for making tests more readable;\n- mockup structures and functions for rte_security_ops;\n- test suite and test cases setup and teardown functions;\n- tests functions;\n- declaration of testcases.\n\nSigned-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>\n---\n app/test/Makefile        |   2 +\n app/test/meson.build     |   3 +\n app/test/test_security.c | 683 +++++++++++++++++++++++++++++++++++++++\n 3 files changed, 688 insertions(+)\n create mode 100644 app/test/test_security.c",
    "diff": "diff --git a/app/test/Makefile b/app/test/Makefile\nindex 1f080d162..153610a32 100644\n--- a/app/test/Makefile\n+++ b/app/test/Makefile\n@@ -231,6 +231,8 @@ SRCS-$(CONFIG_RTE_LIBRTE_BPF) += test_bpf.c\n \n SRCS-$(CONFIG_RTE_LIBRTE_RCU) += test_rcu_qsbr.c test_rcu_qsbr_perf.c\n \n+SRCS-$(CONFIG_RTE_LIBRTE_SECURITY) += test_security.c\n+\n SRCS-$(CONFIG_RTE_LIBRTE_IPSEC) += test_ipsec.c\n SRCS-$(CONFIG_RTE_LIBRTE_IPSEC) += test_ipsec_sad.c\n ifeq ($(CONFIG_RTE_LIBRTE_IPSEC),y)\ndiff --git a/app/test/meson.build b/app/test/meson.build\nindex 351d29cb6..f3c775b34 100644\n--- a/app/test/meson.build\n+++ b/app/test/meson.build\n@@ -103,6 +103,7 @@ test_sources = files('commands.c',\n \t'test_ring_perf.c',\n \t'test_rwlock.c',\n \t'test_sched.c',\n+\t'test_security.c',\n \t'test_service_cores.c',\n \t'test_spinlock.c',\n \t'test_stack.c',\n@@ -150,6 +151,7 @@ test_deps = ['acl',\n \t'reorder',\n \t'rib',\n \t'ring',\n+\t'security',\n \t'stack',\n \t'timer'\n ]\n@@ -211,6 +213,7 @@ fast_tests = [\n         ['rwlock_rds_wrm_autotest', true],\n         ['rwlock_rde_wro_autotest', true],\n         ['sched_autotest', true],\n+\t\t['security_autotest', false],\n         ['spinlock_autotest', true],\n         ['stack_autotest', false],\n         ['stack_lf_autotest', false],\ndiff --git a/app/test/test_security.c b/app/test/test_security.c\nnew file mode 100644\nindex 000000000..3fc83abae\n--- /dev/null\n+++ b/app/test/test_security.c\n@@ -0,0 +1,683 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved\n+ */\n+\n+#include <rte_errno.h>\n+#include <rte_log.h>\n+#include <rte_memory.h>\n+#include <rte_mempool.h>\n+#include <rte_security.h>\n+#include <rte_security_driver.h>\n+\n+/* Before including rte_test.h file you can define\n+ * RTE_TEST_TRACE_FAILURE(_file, _line, _func) macro to better trace/debug test\n+ * failures. Mostly useful in development phase.\n+ */\n+#ifndef RTE_TEST_TRACE_FAILURE\n+#define RTE_TEST_TRACE_FAILURE(_file, _line, _func) \\\n+\tRTE_LOG(DEBUG, EAL, \"in %s:%d %s\\n\", _file, _line, _func)\n+#endif\n+\n+#include <rte_test.h>\n+#include \"test.h\"\n+\n+/**\n+ * Security\n+ * =======\n+ *\n+ * Basic unit tests of the librte_security API.\n+ *\n+ * Structure of the file:\n+ * - macros for making tests more readable;\n+ * - mockup structures and functions for rte_security_ops;\n+ * - test suite and test cases setup and teardown functions;\n+ * - tests functions;\n+ * - declaration of testcases.\n+ */\n+\n+\n+/**\n+ * Macros\n+ *\n+ * Set of macros for making tests easier to read.\n+ */\n+\n+/**\n+ * Verify condition inside mocked up function.\n+ * Mockup function cannot return a test error, so the failure\n+ * of assertion increases counter and print logs.\n+ * The counter can be verified later to check if test case should fail.\n+ *\n+ * @param   fail_counter\tfail counter\n+ * @param   cond\tcondition expected to be true\n+ * @param   msg\tprintf style formatting string for custom message\n+ */\n+#define MOCK_TEST_ASSERT(fail_counter, cond, msg, ...) do {\t\t\\\n+\tif (!(cond)) {\t\t\t\t\t\t\t\\\n+\t\tfail_counter++;\t\t\t\t\t\t\\\n+\t\tRTE_LOG(DEBUG, EAL, \"Test assert %s line %d failed: \"\t\\\n+\t\t\t\tmsg \"\\n\", __func__, __LINE__,\t\t\\\n+\t\t\t\t ##__VA_ARGS__);\t\t\t\\\n+\t\tRTE_TEST_TRACE_FAILURE(__FILE__, __LINE__, __func__);\t\\\n+\t}\t\t\t\t\t\t\t\t\\\n+} while (0)\n+\n+/**\n+ * Verify equality condition inside mocked up function.\n+ * Mockup function cannot return a test error, so the failure\n+ * of assertion increases counter and print logs.\n+ * The counter can be verified later to check if test case should fail.\n+ *\n+ * @param   fail_counter\tfail counter\n+ * @param   a\tfirst value of comparison\n+ * @param   b\tsecond value of comparison\n+ * @param   msg\tprintf style formatting string for custom message\n+ */\n+#define MOCK_TEST_ASSERT_EQUAL(fail_counter, a, b, msg, ...)\t\\\n+\tMOCK_TEST_ASSERT(fail_counter, (a) == (b), msg, ##__VA_ARGS__)\n+\n+\n+/**\n+ * Verify if parameter of the mocked up function matches expected value.\n+ * The expected value is stored in data structure in the field matching\n+ * parameter name.\n+ *\n+ * @param   data\tstructure with expected values\n+ * @param   parameter\tname of the parameter (both field and parameter name)\n+ * @param   spec\tprintf style spec for parameter\n+ */\n+#define MOCK_TEST_ASSERT_PARAMETER(data, parameter, spec)\t\t\\\n+\tMOCK_TEST_ASSERT_EQUAL(data.failed, data.parameter, parameter,\t\\\n+\t\t\t\"Expecting parameter %s to be \" spec\t\t\\\n+\t\t\t\" but it's \" spec, RTE_STR(parameter),\t\t\\\n+\t\t\tdata.parameter, parameter)\n+\n+/**\n+ * Wrap for MOCK_TEST_ASSERT_PARAMETER macro for pointer type parameters.\n+ *\n+ * @param   data\tstructure with expected values\n+ * @param   parameter\tname of the parameter (both field and parameter name)\n+ */\n+#define MOCK_TEST_ASSERT_POINTER_PARAMETER(data, parameter)\t\\\n+\tMOCK_TEST_ASSERT_PARAMETER(data, parameter, \"%p\")\n+\n+/**\n+ * Verify number of calls of the mocked up function\n+ * and check if there were any fails during execution.\n+ * The fails statistics inside mocked up functions are collected\n+ * as \"failed\" field in mockup structures.\n+ *\n+ * @param   mock_data\tstructure with statistics (called, failed)\n+ * @param   exp_calls\texpected number of mockup function calls\n+ */\n+#define TEST_ASSERT_MOCK_CALLS(mock_data, exp_calls) do {\t\t\\\n+\tTEST_ASSERT_EQUAL(exp_calls, mock_data.called,\t\t\t\\\n+\t\t\t\"Expecting sub op to be called %d times, \"\t\\\n+\t\t\t\"but it's called %d times\",\t\t\t\\\n+\t\t\texp_calls, mock_data.called);\t\t\t\\\n+\tTEST_ASSERT_EQUAL(0, mock_data.failed,\t\t\t\t\\\n+\t\t\t\"Expecting sub op asserts not to fail, \"\t\\\n+\t\t\t\"but they're failed %d times\",\t\t\t\\\n+\t\t\tmock_data.failed);\t\t\t\t\\\n+} while (0)\n+\n+/**\n+ * Assert tested function result match expected value\n+ *\n+ * @param   f_name\tname of tested function\n+ * @param   f_ret\tvalue returned by the function\n+ * @param   exp_ret\texpected returned value\n+ * @param   fmt\t\tprintf style format for returned value\n+ */\n+#define TEST_ASSERT_MOCK_FUNCTION_CALL_RET(f_name, f_ret, exp_ret, fmt)\t\\\n+\tTEST_ASSERT_EQUAL(exp_ret, f_ret, \"Expecting \" RTE_STR(f_name)\t\\\n+\t\t\t\" to return \" fmt \", but it returned \" fmt\t\\\n+\t\t\t\"\\n\", exp_ret, f_ret)\n+\n+/**\n+ * Assert tested function result is not NULL\n+ *\n+ * @param   f_name\tname of tested function\n+ * @param   f_ret\tvalue returned by the function\n+ */\n+#define TEST_ASSERT_MOCK_FUNCTION_CALL_NOT_NULL(f_name, f_ret)\t\t\\\n+\tTEST_ASSERT_NOT_NULL(f_ret, \"Expecting \" RTE_STR(f_name)\t\\\n+\t\t\t\" to return not NULL\\n\")\n+\n+/**\n+ * Verify that sess_cnt counter value matches expected\n+ *\n+ * @param   expected_sessions_count\texpected counter value\n+ */\n+#define TEST_ASSERT_SESSION_COUNT(expected_sessions_count) do {\t\t\\\n+\tstruct security_unittest_params *ut_params = &unittest_params;\t\\\n+\tTEST_ASSERT_EQUAL(expected_sessions_count,\t\t\t\\\n+\t\t\tut_params->ctx.sess_cnt,\t\t\t\\\n+\t\t\t\"Expecting session counter to be %u,\"\t\t\\\n+\t\t\t\" but it's %u\",\texpected_sessions_count,\t\\\n+\t\t\tut_params->ctx.sess_cnt);\t\t\t\\\n+} while (0)\n+\n+/**\n+ * Verify usage of mempool by checking if number of allocated objects matches\n+ * expectations. The mempool is used to manage objects for sessions data.\n+ * A single object is acquired from mempool during session_create\n+ * and put back in session_destroy.\n+ *\n+ * @param   expected_mempool_usage\texpected number of used mempool objects\n+ */\n+#define TEST_ASSERT_MEMPOOL_USAGE(expected_mempool_usage) do {\t\t\\\n+\tstruct security_testsuite_params *ts_params = &testsuite_params;\\\n+\tunsigned int mempool_usage;\t\t\t\t\t\\\n+\tmempool_usage = rte_mempool_in_use_count(\t\t\t\\\n+\t\t\tts_params->session_mpool);\t\t\t\\\n+\tTEST_ASSERT_EQUAL(expected_mempool_usage, mempool_usage,\t\\\n+\t\t\t\"Expecting %u mempool allocations, \"\t\t\\\n+\t\t\t\"but there are %u allocated objects\",\t\t\\\n+\t\t\texpected_mempool_usage, mempool_usage);\t\t\\\n+} while (0)\n+\n+\n+/**\n+ * Mockup structures and functions for rte_security_ops;\n+ *\n+ * Set of structures for controlling mockup functions calls.\n+ * Every mockup function X has its corresponding X_data structure\n+ * and an instance of that structure X_exp.\n+ * Structure contains parameters that a mockup function is expected\n+ * to be called with, a value to return (.ret) and 2 statistics:\n+ * .called (number of times the mockup function was called)\n+ * and .failed (number of assertion fails during mockup function call).\n+ *\n+ * Mockup functions verify that the parameters they are called with match\n+ * expected values. The expected values should be stored in corresponding\n+ * structures prior to mockup functions call. Every failure of such\n+ * verification increases .failed counter. Every call of mockup function\n+ * increases .called counter. Function returns value stored in .ret field\n+ * of the structure.\n+ * In case of some parameters in some functions the expected value is unknown\n+ * and cannot be detrmined prior to call. Such parameters are stored\n+ * in structure and can be compared or analyzed later in test case code.\n+ *\n+ * Below structures and functions follow the rules just described.\n+ * Additional remarks and exceptions are added in comments.\n+ */\n+\n+/**\n+ * session_create mockup\n+ *\n+ * Verified parameters: device, conf, mp.\n+ * Saved, not verified parameters: sess.\n+ */\n+static struct mock_session_create_data {\n+\tvoid *device;\n+\tstruct rte_security_session_conf *conf;\n+\tstruct rte_security_session *sess;\n+\tstruct rte_mempool *mp;\n+\n+\tint ret;\n+\n+\tint called;\n+\tint failed;\n+} mock_session_create_exp = {NULL, NULL, NULL, NULL, 0, 0, 0};\n+\n+static int\n+mock_session_create(void *device,\n+\t\tstruct rte_security_session_conf *conf,\n+\t\tstruct rte_security_session *sess,\n+\t\tstruct rte_mempool *mp)\n+{\n+\tmock_session_create_exp.called++;\n+\n+\tMOCK_TEST_ASSERT_POINTER_PARAMETER(mock_session_create_exp, device);\n+\tMOCK_TEST_ASSERT_POINTER_PARAMETER(mock_session_create_exp, conf);\n+\tMOCK_TEST_ASSERT_POINTER_PARAMETER(mock_session_create_exp, mp);\n+\n+\tmock_session_create_exp.sess = sess;\n+\n+\treturn mock_session_create_exp.ret;\n+}\n+\n+/**\n+ * session_destroy mockup\n+ *\n+ * Verified parameters: device, sess.\n+ */\n+static struct mock_session_destroy_data {\n+\tvoid *device;\n+\tstruct rte_security_session *sess;\n+\n+\tint ret;\n+\n+\tint called;\n+\tint failed;\n+} mock_session_destroy_exp = {NULL, NULL, 0, 0, 0};\n+\n+static int\n+mock_session_destroy(void *device, struct rte_security_session *sess)\n+{\n+\tmock_session_destroy_exp.called++;\n+\n+\tMOCK_TEST_ASSERT_POINTER_PARAMETER(mock_session_destroy_exp, device);\n+\tMOCK_TEST_ASSERT_POINTER_PARAMETER(mock_session_destroy_exp, sess);\n+\n+\treturn mock_session_destroy_exp.ret;\n+}\n+\n+/**\n+ * empty_ops\n+ *\n+ * is an empty security operations set (all function pointers set to NULL)\n+ */\n+struct rte_security_ops empty_ops = { NULL };\n+\n+/**\n+ * mock_ops\n+ *\n+ * is a security operations set using mockup functions\n+ */\n+struct rte_security_ops mock_ops = {\n+\t.session_create = mock_session_create,\n+\t.session_destroy = mock_session_destroy,\n+};\n+\n+\n+/**\n+ * Test suite and test cases setup and teardown functions.\n+ */\n+\n+/**\n+ * struct security_testsuite_params defines parameters initialized once\n+ * for whole tests suite.\n+ * Currently the only stored parameter is session_mpool a mempool created\n+ * once in testsuite_setup and released in testsuite_teardown.\n+ * The instance of this structure is stored in testsuite_params variable.\n+ */\n+static struct security_testsuite_params {\n+\tstruct rte_mempool *session_mpool;\n+} testsuite_params = { NULL };\n+\n+/**\n+ * struct security_unittest_params defines parameters initialized\n+ * for every test case. The parameters are initialized in ut_setup\n+ * and released in ut_teardown.\n+ * The instance of this structure is stored in unittest_params variable.\n+ */\n+static struct security_unittest_params {\n+\tstruct rte_security_ctx ctx;\n+\tstruct rte_security_session_conf conf;\n+\tstruct rte_security_session *sess;\n+} unittest_params = {\n+\t.ctx = {\n+\t\t.device = NULL,\n+\t\t.ops = &mock_ops,\n+\t\t.sess_cnt = 0,\n+\t},\n+\t.sess = NULL,\n+};\n+\n+#define SECURITY_TEST_MEMPOOL_NAME \"SecurityTestsMempoolName\"\n+#define SECURITY_TEST_MEMPOOL_SIZE 15\n+#define SECURITY_TEST_SESSION_OBJECT_SIZE sizeof(struct rte_security_session)\n+\n+/**\n+ * testsuite_setup initializes whole test suite parameters.\n+ * It creates a new mempool used in all test cases\n+ * and verifies if it properly created.\n+ */\n+static int\n+testsuite_setup(void)\n+{\n+\tstruct security_testsuite_params *ts_params = &testsuite_params;\n+\tts_params->session_mpool = rte_mempool_create(\n+\t\t\tSECURITY_TEST_MEMPOOL_NAME,\n+\t\t\tSECURITY_TEST_MEMPOOL_SIZE,\n+\t\t\tSECURITY_TEST_SESSION_OBJECT_SIZE,\n+\t\t\t0, 0, NULL, NULL, NULL, NULL,\n+\t\t\tSOCKET_ID_ANY, 0);\n+\tTEST_ASSERT_NOT_NULL(ts_params->session_mpool,\n+\t\t\t\"Cannot create mempool %s\\n\", rte_strerror(rte_errno));\n+\treturn TEST_SUCCESS;\n+}\n+\n+/**\n+ * testsuite_teardown releases test suite wide parameters.\n+ */\n+static void\n+testsuite_teardown(void)\n+{\n+\tstruct security_testsuite_params *ts_params = &testsuite_params;\n+\tif (ts_params->session_mpool) {\n+\t\trte_mempool_free(ts_params->session_mpool);\n+\t\tts_params->session_mpool = NULL;\n+\t}\n+}\n+\n+/**\n+ * ut_setup initializes test case parameters to default values.\n+ * It resets also any .called and .failed statistics of mockup functions\n+ * usage.\n+ */\n+static int\n+ut_setup(void)\n+{\n+\tstruct security_unittest_params *ut_params = &unittest_params;\n+\tut_params->ctx.device = NULL;\n+\tut_params->ctx.ops = &mock_ops;\n+\tut_params->ctx.sess_cnt = 0;\n+\tut_params->sess = NULL;\n+\n+\tmock_session_create_exp.called = 0;\n+\tmock_session_destroy_exp.called = 0;\n+\n+\tmock_session_create_exp.failed = 0;\n+\tmock_session_destroy_exp.failed = 0;\n+\n+\treturn TEST_SUCCESS;\n+}\n+\n+/**\n+ * destroy_session_with_check is a helper function releasing session\n+ * created with rte_security_session_create and stored in test case parameters.\n+ * It's used both to release sessions created in test cases' bodies\n+ * which are assigned to ut_params->sess\n+ */\n+static int\n+destroy_session_with_check(void)\n+{\n+\tstruct security_unittest_params *ut_params = &unittest_params;\n+\tif (ut_params->sess != NULL) {\n+\t\t/* Assure that mockup function for destroy operation is set. */\n+\t\tut_params->ctx.ops = &mock_ops;\n+\n+\t\tmock_session_destroy_exp.device = NULL;\n+\t\tmock_session_destroy_exp.sess = ut_params->sess;\n+\t\tmock_session_destroy_exp.ret = 0;\n+\t\tmock_session_destroy_exp.called = 0;\n+\t\tmock_session_destroy_exp.failed = 0;\n+\n+\t\tint ret = rte_security_session_destroy(&ut_params->ctx,\n+\t\t\t\tut_params->sess);\n+\t\tTEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_destroy,\n+\t\t\t\tret, 0, \"%d\");\n+\t\tTEST_ASSERT_MOCK_CALLS(mock_session_destroy_exp, 1);\n+\n+\t\tut_params->sess = NULL;\n+\t}\n+\treturn TEST_SUCCESS;\n+}\n+\n+/**\n+ * ut_teardown releases test case parameters.\n+ */\n+static void\n+ut_teardown(void)\n+{\n+\tdestroy_session_with_check();\n+}\n+\n+\n+/**\n+ * Test functions\n+ *\n+ * Each test function is related to a single test case.\n+ * They are arranged by tested rte_security API function\n+ * and by rte_security execution paths sequence in code.\n+ */\n+\n+/**\n+ * rte_security_session_create tests\n+ */\n+\n+/**\n+ * Test execution of rte_security_session_create with NULL instance\n+ */\n+static int\n+test_session_create_inv_context(void)\n+{\n+\tstruct security_testsuite_params *ts_params = &testsuite_params;\n+\tstruct security_unittest_params *ut_params = &unittest_params;\n+\tstruct rte_security_session *sess;\n+\n+\tsess = rte_security_session_create(NULL, &ut_params->conf,\n+\t\t\tts_params->session_mpool);\n+\tTEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_create,\n+\t\t\tsess, NULL, \"%p\");\n+\tTEST_ASSERT_MOCK_CALLS(mock_session_create_exp, 0);\n+\tTEST_ASSERT_MEMPOOL_USAGE(0);\n+\tTEST_ASSERT_SESSION_COUNT(0);\n+\n+\treturn TEST_SUCCESS;\n+}\n+\n+/**\n+ * Test execution of rte_security_session_create with invalid\n+ * security operations structure (NULL)\n+ */\n+static int\n+test_session_create_inv_context_ops(void)\n+{\n+\tstruct security_testsuite_params *ts_params = &testsuite_params;\n+\tstruct security_unittest_params *ut_params = &unittest_params;\n+\tstruct rte_security_session *sess;\n+\n+\tut_params->ctx.ops = NULL;\n+\n+\tsess = rte_security_session_create(&ut_params->ctx, &ut_params->conf,\n+\t\t\tts_params->session_mpool);\n+\tTEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_create,\n+\t\t\tsess, NULL, \"%p\");\n+\tTEST_ASSERT_MOCK_CALLS(mock_session_create_exp, 0);\n+\tTEST_ASSERT_MEMPOOL_USAGE(0);\n+\tTEST_ASSERT_SESSION_COUNT(0);\n+\n+\treturn TEST_SUCCESS;\n+}\n+\n+/**\n+ * Test execution of rte_security_session_create with empty\n+ * security operations\n+ */\n+static int\n+test_session_create_inv_context_ops_fun(void)\n+{\n+\tstruct security_testsuite_params *ts_params = &testsuite_params;\n+\tstruct security_unittest_params *ut_params = &unittest_params;\n+\tstruct rte_security_session *sess;\n+\n+\tut_params->ctx.ops = &empty_ops;\n+\n+\tsess = rte_security_session_create(&ut_params->ctx, &ut_params->conf,\n+\t\t\tts_params->session_mpool);\n+\tTEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_create,\n+\t\t\tsess, NULL, \"%p\");\n+\tTEST_ASSERT_MOCK_CALLS(mock_session_create_exp, 0);\n+\tTEST_ASSERT_MEMPOOL_USAGE(0);\n+\tTEST_ASSERT_SESSION_COUNT(0);\n+\n+\treturn TEST_SUCCESS;\n+}\n+\n+/**\n+ * Test execution of rte_security_session_create with NULL conf parameter\n+ */\n+static int\n+test_session_create_inv_configuration(void)\n+{\n+\tstruct security_testsuite_params *ts_params = &testsuite_params;\n+\tstruct security_unittest_params *ut_params = &unittest_params;\n+\tstruct rte_security_session *sess;\n+\n+\tsess = rte_security_session_create(&ut_params->ctx, NULL,\n+\t\t\tts_params->session_mpool);\n+\tTEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_create,\n+\t\t\tsess, NULL, \"%p\");\n+\tTEST_ASSERT_MOCK_CALLS(mock_session_create_exp, 0);\n+\tTEST_ASSERT_MEMPOOL_USAGE(0);\n+\tTEST_ASSERT_SESSION_COUNT(0);\n+\n+\treturn TEST_SUCCESS;\n+}\n+\n+/**\n+ * Test execution of rte_security_session_create with NULL mp parameter\n+ */\n+static int\n+test_session_create_inv_mempool(void)\n+{\n+\tstruct security_unittest_params *ut_params = &unittest_params;\n+\tstruct rte_security_session *sess;\n+\n+\tsess = rte_security_session_create(&ut_params->ctx, &ut_params->conf,\n+\t\t\tNULL);\n+\tTEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_create,\n+\t\t\tsess, NULL, \"%p\");\n+\tTEST_ASSERT_MOCK_CALLS(mock_session_create_exp, 0);\n+\tTEST_ASSERT_MEMPOOL_USAGE(0);\n+\tTEST_ASSERT_SESSION_COUNT(0);\n+\n+\treturn TEST_SUCCESS;\n+}\n+\n+/**\n+ * Test execution of rte_security_session_create in case when mempool\n+ * is fully used and no object can be got from it\n+ */\n+static int\n+test_session_create_mempool_empty(void)\n+{\n+\tstruct security_testsuite_params *ts_params = &testsuite_params;\n+\tstruct security_unittest_params *ut_params = &unittest_params;\n+\tstruct rte_security_session *tmp[SECURITY_TEST_MEMPOOL_SIZE];\n+\tstruct rte_security_session *sess;\n+\n+\t/* Get all available objects from mempool. */\n+\tint i, ret;\n+\tfor (i = 0; i < SECURITY_TEST_MEMPOOL_SIZE; ++i) {\n+\t\tret = rte_mempool_get(ts_params->session_mpool,\n+\t\t\t\t(void **)(&tmp[i]));\n+\t\tTEST_ASSERT_EQUAL(0, ret,\n+\t\t\t\t\"Expect getting %d object from mempool\"\n+\t\t\t\t\" to succeed\", i);\n+\t}\n+\tTEST_ASSERT_MEMPOOL_USAGE(SECURITY_TEST_MEMPOOL_SIZE);\n+\n+\tsess = rte_security_session_create(&ut_params->ctx, &ut_params->conf,\n+\t\t\tts_params->session_mpool);\n+\tTEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_create,\n+\t\t\tsess, NULL, \"%p\");\n+\tTEST_ASSERT_MOCK_CALLS(mock_session_create_exp, 0);\n+\tTEST_ASSERT_MEMPOOL_USAGE(SECURITY_TEST_MEMPOOL_SIZE);\n+\tTEST_ASSERT_SESSION_COUNT(0);\n+\n+\t/* Put objects back to the pool. */\n+\tfor (i = 0; i < SECURITY_TEST_MEMPOOL_SIZE; ++i)\n+\t\trte_mempool_put(ts_params->session_mpool, (void *)(tmp[i]));\n+\tTEST_ASSERT_MEMPOOL_USAGE(0);\n+\n+\treturn TEST_SUCCESS;\n+}\n+\n+/**\n+ * Test execution of rte_security_session_create when session_create\n+ * security operation fails\n+ */\n+static int\n+test_session_create_ops_failure(void)\n+{\n+\tstruct security_testsuite_params *ts_params = &testsuite_params;\n+\tstruct security_unittest_params *ut_params = &unittest_params;\n+\tstruct rte_security_session *sess;\n+\n+\tmock_session_create_exp.device = NULL;\n+\tmock_session_create_exp.conf = &ut_params->conf;\n+\tmock_session_create_exp.mp = ts_params->session_mpool;\n+\tmock_session_create_exp.ret = -1;\t/* Return failure status. */\n+\n+\tsess = rte_security_session_create(&ut_params->ctx, &ut_params->conf,\n+\t\t\tts_params->session_mpool);\n+\tTEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_create,\n+\t\t\tsess, NULL, \"%p\");\n+\tTEST_ASSERT_MOCK_CALLS(mock_session_create_exp, 1);\n+\tTEST_ASSERT_MEMPOOL_USAGE(0);\n+\tTEST_ASSERT_SESSION_COUNT(0);\n+\n+\treturn TEST_SUCCESS;\n+}\n+\n+/**\n+ * Test execution of rte_security_session_create in successful execution path\n+ */\n+static int\n+test_session_create_success(void)\n+{\n+\tstruct security_testsuite_params *ts_params = &testsuite_params;\n+\tstruct security_unittest_params *ut_params = &unittest_params;\n+\tstruct rte_security_session *sess;\n+\n+\tmock_session_create_exp.device = NULL;\n+\tmock_session_create_exp.conf = &ut_params->conf;\n+\tmock_session_create_exp.mp = ts_params->session_mpool;\n+\tmock_session_create_exp.ret = 0;\t/* Return success status. */\n+\n+\tsess = rte_security_session_create(&ut_params->ctx, &ut_params->conf,\n+\t\t\tts_params->session_mpool);\n+\tTEST_ASSERT_MOCK_FUNCTION_CALL_NOT_NULL(rte_security_session_create,\n+\t\t\tsess);\n+\tTEST_ASSERT_EQUAL(sess, mock_session_create_exp.sess,\n+\t\t\t\"Expecting session_create to be called with %p sess\"\n+\t\t\t\" parameter, but it's called %p sess parameter\",\n+\t\t\tsess, mock_session_create_exp.sess);\n+\tTEST_ASSERT_MOCK_CALLS(mock_session_create_exp, 1);\n+\tTEST_ASSERT_MEMPOOL_USAGE(1);\n+\tTEST_ASSERT_SESSION_COUNT(1);\n+\n+\t/*\n+\t * Store created session in test case parameters, so it can be released\n+\t * after test case in ut_teardown by destroy_session_with_check.\n+\t */\n+\tut_params->sess = sess;\n+\n+\treturn TEST_SUCCESS;\n+}\n+\n+\n+/**\n+ * Declaration of testcases\n+ */\n+static struct unit_test_suite security_testsuite  = {\n+\t.suite_name = \"generic security\",\n+\t.setup = testsuite_setup,\n+\t.teardown = testsuite_teardown,\n+\t.unit_test_cases = {\n+\t\tTEST_CASE_ST(ut_setup, ut_teardown,\n+\t\t\t\ttest_session_create_inv_context),\n+\t\tTEST_CASE_ST(ut_setup, ut_teardown,\n+\t\t\t\ttest_session_create_inv_context_ops),\n+\t\tTEST_CASE_ST(ut_setup, ut_teardown,\n+\t\t\t\ttest_session_create_inv_context_ops_fun),\n+\t\tTEST_CASE_ST(ut_setup, ut_teardown,\n+\t\t\t\ttest_session_create_inv_configuration),\n+\t\tTEST_CASE_ST(ut_setup, ut_teardown,\n+\t\t\t\ttest_session_create_inv_mempool),\n+\t\tTEST_CASE_ST(ut_setup, ut_teardown,\n+\t\t\t\ttest_session_create_mempool_empty),\n+\t\tTEST_CASE_ST(ut_setup, ut_teardown,\n+\t\t\t\ttest_session_create_ops_failure),\n+\t\tTEST_CASE_ST(ut_setup, ut_teardown,\n+\t\t\t\ttest_session_create_success),\n+\n+\t\tTEST_CASES_END() /**< NULL terminate unit test array */\n+\t}\n+};\n+\n+static int\n+test_security(void)\n+{\n+\trte_log_set_global_level(RTE_LOG_DEBUG);\n+\trte_log_set_level(RTE_LOGTYPE_EAL, RTE_LOG_DEBUG);\n+\n+\treturn unit_test_suite_runner(&security_testsuite);\n+}\n+\n+REGISTER_TEST_COMMAND(security_autotest, test_security);\n",
    "prefixes": [
        "v3",
        "05/13"
    ]
}