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 46C82A0597; Thu, 9 Apr 2020 19:27:35 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6C4F41D443; Thu, 9 Apr 2020 19:25:51 +0200 (CEST) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id 7D08E1D152 for ; Thu, 9 Apr 2020 19:25:37 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20200409172537euoutp0209625418feb6792eb2979c34e0bf40ea~ENrkXbeaA2229522295euoutp02K for ; Thu, 9 Apr 2020 17:25:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20200409172537euoutp0209625418feb6792eb2979c34e0bf40ea~ENrkXbeaA2229522295euoutp02K DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1586453137; bh=bbaULdOoK7Yqq1zoQqLeE0AbsAwWKDjSXHli5Qu5bes=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=buaryCoSemCltSbBIHzZqnByQPYp98cBXV4mS/ZSkTJFjUhCEJfeh2oHOvJWZlK5h zqweG2KLbD/Yxd6wmxn+Bn87btDTr/DTR8TaUXWBG//5SJJtchtTIEhgYOcqtZE4cs iZXPTXpJb4H8C8jpxeqg08fM824xv67AA5oehA8E= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20200409172536eucas1p29d87b1885c875b91678dfea59c1022f4~ENrj7Our10369803698eucas1p2s for ; Thu, 9 Apr 2020 17:25:36 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id D4.F2.61286.09A5F8E5; Thu, 9 Apr 2020 18:25:36 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20200409172536eucas1p1396c04fb7a9fb80db2a5670f8f3453bb~ENrjochmm2198621986eucas1p16 for ; Thu, 9 Apr 2020 17:25:36 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200409172536eusmtrp15a0dcf736a19fe726700682e150549b7~ENrjn_UFe2463624636eusmtrp1P for ; Thu, 9 Apr 2020 17:25:36 +0000 (GMT) X-AuditID: cbfec7f2-f0bff7000001ef66-3a-5e8f5a9012c3 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 35.48.07950.09A5F8E5; Thu, 9 Apr 2020 18:25:36 +0100 (BST) Received: from localhost.localdomain (unknown [106.210.88.70]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200409172536eusmtip1cbbc78d6a18a6b61941a1cfa7b34eceb~ENrjUEhbK0978609786eusmtip1v for ; Thu, 9 Apr 2020 17:25:36 +0000 (GMT) From: Lukasz Wojciechowski To: Cc: dev@dpdk.org Date: Thu, 9 Apr 2020 19:25:01 +0200 Message-Id: <20200409172502.1693-13-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: H4sIAAAAAAAAA+NgFjrNIsWRmVeSWpSXmKPExsWy7djP87oTovrjDD6+1rN492k7kwOjx68F S1kDGKO4bFJSczLLUov07RK4Mg6cjShYrl0xv20nUwPjN5UuRk4OCQETiYOtixi7GLk4hARW MEqc/bYRymlnklj+8CM7hNPGJLH3SC8zTEvv/JVsEInljBI/t3axwlX1n/jPBlLFJmArcWTm V1YQW0SARWLl9+8sIDazgIDE43vPwOLCAt4Sz/Y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YS4fVu6o0T4k1JrKxKLcqPLyrNSS0+xGgKdNREZinR5HxgqOeVxBuaGppbWBqa G5sbm1koifN2CByMERJITyxJzU5NLUgtgulj4uCUamA85vNh1RFBjp2WT91OXJtcl+Vse23t OYOPHx5wS1x93OmXZsC25oCKoI+wsKN5hXJpXWrB3Mddwh/9FGY38sSZ3mGoNKspvq+4+M0n ho7lydwHt8SwP4h4lhbQvnDeqxMPv8muOTCj1vzFjeDtfgVzxew+r1vR+qAkb3ltvIbbkylK mdc37DuvxFKckWioxVxUnAgAHMXLLz0CAAA= X-CMS-MailID: 20200409172536eucas1p1396c04fb7a9fb80db2a5670f8f3453bb X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200409172536eucas1p1396c04fb7a9fb80db2a5670f8f3453bb X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200409172536eucas1p1396c04fb7a9fb80db2a5670f8f3453bb References: <20200408031351.4288-1-l.wojciechow@partner.samsung.com> <20200409172502.1693-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-dev] [PATCH v3 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" Add unit tests for rte_security_capabilities_get function. Signed-off-by: Lukasz Wojciechowski --- app/test/test_security.c | 138 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) diff --git a/app/test/test_security.c b/app/test/test_security.c index 53b9e122e..3570da2a2 100644 --- a/app/test/test_security.c +++ b/app/test/test_security.c @@ -440,6 +440,30 @@ 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 * @@ -460,6 +484,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, }; @@ -556,6 +581,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; @@ -564,6 +590,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; } @@ -1658,6 +1685,106 @@ test_get_userdata_success(void) } +/** + * rte_security_capabilities_get tests + */ + +/** + * Test execution of rte_security_capabilities_get with NULL instance + */ +static int +test_capabilities_get_inv_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_capabilities_get_inv_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_capabilities_get_inv_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_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_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 */ @@ -1759,6 +1886,17 @@ static struct unit_test_suite security_testsuite = { TEST_CASE_ST(ut_setup_with_session, ut_teardown, test_get_userdata_success), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_capabilities_get_inv_context), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_capabilities_get_inv_context_ops), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_capabilities_get_inv_context_ops_fun), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_capabilities_get_ops_failure), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_capabilities_get_success), + TEST_CASES_END() /**< NULL terminate unit test array */ } }; -- 2.17.1