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 DB21CA0597; Thu, 9 Apr 2020 19:26:55 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 010391D418; Thu, 9 Apr 2020 19:25:46 +0200 (CEST) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id D94691C437 for ; Thu, 9 Apr 2020 19:25:35 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20200409172535euoutp028695180a251d15b8539bee62f4d7506d~ENri1vdtd2096020960euoutp02j for ; Thu, 9 Apr 2020 17:25:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20200409172535euoutp028695180a251d15b8539bee62f4d7506d~ENri1vdtd2096020960euoutp02j DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1586453135; bh=acA+ii0yOmD1r+6N7MuYyRPvxP2ro9kXIxZa9EtWUq4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tsx6aCSSYnSO9oAvOiAfQTugJ7UP6NaJdiuutwjD6hMXKupNgYojDsEQCFDly0s6n wpclchC2FJaUVDO0fWowURSPcery/xwgOw+pDZOq9xumUlATBg55oDZ4w/MqCc47S4 wpvOZV49WCbbyTj1bdkdWxnofeVJ7ECuy2IlsVcw= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20200409172535eucas1p23dd5f75264f146bbd0c1ac7d366f4380~ENrinqmks0369803698eucas1p2o for ; Thu, 9 Apr 2020 17:25:35 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id F3.F2.61286.F8A5F8E5; Thu, 9 Apr 2020 18:25:35 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20200409172534eucas1p2852ae56687fd5bae343437b07198c070~ENrh-zb3t2381823818eucas1p2- for ; Thu, 9 Apr 2020 17:25:34 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200409172534eusmtrp1a3a2fa212b5a0eae301aed532a02bec0~ENrh-V7Mh2463624636eusmtrp1K for ; Thu, 9 Apr 2020 17:25:34 +0000 (GMT) X-AuditID: cbfec7f2-ef1ff7000001ef66-37-5e8f5a8f27cb Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id EC.B9.08375.E8A5F8E5; Thu, 9 Apr 2020 18:25:34 +0100 (BST) Received: from localhost.localdomain (unknown [106.210.88.70]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200409172534eusmtip15054d345eda775610733ae487cd42248~ENrhsDg5f0696806968eusmtip1U 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:57 +0200 Message-Id: <20200409172502.1693-9-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+NgFjrJIsWRmVeSWpSXmKPExsWy7djP87r9Uf1xBm0dIhbvPm1ncmD0+LVg KWsAYxSXTUpqTmZZapG+XQJXxpxdn5gKJphWHLr0j6WB8ZBuFyMnh4SAicSCCd+ZQWwhgRWM EvdfG3cxcgHZ7UwS0160MEI4bUwS85rmMsN0zHh9kAkisZxR4s6yd6xwVbMe3GcEqWITsJU4 MvMrK4gtIsAisfL7dxYQm1lAQOLxvWdgcWEBH4l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c1KLDzGaAt00kVlKNDkfGOp5JfGGpobmFpaG 5sbmxmYWSuK8HQIHY4QE0hNLUrNTUwtSi2D6mDg4pRoYxYQemyU8mci/eXVosOTEXZMeTjq9 64LRiUNntzNf3/PVf/ObixuzmziaVuQn3Wuvn65jnGb3Su5T/T4TBSF5oWmcJ52mrl5Yby6f 7Kp4weVhccyK2V6Jn3Y+WMlftKt5TpLbiaZiN1Px2+VpwhJ1PYYWjvHBq6Qj9vPWlX1iNNnd JDVdc1OgEktxRqKhFnNRcSIAHEK6Vj0CAAA= X-CMS-MailID: 20200409172534eucas1p2852ae56687fd5bae343437b07198c070 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200409172534eucas1p2852ae56687fd5bae343437b07198c070 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200409172534eucas1p2852ae56687fd5bae343437b07198c070 References: <20200408031351.4288-1-l.wojciechow@partner.samsung.com> <20200409172502.1693-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-dev] [PATCH v3 08/13] app/test: add rte security session stats 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_session_stats_get function. Signed-off-by: Lukasz Wojciechowski --- app/test/test_security.c | 173 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 173 insertions(+) diff --git a/app/test/test_security.c b/app/test/test_security.c index 9c5e7d0da..c495449b0 100644 --- a/app/test/test_security.c +++ b/app/test/test_security.c @@ -292,6 +292,36 @@ mock_session_get_size(void *device) return mock_session_get_size_exp.ret; } +/** + * session_stats_get mockup + * + * Verified parameters: device, sess, stats. + */ +static struct mock_session_stats_get_data { + void *device; + struct rte_security_session *sess; + struct rte_security_stats *stats; + + int ret; + + int called; + int failed; +} mock_session_stats_get_exp = {NULL, NULL, NULL, 0, 0, 0}; + +static int +mock_session_stats_get(void *device, + struct rte_security_session *sess, + struct rte_security_stats *stats) +{ + mock_session_stats_get_exp.called++; + + MOCK_TEST_ASSERT_POINTER_PARAMETER(mock_session_stats_get_exp, device); + MOCK_TEST_ASSERT_POINTER_PARAMETER(mock_session_stats_get_exp, sess); + MOCK_TEST_ASSERT_POINTER_PARAMETER(mock_session_stats_get_exp, stats); + + return mock_session_stats_get_exp.ret; +} + /** * session_destroy mockup * @@ -334,6 +364,7 @@ struct rte_security_ops mock_ops = { .session_create = mock_session_create, .session_update = mock_session_update, .session_get_size = mock_session_get_size, + .session_stats_get = mock_session_stats_get, .session_destroy = mock_session_destroy, }; @@ -427,11 +458,13 @@ ut_setup(void) mock_session_create_exp.called = 0; mock_session_update_exp.called = 0; mock_session_get_size_exp.called = 0; + mock_session_stats_get_exp.called = 0; mock_session_destroy_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; return TEST_SUCCESS; @@ -977,6 +1010,133 @@ test_session_get_size_success(void) } +/** + * rte_security_session_stats_get tests + */ + +/** + * Test execution of rte_security_session_stats_get with NULL instance + */ +static int +test_session_stats_get_inv_context(void) +{ + struct security_unittest_params *ut_params = &unittest_params; + struct rte_security_stats stats; + + int ret = rte_security_session_stats_get(NULL, ut_params->sess, &stats); + TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_stats_get, + ret, -EINVAL, "%d"); + TEST_ASSERT_MOCK_CALLS(mock_session_stats_get_exp, 0); + + return TEST_SUCCESS; +} + +/** + * Test execution of rte_security_session_stats_get with invalid + * security operations structure (NULL) + */ +static int +test_session_stats_get_inv_context_ops(void) +{ + struct security_unittest_params *ut_params = &unittest_params; + struct rte_security_stats stats; + ut_params->ctx.ops = NULL; + + int ret = rte_security_session_stats_get(&ut_params->ctx, + ut_params->sess, &stats); + TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_stats_get, + ret, -EINVAL, "%d"); + TEST_ASSERT_MOCK_CALLS(mock_session_stats_get_exp, 0); + + return TEST_SUCCESS; +} + +/** + * Test execution of rte_security_session_stats_get with empty + * security operations + */ +static int +test_session_stats_get_inv_context_ops_fun(void) +{ + struct security_unittest_params *ut_params = &unittest_params; + struct rte_security_stats stats; + ut_params->ctx.ops = &empty_ops; + + int ret = rte_security_session_stats_get(&ut_params->ctx, + ut_params->sess, &stats); + TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_stats_get, + ret, -ENOTSUP, "%d"); + TEST_ASSERT_MOCK_CALLS(mock_session_stats_get_exp, 0); + + return TEST_SUCCESS; +} + +/** + * Test execution of rte_security_session_stats_get with NULL stats parameter + */ +static int +test_session_stats_get_inv_stats(void) +{ + struct security_unittest_params *ut_params = &unittest_params; + + int ret = rte_security_session_stats_get(&ut_params->ctx, + ut_params->sess, NULL); + TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_stats_get, + ret, -EINVAL, "%d"); + TEST_ASSERT_MOCK_CALLS(mock_session_stats_get_exp, 0); + + return TEST_SUCCESS; +} + +/** + * Test execution of rte_security_session_stats_get when session_stats_get + * security operation fails + */ +static int +test_session_stats_get_ops_failure(void) +{ + struct security_unittest_params *ut_params = &unittest_params; + struct rte_security_stats stats; + + mock_session_stats_get_exp.device = NULL; + mock_session_stats_get_exp.sess = ut_params->sess; + mock_session_stats_get_exp.stats = &stats; + mock_session_stats_get_exp.ret = -1; + + int ret = rte_security_session_stats_get(&ut_params->ctx, + ut_params->sess, &stats); + TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_stats_get, + ret, -1, "%d"); + TEST_ASSERT_MOCK_CALLS(mock_session_stats_get_exp, 1); + + return TEST_SUCCESS; +} + +/** + * Test execution of rte_security_session_stats_get in successful execution + * path + */ +static int +test_session_stats_get_success(void) +{ + struct security_unittest_params *ut_params = &unittest_params; + struct rte_security_stats stats; + + mock_session_stats_get_exp.device = NULL; + mock_session_stats_get_exp.sess = ut_params->sess; + mock_session_stats_get_exp.stats = &stats; + mock_session_stats_get_exp.ret = 0; + + int ret = rte_security_session_stats_get(&ut_params->ctx, + ut_params->sess, &stats); + TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_stats_get, + ret, 0, "%d"); + TEST_ASSERT_MOCK_CALLS(mock_session_stats_get_exp, 1); + + return TEST_SUCCESS; +} + + /** * Declaration of testcases */ @@ -1028,6 +1188,19 @@ static struct unit_test_suite security_testsuite = { TEST_CASE_ST(ut_setup_with_session, ut_teardown, test_session_get_size_success), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_session_stats_get_inv_context), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_session_stats_get_inv_context_ops), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_session_stats_get_inv_context_ops_fun), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_session_stats_get_inv_stats), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_session_stats_get_ops_failure), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_session_stats_get_success), + TEST_CASES_END() /**< NULL terminate unit test array */ } }; -- 2.17.1