DPDK patches and discussions
 help / color / mirror / Atom feed
From: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 09/13] app/test: add rte_security_session_destroy tests
Date: Thu, 12 Mar 2020 16:16:50 +0100
Message-ID: <20200312151654.7218-10-l.wojciechow@partner.samsung.com> (raw)
In-Reply-To: <20200312151654.7218-1-l.wojciechow@partner.samsung.com>

Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Change-Id: Id1543157b4ce89bd5ec07fc46ff67b65ec3b4a89
---
 app/test/test_security.c | 160 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 160 insertions(+)

diff --git a/app/test/test_security.c b/app/test/test_security.c
index 647a2dd0a..dc11b96ff 100644
--- a/app/test/test_security.c
+++ b/app/test/test_security.c
@@ -1118,6 +1118,153 @@ test_rte_security_session_stats_get_success(void)
 }
 
 
+/**
+ * rte_security_session_destroy tests
+ */
+
+/**
+ * Test execution of rte_security_session_destroy with NULL instance
+ */
+static int
+test_rte_security_session_destroy_inv_param_context(void)
+{
+	struct security_unittest_params *ut_params = &unittest_params;
+
+	TEST_ASSERT_MEMPOOL_USAGE(1);
+	TEST_ASSERT_SESSION_COUNT(1);
+
+	int ret = rte_security_session_destroy(NULL, ut_params->sess);
+	TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_destroy,
+			ret, -EINVAL, "%d");
+	TEST_ASSERT_MOCK_CALLS(mock_session_destroy_exp, 0);
+	TEST_ASSERT_MEMPOOL_USAGE(1);
+	TEST_ASSERT_SESSION_COUNT(1);
+
+	return TEST_SUCCESS;
+}
+
+/**
+ * Test execution of rte_security_session_destroy with invalid
+ * security operations structure (NULL)
+ */
+static int
+test_rte_security_session_destroy_inv_param_context_ops(void)
+{
+	struct security_unittest_params *ut_params = &unittest_params;
+	ut_params->ctx.ops = NULL;
+
+	TEST_ASSERT_MEMPOOL_USAGE(1);
+	TEST_ASSERT_SESSION_COUNT(1);
+
+	int ret = rte_security_session_destroy(&ut_params->ctx, ut_params->sess);
+	TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_destroy,
+			ret, -EINVAL, "%d");
+	TEST_ASSERT_MOCK_CALLS(mock_session_destroy_exp, 0);
+	TEST_ASSERT_MEMPOOL_USAGE(1);
+	TEST_ASSERT_SESSION_COUNT(1);
+
+	return TEST_SUCCESS;
+}
+
+/**
+ * Test execution of rte_security_session_destroy with empty
+ * security operations
+ */
+static int
+test_rte_security_session_destroy_inv_param_context_ops_fun(void)
+{
+	struct security_unittest_params *ut_params = &unittest_params;
+	ut_params->ctx.ops = &empty_ops;
+
+	TEST_ASSERT_MEMPOOL_USAGE(1);
+	TEST_ASSERT_SESSION_COUNT(1);
+
+	int ret = rte_security_session_destroy(&ut_params->ctx, ut_params->sess);
+	TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_destroy,
+			ret, -ENOTSUP, "%d");
+	TEST_ASSERT_MOCK_CALLS(mock_session_destroy_exp, 0);
+	TEST_ASSERT_MEMPOOL_USAGE(1);
+	TEST_ASSERT_SESSION_COUNT(1);
+
+	return TEST_SUCCESS;
+}
+
+/**
+ * Test execution of rte_security_session_destroy with NULL sess parameter
+ */
+static int
+test_rte_security_session_destroy_inv_param_session(void)
+{
+	struct security_unittest_params *ut_params = &unittest_params;
+
+	TEST_ASSERT_MEMPOOL_USAGE(1);
+	TEST_ASSERT_SESSION_COUNT(1);
+
+	int ret = rte_security_session_destroy(&ut_params->ctx, NULL);
+	TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_destroy,
+			ret, -EINVAL, "%d");
+	TEST_ASSERT_MOCK_CALLS(mock_session_destroy_exp, 0);
+	TEST_ASSERT_MEMPOOL_USAGE(1);
+	TEST_ASSERT_SESSION_COUNT(1);
+
+	return TEST_SUCCESS;
+}
+
+/**
+ * Test execution of rte_security_session_destroy when session_destroy
+ * security operation fails
+ */
+static int
+test_rte_security_session_destroy_ops_failure(void)
+{
+	struct security_unittest_params *ut_params = &unittest_params;
+
+	mock_session_destroy_exp.device = NULL;
+	mock_session_destroy_exp.sess = ut_params->sess;
+	mock_session_destroy_exp.ret = -1;
+
+	TEST_ASSERT_MEMPOOL_USAGE(1);
+	TEST_ASSERT_SESSION_COUNT(1);
+
+	int ret = rte_security_session_destroy(&ut_params->ctx, ut_params->sess);
+	TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_destroy,
+			ret, -1, "%d");
+	TEST_ASSERT_MOCK_CALLS(mock_session_destroy_exp, 1);
+	TEST_ASSERT_MEMPOOL_USAGE(1);
+	TEST_ASSERT_SESSION_COUNT(1);
+
+	return TEST_SUCCESS;
+}
+
+/**
+ * Test execution of rte_security_session_destroy in successful execution path
+ */
+static int
+test_rte_security_session_destroy_success(void)
+{
+	struct security_unittest_params *ut_params = &unittest_params;
+
+	mock_session_destroy_exp.device = NULL;
+	mock_session_destroy_exp.sess = ut_params->sess;
+	mock_session_destroy_exp.ret = 0;
+	TEST_ASSERT_MEMPOOL_USAGE(1);
+	TEST_ASSERT_SESSION_COUNT(1);
+
+	int ret = rte_security_session_destroy(&ut_params->ctx, ut_params->sess);
+	TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_destroy,
+			ret, 0, "%d");
+	TEST_ASSERT_MOCK_CALLS(mock_session_destroy_exp, 1);
+	TEST_ASSERT_MEMPOOL_USAGE(0);
+	TEST_ASSERT_SESSION_COUNT(0);
+
+	// Remove session from test case parameters, so it won't be destroyed
+	// during test case teardown.
+	ut_params->sess = NULL;
+
+	return TEST_SUCCESS;
+}
+
+
 /**
  * Declaration of testcases
  */
