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 1328CA0597; Wed, 8 Apr 2020 05:16:44 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D03C41C0C7; Wed, 8 Apr 2020 05:15:07 +0200 (CEST) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id D82931BF60 for ; Wed, 8 Apr 2020 05:14:54 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20200408031454euoutp025070be77993878880a506a0c882b59d9~Dubg8k5SN1520915209euoutp02y for ; Wed, 8 Apr 2020 03:14:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20200408031454euoutp025070be77993878880a506a0c882b59d9~Dubg8k5SN1520915209euoutp02y DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1586315694; bh=xVHLCwwZpPMlphGkAsIF+b88Vi+kHzKTZBCeQBv7bUI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aS74Zm/YQuJopYelMzyuLvliVId4Ynv8KPWt2P0xm2zY9eZisvfhI7xP1x8D7ky6G GiF3C49ox4X+HpOrQDjxWYR961psDFNt0dT1apOMoSzCQ6nsLTx0W5YniHpzNBbGXI C8auUY179C1bXF18NlcyrXa7iR6EGz5hqb4d4oLs= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20200408031454eucas1p1fdc0c643498b2849a453fa70f4ade098~DubgoYZfW2414224142eucas1p1d for ; Wed, 8 Apr 2020 03:14:54 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 3F.1B.61286.EA14D8E5; Wed, 8 Apr 2020 04:14:54 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20200408031454eucas1p112c6eded420bdcfdb09fad83bf485afb~DubgU9FeL0246502465eucas1p1Q for ; Wed, 8 Apr 2020 03:14:54 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200408031454eusmtrp14ee134718918a8bb28b19f25b9cc1bb4~DubgUcYdy1153511535eusmtrp1x for ; Wed, 8 Apr 2020 03:14:54 +0000 (GMT) X-AuditID: cbfec7f2-ef1ff7000001ef66-6f-5e8d41aeb047 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 20.79.07950.DA14D8E5; Wed, 8 Apr 2020 04:14:53 +0100 (BST) Received: from localhost.localdomain (unknown [106.210.88.70]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200408031453eusmtip13f923838f200c8f93abd7178774e9211~DubgCJ_pK2966429664eusmtip1e for ; Wed, 8 Apr 2020 03:14:53 +0000 (GMT) From: Lukasz Wojciechowski To: Cc: dev@dpdk.org Date: Wed, 8 Apr 2020 05:13:50 +0200 Message-Id: <20200408031351.4288-13-l.wojciechow@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200408031351.4288-1-l.wojciechow@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrFIsWRmVeSWpSXmKPExsWy7djP87rrHHvjDPp/CVu8+7SdyYHR49eC pawBjFFcNimpOZllqUX6dglcGY/6WpgKlmtX3P/7h7WB8ZtKFyMnh4SAicTuNbeYuxi5OIQE VjBKPH36ghXCaWeSaDgwkQXCaWOSmPq4kQ2mZfmLp0wQieWMEgsmvGIBSYBVTV7oCmKzCdhK HJn5lRXEFhFgkVj5/TtYDbOAgMTje8/A4sIC3hJf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h5ilOBgVhLhlertjBPiTUmsrEotyo8vKs1JLT7EaAp000RmKdHkfGCo55XEG5oamltY GpobmxubWSiJ83YIHIwREkhPLEnNTk0tSC2C6WPi4JRqYGzo75oa++VheNc74eWWTyfHXglz ym1fsXmZ1W7emzl/7iyLSVpym0/2hLrscbGDG1dsNDl/hOHw157L4jUFH1b78++9cpa7tM91 3pta7QObbj9K4+wPcylbWrrp05qp5TlLq/z1WuXXT6k4HqxUcbFG5nXo/TtMSx893p+gbpfx QL8xpzHmd5QSS3FGoqEWc1FxIgB2uFnaPQIAAA== X-CMS-MailID: 20200408031454eucas1p112c6eded420bdcfdb09fad83bf485afb X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200408031454eucas1p112c6eded420bdcfdb09fad83bf485afb X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200408031454eucas1p112c6eded420bdcfdb09fad83bf485afb References: <20200312151654.7218-1-l.wojciechow@partner.samsung.com> <20200408031351.4288-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-dev] [PATCH v2 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 230b53891..9da81fa1d 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