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 20863A0597; Thu, 9 Apr 2020 19:26:48 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A9FC91D411; Thu, 9 Apr 2020 19:25:44 +0200 (CEST) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id 143631C43F for ; Thu, 9 Apr 2020 19:25:35 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20200409172534euoutp01e441fb7940ff86a18caade9b09f98fe0~ENriCjyZS0657706577euoutp01X for ; Thu, 9 Apr 2020 17:25:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20200409172534euoutp01e441fb7940ff86a18caade9b09f98fe0~ENriCjyZS0657706577euoutp01X DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1586453134; bh=QqhM7SFSEoVaEdMEtC+Yi4ZZhSzv0A99gHzsJFwdofY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gT+yVZONEO1OIQnQW6JAfjunqc6axVaW6HXAjXjQy2FkozzFkT2ETxiKEKHe8dSyM GALddHnZmvhzd6uPJ7qe0zIdmfS+ttmxY4Q1JaOLULJ5jBOp8qMDFm5aU2LN3U6t4X zR9JBL2vYc07ivnMJZ1FTd/mrh2vuKsr2/Z5lLsw= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20200409172534eucas1p2a16ee6de118626bb6c4d9d2f9496b1d5~ENrh58bqT2398523985eucas1p25 for ; Thu, 9 Apr 2020 17:25:34 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 62.50.60679.E8A5F8E5; Thu, 9 Apr 2020 18:25:34 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20200409172534eucas1p2ee383bc5d8efd40ea8b883b78126ed9f~ENrhlVghu0369803698eucas1p2n for ; Thu, 9 Apr 2020 17:25:34 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200409172534eusmtrp1bee3c0c3f30441b0833d35a5b1cdf859~ENrhk137u2463624636eusmtrp1J for ; Thu, 9 Apr 2020 17:25:34 +0000 (GMT) X-AuditID: cbfec7f4-0e5ff7000001ed07-d9-5e8f5a8e862e Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id D4.48.07950.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 20200409172534eusmtip171f7ea7802590ccd045d7c99837abede~ENrhS7Biq0978609786eusmtip1u for ; Thu, 9 Apr 2020 17:25:33 +0000 (GMT) From: Lukasz Wojciechowski To: Cc: dev@dpdk.org Date: Thu, 9 Apr 2020 19:24:56 +0200 Message-Id: <20200409172502.1693-8-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+NgFjrFIsWRmVeSWpSXmKPExsWy7djP87p9Uf1xBgdvqVm8+7SdyYHR49eC pawBjFFcNimpOZllqUX6dglcGT27L7AVXNSoaDvWytjAeEypi5GTQ0LAROLSxUmMXYxcHEIC KxglHuz8B+W0M0m8W3qYCaRKSKCNSeLzDQWYjqdzOpkhipYzSjybsocFwgEq+rnwOytIFZuA rcSRmV/BbBEBFomV37+zgNjM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sa WFZcmXuIUYKDWUmE17upN06INyWxsiq1KD++qDQntfgQoynQUROZpUST84HBnlcSb2hqaG5h aWhubG5sZqEkztshcDBGSCA9sSQ1OzW1ILUIpo+Jg1OqgdHlbJn0Ba89LI8T/wWsKXQUn/3z noXxxhme6cfZPOvqDxT9j2q1y7tp57OXYe+eAv3vno4/M9lFPOWeOblu35T3f9/MqQUrT94O /3bq6VZvLe/T/3c7t36e/+9ye0J08TZNE9GDvaEsCZLXRD5s/J6zyVHvwp3JU544Za1y7rkh GmTk27aZtVOJpTgj0VCLuag4EQC/oECVPgIAAA== X-CMS-MailID: 20200409172534eucas1p2ee383bc5d8efd40ea8b883b78126ed9f X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200409172534eucas1p2ee383bc5d8efd40ea8b883b78126ed9f X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200409172534eucas1p2ee383bc5d8efd40ea8b883b78126ed9f References: <20200408031351.4288-1-l.wojciechow@partner.samsung.com> <20200409172502.1693-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-dev] [PATCH v3 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