@@ -1182,6 +1329,19 @@ static struct unit_test_suite security_testsuite  = {
 		TEST_CASE_ST(ut_setup_with_session, ut_teardown,
 				test_rte_security_session_stats_get_success),
 
+		TEST_CASE_ST(ut_setup_with_session, ut_teardown,
+				test_rte_security_session_destroy_inv_param_context),
+		TEST_CASE_ST(ut_setup_with_session, ut_teardown,
+				test_rte_security_session_destroy_inv_param_context_ops),
+		TEST_CASE_ST(ut_setup_with_session, ut_teardown,
+				test_rte_security_session_destroy_inv_param_context_ops_fun),
+		TEST_CASE_ST(ut_setup_with_session, ut_teardown,
+				test_rte_security_session_destroy_inv_param_session),
+		TEST_CASE_ST(ut_setup_with_session, ut_teardown,
+				test_rte_security_session_destroy_ops_failure),
+		TEST_CASE_ST(ut_setup_with_session, ut_teardown,
+				test_rte_security_session_destroy_success),
+
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
 };
-- 
2.17.1


  parent reply	other threads:[~2020-03-12 15:19 UTC|newest]

Thread overview: 80+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20200312151708eucas1p2a80bb2ac0556c7d7efb3aedd83923e52@eucas1p2.samsung.com>
2020-03-12 15:16 ` [dpdk-dev] [PATCH 00/13] Fixes and unit tests for librte_security Lukasz Wojciechowski
     [not found]   ` <CGME20200312151708eucas1p2acee543b5f9d236b8e43cd4d1fbed489@eucas1p2.samsung.com>
2020-03-12 15:16     ` [dpdk-dev] [PATCH 01/13] librte_security: fix verification of parameters Lukasz Wojciechowski
2020-03-17 12:59       ` Anoob Joseph
2020-04-03 18:36         ` Lukasz Wojciechowski
2020-04-05 12:54           ` [dpdk-dev] [EXT] " Anoob Joseph
2020-04-06 18:49             ` Lukasz Wojciechowski
2020-04-07  6:20               ` Anoob Joseph
2020-04-08  3:25                 ` Lukasz Wojciechowski
     [not found]   ` <CGME20200312151708eucas1p12db7c8e402be03dd255d53114217dabd@eucas1p1.samsung.com>
