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 B0C21A0597; Wed, 8 Apr 2020 05:15:59 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6FA581C06D; Wed, 8 Apr 2020 05:15:00 +0200 (CEST) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id 43C1B1BFC2 for ; Wed, 8 Apr 2020 05:14:53 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20200408031453euoutp02c3192eff208cf059de7b763681666879~DubfbpHBi1520915209euoutp02x for ; Wed, 8 Apr 2020 03:14:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20200408031453euoutp02c3192eff208cf059de7b763681666879~DubfbpHBi1520915209euoutp02x DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1586315693; bh=QqhM7SFSEoVaEdMEtC+Yi4ZZhSzv0A99gHzsJFwdofY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OnkQ/8idDhG+y+o5IYFz3KSMryQXcpOpg3OAM1wr+dd3woE+uW3upz4+AuYRz8xbD 4KT34HZKlSXOl4kK0wkz7yZRtZkckc1TihWto4A1fRaQeNwK/c8eN+2iHWnCwvz29k 3qt6Vpmyfxz+Q7XkB076QkHW6bGXHd+swFGZcN2M= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20200408031452eucas1p115428ee17d9716a5221a27ebd9e28a47~DubetymeS1603216032eucas1p14 for ; Wed, 8 Apr 2020 03:14:52 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id E7.1A.60698.CA14D8E5; Wed, 8 Apr 2020 04:14:52 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20200408031451eucas1p2313bee1d227e5966fb37c5326aa72529~DubeSulhd3001230012eucas1p2y for ; Wed, 8 Apr 2020 03:14:51 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200408031451eusmtrp2c6ee96a986bcd63b38881dbef6bf00ed~DubeSOWTk0734007340eusmtrp2k for ; Wed, 8 Apr 2020 03:14:51 +0000 (GMT) X-AuditID: cbfec7f5-a29ff7000001ed1a-34-5e8d41acb49a Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 62.DA.08375.BA14D8E5; Wed, 8 Apr 2020 04:14:51 +0100 (BST) Received: from localhost.localdomain (unknown [106.210.88.70]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200408031451eusmtip1a9abf79cd1e01e2391ab23517ea678b8~Dubd79I1t2835528355eusmtip1f 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:45 +0200 Message-Id: <20200408031351.4288-8-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+NgFjrNIsWRmVeSWpSXmKPExsWy7djP87prHHvjDB5281u8+7SdyYHR49eC pawBjFFcNimpOZllqUX6dglcGT27L7AVXNSoaDvWytjAeEypi5GTQ0LARGLHwmssXYxcHEIC Kxglrj6dzgzhtDNJvFn/lh3CaWOS+Pq1iQWm5e6kDVCJ5YwS+99vZ4GrmrjpDCNIFZuArcSR mV9ZQWwRARaJld+/g3UzCwhIPL73DCwuLOAt8a/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nBBvSmJlVWpRfnxRaU5q8SFGU6CbJjJLiSbnA0M9ryTe0NTQ3MLS 0NzY3NjMQkmct0PgYIyQQHpiSWp2ampBahFMHxMHp1QDo7Tih/pSuyVzIu+XSebzTo/1/7Ym +o+j/ixlxd+iZjO+is9UmX/rmJUJb3H5jRffS9+yTA95sjSH51K0rNCtx9cX5mtGLvFZo+6m PuOy6sHKOMt3tge3L9i4Y1PRTLkQadXDzaJ3Nd1W8yU/EH00h0P+2G4Hxd8eFdoGR4qis39r v2F+IO3XqMRSnJFoqMVcVJwIALgJSC49AgAA X-CMS-MailID: 20200408031451eucas1p2313bee1d227e5966fb37c5326aa72529 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200408031451eucas1p2313bee1d227e5966fb37c5326aa72529 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200408031451eucas1p2313bee1d227e5966fb37c5326aa72529 References: <20200312151654.7218-1-l.wojciechow@partner.samsung.com> <20200408031351.4288-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-dev] [PATCH v2 07/13] app/test: add rte security session get size 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_get_size function. Signed-off-by: Lukasz Wojciechowski --- app/test/test_security.c | 132 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) diff --git a/app/test/test_security.c b/app/test/test_security.c index daaf30b62..9c5e7d0da 100644 --- a/app/test/test_security.c +++ b/app/test/test_security.c @@ -268,6 +268,30 @@ mock_session_update(void *device, return mock_session_update_exp.ret; } +/** + * session_get_size mockup + * + * Verified parameters: device. + */ +static struct mock_session_get_size_data { + void *device; + + unsigned int ret; + + int called; + int failed; +} mock_session_get_size_exp = {NULL, 0U, 0, 0}; + +static unsigned int +mock_session_get_size(void *device) +{ + mock_session_get_size_exp.called++; + + MOCK_TEST_ASSERT_POINTER_PARAMETER(mock_session_get_size_exp, device); + + return mock_session_get_size_exp.ret; +} + /** * session_destroy mockup * @@ -309,6 +333,7 @@ struct rte_security_ops empty_ops = { NULL }; struct rte_security_ops mock_ops = { .session_create = mock_session_create, .session_update = mock_session_update, + .session_get_size = mock_session_get_size, .session_destroy = mock_session_destroy, }; @@ -401,10 +426,12 @@ ut_setup(void) mock_session_create_exp.called = 0; mock_session_update_exp.called = 0; + mock_session_get_size_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_destroy_exp.failed = 0; return TEST_SUCCESS; @@ -856,6 +883,100 @@ test_session_update_success(void) } +/** + * rte_security_session_get_size tests + */ + +/** + * Test execution of rte_security_session_get_size with NULL instance + */ +static int +test_session_get_size_inv_context(void) +{ + unsigned int ret = rte_security_session_get_size(NULL); + TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_get_size, + ret, 0, "%u"); + TEST_ASSERT_MOCK_CALLS(mock_session_get_size_exp, 0); + + return TEST_SUCCESS; +} + +/** + * Test execution of rte_security_session_get_size with invalid + * security operations structure (NULL) + */ +static int +test_session_get_size_inv_context_ops(void) +{ + struct security_unittest_params *ut_params = &unittest_params; + ut_params->ctx.ops = NULL; + + unsigned int ret = rte_security_session_get_size(&ut_params->ctx); + TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_get_size, + ret, 0, "%u"); + TEST_ASSERT_MOCK_CALLS(mock_session_get_size_exp, 0); + + return TEST_SUCCESS; +} + +/** + * Test execution of rte_security_session_get_size with empty + * security operations + */ +static int +test_session_get_size_inv_context_ops_fun(void) +{ + struct security_unittest_params *ut_params = &unittest_params; + ut_params->ctx.ops = &empty_ops; + + unsigned int ret = rte_security_session_get_size(&ut_params->ctx); + TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_get_size, + ret, 0, "%u"); + TEST_ASSERT_MOCK_CALLS(mock_session_get_size_exp, 0); + + return TEST_SUCCESS; +} + +/** + * Test execution of rte_security_session_get_size when session_get_size + * security operation fails + */ +static int +test_session_get_size_ops_failure(void) +{ + struct security_unittest_params *ut_params = &unittest_params; + + mock_session_get_size_exp.device = NULL; + mock_session_get_size_exp.ret = 0; + + unsigned int ret = rte_security_session_get_size(&ut_params->ctx); + TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_get_size, + ret, 0, "%u"); + TEST_ASSERT_MOCK_CALLS(mock_session_get_size_exp, 1); + + return TEST_SUCCESS; +} + +/** + * Test execution of rte_security_session_get_size in successful execution path + */ +static int +test_session_get_size_success(void) +{ + struct security_unittest_params *ut_params = &unittest_params; + + mock_session_get_size_exp.device = NULL; + mock_session_get_size_exp.ret = 1024; + + unsigned int ret = rte_security_session_get_size(&ut_params->ctx); + TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_get_size, + ret, 1024U, "%u"); + TEST_ASSERT_MOCK_CALLS(mock_session_get_size_exp, 1); + + return TEST_SUCCESS; +} + + /** * Declaration of testcases */ @@ -896,6 +1017,17 @@ static struct unit_test_suite security_testsuite = { TEST_CASE_ST(ut_setup_with_session, ut_teardown, test_session_update_success), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_session_get_size_inv_context), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_session_get_size_inv_context_ops), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_session_get_size_inv_context_ops_fun), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_session_get_size_ops_failure), + TEST_CASE_ST(ut_setup_with_session, ut_teardown, + test_session_get_size_success), + TEST_CASES_END() /**< NULL terminate unit test array */ } }; -- 2.17.1