1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
7 #include <rte_memory.h>
8 #include <rte_mempool.h>
9 #include <rte_security.h>
10 #include <rte_security_driver.h>
12 /* Before including rte_test.h file you can define
13 * RTE_TEST_TRACE_FAILURE(_file, _line, _func) macro to better trace/debug test
14 * failures. Mostly useful in development phase.
16 #ifndef RTE_TEST_TRACE_FAILURE
17 #define RTE_TEST_TRACE_FAILURE(_file, _line, _func) \
18 RTE_LOG(DEBUG, EAL, "in %s:%d %s\n", _file, _line, _func)
28 * Basic unit tests of the librte_security API.
30 * Structure of the file:
31 * - macros for making tests more readable;
32 * - mockup structures and functions for rte_security_ops;
33 * - test suite and test cases setup and teardown functions;
35 * - declaration of testcases.
42 * Set of macros for making tests easier to read.
46 * Verify condition inside mocked up function.
47 * Mockup function cannot return a test error, so the failure
48 * of assertion increases counter and print logs.
49 * The counter can be verified later to check if test case should fail.
51 * @param fail_counter fail counter
52 * @param cond condition expected to be true
53 * @param msg printf style formatting string for custom message
55 #define MOCK_TEST_ASSERT(fail_counter, cond, msg, ...) do { \
58 RTE_LOG(DEBUG, EAL, "Test assert %s line %d failed: " \
59 msg "\n", __func__, __LINE__, \
61 RTE_TEST_TRACE_FAILURE(__FILE__, __LINE__, __func__); \
66 * Verify equality condition inside mocked up function.
67 * Mockup function cannot return a test error, so the failure
68 * of assertion increases counter and print logs.
69 * The counter can be verified later to check if test case should fail.
71 * @param fail_counter fail counter
72 * @param a first value of comparison
73 * @param b second value of comparison
74 * @param msg printf style formatting string for custom message
76 #define MOCK_TEST_ASSERT_EQUAL(fail_counter, a, b, msg, ...) \
77 MOCK_TEST_ASSERT(fail_counter, (a) == (b), msg, ##__VA_ARGS__)
80 * Verify not null condition inside mocked up function.
81 * Mockup function cannot return a test error, so the failure
82 * of assertion increases counter and print logs.
83 * The counter can be verified later to check if test case should fail.
85 * @param fail_counter fail counter
86 * @param val value expected not to be NULL
87 * @param msg printf style formatting string for custom message
89 #define MOCK_TEST_ASSERT_NOT_NULL(fail_counter, val, msg, ...) \
90 MOCK_TEST_ASSERT(fail_counter, (val) != NULL, msg, ##__VA_ARGS__)
94 * Verify if parameter of the mocked up function matches expected value.
95 * The expected value is stored in data structure in the field matching
98 * @param data structure with expected values
99 * @param parameter name of the parameter (both field and parameter name)
100 * @param spec printf style spec for parameter
102 #define MOCK_TEST_ASSERT_PARAMETER(data, parameter, spec) \
103 MOCK_TEST_ASSERT_EQUAL(data.failed, data.parameter, parameter, \
104 "Expecting parameter %s to be " spec \
105 " but it's " spec, RTE_STR(parameter), \
106 data.parameter, parameter)
109 * Wrap for MOCK_TEST_ASSERT_PARAMETER macro for pointer type parameters.
111 * @param data structure with expected values
112 * @param parameter name of the parameter (both field and parameter name)
114 #define MOCK_TEST_ASSERT_POINTER_PARAMETER(data, parameter) \
115 MOCK_TEST_ASSERT_PARAMETER(data, parameter, "%p")
118 * Wrap for MOCK_TEST_ASSERT_PARAMETER macro for uint64_t type parameters.
120 * @param data structure with expected values
121 * @param parameter name of the parameter (both field and parameter name)
123 #define MOCK_TEST_ASSERT_U64_PARAMETER(data, parameter) \
124 MOCK_TEST_ASSERT_PARAMETER(data, parameter, "%" PRIu64)
127 * Verify number of calls of the mocked up function
128 * and check if there were any fails during execution.
129 * The fails statistics inside mocked up functions are collected
130 * as "failed" field in mockup structures.
132 * @param mock_data structure with statistics (called, failed)
133 * @param exp_calls expected number of mockup function calls
135 #define TEST_ASSERT_MOCK_CALLS(mock_data, exp_calls) do { \
136 TEST_ASSERT_EQUAL(exp_calls, mock_data.called, \
137 "Expecting sub op to be called %d times, " \
138 "but it's called %d times", \
139 exp_calls, mock_data.called); \
140 TEST_ASSERT_EQUAL(0, mock_data.failed, \
141 "Expecting sub op asserts not to fail, " \
142 "but they're failed %d times", \
147 * Assert tested function result match expected value
149 * @param f_name name of tested function
150 * @param f_ret value returned by the function
151 * @param exp_ret expected returned value
152 * @param fmt printf style format for returned value
154 #define TEST_ASSERT_MOCK_FUNCTION_CALL_RET(f_name, f_ret, exp_ret, fmt) \
155 TEST_ASSERT_EQUAL(exp_ret, f_ret, "Expecting " RTE_STR(f_name) \
156 " to return " fmt ", but it returned " fmt \
157 "\n", exp_ret, f_ret)
160 * Assert tested function result is not NULL
162 * @param f_name name of tested function
163 * @param f_ret value returned by the function
165 #define TEST_ASSERT_MOCK_FUNCTION_CALL_NOT_NULL(f_name, f_ret) \
166 TEST_ASSERT_NOT_NULL(f_ret, "Expecting " RTE_STR(f_name) \
167 " to return not NULL\n")
170 * Verify that sess_cnt counter value matches expected
172 * @param expected_sessions_count expected counter value
174 #define TEST_ASSERT_SESSION_COUNT(expected_sessions_count) do { \
175 struct security_unittest_params *ut_params = &unittest_params; \
176 TEST_ASSERT_EQUAL(expected_sessions_count, \
177 ut_params->ctx.sess_cnt, \
178 "Expecting session counter to be %u," \
179 " but it's %u", expected_sessions_count, \
180 ut_params->ctx.sess_cnt); \
184 * Verify usage of mempool by checking if number of allocated objects matches
185 * expectations. The mempool is used to manage objects for sessions data.
186 * A single object is acquired from mempool during session_create
187 * and put back in session_destroy.
189 * @param expected_mempool_usage expected number of used mempool objects
191 #define TEST_ASSERT_MEMPOOL_USAGE(expected_mempool_usage) do { \
192 struct security_testsuite_params *ts_params = &testsuite_params;\
193 unsigned int mempool_usage; \
194 mempool_usage = rte_mempool_in_use_count( \
195 ts_params->session_mpool); \
196 TEST_ASSERT_EQUAL(expected_mempool_usage, mempool_usage, \
197 "Expecting %u mempool allocations, " \
198 "but there are %u allocated objects", \
199 expected_mempool_usage, mempool_usage); \
204 * Mockup structures and functions for rte_security_ops;
206 * Set of structures for controlling mockup functions calls.
207 * Every mockup function X has its corresponding X_data structure
208 * and an instance of that structure X_exp.
209 * Structure contains parameters that a mockup function is expected
210 * to be called with, a value to return (.ret) and 2 statistics:
211 * .called (number of times the mockup function was called)
212 * and .failed (number of assertion fails during mockup function call).
214 * Mockup functions verify that the parameters they are called with match
215 * expected values. The expected values should be stored in corresponding
216 * structures prior to mockup functions call. Every failure of such
217 * verification increases .failed counter. Every call of mockup function
218 * increases .called counter. Function returns value stored in .ret field
220 * In case of some parameters in some functions the expected value is unknown
221 * and cannot be detrmined prior to call. Such parameters are stored
222 * in structure and can be compared or analyzed later in test case code.
224 * Below structures and functions follow the rules just described.
225 * Additional remarks and exceptions are added in comments.
229 * session_create mockup
231 * Verified parameters: device, conf, mp.
232 * Saved, not verified parameters: sess.
234 static struct mock_session_create_data {
236 struct rte_security_session_conf *conf;
237 struct rte_security_session *sess;
238 struct rte_mempool *mp;
244 } mock_session_create_exp = {NULL, NULL, NULL, NULL, 0, 0, 0};
247 mock_session_create(void *device,
248 struct rte_security_session_conf *conf,
249 struct rte_security_session *sess,
250 struct rte_mempool *mp)
252 mock_session_create_exp.called++;
254 MOCK_TEST_ASSERT_POINTER_PARAMETER(mock_session_create_exp, device);
255 MOCK_TEST_ASSERT_POINTER_PARAMETER(mock_session_create_exp, conf);
256 MOCK_TEST_ASSERT_POINTER_PARAMETER(mock_session_create_exp, mp);
258 mock_session_create_exp.sess = sess;
260 return mock_session_create_exp.ret;
264 * session_update mockup
266 * Verified parameters: device, sess, conf.
268 static struct mock_session_update_data {
270 struct rte_security_session *sess;
271 struct rte_security_session_conf *conf;
277 } mock_session_update_exp = {NULL, NULL, NULL, 0, 0, 0};
280 mock_session_update(void *device,
281 struct rte_security_session *sess,
282 struct rte_security_session_conf *conf)
284 mock_session_update_exp.called++;
286 MOCK_TEST_ASSERT_POINTER_PARAMETER(mock_session_update_exp, device);
287 MOCK_TEST_ASSERT_POINTER_PARAMETER(mock_session_update_exp, sess);
288 MOCK_TEST_ASSERT_POINTER_PARAMETER(mock_session_update_exp, conf);
290 return mock_session_update_exp.ret;
294 * session_get_size mockup
296 * Verified parameters: device.
298 static struct mock_session_get_size_data {
305 } mock_session_get_size_exp = {NULL, 0U, 0, 0};
308 mock_session_get_size(void *device)
310 mock_session_get_size_exp.called++;
312 MOCK_TEST_ASSERT_POINTER_PARAMETER(mock_session_get_size_exp, device);
314 return mock_session_get_size_exp.ret;
318 * session_stats_get mockup
320 * Verified parameters: device, sess, stats.
322 static struct mock_session_stats_get_data {
324 struct rte_security_session *sess;
325 struct rte_security_stats *stats;
331 } mock_session_stats_get_exp = {NULL, NULL, NULL, 0, 0, 0};
334 mock_session_stats_get(void *device,
335 struct rte_security_session *sess,
336 struct rte_security_stats *stats)
338 mock_session_stats_get_exp.called++;
340 MOCK_TEST_ASSERT_POINTER_PARAMETER(mock_session_stats_get_exp, device);
341 MOCK_TEST_ASSERT_POINTER_PARAMETER(mock_session_stats_get_exp, sess);
342 MOCK_TEST_ASSERT_POINTER_PARAMETER(mock_session_stats_get_exp, stats);
344 return mock_session_stats_get_exp.ret;
348 * session_destroy mockup
350 * Verified parameters: device, sess.
352 static struct mock_session_destroy_data {
354 struct rte_security_session *sess;
360 } mock_session_destroy_exp = {NULL, NULL, 0, 0, 0};
363 mock_session_destroy(void *device, struct rte_security_session *sess)
365 mock_session_destroy_exp.called++;
367 MOCK_TEST_ASSERT_POINTER_PARAMETER(mock_session_destroy_exp, device);
368 MOCK_TEST_ASSERT_POINTER_PARAMETER(mock_session_destroy_exp, sess);
370 return mock_session_destroy_exp.ret;
374 * set_pkt_metadata mockup
376 * Verified parameters: device, sess, m, params.
378 static struct mock_set_pkt_metadata_data {
380 struct rte_security_session *sess;
388 } mock_set_pkt_metadata_exp = {NULL, NULL, NULL, NULL, 0, 0, 0};
391 mock_set_pkt_metadata(void *device,
392 struct rte_security_session *sess,
396 mock_set_pkt_metadata_exp.called++;
398 MOCK_TEST_ASSERT_POINTER_PARAMETER(mock_set_pkt_metadata_exp, device);
399 MOCK_TEST_ASSERT_POINTER_PARAMETER(mock_set_pkt_metadata_exp, sess);
400 MOCK_TEST_ASSERT_POINTER_PARAMETER(mock_set_pkt_metadata_exp, m);
401 MOCK_TEST_ASSERT_POINTER_PARAMETER(mock_set_pkt_metadata_exp, params);
403 return mock_set_pkt_metadata_exp.ret;
407 * get_userdata mockup
409 * Verified parameters: device, md.
410 * The userdata parameter works as an output parameter, so a passed address
411 * is verified not to be NULL and filled with userdata stored in structure.
413 static struct mock_get_userdata_data {
422 } mock_get_userdata_exp = {NULL, 0UL, NULL, 0, 0, 0};
425 mock_get_userdata(void *device,
429 mock_get_userdata_exp.called++;
431 MOCK_TEST_ASSERT_POINTER_PARAMETER(mock_get_userdata_exp, device);
432 MOCK_TEST_ASSERT_U64_PARAMETER(mock_get_userdata_exp, md);
434 MOCK_TEST_ASSERT_NOT_NULL(mock_get_userdata_exp.failed,
436 "Expecting parameter userdata not to be NULL but it's %p",
438 *userdata = mock_get_userdata_exp.userdata;
440 return mock_get_userdata_exp.ret;
444 * capabilities_get mockup
446 * Verified parameters: device.
448 static struct mock_capabilities_get_data {
451 struct rte_security_capability *ret;
455 } mock_capabilities_get_exp = {NULL, NULL, 0, 0};
457 static const struct rte_security_capability *
458 mock_capabilities_get(void *device)
460 mock_capabilities_get_exp.called++;
462 MOCK_TEST_ASSERT_POINTER_PARAMETER(mock_capabilities_get_exp, device);
464 return mock_capabilities_get_exp.ret;
470 * is an empty security operations set (all function pointers set to NULL)
472 struct rte_security_ops empty_ops = { NULL };
477 * is a security operations set using mockup functions
479 struct rte_security_ops mock_ops = {
480 .session_create = mock_session_create,
481 .session_update = mock_session_update,
482 .session_get_size = mock_session_get_size,
483 .session_stats_get = mock_session_stats_get,
484 .session_destroy = mock_session_destroy,
485 .set_pkt_metadata = mock_set_pkt_metadata,
486 .get_userdata = mock_get_userdata,
487 .capabilities_get = mock_capabilities_get,
492 * Test suite and test cases setup and teardown functions.
496 * struct security_testsuite_params defines parameters initialized once
497 * for whole tests suite.
498 * Currently the only stored parameter is session_mpool a mempool created
499 * once in testsuite_setup and released in testsuite_teardown.
500 * The instance of this structure is stored in testsuite_params variable.
502 static struct security_testsuite_params {
503 struct rte_mempool *session_mpool;
504 } testsuite_params = { NULL };
507 * struct security_unittest_params defines parameters initialized
508 * for every test case. The parameters are initialized in ut_setup
509 * or ut_setup_with_session (depending on the testcase)
510 * and released in ut_teardown.
511 * The instance of this structure is stored in unittest_params variable.
513 static struct security_unittest_params {
514 struct rte_security_ctx ctx;
515 struct rte_security_session_conf conf;
516 struct rte_security_session *sess;
517 } unittest_params = {
526 #define SECURITY_TEST_MEMPOOL_NAME "SecurityTestsMempoolName"
527 #define SECURITY_TEST_MEMPOOL_SIZE 15
528 #define SECURITY_TEST_SESSION_OBJECT_SIZE sizeof(struct rte_security_session)
531 * testsuite_setup initializes whole test suite parameters.
532 * It creates a new mempool used in all test cases
533 * and verifies if it properly created.
536 testsuite_setup(void)
538 struct security_testsuite_params *ts_params = &testsuite_params;
539 ts_params->session_mpool = rte_mempool_create(
540 SECURITY_TEST_MEMPOOL_NAME,
541 SECURITY_TEST_MEMPOOL_SIZE,
542 SECURITY_TEST_SESSION_OBJECT_SIZE,
543 0, 0, NULL, NULL, NULL, NULL,
545 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
546 "Cannot create mempool %s\n", rte_strerror(rte_errno));
551 * testsuite_teardown releases test suite wide parameters.
554 testsuite_teardown(void)
556 struct security_testsuite_params *ts_params = &testsuite_params;
557 if (ts_params->session_mpool) {
558 rte_mempool_free(ts_params->session_mpool);
559 ts_params->session_mpool = NULL;
564 * ut_setup initializes test case parameters to default values.
565 * It resets also any .called and .failed statistics of mockup functions
571 struct security_unittest_params *ut_params = &unittest_params;
572 ut_params->ctx.device = NULL;
573 ut_params->ctx.ops = &mock_ops;
574 ut_params->ctx.sess_cnt = 0;
575 ut_params->sess = NULL;
577 mock_session_create_exp.called = 0;
578 mock_session_update_exp.called = 0;
579 mock_session_get_size_exp.called = 0;
580 mock_session_stats_get_exp.called = 0;
581 mock_session_destroy_exp.called = 0;
582 mock_set_pkt_metadata_exp.called = 0;
583 mock_get_userdata_exp.called = 0;
584 mock_capabilities_get_exp.called = 0;
586 mock_session_create_exp.failed = 0;
587 mock_session_update_exp.failed = 0;
588 mock_session_get_size_exp.failed = 0;
589 mock_session_stats_get_exp.failed = 0;
590 mock_session_destroy_exp.failed = 0;
591 mock_set_pkt_metadata_exp.failed = 0;
592 mock_get_userdata_exp.failed = 0;
593 mock_capabilities_get_exp.failed = 0;
599 * destroy_session_with_check is a helper function releasing session
600 * created with rte_security_session_create and stored in test case parameters.
601 * It's used both to release sessions created in test cases' bodies
602 * which are assigned to ut_params->sess
603 * as well as sessions created in ut_setup_with_session.
606 destroy_session_with_check(void)
608 struct security_unittest_params *ut_params = &unittest_params;
609 if (ut_params->sess != NULL) {
610 /* Assure that mockup function for destroy operation is set. */
611 ut_params->ctx.ops = &mock_ops;
613 mock_session_destroy_exp.device = NULL;
614 mock_session_destroy_exp.sess = ut_params->sess;
615 mock_session_destroy_exp.ret = 0;
616 mock_session_destroy_exp.called = 0;
617 mock_session_destroy_exp.failed = 0;
619 int ret = rte_security_session_destroy(&ut_params->ctx,
621 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_destroy,
623 TEST_ASSERT_MOCK_CALLS(mock_session_destroy_exp, 1);
625 ut_params->sess = NULL;
631 * ut_teardown releases test case parameters.
636 destroy_session_with_check();
640 * ut_setup_with_session initializes test case parameters by
641 * - calling standard ut_setup,
642 * - creating a session that can be used in test case.
645 ut_setup_with_session(void)
647 struct security_unittest_params *ut_params = &unittest_params;
648 struct security_testsuite_params *ts_params = &testsuite_params;
649 struct rte_security_session *sess;
651 int ret = ut_setup();
652 if (ret != TEST_SUCCESS)
655 mock_session_create_exp.device = NULL;
656 mock_session_create_exp.conf = &ut_params->conf;
657 mock_session_create_exp.mp = ts_params->session_mpool;
658 mock_session_create_exp.ret = 0;
660 sess = rte_security_session_create(&ut_params->ctx, &ut_params->conf,
661 ts_params->session_mpool);
662 TEST_ASSERT_MOCK_FUNCTION_CALL_NOT_NULL(rte_security_session_create,
664 TEST_ASSERT_EQUAL(sess, mock_session_create_exp.sess,
665 "Expecting session_create to be called with %p sess"
666 " parameter, but it's called %p sess parameter",
667 sess, mock_session_create_exp.sess);
668 TEST_ASSERT_MOCK_CALLS(mock_session_create_exp, 1);
671 * Store created session in test case parameters, so it can be released
672 * after test case in ut_teardown by destroy_session_with_check.
674 ut_params->sess = sess;
683 * Each test function is related to a single test case.
684 * They are arranged by tested rte_security API function
685 * and by rte_security execution paths sequence in code.
689 * rte_security_session_create tests
693 * Test execution of rte_security_session_create with NULL instance
696 test_session_create_inv_context(void)
698 struct security_testsuite_params *ts_params = &testsuite_params;
699 struct security_unittest_params *ut_params = &unittest_params;
700 struct rte_security_session *sess;
702 sess = rte_security_session_create(NULL, &ut_params->conf,
703 ts_params->session_mpool);
704 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_create,
706 TEST_ASSERT_MOCK_CALLS(mock_session_create_exp, 0);
707 TEST_ASSERT_MEMPOOL_USAGE(0);
708 TEST_ASSERT_SESSION_COUNT(0);
714 * Test execution of rte_security_session_create with invalid
715 * security operations structure (NULL)
718 test_session_create_inv_context_ops(void)
720 struct security_testsuite_params *ts_params = &testsuite_params;
721 struct security_unittest_params *ut_params = &unittest_params;
722 struct rte_security_session *sess;
724 ut_params->ctx.ops = NULL;
726 sess = rte_security_session_create(&ut_params->ctx, &ut_params->conf,
727 ts_params->session_mpool);
728 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_create,
730 TEST_ASSERT_MOCK_CALLS(mock_session_create_exp, 0);
731 TEST_ASSERT_MEMPOOL_USAGE(0);
732 TEST_ASSERT_SESSION_COUNT(0);
738 * Test execution of rte_security_session_create with empty
739 * security operations
742 test_session_create_inv_context_ops_fun(void)
744 struct security_testsuite_params *ts_params = &testsuite_params;
745 struct security_unittest_params *ut_params = &unittest_params;
746 struct rte_security_session *sess;
748 ut_params->ctx.ops = &empty_ops;
750 sess = rte_security_session_create(&ut_params->ctx, &ut_params->conf,
751 ts_params->session_mpool);
752 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_create,
754 TEST_ASSERT_MOCK_CALLS(mock_session_create_exp, 0);
755 TEST_ASSERT_MEMPOOL_USAGE(0);
756 TEST_ASSERT_SESSION_COUNT(0);
762 * Test execution of rte_security_session_create with NULL conf parameter
765 test_session_create_inv_configuration(void)
767 struct security_testsuite_params *ts_params = &testsuite_params;
768 struct security_unittest_params *ut_params = &unittest_params;
769 struct rte_security_session *sess;
771 sess = rte_security_session_create(&ut_params->ctx, NULL,
772 ts_params->session_mpool);
773 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_create,
775 TEST_ASSERT_MOCK_CALLS(mock_session_create_exp, 0);
776 TEST_ASSERT_MEMPOOL_USAGE(0);
777 TEST_ASSERT_SESSION_COUNT(0);
783 * Test execution of rte_security_session_create with NULL mp parameter
786 test_session_create_inv_mempool(void)
788 struct security_unittest_params *ut_params = &unittest_params;
789 struct rte_security_session *sess;
791 sess = rte_security_session_create(&ut_params->ctx, &ut_params->conf,
793 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_create,
795 TEST_ASSERT_MOCK_CALLS(mock_session_create_exp, 0);
796 TEST_ASSERT_MEMPOOL_USAGE(0);
797 TEST_ASSERT_SESSION_COUNT(0);
803 * Test execution of rte_security_session_create in case when mempool
804 * is fully used and no object can be got from it
807 test_session_create_mempool_empty(void)
809 struct security_testsuite_params *ts_params = &testsuite_params;
810 struct security_unittest_params *ut_params = &unittest_params;
811 struct rte_security_session *tmp[SECURITY_TEST_MEMPOOL_SIZE];
812 struct rte_security_session *sess;
814 /* Get all available objects from mempool. */
816 for (i = 0; i < SECURITY_TEST_MEMPOOL_SIZE; ++i) {
817 ret = rte_mempool_get(ts_params->session_mpool,
819 TEST_ASSERT_EQUAL(0, ret,
820 "Expect getting %d object from mempool"
823 TEST_ASSERT_MEMPOOL_USAGE(SECURITY_TEST_MEMPOOL_SIZE);
825 sess = rte_security_session_create(&ut_params->ctx, &ut_params->conf,
826 ts_params->session_mpool);
827 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_create,
829 TEST_ASSERT_MOCK_CALLS(mock_session_create_exp, 0);
830 TEST_ASSERT_MEMPOOL_USAGE(SECURITY_TEST_MEMPOOL_SIZE);
831 TEST_ASSERT_SESSION_COUNT(0);
833 /* Put objects back to the pool. */
834 for (i = 0; i < SECURITY_TEST_MEMPOOL_SIZE; ++i)
835 rte_mempool_put(ts_params->session_mpool, (void *)(tmp[i]));
836 TEST_ASSERT_MEMPOOL_USAGE(0);
842 * Test execution of rte_security_session_create when session_create
843 * security operation fails
846 test_session_create_ops_failure(void)
848 struct security_testsuite_params *ts_params = &testsuite_params;
849 struct security_unittest_params *ut_params = &unittest_params;
850 struct rte_security_session *sess;
852 mock_session_create_exp.device = NULL;
853 mock_session_create_exp.conf = &ut_params->conf;
854 mock_session_create_exp.mp = ts_params->session_mpool;
855 mock_session_create_exp.ret = -1; /* Return failure status. */
857 sess = rte_security_session_create(&ut_params->ctx, &ut_params->conf,
858 ts_params->session_mpool);
859 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_create,
861 TEST_ASSERT_MOCK_CALLS(mock_session_create_exp, 1);
862 TEST_ASSERT_MEMPOOL_USAGE(0);
863 TEST_ASSERT_SESSION_COUNT(0);
869 * Test execution of rte_security_session_create in successful execution path
872 test_session_create_success(void)
874 struct security_testsuite_params *ts_params = &testsuite_params;
875 struct security_unittest_params *ut_params = &unittest_params;
876 struct rte_security_session *sess;
878 mock_session_create_exp.device = NULL;
879 mock_session_create_exp.conf = &ut_params->conf;
880 mock_session_create_exp.mp = ts_params->session_mpool;
881 mock_session_create_exp.ret = 0; /* Return success status. */
883 sess = rte_security_session_create(&ut_params->ctx, &ut_params->conf,
884 ts_params->session_mpool);
885 TEST_ASSERT_MOCK_FUNCTION_CALL_NOT_NULL(rte_security_session_create,
887 TEST_ASSERT_EQUAL(sess, mock_session_create_exp.sess,
888 "Expecting session_create to be called with %p sess"
889 " parameter, but it's called %p sess parameter",
890 sess, mock_session_create_exp.sess);
891 TEST_ASSERT_MOCK_CALLS(mock_session_create_exp, 1);
892 TEST_ASSERT_MEMPOOL_USAGE(1);
893 TEST_ASSERT_SESSION_COUNT(1);
896 * Store created session in test case parameters, so it can be released
897 * after test case in ut_teardown by destroy_session_with_check.
899 ut_params->sess = sess;
906 * rte_security_session_update tests
910 * Test execution of rte_security_session_update with NULL instance
913 test_session_update_inv_context(void)
915 struct security_unittest_params *ut_params = &unittest_params;
917 int ret = rte_security_session_update(NULL, ut_params->sess,
919 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_update,
921 TEST_ASSERT_MOCK_CALLS(mock_session_update_exp, 0);
927 * Test execution of rte_security_session_update with invalid
928 * security operations structure (NULL)
931 test_session_update_inv_context_ops(void)
933 struct security_unittest_params *ut_params = &unittest_params;
934 ut_params->ctx.ops = NULL;
936 int ret = rte_security_session_update(&ut_params->ctx, ut_params->sess,
938 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_update,
940 TEST_ASSERT_MOCK_CALLS(mock_session_update_exp, 0);
946 * Test execution of rte_security_session_update with empty
947 * security operations
950 test_session_update_inv_context_ops_fun(void)
952 struct security_unittest_params *ut_params = &unittest_params;
953 ut_params->ctx.ops = &empty_ops;
955 int ret = rte_security_session_update(&ut_params->ctx, ut_params->sess,
957 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_update,
958 ret, -ENOTSUP, "%d");
959 TEST_ASSERT_MOCK_CALLS(mock_session_update_exp, 0);
965 * Test execution of rte_security_session_update with NULL conf parameter
968 test_session_update_inv_configuration(void)
970 struct security_unittest_params *ut_params = &unittest_params;
972 int ret = rte_security_session_update(&ut_params->ctx, ut_params->sess,
974 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_update,
976 TEST_ASSERT_MOCK_CALLS(mock_session_update_exp, 0);
982 * Test execution of rte_security_session_update with NULL sess parameter
985 test_session_update_inv_session(void)
987 struct security_unittest_params *ut_params = &unittest_params;
989 int ret = rte_security_session_update(&ut_params->ctx, NULL,
991 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_update,
993 TEST_ASSERT_MOCK_CALLS(mock_session_update_exp, 0);
999 * Test execution of rte_security_session_update when session_update
1000 * security operation fails
1003 test_session_update_ops_failure(void)
1005 struct security_unittest_params *ut_params = &unittest_params;
1007 mock_session_update_exp.device = NULL;
1008 mock_session_update_exp.sess = ut_params->sess;
1009 mock_session_update_exp.conf = &ut_params->conf;
1010 mock_session_update_exp.ret = -1; /* Return failure status. */
1012 int ret = rte_security_session_update(&ut_params->ctx, ut_params->sess,
1014 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_update,
1016 TEST_ASSERT_MOCK_CALLS(mock_session_update_exp, 1);
1018 return TEST_SUCCESS;
1022 * Test execution of rte_security_session_update in successful execution path
1025 test_session_update_success(void)
1027 struct security_unittest_params *ut_params = &unittest_params;
1029 mock_session_update_exp.device = NULL;
1030 mock_session_update_exp.sess = ut_params->sess;
1031 mock_session_update_exp.conf = &ut_params->conf;
1032 mock_session_update_exp.ret = 0; /* Return success status. */
1034 int ret = rte_security_session_update(&ut_params->ctx, ut_params->sess,
1036 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_update,
1038 TEST_ASSERT_MOCK_CALLS(mock_session_update_exp, 1);
1040 return TEST_SUCCESS;
1045 * rte_security_session_get_size tests
1049 * Test execution of rte_security_session_get_size with NULL instance
1052 test_session_get_size_inv_context(void)
1054 unsigned int ret = rte_security_session_get_size(NULL);
1055 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_get_size,
1057 TEST_ASSERT_MOCK_CALLS(mock_session_get_size_exp, 0);
1059 return TEST_SUCCESS;
1063 * Test execution of rte_security_session_get_size with invalid
1064 * security operations structure (NULL)
1067 test_session_get_size_inv_context_ops(void)
1069 struct security_unittest_params *ut_params = &unittest_params;
1070 ut_params->ctx.ops = NULL;
1072 unsigned int ret = rte_security_session_get_size(&ut_params->ctx);
1073 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_get_size,
1075 TEST_ASSERT_MOCK_CALLS(mock_session_get_size_exp, 0);
1077 return TEST_SUCCESS;
1081 * Test execution of rte_security_session_get_size with empty
1082 * security operations
1085 test_session_get_size_inv_context_ops_fun(void)
1087 struct security_unittest_params *ut_params = &unittest_params;
1088 ut_params->ctx.ops = &empty_ops;
1090 unsigned int ret = rte_security_session_get_size(&ut_params->ctx);
1091 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_get_size,
1093 TEST_ASSERT_MOCK_CALLS(mock_session_get_size_exp, 0);
1095 return TEST_SUCCESS;
1099 * Test execution of rte_security_session_get_size when session_get_size
1100 * security operation fails
1103 test_session_get_size_ops_failure(void)
1105 struct security_unittest_params *ut_params = &unittest_params;
1107 mock_session_get_size_exp.device = NULL;
1108 mock_session_get_size_exp.ret = 0;
1110 unsigned int ret = rte_security_session_get_size(&ut_params->ctx);
1111 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_get_size,
1113 TEST_ASSERT_MOCK_CALLS(mock_session_get_size_exp, 1);
1115 return TEST_SUCCESS;
1119 * Test execution of rte_security_session_get_size in successful execution path
1122 test_session_get_size_success(void)
1124 struct security_unittest_params *ut_params = &unittest_params;
1126 mock_session_get_size_exp.device = NULL;
1127 mock_session_get_size_exp.ret = 1024;
1129 unsigned int ret = rte_security_session_get_size(&ut_params->ctx);
1130 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_get_size,
1132 TEST_ASSERT_MOCK_CALLS(mock_session_get_size_exp, 1);
1134 return TEST_SUCCESS;
1139 * rte_security_session_stats_get tests
1143 * Test execution of rte_security_session_stats_get with NULL instance
1146 test_session_stats_get_inv_context(void)
1148 struct security_unittest_params *ut_params = &unittest_params;
1149 struct rte_security_stats stats;
1151 int ret = rte_security_session_stats_get(NULL, ut_params->sess, &stats);
1152 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_stats_get,
1153 ret, -EINVAL, "%d");
1154 TEST_ASSERT_MOCK_CALLS(mock_session_stats_get_exp, 0);
1156 return TEST_SUCCESS;
1160 * Test execution of rte_security_session_stats_get with invalid
1161 * security operations structure (NULL)
1164 test_session_stats_get_inv_context_ops(void)
1166 struct security_unittest_params *ut_params = &unittest_params;
1167 struct rte_security_stats stats;
1168 ut_params->ctx.ops = NULL;
1170 int ret = rte_security_session_stats_get(&ut_params->ctx,
1171 ut_params->sess, &stats);
1172 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_stats_get,
1173 ret, -EINVAL, "%d");
1174 TEST_ASSERT_MOCK_CALLS(mock_session_stats_get_exp, 0);
1176 return TEST_SUCCESS;
1180 * Test execution of rte_security_session_stats_get with empty
1181 * security operations
1184 test_session_stats_get_inv_context_ops_fun(void)
1186 struct security_unittest_params *ut_params = &unittest_params;
1187 struct rte_security_stats stats;
1188 ut_params->ctx.ops = &empty_ops;
1190 int ret = rte_security_session_stats_get(&ut_params->ctx,
1191 ut_params->sess, &stats);
1192 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_stats_get,
1193 ret, -ENOTSUP, "%d");
1194 TEST_ASSERT_MOCK_CALLS(mock_session_stats_get_exp, 0);
1196 return TEST_SUCCESS;
1200 * Test execution of rte_security_session_stats_get with NULL stats parameter
1203 test_session_stats_get_inv_stats(void)
1205 struct security_unittest_params *ut_params = &unittest_params;
1207 int ret = rte_security_session_stats_get(&ut_params->ctx,
1208 ut_params->sess, NULL);
1209 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_stats_get,
1210 ret, -EINVAL, "%d");
1211 TEST_ASSERT_MOCK_CALLS(mock_session_stats_get_exp, 0);
1213 return TEST_SUCCESS;
1217 * Test execution of rte_security_session_stats_get when session_stats_get
1218 * security operation fails
1221 test_session_stats_get_ops_failure(void)
1223 struct security_unittest_params *ut_params = &unittest_params;
1224 struct rte_security_stats stats;
1226 mock_session_stats_get_exp.device = NULL;
1227 mock_session_stats_get_exp.sess = ut_params->sess;
1228 mock_session_stats_get_exp.stats = &stats;
1229 mock_session_stats_get_exp.ret = -1;
1231 int ret = rte_security_session_stats_get(&ut_params->ctx,
1232 ut_params->sess, &stats);
1233 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_stats_get,
1235 TEST_ASSERT_MOCK_CALLS(mock_session_stats_get_exp, 1);
1237 return TEST_SUCCESS;
1241 * Test execution of rte_security_session_stats_get in successful execution
1245 test_session_stats_get_success(void)
1247 struct security_unittest_params *ut_params = &unittest_params;
1248 struct rte_security_stats stats;
1250 mock_session_stats_get_exp.device = NULL;
1251 mock_session_stats_get_exp.sess = ut_params->sess;
1252 mock_session_stats_get_exp.stats = &stats;
1253 mock_session_stats_get_exp.ret = 0;
1255 int ret = rte_security_session_stats_get(&ut_params->ctx,
1256 ut_params->sess, &stats);
1257 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_stats_get,
1259 TEST_ASSERT_MOCK_CALLS(mock_session_stats_get_exp, 1);
1261 return TEST_SUCCESS;
1266 * rte_security_session_destroy tests
1270 * Test execution of rte_security_session_destroy with NULL instance
1273 test_session_destroy_inv_context(void)
1275 struct security_unittest_params *ut_params = &unittest_params;
1277 TEST_ASSERT_MEMPOOL_USAGE(1);
1278 TEST_ASSERT_SESSION_COUNT(1);
1280 int ret = rte_security_session_destroy(NULL, ut_params->sess);
1281 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_destroy,
1282 ret, -EINVAL, "%d");
1283 TEST_ASSERT_MOCK_CALLS(mock_session_destroy_exp, 0);
1284 TEST_ASSERT_MEMPOOL_USAGE(1);
1285 TEST_ASSERT_SESSION_COUNT(1);
1287 return TEST_SUCCESS;
1291 * Test execution of rte_security_session_destroy with invalid
1292 * security operations structure (NULL)
1295 test_session_destroy_inv_context_ops(void)
1297 struct security_unittest_params *ut_params = &unittest_params;
1298 ut_params->ctx.ops = NULL;
1300 TEST_ASSERT_MEMPOOL_USAGE(1);
1301 TEST_ASSERT_SESSION_COUNT(1);
1303 int ret = rte_security_session_destroy(&ut_params->ctx,
1305 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_destroy,
1306 ret, -EINVAL, "%d");
1307 TEST_ASSERT_MOCK_CALLS(mock_session_destroy_exp, 0);
1308 TEST_ASSERT_MEMPOOL_USAGE(1);
1309 TEST_ASSERT_SESSION_COUNT(1);
1311 return TEST_SUCCESS;
1315 * Test execution of rte_security_session_destroy with empty
1316 * security operations
1319 test_session_destroy_inv_context_ops_fun(void)
1321 struct security_unittest_params *ut_params = &unittest_params;
1322 ut_params->ctx.ops = &empty_ops;
1324 TEST_ASSERT_MEMPOOL_USAGE(1);
1325 TEST_ASSERT_SESSION_COUNT(1);
1327 int ret = rte_security_session_destroy(&ut_params->ctx,
1329 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_destroy,
1330 ret, -ENOTSUP, "%d");
1331 TEST_ASSERT_MOCK_CALLS(mock_session_destroy_exp, 0);
1332 TEST_ASSERT_MEMPOOL_USAGE(1);
1333 TEST_ASSERT_SESSION_COUNT(1);
1335 return TEST_SUCCESS;
1339 * Test execution of rte_security_session_destroy with NULL sess parameter
1342 test_session_destroy_inv_session(void)
1344 struct security_unittest_params *ut_params = &unittest_params;
1346 TEST_ASSERT_MEMPOOL_USAGE(1);
1347 TEST_ASSERT_SESSION_COUNT(1);
1349 int ret = rte_security_session_destroy(&ut_params->ctx, NULL);
1350 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_destroy,
1351 ret, -EINVAL, "%d");
1352 TEST_ASSERT_MOCK_CALLS(mock_session_destroy_exp, 0);
1353 TEST_ASSERT_MEMPOOL_USAGE(1);
1354 TEST_ASSERT_SESSION_COUNT(1);
1356 return TEST_SUCCESS;
1360 * Test execution of rte_security_session_destroy when session_destroy
1361 * security operation fails
1364 test_session_destroy_ops_failure(void)
1366 struct security_unittest_params *ut_params = &unittest_params;
1368 mock_session_destroy_exp.device = NULL;
1369 mock_session_destroy_exp.sess = ut_params->sess;
1370 mock_session_destroy_exp.ret = -1;
1372 TEST_ASSERT_MEMPOOL_USAGE(1);
1373 TEST_ASSERT_SESSION_COUNT(1);
1375 int ret = rte_security_session_destroy(&ut_params->ctx,
1377 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_destroy,
1379 TEST_ASSERT_MOCK_CALLS(mock_session_destroy_exp, 1);
1380 TEST_ASSERT_MEMPOOL_USAGE(1);
1381 TEST_ASSERT_SESSION_COUNT(1);
1383 return TEST_SUCCESS;
1387 * Test execution of rte_security_session_destroy in successful execution path
1390 test_session_destroy_success(void)
1392 struct security_unittest_params *ut_params = &unittest_params;
1394 mock_session_destroy_exp.device = NULL;
1395 mock_session_destroy_exp.sess = ut_params->sess;
1396 mock_session_destroy_exp.ret = 0;
1397 TEST_ASSERT_MEMPOOL_USAGE(1);
1398 TEST_ASSERT_SESSION_COUNT(1);
1400 int ret = rte_security_session_destroy(&ut_params->ctx,
1402 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_destroy,
1404 TEST_ASSERT_MOCK_CALLS(mock_session_destroy_exp, 1);
1405 TEST_ASSERT_MEMPOOL_USAGE(0);
1406 TEST_ASSERT_SESSION_COUNT(0);
1409 * Remove session from test case parameters, so it won't be destroyed
1410 * during test case teardown.
1412 ut_params->sess = NULL;
1414 return TEST_SUCCESS;
1419 * rte_security_set_pkt_metadata tests
1423 * Test execution of rte_security_set_pkt_metadata with NULL instance
1426 test_set_pkt_metadata_inv_context(void)
1429 struct security_unittest_params *ut_params = &unittest_params;
1433 int ret = rte_security_set_pkt_metadata(NULL, ut_params->sess, &m,
1435 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_set_pkt_metadata,
1436 ret, -EINVAL, "%d");
1437 TEST_ASSERT_MOCK_CALLS(mock_set_pkt_metadata_exp, 0);
1439 return TEST_SUCCESS;
1441 return TEST_SKIPPED;
1446 * Test execution of rte_security_set_pkt_metadata with invalid
1447 * security operations structure (NULL)
1450 test_set_pkt_metadata_inv_context_ops(void)
1453 struct security_unittest_params *ut_params = &unittest_params;
1456 ut_params->ctx.ops = NULL;
1458 int ret = rte_security_set_pkt_metadata(&ut_params->ctx,
1459 ut_params->sess, &m, ¶ms);
1460 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_set_pkt_metadata,
1461 ret, -EINVAL, "%d");
1462 TEST_ASSERT_MOCK_CALLS(mock_set_pkt_metadata_exp, 0);
1464 return TEST_SUCCESS;
1466 return TEST_SKIPPED;
1471 * Test execution of rte_security_set_pkt_metadata with empty
1472 * security operations
1475 test_set_pkt_metadata_inv_context_ops_fun(void)
1478 struct security_unittest_params *ut_params = &unittest_params;
1481 ut_params->ctx.ops = &empty_ops;
1483 int ret = rte_security_set_pkt_metadata(&ut_params->ctx,
1484 ut_params->sess, &m, ¶ms);
1485 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_set_pkt_metadata,
1486 ret, -ENOTSUP, "%d");
1487 TEST_ASSERT_MOCK_CALLS(mock_set_pkt_metadata_exp, 0);
1489 return TEST_SUCCESS;
1491 return TEST_SKIPPED;
1496 * Test execution of rte_security_set_pkt_metadata with NULL sess parameter
1499 test_set_pkt_metadata_inv_session(void)
1502 struct security_unittest_params *ut_params = &unittest_params;
1506 int ret = rte_security_set_pkt_metadata(&ut_params->ctx, NULL,
1508 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_set_pkt_metadata,
1509 ret, -EINVAL, "%d");
1510 TEST_ASSERT_MOCK_CALLS(mock_set_pkt_metadata_exp, 0);
1512 return TEST_SUCCESS;
1514 return TEST_SKIPPED;
1519 * Test execution of rte_security_set_pkt_metadata when set_pkt_metadata
1520 * security operation fails
1523 test_set_pkt_metadata_ops_failure(void)
1525 struct security_unittest_params *ut_params = &unittest_params;
1529 mock_set_pkt_metadata_exp.device = NULL;
1530 mock_set_pkt_metadata_exp.sess = ut_params->sess;
1531 mock_set_pkt_metadata_exp.m = &m;
1532 mock_set_pkt_metadata_exp.params = ¶ms;
1533 mock_set_pkt_metadata_exp.ret = -1;
1535 int ret = rte_security_set_pkt_metadata(&ut_params->ctx,
1536 ut_params->sess, &m, ¶ms);
1537 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_set_pkt_metadata,
1539 TEST_ASSERT_MOCK_CALLS(mock_set_pkt_metadata_exp, 1);
1541 return TEST_SUCCESS;
1545 * Test execution of rte_security_set_pkt_metadata in successful execution path
1548 test_set_pkt_metadata_success(void)
1550 struct security_unittest_params *ut_params = &unittest_params;
1554 mock_set_pkt_metadata_exp.device = NULL;
1555 mock_set_pkt_metadata_exp.sess = ut_params->sess;
1556 mock_set_pkt_metadata_exp.m = &m;
1557 mock_set_pkt_metadata_exp.params = ¶ms;
1558 mock_set_pkt_metadata_exp.ret = 0;
1560 int ret = rte_security_set_pkt_metadata(&ut_params->ctx,
1561 ut_params->sess, &m, ¶ms);
1562 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_set_pkt_metadata,
1564 TEST_ASSERT_MOCK_CALLS(mock_set_pkt_metadata_exp, 1);
1566 return TEST_SUCCESS;
1571 * rte_security_get_userdata tests
1575 * Test execution of rte_security_get_userdata with NULL instance
1578 test_get_userdata_inv_context(void)
1581 uint64_t md = 0xDEADBEEF;
1583 void *ret = rte_security_get_userdata(NULL, md);
1584 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_get_userdata,
1586 TEST_ASSERT_MOCK_CALLS(mock_get_userdata_exp, 0);
1588 return TEST_SUCCESS;
1590 return TEST_SKIPPED;
1595 * Test execution of rte_security_get_userdata with invalid
1596 * security operations structure (NULL)
1599 test_get_userdata_inv_context_ops(void)
1602 struct security_unittest_params *ut_params = &unittest_params;
1603 uint64_t md = 0xDEADBEEF;
1604 ut_params->ctx.ops = NULL;
1606 void *ret = rte_security_get_userdata(&ut_params->ctx, md);
1607 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_get_userdata,
1609 TEST_ASSERT_MOCK_CALLS(mock_get_userdata_exp, 0);
1611 return TEST_SUCCESS;
1613 return TEST_SKIPPED;
1618 * Test execution of rte_security_get_userdata with empty
1619 * security operations
1622 test_get_userdata_inv_context_ops_fun(void)
1625 struct security_unittest_params *ut_params = &unittest_params;
1626 uint64_t md = 0xDEADBEEF;
1627 ut_params->ctx.ops = &empty_ops;
1629 void *ret = rte_security_get_userdata(&ut_params->ctx, md);
1630 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_get_userdata,
1632 TEST_ASSERT_MOCK_CALLS(mock_get_userdata_exp, 0);
1634 return TEST_SUCCESS;
1636 return TEST_SKIPPED;
1641 * Test execution of rte_security_get_userdata when get_userdata
1642 * security operation fails
1645 test_get_userdata_ops_failure(void)
1647 struct security_unittest_params *ut_params = &unittest_params;
1648 uint64_t md = 0xDEADBEEF;
1649 void *userdata = (void *)0x7E577E57;
1651 mock_get_userdata_exp.device = NULL;
1652 mock_get_userdata_exp.md = md;
1653 mock_get_userdata_exp.userdata = userdata;
1654 mock_get_userdata_exp.ret = -1;
1656 void *ret = rte_security_get_userdata(&ut_params->ctx, md);
1657 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_get_userdata,
1659 TEST_ASSERT_MOCK_CALLS(mock_get_userdata_exp, 1);
1661 return TEST_SUCCESS;
1665 * Test execution of rte_security_get_userdata in successful execution path
1668 test_get_userdata_success(void)
1670 struct security_unittest_params *ut_params = &unittest_params;
1671 uint64_t md = 0xDEADBEEF;
1672 void *userdata = (void *)0x7E577E57;
1674 mock_get_userdata_exp.device = NULL;
1675 mock_get_userdata_exp.md = md;
1676 mock_get_userdata_exp.userdata = userdata;
1677 mock_get_userdata_exp.ret = 0;
1679 void *ret = rte_security_get_userdata(&ut_params->ctx, md);
1680 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_get_userdata,
1681 ret, userdata, "%p");
1682 TEST_ASSERT_MOCK_CALLS(mock_get_userdata_exp, 1);
1684 return TEST_SUCCESS;
1689 * rte_security_capabilities_get tests
1693 * Test execution of rte_security_capabilities_get with NULL instance
1696 test_capabilities_get_inv_context(void)
1698 const struct rte_security_capability *ret;
1699 ret = rte_security_capabilities_get(NULL);
1700 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capabilities_get,
1702 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 0);
1704 return TEST_SUCCESS;
1708 * Test execution of rte_security_capabilities_get with invalid
1709 * security operations structure (NULL)
1712 test_capabilities_get_inv_context_ops(void)
1714 struct security_unittest_params *ut_params = &unittest_params;
1715 ut_params->ctx.ops = NULL;
1717 const struct rte_security_capability *ret;
1718 ret = rte_security_capabilities_get(&ut_params->ctx);
1719 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capabilities_get,
1721 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 0);
1723 return TEST_SUCCESS;
1727 * Test execution of rte_security_capabilities_get with empty
1728 * security operations
1731 test_capabilities_get_inv_context_ops_fun(void)
1733 struct security_unittest_params *ut_params = &unittest_params;
1734 ut_params->ctx.ops = &empty_ops;
1736 const struct rte_security_capability *ret;
1737 ret = rte_security_capabilities_get(&ut_params->ctx);
1738 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capabilities_get,
1740 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 0);
1742 return TEST_SUCCESS;
1746 * Test execution of rte_security_capabilities_get when capabilities_get
1747 * security operation fails
1750 test_capabilities_get_ops_failure(void)
1752 struct security_unittest_params *ut_params = &unittest_params;
1754 mock_capabilities_get_exp.device = NULL;
1755 mock_capabilities_get_exp.ret = NULL;
1757 const struct rte_security_capability *ret;
1758 ret = rte_security_capabilities_get(&ut_params->ctx);
1759 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capabilities_get,
1761 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 1);
1763 return TEST_SUCCESS;
1767 * Test execution of rte_security_capabilities_get in successful execution path
1770 test_capabilities_get_success(void)
1772 struct security_unittest_params *ut_params = &unittest_params;
1773 struct rte_security_capability capabilities;
1775 mock_capabilities_get_exp.device = NULL;
1776 mock_capabilities_get_exp.ret = &capabilities;
1778 const struct rte_security_capability *ret;
1779 ret = rte_security_capabilities_get(&ut_params->ctx);
1780 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capabilities_get,
1781 ret, &capabilities, "%p");
1782 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 1);
1784 return TEST_SUCCESS;
1789 * rte_security_capability_get tests
1793 * Test execution of rte_security_capability_get with NULL instance
1796 test_capability_get_inv_context(void)
1798 struct rte_security_capability_idx idx;
1800 const struct rte_security_capability *ret;
1801 ret = rte_security_capability_get(NULL, &idx);
1802 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capability_get,
1804 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 0);
1806 return TEST_SUCCESS;
1810 * Test execution of rte_security_capability_get with invalid
1811 * security operations structure (NULL)
1814 test_capability_get_inv_context_ops(void)
1816 struct security_unittest_params *ut_params = &unittest_params;
1817 struct rte_security_capability_idx idx;
1818 ut_params->ctx.ops = NULL;
1820 const struct rte_security_capability *ret;
1821 ret = rte_security_capability_get(&ut_params->ctx, &idx);
1822 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capability_get,
1824 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 0);
1826 return TEST_SUCCESS;
1830 * Test execution of rte_security_capability_get with empty
1831 * security operations
1834 test_capability_get_inv_context_ops_fun(void)
1836 struct security_unittest_params *ut_params = &unittest_params;
1837 struct rte_security_capability_idx idx;
1838 ut_params->ctx.ops = &empty_ops;
1840 const struct rte_security_capability *ret;
1841 ret = rte_security_capability_get(&ut_params->ctx, &idx);
1842 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capability_get,
1844 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 0);
1846 return TEST_SUCCESS;
1850 * Test execution of rte_security_capability_get with NULL idx parameter
1853 test_capability_get_inv_idx(void)
1855 struct security_unittest_params *ut_params = &unittest_params;
1857 const struct rte_security_capability *ret;
1858 ret = rte_security_capability_get(&ut_params->ctx, NULL);
1859 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capability_get,
1861 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 0);
1863 return TEST_SUCCESS;
1867 * Test execution of rte_security_capability_get when capabilities_get
1868 * security operation fails
1871 test_capability_get_ops_failure(void)
1873 struct security_unittest_params *ut_params = &unittest_params;
1874 struct rte_security_capability_idx idx;
1876 mock_capabilities_get_exp.device = NULL;
1877 mock_capabilities_get_exp.ret = NULL;
1879 const struct rte_security_capability *ret;
1880 ret = rte_security_capability_get(&ut_params->ctx, &idx);
1881 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capability_get,
1883 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 1);
1885 return TEST_SUCCESS;
1889 * Test execution of rte_security_capability_get when capabilities table
1890 * is empty (contains only RTE_SECURITY_ACTION_TYPE_NONE ending entry)
1893 test_capability_get_empty_table(void)
1895 struct security_unittest_params *ut_params = &unittest_params;
1896 struct rte_security_capability_idx idx;
1897 struct rte_security_capability capabilities[] = {
1899 .action = RTE_SECURITY_ACTION_TYPE_NONE,
1903 mock_capabilities_get_exp.device = NULL;
1904 mock_capabilities_get_exp.ret = capabilities;
1906 const struct rte_security_capability *ret;
1907 ret = rte_security_capability_get(&ut_params->ctx, &idx);
1908 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capability_get,
1910 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 1);
1912 return TEST_SUCCESS;
1916 * Test execution of rte_security_capability_get when capabilities table
1917 * does not contain entry with matching action
1920 test_capability_get_no_matching_action(void)
1922 struct security_unittest_params *ut_params = &unittest_params;
1923 struct rte_security_capability_idx idx = {
1924 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
1926 struct rte_security_capability capabilities[] = {
1928 .action = RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO,
1931 .action = RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL,
1934 .action = RTE_SECURITY_ACTION_TYPE_NONE,
1938 mock_capabilities_get_exp.device = NULL;
1939 mock_capabilities_get_exp.ret = capabilities;
1941 const struct rte_security_capability *ret;
1942 ret = rte_security_capability_get(&ut_params->ctx, &idx);
1943 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capability_get,
1945 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 1);
1947 return TEST_SUCCESS;
1951 * Test execution of rte_security_capability_get when capabilities table
1952 * does not contain entry with matching protocol
1955 test_capability_get_no_matching_protocol(void)
1957 struct security_unittest_params *ut_params = &unittest_params;
1958 struct rte_security_capability_idx idx = {
1959 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
1960 .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
1962 struct rte_security_capability capabilities[] = {
1964 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
1965 .protocol = RTE_SECURITY_PROTOCOL_MACSEC,
1968 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
1969 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
1972 .action = RTE_SECURITY_ACTION_TYPE_NONE,
1976 mock_capabilities_get_exp.device = NULL;
1977 mock_capabilities_get_exp.ret = capabilities;
1979 const struct rte_security_capability *ret;
1980 ret = rte_security_capability_get(&ut_params->ctx, &idx);
1981 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capability_get,
1983 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 1);
1985 return TEST_SUCCESS;
1989 * Test execution of rte_security_capability_get when macsec protocol
1990 * is searched and capabilities table contain proper entry.
1991 * However macsec records search is not supported in rte_security.
1994 test_capability_get_no_support_for_macsec(void)
1996 struct security_unittest_params *ut_params = &unittest_params;
1997 struct rte_security_capability_idx idx = {
1998 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
1999 .protocol = RTE_SECURITY_PROTOCOL_MACSEC,
2001 struct rte_security_capability capabilities[] = {
2003 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
2004 .protocol = RTE_SECURITY_PROTOCOL_MACSEC,
2007 .action = RTE_SECURITY_ACTION_TYPE_NONE,
2011 mock_capabilities_get_exp.device = NULL;
2012 mock_capabilities_get_exp.ret = capabilities;
2014 const struct rte_security_capability *ret;
2015 ret = rte_security_capability_get(&ut_params->ctx, &idx);
2016 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capability_get,
2018 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 1);
2020 return TEST_SUCCESS;
2024 * Test execution of rte_security_capability_get when capabilities table
2025 * does not contain entry with matching ipsec proto field
2028 test_capability_get_ipsec_mismatch_proto(void)
2030 struct security_unittest_params *ut_params = &unittest_params;
2031 struct rte_security_capability_idx idx = {
2032 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
2033 .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
2035 .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP,
2038 struct rte_security_capability capabilities[] = {
2040 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
2041 .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
2043 .proto = RTE_SECURITY_IPSEC_SA_PROTO_AH,
2047 .action = RTE_SECURITY_ACTION_TYPE_NONE,
2051 mock_capabilities_get_exp.device = NULL;
2052 mock_capabilities_get_exp.ret = capabilities;
2054 const struct rte_security_capability *ret;
2055 ret = rte_security_capability_get(&ut_params->ctx, &idx);
2056 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capability_get,
2058 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 1);
2060 return TEST_SUCCESS;
2064 * Test execution of rte_security_capability_get when capabilities table
2065 * does not contain entry with matching ipsec mode field
2068 test_capability_get_ipsec_mismatch_mode(void)
2070 struct security_unittest_params *ut_params = &unittest_params;
2071 struct rte_security_capability_idx idx = {
2072 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
2073 .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
2075 .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP,
2076 .mode = RTE_SECURITY_IPSEC_SA_MODE_TRANSPORT,
2079 struct rte_security_capability capabilities[] = {
2081 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
2082 .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
2084 .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP,
2085 .mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL,
2089 .action = RTE_SECURITY_ACTION_TYPE_NONE,
2093 mock_capabilities_get_exp.device = NULL;
2094 mock_capabilities_get_exp.ret = capabilities;
2096 const struct rte_security_capability *ret;
2097 ret = rte_security_capability_get(&ut_params->ctx, &idx);
2098 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capability_get,
2100 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 1);
2102 return TEST_SUCCESS;
2106 * Test execution of rte_security_capability_get when capabilities table
2107 * does not contain entry with matching ipsec direction field
2110 test_capability_get_ipsec_mismatch_dir(void)
2112 struct security_unittest_params *ut_params = &unittest_params;
2113 struct rte_security_capability_idx idx = {
2114 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
2115 .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
2117 .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP,
2118 .mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL,
2119 .direction = RTE_SECURITY_IPSEC_SA_DIR_EGRESS,
2122 struct rte_security_capability capabilities[] = {
2124 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
2125 .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
2127 .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP,
2128 .mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL,
2129 .direction = RTE_SECURITY_IPSEC_SA_DIR_INGRESS,
2133 .action = RTE_SECURITY_ACTION_TYPE_NONE,
2137 mock_capabilities_get_exp.device = NULL;
2138 mock_capabilities_get_exp.ret = capabilities;
2140 const struct rte_security_capability *ret;
2141 ret = rte_security_capability_get(&ut_params->ctx, &idx);
2142 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capability_get,
2144 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 1);
2146 return TEST_SUCCESS;
2150 * Test execution of rte_security_capability_get when capabilities table
2151 * contains matching ipsec entry
2154 test_capability_get_ipsec_match(void)
2156 struct security_unittest_params *ut_params = &unittest_params;
2157 struct rte_security_capability_idx idx = {
2158 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
2159 .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
2161 .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP,
2162 .mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL,
2163 .direction = RTE_SECURITY_IPSEC_SA_DIR_INGRESS,
2166 struct rte_security_capability capabilities[] = {
2168 .action = RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO,
2171 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
2172 .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
2174 .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP,
2175 .mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL,
2176 .direction = RTE_SECURITY_IPSEC_SA_DIR_INGRESS,
2180 .action = RTE_SECURITY_ACTION_TYPE_NONE,
2184 mock_capabilities_get_exp.device = NULL;
2185 mock_capabilities_get_exp.ret = capabilities;
2187 const struct rte_security_capability *ret;
2188 ret = rte_security_capability_get(&ut_params->ctx, &idx);
2189 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capability_get,
2190 ret, &capabilities[1], "%p");
2191 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 1);
2193 return TEST_SUCCESS;
2197 * Test execution of rte_security_capability_get when capabilities table
2198 * does not contain entry with matching pdcp domain field
2201 test_capability_get_pdcp_mismatch_domain(void)
2203 struct security_unittest_params *ut_params = &unittest_params;
2204 struct rte_security_capability_idx idx = {
2205 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
2206 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
2208 .domain = RTE_SECURITY_PDCP_MODE_CONTROL,
2211 struct rte_security_capability capabilities[] = {
2213 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
2214 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
2216 .domain = RTE_SECURITY_PDCP_MODE_DATA,
2220 .action = RTE_SECURITY_ACTION_TYPE_NONE,
2224 mock_capabilities_get_exp.device = NULL;
2225 mock_capabilities_get_exp.ret = capabilities;
2227 const struct rte_security_capability *ret;
2228 ret = rte_security_capability_get(&ut_params->ctx, &idx);
2229 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capability_get,
2231 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 1);
2233 return TEST_SUCCESS;
2237 * Test execution of rte_security_capability_get when capabilities table
2238 * contains matching pdcp entry
2241 test_capability_get_pdcp_match(void)
2243 struct security_unittest_params *ut_params = &unittest_params;
2244 struct rte_security_capability_idx idx = {
2245 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
2246 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
2248 .domain = RTE_SECURITY_PDCP_MODE_CONTROL,
2251 struct rte_security_capability capabilities[] = {
2253 .action = RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO,
2256 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
2257 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
2259 .domain = RTE_SECURITY_PDCP_MODE_CONTROL,
2263 .action = RTE_SECURITY_ACTION_TYPE_NONE,
2267 mock_capabilities_get_exp.device = NULL;
2268 mock_capabilities_get_exp.ret = capabilities;
2270 const struct rte_security_capability *ret;
2271 ret = rte_security_capability_get(&ut_params->ctx, &idx);
2272 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capability_get,
2273 ret, &capabilities[1], "%p");
2274 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 1);
2276 return TEST_SUCCESS;
2280 * Declaration of testcases
2282 static struct unit_test_suite security_testsuite = {
2283 .suite_name = "generic security",
2284 .setup = testsuite_setup,
2285 .teardown = testsuite_teardown,
2286 .unit_test_cases = {
2287 TEST_CASE_ST(ut_setup, ut_teardown,
2288 test_session_create_inv_context),
2289 TEST_CASE_ST(ut_setup, ut_teardown,
2290 test_session_create_inv_context_ops),
2291 TEST_CASE_ST(ut_setup, ut_teardown,
2292 test_session_create_inv_context_ops_fun),
2293 TEST_CASE_ST(ut_setup, ut_teardown,
2294 test_session_create_inv_configuration),
2295 TEST_CASE_ST(ut_setup, ut_teardown,
2296 test_session_create_inv_mempool),
2297 TEST_CASE_ST(ut_setup, ut_teardown,
2298 test_session_create_mempool_empty),
2299 TEST_CASE_ST(ut_setup, ut_teardown,
2300 test_session_create_ops_failure),
2301 TEST_CASE_ST(ut_setup, ut_teardown,
2302 test_session_create_success),
2304 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2305 test_session_update_inv_context),
2306 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2307 test_session_update_inv_context_ops),
2308 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2309 test_session_update_inv_context_ops_fun),
2310 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2311 test_session_update_inv_configuration),
2312 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2313 test_session_update_inv_session),
2314 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2315 test_session_update_ops_failure),
2316 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2317 test_session_update_success),
2319 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2320 test_session_get_size_inv_context),
2321 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2322 test_session_get_size_inv_context_ops),
2323 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2324 test_session_get_size_inv_context_ops_fun),
2325 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2326 test_session_get_size_ops_failure),
2327 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2328 test_session_get_size_success),
2330 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2331 test_session_stats_get_inv_context),
2332 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2333 test_session_stats_get_inv_context_ops),
2334 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2335 test_session_stats_get_inv_context_ops_fun),
2336 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2337 test_session_stats_get_inv_stats),
2338 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2339 test_session_stats_get_ops_failure),
2340 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2341 test_session_stats_get_success),
2343 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2344 test_session_destroy_inv_context),
2345 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2346 test_session_destroy_inv_context_ops),
2347 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2348 test_session_destroy_inv_context_ops_fun),
2349 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2350 test_session_destroy_inv_session),
2351 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2352 test_session_destroy_ops_failure),
2353 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2354 test_session_destroy_success),
2356 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2357 test_set_pkt_metadata_inv_context),
2358 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2359 test_set_pkt_metadata_inv_context_ops),
2360 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2361 test_set_pkt_metadata_inv_context_ops_fun),
2362 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2363 test_set_pkt_metadata_inv_session),
2364 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2365 test_set_pkt_metadata_ops_failure),
2366 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2367 test_set_pkt_metadata_success),
2369 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2370 test_get_userdata_inv_context),
2371 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2372 test_get_userdata_inv_context_ops),
2373 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2374 test_get_userdata_inv_context_ops_fun),
2375 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2376 test_get_userdata_ops_failure),
2377 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2378 test_get_userdata_success),
2380 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2381 test_capabilities_get_inv_context),
2382 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2383 test_capabilities_get_inv_context_ops),
2384 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2385 test_capabilities_get_inv_context_ops_fun),
2386 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2387 test_capabilities_get_ops_failure),
2388 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2389 test_capabilities_get_success),
2391 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2392 test_capability_get_inv_context),
2393 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2394 test_capability_get_inv_context_ops),
2395 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2396 test_capability_get_inv_context_ops_fun),
2397 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2398 test_capability_get_inv_idx),
2399 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2400 test_capability_get_ops_failure),
2401 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2402 test_capability_get_empty_table),
2403 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2404 test_capability_get_no_matching_action),
2405 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2406 test_capability_get_no_matching_protocol),
2407 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2408 test_capability_get_no_support_for_macsec),
2409 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2410 test_capability_get_ipsec_mismatch_proto),
2411 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2412 test_capability_get_ipsec_mismatch_mode),
2413 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2414 test_capability_get_ipsec_mismatch_dir),
2415 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2416 test_capability_get_ipsec_match),
2417 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2418 test_capability_get_pdcp_mismatch_domain),
2419 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2420 test_capability_get_pdcp_match),
2422 TEST_CASES_END() /**< NULL terminate unit test array */
2429 rte_log_set_global_level(RTE_LOG_DEBUG);
2430 rte_log_set_level(RTE_LOGTYPE_EAL, RTE_LOG_DEBUG);
2432 return unit_test_suite_runner(&security_testsuite);
2435 REGISTER_TEST_COMMAND(security_autotest, test_security);