2020-03-12 15:16     ` [dpdk-dev] [PATCH 02/13] librte_security: fix return types in documentation Lukasz Wojciechowski
2020-03-17 16:34       ` Anoob Joseph
     [not found]   ` <CGME20200312151708eucas1p2536ef1df74b35ead436db85f8a5628b4@eucas1p2.samsung.com>
2020-03-12 15:16     ` [dpdk-dev] [PATCH 03/13] librte_security: fix session counter Lukasz Wojciechowski
2020-03-17 17:08       ` Anoob Joseph
     [not found]   ` <CGME20200312151708eucas1p18d3cde72ccadf22d43b8907ab9de6d97@eucas1p1.samsung.com>
2020-03-12 15:16     ` [dpdk-dev] [PATCH 04/13] app/test: fix macro definition Lukasz Wojciechowski
     [not found]   ` <CGME20200312151709eucas1p2df38aed23b7445d3db7d4d3ea8fe3222@eucas1p2.samsung.com>
2020-03-12 15:16     ` [dpdk-dev] [PATCH 05/13] app/test: introduce librte_security tests Lukasz Wojciechowski
2020-04-01 17:09       ` Akhil Goyal
2020-04-01 17:51         ` Thomas Monjalon
2020-04-02 19:49           ` Lukasz Wojciechowski
2020-04-02 20:51             ` Thomas Monjalon
2020-04-03 19:24         ` Lukasz Wojciechowski
     [not found]   ` <CGME20200312151709eucas1p1a01f789059de888cb2d719526434e4f9@eucas1p1.samsung.com>
2020-03-12 15:16     ` [dpdk-dev] [PATCH 06/13] app/test: add rte_security_session_update tests Lukasz Wojciechowski
     [not found]   ` <CGME20200312151709eucas1p139311cecb925f566cbbf1444d14c31b1@eucas1p1.samsung.com>
2020-03-12 15:16     ` [dpdk-dev] [PATCH 07/13] app/test: add rte_security_session_get_size tests Lukasz Wojciechowski
     [not found]   ` <CGME20200312151709eucas1p15263f75e2ad73aa9b8d2fb2d4cf51439@eucas1p1.samsung.com>
2020-03-12 15:16     ` [dpdk-dev] [PATCH 08/13] app/test: add rte_security_session_stats_get tests Lukasz Wojciechowski
     [not found]   ` <CGME20200312151710eucas1p22f051449e6e7edeadefe65b66ffaed32@eucas1p2.samsung.com>
2020-03-12 15:16     ` Lukasz Wojciechowski [this message]
     [not found]   ` <CGME20200312151710eucas1p10124737620ec6414aa593e7fa67ee56b@eucas1p1.samsung.com>
2020-03-12 15:16     ` [dpdk-dev] [PATCH 10/13] app/test: add rte_security_set_pkt_metadata tests Lukasz Wojciechowski
     [not found]   ` <CGME20200312151710eucas1p1c3590b55d00bea25b26539a560199b96@eucas1p1.samsung.com>
2020-03-12 15:16     ` [dpdk-dev] [PATCH 11/13] app/test: add rte_security_get_userdata tests Lukasz Wojciechowski
     [not found]   ` <CGME20200312151710eucas1p21882b138d4fd79753f993c30c997e615@eucas1p2.samsung.com>
2020-03-12 15:16     ` [dpdk-dev] [PATCH 12/13] app/test: add rte_security_capabilities_get tests Lukasz Wojciechowski
     [not found]   ` <CGME20200312151710eucas1p1fd5b1484c9ee807327d2d34511a47a12@eucas1p1.samsung.com>
2020-03-12 15:16     ` [dpdk-dev] [PATCH 13/13] app/test: add rte_security_capability_get tests Lukasz Wojciechowski
     [not found]   ` <CGME20200408031435eucas1p23b452d748e39e46c626f695b7f55096a@eucas1p2.samsung.com>
2020-04-08  3:13     ` [dpdk-dev] [PATCH v2 00/13] Fixes and unit tests for librte_security Lukasz Wojciechowski
     [not found]       ` <CGME20200408031447eucas1p1376332353faa0d217e7be8c32271405f@eucas1p1.samsung.com>
2020-04-08  3:13         ` [dpdk-dev] [PATCH v2 01/13] security: fix verification of parameters Lukasz Wojciechowski
2020-04-08 12:54           ` Thomas Monjalon
2020-04-08 13:02             ` Anoob Joseph
2020-04-08 13:26               ` Thomas Monjalon
2020-04-08 14:44                 ` [dpdk-dev] [EXT] " Anoob Joseph
2020-04-08 15:49                   ` Lukasz Wojciechowski
2020-04-08 17:51                     ` Thomas Monjalon
2020-04-09 10:14                       ` Bruce Richardson
2020-04-09 10:54                         ` Thomas Monjalon
2020-04-09 11:13                           ` Bruce Richardson
2020-04-09 14:07                             ` Lukasz Wojciechowski
2020-04-09 14:21                               ` Lukasz Wojciechowski
2020-04-09 15:22                                 ` Thomas Monjalon
2020-04-09 16:10                                   ` Lukasz Wojciechowski
2020-04-10  8:45                                     ` Bruce Richardson
     [not found]       ` <CGME20200408031448eucas1p2b36997fc73f5b5e2aadb6e4bb965063b@eucas1p2.samsung.com>
2020-04-08  3:13         ` [dpdk-dev] [PATCH v2 02/13] security: fix return types in documentation Lukasz Wojciechowski
     [not found]       ` <CGME20200408031448eucas1p2d6df7ff419bb093606a2f9115297f45a@eucas1p2.samsung.com>
2020-04-08  3:13         ` [dpdk-dev] [PATCH v2 03/13] security: fix session counter Lukasz Wojciechowski
     [not found]       ` <CGME20200408031449eucas1p1ca89719463cbaf29e9f7c81beaec88c2@eucas1p1.samsung.com>
2020-04-08  3:13         ` [dpdk-dev] [PATCH v2 04/13] app/test: fix macro definition Lukasz Wojciechowski
2020-04-08 12:53           ` Thomas Monjalon
2020-04-08 16:15             ` Lukasz Wojciechowski
2020-04-08 17:47               ` Thomas Monjalon
2020-04-09 14:10                 ` Lukasz Wojciechowski
     [not found]       ` <CGME20200408031450eucas1p1a0b6ca84cbac2f7542212e185de1ddf5@eucas1p1.samsung.com>
2020-04-08  3:13         ` [dpdk-dev] [PATCH v2 05/13] app/test: introduce librte security tests Lukasz Wojciechowski
     [not found]       ` <CGME20200408031451eucas1p2769ae9d814ef1ccd286407767054e117@eucas1p2.samsung.com>
2020-04-08  3:13         ` [dpdk-dev] [PATCH v2 06/13] app/test: add rte security session update tests Lukasz Wojciechowski
     [not found]       ` <CGME20200408031451eucas1p2313bee1d227e5966fb37c5326aa72529@eucas1p2.samsung.com>
2020-04-08  3:13         ` [dpdk-dev] [PATCH v2 07/13] app/test: add rte security session get size tests Lukasz Wojciechowski
     [not found]       ` <CGME20200408031452eucas1p2f75a75363e148c54f38b01b9a9a0ea47@eucas1p2.samsung.com>
2020-04-08  3:13         ` [dpdk-dev] [PATCH v2 08/13] app/test: add rte security session stats get tests Lukasz Wojciechowski
     [not found]       ` <CGME20200408031452eucas1p1b4de173fadca62824b472b8a3dd69e32@eucas1p1.samsung.com>
2020-04-08  3:13         ` [dpdk-dev] [PATCH v2 09/13] app/test: add rte security session destroy tests Lukasz Wojciechowski
     [not found]       ` <CGME20200408031453eucas1p15bf7f54b1a5b1ae7810a72c71bd6271c@eucas1p1.samsung.com>
2020-04-08  3:13         ` [dpdk-dev] [PATCH v2 10/13] app/test: add rte security set pkt metadata tests Lukasz Wojciechowski
     [not found]       ` <CGME20200408031453eucas1p1b26ad6b1f924b817e83fc2d2d61a0b0b@eucas1p1.samsung.com>
2020-04-08  3:13         ` [dpdk-dev] [PATCH v2 11/13] app/test: add rte security get userdata tests Lukasz Wojciechowski
     [not found]       ` <CGME20200408031454eucas1p112c6eded420bdcfdb09fad83bf485afb@eucas1p1.samsung.com>
2020-04-08  3:13         ` [dpdk-dev] [PATCH v2 12/13] app/test: add rte security capabilities get tests Lukasz Wojciechowski
     [not found]       ` <CGME20200408031454eucas1p2e09e0ab0a1ffa5c657bcf35d89c40a55@eucas1p2.samsung.com>
2020-04-08  3:13         ` [dpdk-dev] [PATCH v2 13/13] app/test: add rte security capability " Lukasz Wojciechowski
     [not found]       ` <CGME20200409172528eucas1p1186911653001cab0e69f10fc42790023@eucas1p1.samsung.com>
2020-04-09 17:24         ` [dpdk-dev] [PATCH v3 00/13] Fixes and unit tests for librte_security Lukasz Wojciechowski
     [not found]           ` <CGME20200409172529eucas1p1f02aaf66052f45ac75ba9e9f63ef1c3a@eucas1p1.samsung.com>
2020-04-09 17:24             ` [dpdk-dev] [PATCH v3 01/13] security: fix verification of parameters Lukasz Wojciechowski
2020-04-13 15:42               ` Anoob Joseph
     [not found]           ` <CGME20200409172530eucas1p27297a83a9d7508e3f8a8f88850cbe37c@eucas1p2.samsung.com>
