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 2C95BA056E; Thu, 12 Mar 2020 16:19:14 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CE7D61C0C5; Thu, 12 Mar 2020 16:17:23 +0100 (CET) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id 01A262BE6 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 20200312151710euoutp012562f6e0e90c720cc47c1f5034b12de2~7l3bjq8kS0594305943euoutp01J for ; Thu, 12 Mar 2020 15:17:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20200312151710euoutp012562f6e0e90c720cc47c1f5034b12de2~7l3bjq8kS0594305943euoutp01J DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1584026230; bh=rxjwED2j6idGWtR2BI/xAgWu+8XPq93cS43i5LvWjeU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=KBQvjLgywg6FUWGnMGrsPE9JrYXE52nNtn/+ju7Uy49KELL7FWW/R0Jv0eah3saDf Fhmg6IKbf4fd6peHT+JKr+VN0oYj4sCtazbGc29mhlADdL8wThRiYY9dNUA8joWown y78fSDfkmkcprDgHpi3J3YmWty3lub3WscOI4Lgc= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20200312151710eucas1p213c73a1bb31ae9ab3a07c0ddf919f0ee~7l3bRAth12375023750eucas1p2i for ; Thu, 12 Mar 2020 15:17:10 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 0B.B9.60698.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 20200312151710eucas1p22f051449e6e7edeadefe65b66ffaed32~7l3a6lLT61698716987eucas1p2x 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 20200312151710eusmtrp23ca1bba26d778ae00defcc1cdfee636b~7l3a6DbOQ1238312383eusmtrp2N for ; Thu, 12 Mar 2020 15:17:10 +0000 (GMT) X-AuditID: cbfec7f5-a0fff7000001ed1a-a8-5e6a52768ec3 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id E1.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 20200312151709eusmtip1aa38ae54be42f6110588c3b68dfe782e~7l3arkQlM1532415324eusmtip1S for ; Thu, 12 Mar 2020 15:17:09 +0000 (GMT) From: Lukasz Wojciechowski To: dev@dpdk.org Date: Thu, 12 Mar 2020 16:16:50 +0100 Message-Id: <20200312151654.7218-10-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+NgFtrDIsWRmVeSWpSXmKPExsWy7djP87plQVlxBr3PZCzefdrO5MDo8WvB UtYAxigum5TUnMyy1CJ9uwSujKs/77AUHNStuHJtMmsD41X1LkYODgkBE4lv6wq7GDk5hARW MErsu5UCYbczSVycr9fFyAVktzFJrFz+iwUkAVI/b9V+VojEckaJU//bWCAcoI5zX3rBqtgE bCWOzPzKCmKLCAhIfO5czAZiCwu4S8zv/gEWZxFQlbj94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tDU0NzC0tDc2NzYzEJJnLdD 4GCMkEB6YklqdmpqQWoRTB8TB6dUAyND0Lvf8uf/vV34rKjzNNfTBc0Wxu5/z982Vle3zfkg yrj44g/Lw/7vw8R+umx99rTj18GrVTeC3ivY/k4zUHlx4GO8av6jJ4wyljOXqKi8qdvTW3Zb aqpLYaSNwCVG2QSxP+5Ky4OFTv5+svrRHiPPjqtHVF+sXql9U3pDc+Sr/Oe//CcrlzoosRRn JBpqMRcVJwIAoF/HDDECAAA= X-CMS-MailID: 20200312151710eucas1p22f051449e6e7edeadefe65b66ffaed32 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200312151710eucas1p22f051449e6e7edeadefe65b66ffaed32 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200312151710eucas1p22f051449e6e7edeadefe65b66ffaed32 References: <20200312151654.7218-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-dev] [PATCH 09/13] app/test: add rte_security_session_destroy 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: Id1543157b4ce89bd5ec07fc46ff67b65ec3b4a89 --- app/test/test_security.c | 160 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 160 insertions(+) diff --git a/app/test/test_security.c b/app/test/test_security.c index 647a2dd0a..dc11b96ff 100644 --- a/app/test/test_security.c +++ b/app/test/test_security.c @@ -1118,6 +1118,153 @@ test_rte_security_session_stats_get_success(void) } +/** + * rte_security_session_destroy tests + */ + +/** + * Test execution of rte_security_session_destroy with NULL instance + */ +static int +test_rte_security_session_destroy_inv_param_context(void) +{ + struct security_unittest_params *ut_params = &unittest_params; + + TEST_ASSERT_MEMPOOL_USAGE(1); + TEST_ASSERT_SESSION_COUNT(1); + + int ret = rte_security_session_destroy(NULL, ut_params->sess); + TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_destroy, + ret, -EINVAL, "%d"); + TEST_ASSERT_MOCK_CALLS(mock_session_destroy_exp, 0); + TEST_ASSERT_MEMPOOL_USAGE(1); + TEST_ASSERT_SESSION_COUNT(1); + + return TEST_SUCCESS; +} + +/** + * Test execution of rte_security_session_destroy with invalid + * security operations structure (NULL) + */ +static int +test_rte_security_session_destroy_inv_param_context_ops(void) +{ + struct security_unittest_params *ut_params = &unittest_params; + ut_params->ctx.ops = NULL; + + TEST_ASSERT_MEMPOOL_USAGE(1); + TEST_ASSERT_SESSION_COUNT(1); + + int ret = rte_security_session_destroy(&ut_params->ctx, ut_params->sess); + TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_destroy, + ret, -EINVAL, "%d"); + TEST_ASSERT_MOCK_CALLS(mock_session_destroy_exp, 0); + TEST_ASSERT_MEMPOOL_USAGE(1); + TEST_ASSERT_SESSION_COUNT(1); + + return TEST_SUCCESS; +} + +/** + * Test execution of rte_security_session_destroy with empty + * security operations + */ +static int +test_rte_security_session_destroy_inv_param_context_ops_fun(void) +{ + struct security_unittest_params *ut_params = &unittest_params; + ut_params->ctx.ops = &empty_ops; + + TEST_ASSERT_MEMPOOL_USAGE(1); + TEST_ASSERT_SESSION_COUNT(1); + + int ret = rte_security_session_destroy(&ut_params->ctx, ut_params->sess); + TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_destroy, + ret, -ENOTSUP, "%d"); + TEST_ASSERT_MOCK_CALLS(mock_session_destroy_exp, 0); + TEST_ASSERT_MEMPOOL_USAGE(1); + TEST_ASSERT_SESSION_COUNT(1); + + return TEST_SUCCESS; +} + +/** + * Test execution of rte_security_session_destroy with NULL sess parameter + */ +static int +test_rte_security_session_destroy_inv_param_session(void) +{ + struct security_unittest_params *ut_params = &unittest_params; + + TEST_ASSERT_MEMPOOL_USAGE(1); + TEST_ASSERT_SESSION_COUNT(1); + + int ret = rte_security_session_destroy(&ut_params->ctx, NULL); + TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_destroy, + ret, -EINVAL, "%d"); + TEST_ASSERT_MOCK_CALLS(mock_session_destroy_exp, 0); + TEST_ASSERT_MEMPOOL_USAGE(1); + TEST_ASSERT_SESSION_COUNT(1); + + return TEST_SUCCESS; +} + +/** + * Test execution of rte_security_session_destroy when session_destroy + * security operation fails + */ +static int +test_rte_security_session_destroy_ops_failure(void) +{ + struct security_unittest_params *ut_params = &unittest_params; + + mock_session_destroy_exp.device = NULL; + mock_session_destroy_exp.sess = ut_params->sess; + mock_session_destroy_exp.ret = -1; + + TEST_ASSERT_MEMPOOL_USAGE(1); + TEST_ASSERT_SESSION_COUNT(1); + + int ret = rte_security_session_destroy(&ut_params->ctx, ut_params->sess); + TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_destroy, + ret, -1, "%d"); + TEST_ASSERT_MOCK_CALLS(mock_session_destroy_exp, 1); + TEST_ASSERT_MEMPOOL_USAGE(1); + TEST_ASSERT_SESSION_COUNT(1); + + return TEST_SUCCESS; +} + +/** + * Test execution of rte_security_session_destroy in successful execution path + */ +static int +test_rte_security_session_destroy_success(void) +{ + struct security_unittest_params *ut_params = &unittest_params; + + mock_session_destroy_exp.device = NULL; + mock_session_destroy_exp.sess = ut_params->sess; + mock_session_destroy_exp.ret = 0; + TEST_ASSERT_MEMPOOL_USAGE(1); + TEST_ASSERT_SESSION_COUNT(1); + + int ret = rte_security_session_destroy(&ut_params->ctx, ut_params->sess); + TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_destroy, + ret, 0, "%d"); + TEST_ASSERT_MOCK_CALLS(mock_session_destroy_exp, 1); + TEST_ASSERT_MEMPOOL_USAGE(0); + TEST_ASSERT_SESSION_COUNT(0); + + // Remove session from test case parameters, so it won't be destroyed + // during test case teardown. + ut_params->sess = NULL; + + return TEST_SUCCESS; +} + + /** * Declaration of testcases */ @@ -1182,6 +1329,19 @@ static struct unit_test_suite security_testsuite = { TEST_CASE_ST(ut_setup_with_session, ut_teardown, test_rte_security_session_stats_get_success), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_rte_security_session_destroy_inv_param_context), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_rte_security_session_destroy_inv_param_context_ops), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_rte_security_session_destroy_inv_param_context_ops_fun), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_rte_security_session_destroy_inv_param_session), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_rte_security_session_destroy_ops_failure), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_rte_security_session_destroy_success), + TEST_CASES_END() /**< NULL terminate unit test array */ } }; -- 2.17.1