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 B8C4DA056D; Thu, 12 Mar 2020 16:18:57 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AA41B1C0BE; Thu, 12 Mar 2020 16:17:22 +0100 (CET) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id ACAE32BE6 for ; Thu, 12 Mar 2020 16:17:10 +0100 (CET) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20200312151710euoutp014dee6dbb13e3b2a52efe8809ec5fbf17~7l3a_KMBS0594005940euoutp01K for ; Thu, 12 Mar 2020 15:17:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20200312151710euoutp014dee6dbb13e3b2a52efe8809ec5fbf17~7l3a_KMBS0594005940euoutp01K DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1584026230; bh=ryNbrMY0w9JMLHi/WM+ZmUR+ackKFbkjvc+x5YF/z4Q=; h=From:To:Subject:Date:In-Reply-To:References:From; b=nDIRIIH8/8HSVW0UTKKYcPcyd0QC4CW1ls+vH188z4+khGw89oX/euN7MSmdC5aMB 9z/07kea52SPIx6znNwsG1Kvjh3Sj9oaliot2j/fKfb4Ndg1wJV1egDKsQooJF3I41 WyhyX1ZQ+SRZSte/CQ+aEtLQgY9jY/03PKUYTsRU= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20200312151709eucas1p1cf443df68476fdb61399e1e9b6bedfe9~7l3ax712F0788307883eucas1p16 for ; Thu, 12 Mar 2020 15:17:09 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 7E.BD.60679.5725A6E5; Thu, 12 Mar 2020 15:17:09 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20200312151709eucas1p139311cecb925f566cbbf1444d14c31b1~7l3ae7Msw1595115951eucas1p1g for ; Thu, 12 Mar 2020 15:17:09 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200312151709eusmtrp217d1c83ed6145c4ba3520b7311e9f210~7l3aeed4V1238312383eusmtrp2M for ; Thu, 12 Mar 2020 15:17:09 +0000 (GMT) X-AuditID: cbfec7f4-0cbff7000001ed07-2c-5e6a527554ce Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 22.3F.08375.5725A6E5; Thu, 12 Mar 2020 15:17:09 +0000 (GMT) Received: from Padamandas.example.org (unknown [106.120.51.19]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200312151709eusmtip1a8a8f81c93bf4be9e19274dd10232833~7l3aTQoLi1547515475eusmtip1P for ; Thu, 12 Mar 2020 15:17:09 +0000 (GMT) From: Lukasz Wojciechowski To: dev@dpdk.org Date: Thu, 12 Mar 2020 16:16:48 +0100 Message-Id: <20200312151654.7218-8-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+NgFtrHIsWRmVeSWpSXmKPExsWy7djPc7qlQVlxBgsuW1u8+7SdyYHR49eC pawBjFFcNimpOZllqUX6dglcGfemfGYs6NCq+L/yAGsDY7NKFyMnh4SAicS2W0dZuhi5OIQE VjBKfFhwhR3CaWeS2LlpEiOE08Yk0fT/EhtMy4HVM9ggEssZJf78eMcEkgBrObiXC8RmE7CV ODLzKyuILSIgIPG5czFYs7CAh0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JqTWnyI0RToponMUqLJ+cCQziuJNzQ1NLewNDQ3Njc2s1AS5+0Q OBgjJJCeWJKanZpakFoE08fEwSnVwJj897XWypmCe82r3GQDuydt1f4WtUBN6W+4p/TEZ7Vu SwUVFjpm7V2mpCFoXPdl6UGfwDbP5V+9M/8ECG+aEpX/YN9CXs8HcnvaEkOMLmZfFLrOOPeV /d7p604p19+/Wfawd3Mkw+XYrMJt2/Zl83/dtlpCW2LR1n+qhx+fmSCb+6s25v4ZGU4lluKM REMt5qLiRAANwu05MQIAAA== X-CMS-MailID: 20200312151709eucas1p139311cecb925f566cbbf1444d14c31b1 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200312151709eucas1p139311cecb925f566cbbf1444d14c31b1 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200312151709eucas1p139311cecb925f566cbbf1444d14c31b1 References: <20200312151654.7218-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-dev] [PATCH 07/13] app/test: add rte_security_session_get_size 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: I1d1238d38c0cca5ba9c14c8ba395a16d686ae110 --- app/test/test_security.c | 131 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) diff --git a/app/test/test_security.c b/app/test/test_security.c index cf13b8080..d4b3e9515 100644 --- a/app/test/test_security.c +++ b/app/test/test_security.c @@ -263,6 +263,29 @@ mock_session_update(void *device, return mock_session_update_exp.ret; } +/** + * session_get_size mockup + * + * Verified parameters: device. + */ +static struct mock_session_get_size_data { + void *device; + + unsigned int ret; + + int called; + int failed; +} mock_session_get_size_exp = {NULL, 0U, 0, 0}; + +static unsigned int +mock_session_get_size(void *device) { + mock_session_get_size_exp.called++; + + MOCK_TEST_ASSERT_POINTER_PARAMETER(mock_session_get_size_exp, device); + + return mock_session_get_size_exp.ret; +} + /** * session_destroy mockup * @@ -304,6 +327,7 @@ struct rte_security_ops empty_ops = { NULL }; struct rte_security_ops mock_ops = { .session_create = mock_session_create, .session_update = mock_session_update, + .session_get_size = mock_session_get_size, .session_destroy = mock_session_destroy, }; @@ -393,10 +417,12 @@ ut_setup(void) { mock_session_create_exp.called = 0; mock_session_update_exp.called = 0; + mock_session_get_size_exp.called = 0; mock_session_destroy_exp.called = 0; mock_session_create_exp.failed = 0; mock_session_update_exp.failed = 0; + mock_session_get_size_exp.failed = 0; mock_session_destroy_exp.failed = 0; return TEST_SUCCESS; @@ -839,6 +865,100 @@ test_rte_security_session_update_success(void) } +/** + * rte_security_session_get_size tests + */ + +/** + * Test execution of rte_security_session_get_size with NULL instance + */ +static int +test_rte_security_session_get_size_inv_param_context(void) +{ + unsigned int ret = rte_security_session_get_size(NULL); + TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_get_size, + ret, 0, "%u"); + TEST_ASSERT_MOCK_CALLS(mock_session_get_size_exp, 0); + + return TEST_SUCCESS; +} + +/** + * Test execution of rte_security_session_get_size with invalid + * security operations structure (NULL) + */ +static int +test_rte_security_session_get_size_inv_param_context_ops(void) +{ + struct security_unittest_params *ut_params = &unittest_params; + ut_params->ctx.ops = NULL; + + unsigned int ret = rte_security_session_get_size(&ut_params->ctx); + TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_get_size, + ret, 0, "%u"); + TEST_ASSERT_MOCK_CALLS(mock_session_get_size_exp, 0); + + return TEST_SUCCESS; +} + +/** + * Test execution of rte_security_session_get_size with empty + * security operations + */ +static int +test_rte_security_session_get_size_inv_param_context_ops_fun(void) +{ + struct security_unittest_params *ut_params = &unittest_params; + ut_params->ctx.ops = &empty_ops; + + unsigned int ret = rte_security_session_get_size(&ut_params->ctx); + TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_get_size, + ret, 0, "%u"); + TEST_ASSERT_MOCK_CALLS(mock_session_get_size_exp, 0); + + return TEST_SUCCESS; +} + +/** + * Test execution of rte_security_session_get_size when session_get_size + * security operation fails + */ +static int +test_rte_security_session_get_size_ops_failure(void) +{ + struct security_unittest_params *ut_params = &unittest_params; + + mock_session_get_size_exp.device = NULL; + mock_session_get_size_exp.ret = 0; + + unsigned int ret = rte_security_session_get_size(&ut_params->ctx); + TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_get_size, + ret, 0, "%u"); + TEST_ASSERT_MOCK_CALLS(mock_session_get_size_exp, 1); + + return TEST_SUCCESS; +} + +/** + * Test execution of rte_security_session_get_size in successful execution path + */ +static int +test_rte_security_session_get_size_success(void) +{ + struct security_unittest_params *ut_params = &unittest_params; + + mock_session_get_size_exp.device = NULL; + mock_session_get_size_exp.ret = 1024; + + unsigned int ret = rte_security_session_get_size(&ut_params->ctx); + TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_get_size, + ret, 1024U, "%u"); + TEST_ASSERT_MOCK_CALLS(mock_session_get_size_exp, 1); + + return TEST_SUCCESS; +} + + /** * Declaration of testcases */ @@ -879,6 +999,17 @@ static struct unit_test_suite security_testsuite = { TEST_CASE_ST(ut_setup_with_session, ut_teardown, test_rte_security_session_update_success), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_rte_security_session_get_size_inv_param_context), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_rte_security_session_get_size_inv_param_context_ops), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_rte_security_session_get_size_inv_param_context_ops_fun), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_rte_security_session_get_size_ops_failure), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_rte_security_session_get_size_success), + TEST_CASES_END() /**< NULL terminate unit test array */ } }; -- 2.17.1