2020-04-09 17:24             ` [dpdk-dev] [PATCH v3 02/13] security: fix return types in documentation Lukasz Wojciechowski
2020-04-13 15:43               ` Anoob Joseph
     [not found]           ` <CGME20200409172531eucas1p1c3ec21532e5e232ff2d68d56f096e71c@eucas1p1.samsung.com>
2020-04-09 17:24             ` [dpdk-dev] [PATCH v3 03/13] security: fix session counter Lukasz Wojciechowski
2020-04-13 15:48               ` Anoob Joseph
     [not found]           ` <CGME20200409172532eucas1p285bc6767be1d62a0098d177a7757169f@eucas1p2.samsung.com>
2020-04-09 17:24             ` [dpdk-dev] [PATCH v3 04/13] app/test: remove macro definition Lukasz Wojciechowski
     [not found]           ` <CGME20200409172533eucas1p1f4363aa89cfbda87e5d20da1006e21c0@eucas1p1.samsung.com>
2020-04-09 17:24             ` [dpdk-dev] [PATCH v3 05/13] app/test: introduce librte security tests Lukasz Wojciechowski
     [not found]           ` <CGME20200409172533eucas1p252ed0cac1689b067a83589a0665c9033@eucas1p2.samsung.com>
2020-04-09 17:24             ` [dpdk-dev] [PATCH v3 06/13] app/test: add rte security session update tests Lukasz Wojciechowski
     [not found]           ` <CGME20200409172534eucas1p2ee383bc5d8efd40ea8b883b78126ed9f@eucas1p2.samsung.com>
