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 88E59A056D; Thu, 12 Mar 2020 16:19:32 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 235FB1C0CE; Thu, 12 Mar 2020 16:17:25 +0100 (CET) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id 10C621BFBF for ; Thu, 12 Mar 2020 16:17:11 +0100 (CET) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20200312151710euoutp01c9d29802ae89516b7927cfd60c1cb9d3~7l3bkX-xQ0474204742euoutp01E for ; Thu, 12 Mar 2020 15:17:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20200312151710euoutp01c9d29802ae89516b7927cfd60c1cb9d3~7l3bkX-xQ0474204742euoutp01E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1584026230; bh=dn0wr9Wp6Y8StzL2s7wq+NPqdjDPCu2dmcQiGHjSTaw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=FihYWITiRPnS1PA/Px9GwWw4VXWkM08ieTDuXHKO9vUd+eyme0CeE6BEuyM4YceOB JlO1OJaQzF/kS9n2QDHIORenJA7BKaw4Mynailed3GjpK2SRXzlzmp3aStH8rJhpsN c0OdSta9IxmkTEuE46l9d8FR6f+nBuBgix3jDsVw= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20200312151710eucas1p125e9705aeaa33f31bd3b0bc9c82d4276~7l3bW_PVG1595115951eucas1p1i for ; Thu, 12 Mar 2020 15:17:10 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 2B.B9.60698.6725A6E5; Thu, 12 Mar 2020 15:17:10 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20200312151710eucas1p10124737620ec6414aa593e7fa67ee56b~7l3bGebbT0788307883eucas1p18 for ; Thu, 12 Mar 2020 15:17:10 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200312151710eusmtrp2e49e130299f524cbfc9c78e8cf7ff104~7l3bF_Qbd1238312383eusmtrp2O for ; Thu, 12 Mar 2020 15:17:10 +0000 (GMT) X-AuditID: cbfec7f5-a29ff7000001ed1a-a9-5e6a5276e3d7 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 52.2D.07950.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 20200312151710eusmtip1856ab0de4d5229c683f36af768507a23~7l3a3tMYM1547415474eusmtip1Y for ; Thu, 12 Mar 2020 15:17:10 +0000 (GMT) From: Lukasz Wojciechowski To: dev@dpdk.org Date: Thu, 12 Mar 2020 16:16:51 +0100 Message-Id: <20200312151654.7218-11-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+NgFtrPIsWRmVeSWpSXmKPExsWy7djPc7plQVlxBi9fqFi8+7SdyYHR49eC pawBjFFcNimpOZllqUX6dglcGb2/djAWvLWpmPn7P2MD41STLkYODgkBE4k9a/m7GLk4hARW MEpsXjeXHcJpZ5K4efM2E4TTxiTxsGk2UIYTrKPpVQ8jRGI5o8T6+c/Z4FpeH13BAlLFJmAr cWTmV1YQW0RAQOJz52I2EFtYwEN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qcWHGE2BjprILCWanA8M6bySeENTQ3MLS0NzY3NjMwslcd4O gYMxQgLpiSWp2ampBalFMH1MHJxSDYwqpk4XH3+7wniBIb2gKyHgZ266wppPy6bercwOFdSY UvFghXj4M+aK/7ef6X8MLuZlPjt7z+FuCdNL+6uPOj3I2b2K6TTLM+1b7hNO3byl8E5/zdPd 4le2vHPXTVEL6NgYY667/nGsarl+y4mEIy7uyk5uZyT7y8y2Rz6YXqwlwBz1vmdh5C0lluKM REMt5qLiRAAODhC4MQIAAA== X-CMS-MailID: 20200312151710eucas1p10124737620ec6414aa593e7fa67ee56b X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200312151710eucas1p10124737620ec6414aa593e7fa67ee56b X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200312151710eucas1p10124737620ec6414aa593e7fa67ee56b References: <20200312151654.7218-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-dev] [PATCH 10/13] app/test: add rte_security_set_pkt_metadata 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: Id5b4304e83a12443c62557c2a917125084e14f6b --- app/test/test_security.c | 204 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 204 insertions(+) diff --git a/app/test/test_security.c b/app/test/test_security.c index dc11b96ff..fa9141f89 100644 --- a/app/test/test_security.c +++ b/app/test/test_security.c @@ -341,6 +341,38 @@ mock_session_destroy(void *device, return mock_session_destroy_exp.ret; } +/** + * set_pkt_metadata mockup + * + * Verified parameters: device, sess, m, params. + */ +static struct mock_set_pkt_metadata_data { + void *device; + struct rte_security_session *sess; + struct rte_mbuf *m; + void *params; + + int ret; + + int called; + int failed; +} mock_set_pkt_metadata_exp = {NULL, NULL, NULL, NULL, 0, 0, 0}; + +static int +mock_set_pkt_metadata(void *device, + struct rte_security_session *sess, + struct rte_mbuf *m, + void *params) { + mock_set_pkt_metadata_exp.called++; + + MOCK_TEST_ASSERT_POINTER_PARAMETER(mock_set_pkt_metadata_exp, device); + MOCK_TEST_ASSERT_POINTER_PARAMETER(mock_set_pkt_metadata_exp, sess); + MOCK_TEST_ASSERT_POINTER_PARAMETER(mock_set_pkt_metadata_exp, m); + MOCK_TEST_ASSERT_POINTER_PARAMETER(mock_set_pkt_metadata_exp, params); + + return mock_set_pkt_metadata_exp.ret; +} + /** * empty_ops * @@ -359,6 +391,7 @@ struct rte_security_ops mock_ops = { .session_get_size = mock_session_get_size, .session_stats_get = mock_session_stats_get, .session_destroy = mock_session_destroy, + .set_pkt_metadata = mock_set_pkt_metadata, }; @@ -450,12 +483,14 @@ ut_setup(void) { mock_session_get_size_exp.called = 0; mock_session_stats_get_exp.called = 0; mock_session_destroy_exp.called = 0; + mock_set_pkt_metadata_exp.called = 0; mock_session_create_exp.failed = 0; mock_session_update_exp.failed = 0; mock_session_get_size_exp.failed = 0; mock_session_stats_get_exp.failed = 0; mock_session_destroy_exp.failed = 0; + mock_set_pkt_metadata_exp.failed = 0; return TEST_SUCCESS; } @@ -1265,6 +1300,160 @@ test_rte_security_session_destroy_success(void) } +/** + * rte_security_set_pkt_metadata tests + */ + +/** + * Test execution of rte_security_set_pkt_metadata with NULL instance + */ +static int +test_rte_security_set_pkt_metadata_inv_param_context(void) +{ + struct security_unittest_params *ut_params = &unittest_params; + struct rte_mbuf m; + int params; + + int ret = rte_security_set_pkt_metadata(NULL, ut_params->sess, &m, + ¶ms); + TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_set_pkt_metadata, + ret, -EINVAL, "%d"); + TEST_ASSERT_MOCK_CALLS(mock_set_pkt_metadata_exp, 0); + + return TEST_SUCCESS; +} + +/** + * Test execution of rte_security_set_pkt_metadata with invalid + * security operations structure (NULL) + */ +static int +test_rte_security_set_pkt_metadata_inv_param_context_ops(void) +{ + struct security_unittest_params *ut_params = &unittest_params; + struct rte_mbuf m; + int params; + ut_params->ctx.ops = NULL; + + int ret = rte_security_set_pkt_metadata(&ut_params->ctx, ut_params->sess, + &m, ¶ms); + TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_set_pkt_metadata, + ret, -EINVAL, "%d"); + TEST_ASSERT_MOCK_CALLS(mock_set_pkt_metadata_exp, 0); + + return TEST_SUCCESS; +} + +/** + * Test execution of rte_security_set_pkt_metadata with empty + * security operations + */ +static int +test_rte_security_set_pkt_metadata_inv_param_context_ops_fun(void) +{ + struct security_unittest_params *ut_params = &unittest_params; + struct rte_mbuf m; + int params; + ut_params->ctx.ops = &empty_ops; + + int ret = rte_security_set_pkt_metadata(&ut_params->ctx, ut_params->sess, + &m, ¶ms); + TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_set_pkt_metadata, + ret, -ENOTSUP, "%d"); + TEST_ASSERT_MOCK_CALLS(mock_set_pkt_metadata_exp, 0); + + return TEST_SUCCESS; +} + +/** + * Test execution of rte_security_set_pkt_metadata with NULL sess parameter + */ +static int +test_rte_security_set_pkt_metadata_inv_param_session(void) +{ + struct security_unittest_params *ut_params = &unittest_params; + struct rte_mbuf m; + int params; + + int ret = rte_security_set_pkt_metadata(&ut_params->ctx, NULL, + &m, ¶ms); + TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_set_pkt_metadata, + ret, -EINVAL, "%d"); + TEST_ASSERT_MOCK_CALLS(mock_set_pkt_metadata_exp, 0); + + return TEST_SUCCESS; +} + +/** + * Test execution of rte_security_set_pkt_metadata with NULL m parameter + */ +static int +test_rte_security_set_pkt_metadata_inv_param_m(void) +{ + struct security_unittest_params *ut_params = &unittest_params; + int params; + + int ret = rte_security_set_pkt_metadata(&ut_params->ctx, ut_params->sess, + NULL, ¶ms); + TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_set_pkt_metadata, + ret, -EINVAL, "%d"); + TEST_ASSERT_MOCK_CALLS(mock_set_pkt_metadata_exp, 0); + + return TEST_SUCCESS; +} + +/** + * Test execution of rte_security_set_pkt_metadata when set_pkt_metadata + * security operation fails + */ +static int +test_rte_security_set_pkt_metadata_ops_failure(void) +{ + struct security_unittest_params *ut_params = &unittest_params; + struct rte_mbuf m; + int params; + + mock_set_pkt_metadata_exp.device = NULL; + mock_set_pkt_metadata_exp.sess = ut_params->sess; + mock_set_pkt_metadata_exp.m = &m; + mock_set_pkt_metadata_exp.params = ¶ms; + mock_set_pkt_metadata_exp.ret = -1; + + int ret = rte_security_set_pkt_metadata(&ut_params->ctx, ut_params->sess, + &m, ¶ms); + TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_set_pkt_metadata, + ret, -1, "%d"); + TEST_ASSERT_MOCK_CALLS(mock_set_pkt_metadata_exp, 1); + + return TEST_SUCCESS; +} + +/** + * Test execution of rte_security_set_pkt_metadata in successful execution path + */ +static int +test_rte_security_set_pkt_metadata_success(void) +{ + struct security_unittest_params *ut_params = &unittest_params; + struct rte_mbuf m; + int params; + + mock_set_pkt_metadata_exp.device = NULL; + mock_set_pkt_metadata_exp.sess = ut_params->sess; + mock_set_pkt_metadata_exp.m = &m; + mock_set_pkt_metadata_exp.params = ¶ms; + mock_set_pkt_metadata_exp.ret = 0; + + int ret = rte_security_set_pkt_metadata(&ut_params->ctx, ut_params->sess, + &m, ¶ms); + TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_set_pkt_metadata, + ret, 0, "%d"); + TEST_ASSERT_MOCK_CALLS(mock_set_pkt_metadata_exp, 1); + + return TEST_SUCCESS; +} + + /** * Declaration of testcases */ @@ -1342,6 +1531,21 @@ static struct unit_test_suite security_testsuite = { TEST_CASE_ST(ut_setup_with_session, ut_teardown, test_rte_security_session_destroy_success), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_rte_security_set_pkt_metadata_inv_param_context), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_rte_security_set_pkt_metadata_inv_param_context_ops), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_rte_security_set_pkt_metadata_inv_param_context_ops_fun), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_rte_security_set_pkt_metadata_inv_param_session), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_rte_security_set_pkt_metadata_inv_param_m), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_rte_security_set_pkt_metadata_ops_failure), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_rte_security_set_pkt_metadata_success), + TEST_CASES_END() /**< NULL terminate unit test array */ } }; -- 2.17.1