From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9C6C4A056D; Thu, 12 Mar 2020 16:20:07 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6EF831C10C; Thu, 12 Mar 2020 16:17:27 +0100 (CET) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id A0AE42BE6 for ; Thu, 12 Mar 2020 16:17:11 +0100 (CET) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20200312151711euoutp02d38dade6c64d8db7c983eb9fed2f5302~7l3cJNQS22892528925euoutp02z for ; Thu, 12 Mar 2020 15:17:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20200312151711euoutp02d38dade6c64d8db7c983eb9fed2f5302~7l3cJNQS22892528925euoutp02z DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1584026231; bh=XTYbNWcrP25QCQQf/+gPRqGFbyG15EJfzn5VU3HEW0Y=; h=From:To:Subject:Date:In-Reply-To:References:From; b=S5LwNxcsQnrDA2LpspRDsNWYOH+/1HCyRLyutM82j/OI3Azcf2I84kqrLVQVlLaLC 9EFQR//iHeyu4riSNWuES+bbYdUZ+ZKllVZ+QSuuhN9QfJIoU2b9LlqKD2ykmqUqJy MTtKq+lUaFlic0z+vrwPLlQsRBrv28Ii3j2Mx4W4= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20200312151711eucas1p1c3c7876942e2c02df9e4f63f9a3e425d~7l3buKhIj1794017940eucas1p1e for ; Thu, 12 Mar 2020 15:17:11 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id F2.62.61286.6725A6E5; Thu, 12 Mar 2020 15:17:10 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20200312151710eucas1p21882b138d4fd79753f993c30c997e615~7l3bgder31698716987eucas1p2y for ; Thu, 12 Mar 2020 15:17:10 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200312151710eusmtrp2364d8a76f6ef7b5225dfa2cabf10cb9a~7l3bgB3Mt1238312383eusmtrp2Q for ; Thu, 12 Mar 2020 15:17:10 +0000 (GMT) X-AuditID: cbfec7f2-ef1ff7000001ef66-c0-5e6a52763c70 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 62.3F.08375.6725A6E5; Thu, 12 Mar 2020 15:17:10 +0000 (GMT) Received: from Padamandas.example.org (unknown [106.120.51.19]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200312151710eusmtip19317a169ef5581543d77f85d3926792a~7l3bQx_Ux1547515475eusmtip1Q for ; Thu, 12 Mar 2020 15:17:10 +0000 (GMT) From: Lukasz Wojciechowski To: dev@dpdk.org Date: Thu, 12 Mar 2020 16:16:53 +0100 Message-Id: <20200312151654.7218-13-l.wojciechow@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200312151654.7218-1-l.wojciechow@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrHIsWRmVeSWpSXmKPExsWy7djPc7plQVlxBptu2Fi8+7SdyYHR49eC pawBjFFcNimpOZllqUX6dglcGQ/uTGQveKRT8f/lM+YGxq1qXYycHBICJhI/ry5l7mLk4hAS WMEo8erKLSinnUniT/MTRginjUli2+9JzDAtc77OYQKxhQSWM0psmmAF13Hi/AE2kASbgK3E kZlfWUFsEQEBic+di8HiwgIeEnMWLGPvYuT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GYp0eR8YEDnlcQbmhqaW1gamhubG5tZKInz dggcjBESSE8sSc1OTS1ILYLpY+LglGpgZPjy5/XS6RsnnEjk2xs+p+Xyxn4OE0Mj59LneyfM Wavdsj3la+CzCyy5NS0Bf25xB/jaRN3psG3JPXbi1baY3tXaL7b9nB3YPOPS2pb7S7Ypf3nj FOz2+0LHb9P71fI8YaHH1wb0PGZ2sl9du+De9Jef9y2ZOKHB6MCLN/3CVhs2lZ6uWat777kS S3FGoqEWc1FxIgBLIHpZMAIAAA== X-CMS-MailID: 20200312151710eucas1p21882b138d4fd79753f993c30c997e615 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200312151710eucas1p21882b138d4fd79753f993c30c997e615 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200312151710eucas1p21882b138d4fd79753f993c30c997e615 References: <20200312151654.7218-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-dev] [PATCH 12/13] app/test: add rte_security_capabilities_get tests X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Signed-off-by: Lukasz Wojciechowski Change-Id: Iaa273d1b4e663a6238ad67bbf0ec6dd40c21d075 --- app/test/test_security.c | 137 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) diff --git a/app/test/test_security.c b/app/test/test_security.c index e8aba2870..895e4a03e 100644 --- a/app/test/test_security.c +++ b/app/test/test_security.c @@ -431,6 +431,29 @@ mock_get_userdata(void *device, return mock_get_userdata_exp.ret; } +/** + * capabilities_get mockup + * + * Verified parameters: device. + */ +static struct mock_capabilities_get_data { + void *device; + + struct rte_security_capability * ret; + + int called; + int failed; +} mock_capabilities_get_exp = {NULL, NULL, 0, 0}; + +static const struct rte_security_capability * +mock_capabilities_get(void *device) { + mock_capabilities_get_exp.called++; + + MOCK_TEST_ASSERT_POINTER_PARAMETER(mock_capabilities_get_exp, device); + + return mock_capabilities_get_exp.ret; +} + /** * empty_ops * @@ -451,6 +474,7 @@ struct rte_security_ops mock_ops = { .session_destroy = mock_session_destroy, .set_pkt_metadata = mock_set_pkt_metadata, .get_userdata = mock_get_userdata, + .capabilities_get = mock_capabilities_get, }; @@ -544,6 +568,7 @@ ut_setup(void) { mock_session_destroy_exp.called = 0; mock_set_pkt_metadata_exp.called = 0; mock_get_userdata_exp.called = 0; + mock_capabilities_get_exp.called = 0; mock_session_create_exp.failed = 0; mock_session_update_exp.failed = 0; @@ -552,6 +577,7 @@ ut_setup(void) { mock_session_destroy_exp.failed = 0; mock_set_pkt_metadata_exp.failed = 0; mock_get_userdata_exp.failed = 0; + mock_capabilities_get_exp.failed = 0; return TEST_SUCCESS; } @@ -1621,6 +1647,106 @@ test_rte_security_get_userdata_success(void) } +/** + * rte_security_capabilities_get tests + */ + +/** + * Test execution of rte_security_capabilities_get with NULL instance + */ +static int +test_rte_security_capabilities_get_inv_param_context(void) +{ + const struct rte_security_capability *ret; + ret = rte_security_capabilities_get(NULL); + TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capabilities_get, + ret, NULL, "%p"); + TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 0); + + return TEST_SUCCESS; +} + +/** + * Test execution of rte_security_capabilities_get with invalid + * security operations structure (NULL) + */ +static int +test_rte_security_capabilities_get_inv_param_context_ops(void) +{ + struct security_unittest_params *ut_params = &unittest_params; + ut_params->ctx.ops = NULL; + + const struct rte_security_capability *ret; + ret = rte_security_capabilities_get(&ut_params->ctx); + TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capabilities_get, + ret, NULL, "%p"); + TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 0); + + return TEST_SUCCESS; +} + +/** + * Test execution of rte_security_capabilities_get with empty + * security operations + */ +static int +test_rte_security_capabilities_get_inv_param_context_ops_fun(void) +{ + struct security_unittest_params *ut_params = &unittest_params; + ut_params->ctx.ops = &empty_ops; + + const struct rte_security_capability *ret; + ret = rte_security_capabilities_get(&ut_params->ctx); + TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capabilities_get, + ret, NULL, "%p"); + TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 0); + + return TEST_SUCCESS; +} + +/** + * Test execution of rte_security_capabilities_get when capabilities_get + * security operation fails + */ +static int +test_rte_security_capabilities_get_ops_failure(void) +{ + struct security_unittest_params *ut_params = &unittest_params; + + mock_capabilities_get_exp.device = NULL; + mock_capabilities_get_exp.ret = NULL; + + const struct rte_security_capability *ret; + ret = rte_security_capabilities_get(&ut_params->ctx); + TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capabilities_get, + ret, NULL, "%p"); + TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 1); + + return TEST_SUCCESS; +} + +/** + * Test execution of rte_security_capabilities_get in successful execution path + */ +static int +test_rte_security_capabilities_get_success(void) +{ + struct security_unittest_params *ut_params = &unittest_params; + struct rte_security_capability capabilities; + + mock_capabilities_get_exp.device = NULL; + mock_capabilities_get_exp.ret = &capabilities; + + const struct rte_security_capability *ret; + ret = rte_security_capabilities_get(&ut_params->ctx); + TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capabilities_get, + ret, &capabilities, "%p"); + TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 1); + + return TEST_SUCCESS; +} + + /** * Declaration of testcases */ @@ -1724,6 +1850,17 @@ static struct unit_test_suite security_testsuite = { TEST_CASE_ST(ut_setup_with_session, ut_teardown, test_rte_security_get_userdata_success), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_rte_security_capabilities_get_inv_param_context), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_rte_security_capabilities_get_inv_param_context_ops), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_rte_security_capabilities_get_inv_param_context_ops_fun), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_rte_security_capabilities_get_ops_failure), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_rte_security_capabilities_get_success), + TEST_CASES_END() /**< NULL terminate unit test array */ } }; -- 2.17.1