2020-04-09 17:24             ` [dpdk-dev] [PATCH v3 07/13] app/test: add rte security session get size tests Lukasz Wojciechowski
     [not found]           ` <CGME20200409172534eucas1p2852ae56687fd5bae343437b07198c070@eucas1p2.samsung.com>
2020-04-09 17:24             ` [dpdk-dev] [PATCH v3 08/13] app/test: add rte security session stats get tests Lukasz Wojciechowski
     [not found]           ` <CGME20200409172535eucas1p152b3d17bd9d2194f9f2669116130331d@eucas1p1.samsung.com>
2020-04-09 17:24             ` [dpdk-dev] [PATCH v3 09/13] app/test: add rte security session destroy tests Lukasz Wojciechowski
     [not found]           ` <CGME20200409172535eucas1p2c215489de77c708fc0bec6b9e2e3dd6d@eucas1p2.samsung.com>
2020-04-09 17:24             ` [dpdk-dev] [PATCH v3 10/13] app/test: add rte security set pkt metadata tests Lukasz Wojciechowski
     [not found]           ` <CGME20200409172536eucas1p282854dae8a3b6cceafdea5e2f4fa0896@eucas1p2.samsung.com>
2020-04-09 17:25             ` [dpdk-dev] [PATCH v3 11/13] app/test: add rte security get userdata tests Lukasz Wojciechowski
     [not found]           ` <CGME20200409172536eucas1p1396c04fb7a9fb80db2a5670f8f3453bb@eucas1p1.samsung.com>
2020-04-09 17:25             ` [dpdk-dev] [PATCH v3 12/13] app/test: add rte security capabilities get tests Lukasz Wojciechowski
     [not found]           ` <CGME20200409172538eucas1p1dcd99eeedf6fca44c2e2e53e94b08d91@eucas1p1.samsung.com>
2020-04-09 17:25             ` [dpdk-dev] [PATCH v3 13/13] app/test: add rte security capability " Lukasz Wojciechowski
2020-04-17 19:46           ` [dpdk-dev] [PATCH v3 00/13] Fixes and unit tests for librte_security Akhil Goyal
2020-04-17 20:14             ` Lukasz Wojciechowski
2020-04-17 20:21               ` Akhil Goyal
2020-04-17 20:39                 ` Lukasz Wojciechowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200312151654.7218-10-l.wojciechow@partner.samsung.com \
    --to=l.wojciechow@partner.samsung.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ http://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git