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 7B56CA056D; Thu, 12 Mar 2020 16:18:43 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7A12A1C0B3; Thu, 12 Mar 2020 16:17:21 +0100 (CET) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id 8837F1BFC9 for ; Thu, 12 Mar 2020 16:17:10 +0100 (CET) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20200312151710euoutp02412d97eacedd10d8db223e32679bd001~7l3bI2c872975029750euoutp02J for ; Thu, 12 Mar 2020 15:17:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20200312151710euoutp02412d97eacedd10d8db223e32679bd001~7l3bI2c872975029750euoutp02J DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1584026230; bh=VIVTeODXDCX/JANAKU8NjLFYDZlBtIsK5k1x4sHavAE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=BCJm8K/K3WEeOspX0YK1u3xGLhlAi4A5ph1ec4jbBHu+HMFaXf3+wqO0OsNX784+8 3je8gR7VljEl5BB4nsSOUpg+oGIlmsgXzDAlnwQ3OS5fI+ZoK19qe7xjb+RHc2eMZK rdRfo98qg2kLlk9VW45FdPO0h4UY1JJgS8qVCkFI= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20200312151710eucas1p203d0656e583c4ac0dac64237bdd6ae1b~7l3a91yHy2375023750eucas1p2g for ; Thu, 12 Mar 2020 15:17:10 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 9E.BD.60679.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 20200312151709eucas1p15263f75e2ad73aa9b8d2fb2d4cf51439~7l3arVK_I0782307823eucas1p1r for ; Thu, 12 Mar 2020 15:17:09 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200312151709eusmtrp20750385c54d5fd383974420e94dde52e~7l3aq3qN11238412384eusmtrp2G for ; Thu, 12 Mar 2020 15:17:09 +0000 (GMT) X-AuditID: cbfec7f4-0e5ff7000001ed07-2d-5e6a5276900e Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id C1.2D.07950.5725A6E5; Thu, 12 Mar 2020 15:17:09 +0000 (GMT) Received: from Padamandas.example.org (unknown [106.120.51.19]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200312151709eusmtip1df0f7ff24db9d97539df233012c3f0c9~7l3afeYMO1553915539eusmtip1P for ; Thu, 12 Mar 2020 15:17:09 +0000 (GMT) From: Lukasz Wojciechowski To: dev@dpdk.org Date: Thu, 12 Mar 2020 16:16:49 +0100 Message-Id: <20200312151654.7218-9-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+NgFtrLIsWRmVeSWpSXmKPExsWy7djPc7plQVlxBj9+sFq8+7SdyYHR49eC pawBjFFcNimpOZllqUX6dglcGS9P72IqeGdWcfKzSQPjUv0uRk4OCQETiU/Xz7B0MXJxCAms YJS492ERG4TTziSx4Ow+dginjUli9p797DAtU+f8Z4ZILGeUuNzagtCy6sEvZpAqNgFbiSMz v7KC2CICAhKfOxezgdjCAp4S368cB1rIwcEioCrx91woiMkr4C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SjQ5HxjOeSXxhqaG5haWhubG5sZmFkrivB0C B2OEBNITS1KzU1MLUotg+pg4OKUaGJdMMGk/sHmBCJ/19I9bi+OFb/U7XTm1euO1qa+MA+p3 9zh5Tb6tMuPdpeT9whqG680kLrPceOPw0kaEb8bEsgNBz1zNmxrN7ilbGa55Uv90/r1Ujfri 2mUvJjUI72O7er3il/2zt+18+uw9dyZaMwYJBm3+kyF94cO/o6uVLv2TfHIuUFToobgSS3FG oqEWc1FxIgApIAZoLwIAAA== X-CMS-MailID: 20200312151709eucas1p15263f75e2ad73aa9b8d2fb2d4cf51439 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200312151709eucas1p15263f75e2ad73aa9b8d2fb2d4cf51439 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200312151709eucas1p15263f75e2ad73aa9b8d2fb2d4cf51439 References: <20200312151654.7218-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-dev] [PATCH 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" Signed-off-by: Lukasz Wojciechowski Change-Id: Ib373d2e01aba2924e2f21ff2d5edfa1643e9eff4 --- app/test/test_security.c | 172 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 172 insertions(+) diff --git a/app/test/test_security.c b/app/test/test_security.c index d4b3e9515..647a2dd0a 100644 --- a/app/test/test_security.c +++ b/app/test/test_security.c @@ -286,6 +286,35 @@ 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 * @@ -328,6 +357,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, }; @@ -418,11 +448,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; @@ -959,6 +991,133 @@ test_rte_security_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_rte_security_session_stats_get_inv_param_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_rte_security_session_stats_get_inv_param_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_rte_security_session_stats_get_inv_param_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_rte_security_session_stats_get_inv_param_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_rte_security_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_rte_security_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 */ @@ -1010,6 +1169,19 @@ static struct unit_test_suite security_testsuite = { TEST_CASE_ST(ut_setup_with_session, ut_teardown, test_rte_security_session_get_size_success), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_rte_security_session_stats_get_inv_param_context), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_rte_security_session_stats_get_inv_param_context_ops), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_rte_security_session_stats_get_inv_param_context_ops_fun), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_rte_security_session_stats_get_inv_param_stats), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_rte_security_session_stats_get_ops_failure), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_rte_security_session_stats_get_success), + TEST_CASES_END() /**< NULL terminate unit test array */ } }; -- 2.17.1