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 5E162A0597; Thu, 9 Apr 2020 19:27:05 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 50E791D41D; Thu, 9 Apr 2020 19:25:47 +0200 (CEST) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id 5B93A1D152 for ; Thu, 9 Apr 2020 19:25:36 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20200409172536euoutp025dd32a307cc0808d24088adff8618a62~ENrjT32H32229522295euoutp02J for ; Thu, 9 Apr 2020 17:25:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20200409172536euoutp025dd32a307cc0808d24088adff8618a62~ENrjT32H32229522295euoutp02J DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1586453136; bh=igxkj1rh0eTu9I7h5X2CfjMMhnmGhIJ6tYnNcUVR9fk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=up54j6Sb6hWC84cUB5mcXXWGL7tgQZjGmuDs3Py/G7swc7R+akhwXheIfuAJdsS9Z +yueyuG9qvF92+2wRmmpVptrfRFynvWvUW6l6aCTI1IRptPGMtmfDHk4ToaXkvphH+ SPWWnQ+ES7T4mm8Z4bkrpt5slZIvtB9CXpjMpAiQ= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20200409172535eucas1p24b523894175c6cde11693ac9ef0d4fa6~ENrjBjbPy0369803698eucas1p2q for ; Thu, 9 Apr 2020 17:25:35 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 82.50.60679.F8A5F8E5; Thu, 9 Apr 2020 18:25:35 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20200409172535eucas1p152b3d17bd9d2194f9f2669116130331d~ENriVtq7J2193421934eucas1p1G for ; Thu, 9 Apr 2020 17:25:35 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200409172535eusmtrp118732d4df1fcc1ee03b03fd08b6d8ddb~ENriVPsJH2463624636eusmtrp1M for ; Thu, 9 Apr 2020 17:25:35 +0000 (GMT) X-AuditID: cbfec7f4-0e5ff7000001ed07-db-5e8f5a8fa146 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 2D.B9.08375.F8A5F8E5; Thu, 9 Apr 2020 18:25:35 +0100 (BST) Received: from localhost.localdomain (unknown [106.210.88.70]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200409172534eusmtip12b2ccc658c6fb3d7f43709c51367db56~ENriEf5QQ0971609716eusmtip1W for ; Thu, 9 Apr 2020 17:25:34 +0000 (GMT) From: Lukasz Wojciechowski To: Cc: dev@dpdk.org Date: Thu, 9 Apr 2020 19:24:58 +0200 Message-Id: <20200409172502.1693-10-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+NgFjrFIsWRmVeSWpSXmKPExsWy7djPc7r9Uf1xBh3/jC3efdrO5MDo8WvB UtYAxigum5TUnMyy1CJ9uwSujM5bG5kKmnUqZq76xtTA+EO1i5GDQ0LARGLVUpcuRi4OIYEV jBLL9jxjhHDamSQat31mhnDamCS+P3zE1MXICdYxfck+JojEckaJG+euIVQ1fPjOCFLFJmAr cWTmV1YQW0SARWLl9+8sIDazgIDE43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ytxDjBIczEoivN5NvXFCvCmJlVWpRfnxRaU5qcWHGE2BbprILCWanA8M9bySeENTQ3MLS0Nz Y3NjMwslcd4OgYMxQgLpiSWp2ampBalFMH1MHJxSDYyWEhd9b6ucPHG8KDj1eXpJtsS+CbEv WdS+Bqb2f9/fcXfTqde5d9rPCQpUebOmxMXcnbTp4/c0FfvG9EP8G6vvma5o9LvSIMPyOfPO J819Uh4ROa0nlz6J/GLbu17nfDYrd5LuXc5Qtoh1Xyt5ko199ivLqJtPE0t8uurhOq9tr2dI m+c1fFRiKc5INNRiLipOBADEDSAMPQIAAA== X-CMS-MailID: 20200409172535eucas1p152b3d17bd9d2194f9f2669116130331d X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200409172535eucas1p152b3d17bd9d2194f9f2669116130331d X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200409172535eucas1p152b3d17bd9d2194f9f2669116130331d References: <20200408031351.4288-1-l.wojciechow@partner.samsung.com> <20200409172502.1693-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-dev] [PATCH v3 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" Add unit tests for rte_security_session_destroy function. Signed-off-by: Lukasz Wojciechowski --- app/test/test_security.c | 166 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 166 insertions(+) diff --git a/app/test/test_security.c b/app/test/test_security.c index c495449b0..b1a907bd9 100644 --- a/app/test/test_security.c +++ b/app/test/test_security.c @@ -1137,6 +1137,159 @@ test_session_stats_get_success(void) } +/** + * rte_security_session_destroy tests + */ + +/** + * Test execution of rte_security_session_destroy with NULL instance + */ +static int +test_session_destroy_inv_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_session_destroy_inv_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_session_destroy_inv_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_session_destroy_inv_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_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_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 */ @@ -1201,6 +1354,19 @@ static struct unit_test_suite security_testsuite = { TEST_CASE_ST(ut_setup_with_session, ut_teardown, test_session_stats_get_success), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_session_destroy_inv_context), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_session_destroy_inv_context_ops), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_session_destroy_inv_context_ops_fun), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_session_destroy_inv_session), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_session_destroy_ops_failure), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_session_destroy_success), + TEST_CASES_END() /**< NULL terminate unit test array */ } }; -- 2.17.1