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 97C78A0597; Wed, 8 Apr 2020 05:16:08 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A13AD1C0AD; Wed, 8 Apr 2020 05:15:01 +0200 (CEST) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id 606901BFC6 for ; Wed, 8 Apr 2020 05:14:53 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20200408031453euoutp01e0cb883a361456844d9d0cd1c5a1a311~DubfjiIIK2124521245euoutp01V for ; Wed, 8 Apr 2020 03:14:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20200408031453euoutp01e0cb883a361456844d9d0cd1c5a1a311~DubfjiIIK2124521245euoutp01V DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1586315693; bh=acA+ii0yOmD1r+6N7MuYyRPvxP2ro9kXIxZa9EtWUq4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k3zOi1DfgIP07E/fs/fuLAPX1uMDTdKBqRpM6nvA53T/jz0x37UWRox+agNrVkY9z pKDfGOqwpo53oHPfGFi3uZ3o5WWKmnSUe8n9d9nIGizJkNzgvwOMjuvCaAXmW98iUF KxOQ3QCrO8cYhyRIXSvgbTgEvf+Gh0y5wOLvYD44= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20200408031453eucas1p23b63e592bf2f5647d40d8222a1632469~DubfZaa2L3007630076eucas1p2p for ; Wed, 8 Apr 2020 03:14:53 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 1A.47.60679.CA14D8E5; Wed, 8 Apr 2020 04:14:52 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20200408031452eucas1p2f75a75363e148c54f38b01b9a9a0ea47~DubevlBZ73008430084eucas1p2b for ; Wed, 8 Apr 2020 03:14:52 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200408031452eusmtrp150bf150a2ca1a983c86af1b10f40c737~DubevEZFu1153511535eusmtrp1v for ; Wed, 8 Apr 2020 03:14:52 +0000 (GMT) X-AuditID: cbfec7f4-0cbff7000001ed07-60-5e8d41acc1dd Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id EF.69.07950.CA14D8E5; Wed, 8 Apr 2020 04:14:52 +0100 (BST) Received: from localhost.localdomain (unknown [106.210.88.70]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200408031451eusmtip158925a75978c374169ea783dd0624177~DubeYNslp2966429664eusmtip1c for ; Wed, 8 Apr 2020 03:14:51 +0000 (GMT) From: Lukasz Wojciechowski To: Cc: dev@dpdk.org Date: Wed, 8 Apr 2020 05:13:46 +0200 Message-Id: <20200408031351.4288-9-l.wojciechow@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200408031351.4288-1-l.wojciechow@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrBIsWRmVeSWpSXmKPExsWy7djPc7prHHvjDJbutLB492k7kwOjx68F S1kDGKO4bFJSczLLUov07RK4Mubs+sRUMMG04tClfywNjId0uxg5OSQETCQ2rr7O3sXIxSEk sIJRouvMWjaQhJBAO5PEt4OlEIk2JomHnQ1sMB1rH01igUgsZ5T43viIDa5qzYmJrCBVbAK2 EkdmfgWzRQRYJFZ+/84CYjMLCEg8vvcMLC4s4COx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id6UxMqq1KL8+KLSnNTiQ4ymQDdNZJYSTc4HhnpeSbyhqaG5 haWhubG5sZmFkjhvh8DBGCGB9MSS1OzU1ILUIpg+Jg5OqQbGshfBmsZXUs9JKWwLfHRLKPH8 CXGL8w4pWpW21lGXGecIJdqnzVER7Z50kNspIsV7e71FH3devGSBRvUM7z2LTP4//nTT8MCT M8EpxnMkdKI0+udMifedzun//zvXqmeqnM+YDl9ee8LK40+69ukN0cEr9Y+e+Tf33JquTL5j 5p03Hb69996ixFKckWioxVxUnAgAHWRU/T0CAAA= X-CMS-MailID: 20200408031452eucas1p2f75a75363e148c54f38b01b9a9a0ea47 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200408031452eucas1p2f75a75363e148c54f38b01b9a9a0ea47 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200408031452eucas1p2f75a75363e148c54f38b01b9a9a0ea47 References: <20200312151654.7218-1-l.wojciechow@partner.samsung.com> <20200408031351.4288-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-dev] [PATCH v2 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