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)
1477 struct security_unittest_params *ut_params = &unittest_params;
1480 ut_params->ctx.ops = &empty_ops;
1482 int ret = rte_security_set_pkt_metadata(&ut_params->ctx,
1483 ut_params->sess, &m, ¶ms);
1484 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_set_pkt_metadata,
1485 ret, -ENOTSUP, "%d");
1486 TEST_ASSERT_MOCK_CALLS(mock_set_pkt_metadata_exp, 0);
1488 return TEST_SUCCESS;
1492 * Test execution of rte_security_set_pkt_metadata with NULL sess parameter
1495 test_set_pkt_metadata_inv_session(void)
1498 struct security_unittest_params *ut_params = &unittest_params;
1502 int ret = rte_security_set_pkt_metadata(&ut_params->ctx, NULL,
1504 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_set_pkt_metadata,
1505 ret, -EINVAL, "%d");
1506 TEST_ASSERT_MOCK_CALLS(mock_set_pkt_metadata_exp, 0);
1508 return TEST_SUCCESS;
1510 return TEST_SKIPPED;
1515 * Test execution of rte_security_set_pkt_metadata when set_pkt_metadata
1516 * security operation fails
1519 test_set_pkt_metadata_ops_failure(void)
1521 struct security_unittest_params *ut_params = &unittest_params;
1525 mock_set_pkt_metadata_exp.device = NULL;
1526 mock_set_pkt_metadata_exp.sess = ut_params->sess;
1527 mock_set_pkt_metadata_exp.m = &m;
1528 mock_set_pkt_metadata_exp.params = ¶ms;
1529 mock_set_pkt_metadata_exp.ret = -1;
1531 int ret = rte_security_set_pkt_metadata(&ut_params->ctx,
1532 ut_params->sess, &m, ¶ms);
1533 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_set_pkt_metadata,
1535 TEST_ASSERT_MOCK_CALLS(mock_set_pkt_metadata_exp, 1);
1537 return TEST_SUCCESS;
1541 * Test execution of rte_security_set_pkt_metadata in successful execution path
1544 test_set_pkt_metadata_success(void)
1546 struct security_unittest_params *ut_params = &unittest_params;
1550 mock_set_pkt_metadata_exp.device = NULL;
1551 mock_set_pkt_metadata_exp.sess = ut_params->sess;
1552 mock_set_pkt_metadata_exp.m = &m;
1553 mock_set_pkt_metadata_exp.params = ¶ms;
1554 mock_set_pkt_metadata_exp.ret = 0;
1556 int ret = rte_security_set_pkt_metadata(&ut_params->ctx,
1557 ut_params->sess, &m, ¶ms);
1558 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_set_pkt_metadata,
1560 TEST_ASSERT_MOCK_CALLS(mock_set_pkt_metadata_exp, 1);
1562 return TEST_SUCCESS;
1567 * rte_security_get_userdata tests
1571 * Test execution of rte_security_get_userdata with NULL instance
1574 test_get_userdata_inv_context(void)
1577 uint64_t md = 0xDEADBEEF;
1579 void *ret = rte_security_get_userdata(NULL, md);
1580 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_get_userdata,
1582 TEST_ASSERT_MOCK_CALLS(mock_get_userdata_exp, 0);
1584 return TEST_SUCCESS;
1586 return TEST_SKIPPED;
1591 * Test execution of rte_security_get_userdata with invalid
1592 * security operations structure (NULL)
1595 test_get_userdata_inv_context_ops(void)
1598 struct security_unittest_params *ut_params = &unittest_params;
1599 uint64_t md = 0xDEADBEEF;
1600 ut_params->ctx.ops = NULL;
1602 void *ret = rte_security_get_userdata(&ut_params->ctx, md);
1603 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_get_userdata,
1605 TEST_ASSERT_MOCK_CALLS(mock_get_userdata_exp, 0);
1607 return TEST_SUCCESS;
1609 return TEST_SKIPPED;
1614 * Test execution of rte_security_get_userdata with empty
1615 * security operations
1618 test_get_userdata_inv_context_ops_fun(void)
1620 struct security_unittest_params *ut_params = &unittest_params;
1621 uint64_t md = 0xDEADBEEF;
1622 ut_params->ctx.ops = &empty_ops;
1624 void *ret = rte_security_get_userdata(&ut_params->ctx, md);
1625 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_get_userdata,
1627 TEST_ASSERT_MOCK_CALLS(mock_get_userdata_exp, 0);
1629 return TEST_SUCCESS;
1633 * Test execution of rte_security_get_userdata when get_userdata
1634 * security operation fails
1637 test_get_userdata_ops_failure(void)
1639 struct security_unittest_params *ut_params = &unittest_params;
1640 uint64_t md = 0xDEADBEEF;
1641 void *userdata = (void *)0x7E577E57;
1643 mock_get_userdata_exp.device = NULL;
1644 mock_get_userdata_exp.md = md;
1645 mock_get_userdata_exp.userdata = userdata;
1646 mock_get_userdata_exp.ret = -1;
1648 void *ret = rte_security_get_userdata(&ut_params->ctx, md);
1649 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_get_userdata,
1651 TEST_ASSERT_MOCK_CALLS(mock_get_userdata_exp, 1);
1653 return TEST_SUCCESS;
1657 * Test execution of rte_security_get_userdata in successful execution path
1660 test_get_userdata_success(void)
1662 struct security_unittest_params *ut_params = &unittest_params;
1663 uint64_t md = 0xDEADBEEF;
1664 void *userdata = (void *)0x7E577E57;
1666 mock_get_userdata_exp.device = NULL;
1667 mock_get_userdata_exp.md = md;
1668 mock_get_userdata_exp.userdata = userdata;
1669 mock_get_userdata_exp.ret = 0;
1671 void *ret = rte_security_get_userdata(&ut_params->ctx, md);
1672 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_get_userdata,
1673 ret, userdata, "%p");
1674 TEST_ASSERT_MOCK_CALLS(mock_get_userdata_exp, 1);
1676 return TEST_SUCCESS;
1681 * rte_security_capabilities_get tests
1685 * Test execution of rte_security_capabilities_get with NULL instance
1688 test_capabilities_get_inv_context(void)
1690 const struct rte_security_capability *ret;
1691 ret = rte_security_capabilities_get(NULL);
1692 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capabilities_get,
1694 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 0);
1696 return TEST_SUCCESS;
1700 * Test execution of rte_security_capabilities_get with invalid
1701 * security operations structure (NULL)
1704 test_capabilities_get_inv_context_ops(void)
1706 struct security_unittest_params *ut_params = &unittest_params;
1707 ut_params->ctx.ops = NULL;
1709 const struct rte_security_capability *ret;
1710 ret = rte_security_capabilities_get(&ut_params->ctx);
1711 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capabilities_get,
1713 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 0);
1715 return TEST_SUCCESS;
1719 * Test execution of rte_security_capabilities_get with empty
1720 * security operations
1723 test_capabilities_get_inv_context_ops_fun(void)
1725 struct security_unittest_params *ut_params = &unittest_params;
1726 ut_params->ctx.ops = &empty_ops;
1728 const struct rte_security_capability *ret;
1729 ret = rte_security_capabilities_get(&ut_params->ctx);
1730 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capabilities_get,
1732 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 0);
1734 return TEST_SUCCESS;
1738 * Test execution of rte_security_capabilities_get when capabilities_get
1739 * security operation fails
1742 test_capabilities_get_ops_failure(void)
1744 struct security_unittest_params *ut_params = &unittest_params;
1746 mock_capabilities_get_exp.device = NULL;
1747 mock_capabilities_get_exp.ret = NULL;
1749 const struct rte_security_capability *ret;
1750 ret = rte_security_capabilities_get(&ut_params->ctx);
1751 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capabilities_get,
1753 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 1);
1755 return TEST_SUCCESS;
1759 * Test execution of rte_security_capabilities_get in successful execution path
1762 test_capabilities_get_success(void)
1764 struct security_unittest_params *ut_params = &unittest_params;
1765 struct rte_security_capability capabilities;
1767 mock_capabilities_get_exp.device = NULL;
1768 mock_capabilities_get_exp.ret = &capabilities;
1770 const struct rte_security_capability *ret;
1771 ret = rte_security_capabilities_get(&ut_params->ctx);
1772 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capabilities_get,
1773 ret, &capabilities, "%p");
1774 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 1);
1776 return TEST_SUCCESS;
1781 * rte_security_capability_get tests
1785 * Test execution of rte_security_capability_get with NULL instance
1788 test_capability_get_inv_context(void)
1790 struct rte_security_capability_idx idx;
1792 const struct rte_security_capability *ret;
1793 ret = rte_security_capability_get(NULL, &idx);
1794 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capability_get,
1796 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 0);
1798 return TEST_SUCCESS;
1802 * Test execution of rte_security_capability_get with invalid
1803 * security operations structure (NULL)
1806 test_capability_get_inv_context_ops(void)
1808 struct security_unittest_params *ut_params = &unittest_params;
1809 struct rte_security_capability_idx idx;
1810 ut_params->ctx.ops = NULL;
1812 const struct rte_security_capability *ret;
1813 ret = rte_security_capability_get(&ut_params->ctx, &idx);
1814 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capability_get,
1816 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 0);
1818 return TEST_SUCCESS;
1822 * Test execution of rte_security_capability_get with empty
1823 * security operations
1826 test_capability_get_inv_context_ops_fun(void)
1828 struct security_unittest_params *ut_params = &unittest_params;
1829 struct rte_security_capability_idx idx;
1830 ut_params->ctx.ops = &empty_ops;
1832 const struct rte_security_capability *ret;
1833 ret = rte_security_capability_get(&ut_params->ctx, &idx);
1834 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capability_get,
1836 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 0);
1838 return TEST_SUCCESS;
1842 * Test execution of rte_security_capability_get with NULL idx parameter
1845 test_capability_get_inv_idx(void)
1847 struct security_unittest_params *ut_params = &unittest_params;
1849 const struct rte_security_capability *ret;
1850 ret = rte_security_capability_get(&ut_params->ctx, NULL);
1851 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capability_get,
1853 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 0);
1855 return TEST_SUCCESS;
1859 * Test execution of rte_security_capability_get when capabilities_get
1860 * security operation fails
1863 test_capability_get_ops_failure(void)
1865 struct security_unittest_params *ut_params = &unittest_params;
1866 struct rte_security_capability_idx idx;
1868 mock_capabilities_get_exp.device = NULL;
1869 mock_capabilities_get_exp.ret = NULL;
1871 const struct rte_security_capability *ret;
1872 ret = rte_security_capability_get(&ut_params->ctx, &idx);
1873 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capability_get,
1875 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 1);
1877 return TEST_SUCCESS;
1881 * Test execution of rte_security_capability_get when capabilities table
1882 * is empty (contains only RTE_SECURITY_ACTION_TYPE_NONE ending entry)
1885 test_capability_get_empty_table(void)
1887 struct security_unittest_params *ut_params = &unittest_params;
1888 struct rte_security_capability_idx idx;
1889 struct rte_security_capability capabilities[] = {
1891 .action = RTE_SECURITY_ACTION_TYPE_NONE,
1895 mock_capabilities_get_exp.device = NULL;
1896 mock_capabilities_get_exp.ret = capabilities;
1898 const struct rte_security_capability *ret;
1899 ret = rte_security_capability_get(&ut_params->ctx, &idx);
1900 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capability_get,
1902 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 1);
1904 return TEST_SUCCESS;
1908 * Test execution of rte_security_capability_get when capabilities table
1909 * does not contain entry with matching action
1912 test_capability_get_no_matching_action(void)
1914 struct security_unittest_params *ut_params = &unittest_params;
1915 struct rte_security_capability_idx idx = {
1916 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
1918 struct rte_security_capability capabilities[] = {
1920 .action = RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO,
1923 .action = RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL,
1926 .action = RTE_SECURITY_ACTION_TYPE_NONE,
1930 mock_capabilities_get_exp.device = NULL;
1931 mock_capabilities_get_exp.ret = capabilities;
1933 const struct rte_security_capability *ret;
1934 ret = rte_security_capability_get(&ut_params->ctx, &idx);
1935 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capability_get,
1937 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 1);
1939 return TEST_SUCCESS;
1943 * Test execution of rte_security_capability_get when capabilities table
1944 * does not contain entry with matching protocol
1947 test_capability_get_no_matching_protocol(void)
1949 struct security_unittest_params *ut_params = &unittest_params;
1950 struct rte_security_capability_idx idx = {
1951 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
1952 .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
1954 struct rte_security_capability capabilities[] = {
1956 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
1957 .protocol = RTE_SECURITY_PROTOCOL_MACSEC,
1960 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
1961 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
1964 .action = RTE_SECURITY_ACTION_TYPE_NONE,
1968 mock_capabilities_get_exp.device = NULL;
1969 mock_capabilities_get_exp.ret = capabilities;
1971 const struct rte_security_capability *ret;
1972 ret = rte_security_capability_get(&ut_params->ctx, &idx);
1973 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capability_get,
1975 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 1);
1977 return TEST_SUCCESS;
1981 * Test execution of rte_security_capability_get when macsec protocol
1982 * is searched and capabilities table contain proper entry.
1983 * However macsec records search is not supported in rte_security.
1986 test_capability_get_no_support_for_macsec(void)
1988 struct security_unittest_params *ut_params = &unittest_params;
1989 struct rte_security_capability_idx idx = {
1990 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
1991 .protocol = RTE_SECURITY_PROTOCOL_MACSEC,
1993 struct rte_security_capability capabilities[] = {
1995 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
1996 .protocol = RTE_SECURITY_PROTOCOL_MACSEC,
1999 .action = RTE_SECURITY_ACTION_TYPE_NONE,
2003 mock_capabilities_get_exp.device = NULL;
2004 mock_capabilities_get_exp.ret = capabilities;
2006 const struct rte_security_capability *ret;
2007 ret = rte_security_capability_get(&ut_params->ctx, &idx);
2008 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capability_get,
2010 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 1);
2012 return TEST_SUCCESS;
2016 * Test execution of rte_security_capability_get when capabilities table
2017 * does not contain entry with matching ipsec proto field
2020 test_capability_get_ipsec_mismatch_proto(void)
2022 struct security_unittest_params *ut_params = &unittest_params;
2023 struct rte_security_capability_idx idx = {
2024 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
2025 .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
2027 .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP,
2030 struct rte_security_capability capabilities[] = {
2032 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
2033 .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
2035 .proto = RTE_SECURITY_IPSEC_SA_PROTO_AH,
2039 .action = RTE_SECURITY_ACTION_TYPE_NONE,
2043 mock_capabilities_get_exp.device = NULL;
2044 mock_capabilities_get_exp.ret = capabilities;
2046 const struct rte_security_capability *ret;
2047 ret = rte_security_capability_get(&ut_params->ctx, &idx);
2048 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capability_get,
2050 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 1);
2052 return TEST_SUCCESS;
2056 * Test execution of rte_security_capability_get when capabilities table
2057 * does not contain entry with matching ipsec mode field
2060 test_capability_get_ipsec_mismatch_mode(void)
2062 struct security_unittest_params *ut_params = &unittest_params;
2063 struct rte_security_capability_idx idx = {
2064 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
2065 .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
2067 .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP,
2068 .mode = RTE_SECURITY_IPSEC_SA_MODE_TRANSPORT,
2071 struct rte_security_capability capabilities[] = {
2073 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
2074 .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
2076 .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP,
2077 .mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL,
2081 .action = RTE_SECURITY_ACTION_TYPE_NONE,
2085 mock_capabilities_get_exp.device = NULL;
2086 mock_capabilities_get_exp.ret = capabilities;
2088 const struct rte_security_capability *ret;
2089 ret = rte_security_capability_get(&ut_params->ctx, &idx);
2090 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capability_get,
2092 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 1);
2094 return TEST_SUCCESS;
2098 * Test execution of rte_security_capability_get when capabilities table
2099 * does not contain entry with matching ipsec direction field
2102 test_capability_get_ipsec_mismatch_dir(void)
2104 struct security_unittest_params *ut_params = &unittest_params;
2105 struct rte_security_capability_idx idx = {
2106 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
2107 .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
2109 .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP,
2110 .mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL,
2111 .direction = RTE_SECURITY_IPSEC_SA_DIR_EGRESS,
2114 struct rte_security_capability capabilities[] = {
2116 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
2117 .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
2119 .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP,
2120 .mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL,
2121 .direction = RTE_SECURITY_IPSEC_SA_DIR_INGRESS,
2125 .action = RTE_SECURITY_ACTION_TYPE_NONE,
2129 mock_capabilities_get_exp.device = NULL;
2130 mock_capabilities_get_exp.ret = capabilities;
2132 const struct rte_security_capability *ret;
2133 ret = rte_security_capability_get(&ut_params->ctx, &idx);
2134 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capability_get,
2136 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 1);
2138 return TEST_SUCCESS;
2142 * Test execution of rte_security_capability_get when capabilities table
2143 * contains matching ipsec entry
2146 test_capability_get_ipsec_match(void)
2148 struct security_unittest_params *ut_params = &unittest_params;
2149 struct rte_security_capability_idx idx = {
2150 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
2151 .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
2153 .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP,
2154 .mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL,
2155 .direction = RTE_SECURITY_IPSEC_SA_DIR_INGRESS,
2158 struct rte_security_capability capabilities[] = {
2160 .action = RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO,
2163 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
2164 .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
2166 .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP,
2167 .mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL,
2168 .direction = RTE_SECURITY_IPSEC_SA_DIR_INGRESS,
2172 .action = RTE_SECURITY_ACTION_TYPE_NONE,
2176 mock_capabilities_get_exp.device = NULL;
2177 mock_capabilities_get_exp.ret = capabilities;
2179 const struct rte_security_capability *ret;
2180 ret = rte_security_capability_get(&ut_params->ctx, &idx);
2181 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capability_get,
2182 ret, &capabilities[1], "%p");
2183 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 1);
2185 return TEST_SUCCESS;
2189 * Test execution of rte_security_capability_get when capabilities table
2190 * does not contain entry with matching pdcp domain field
2193 test_capability_get_pdcp_mismatch_domain(void)
2195 struct security_unittest_params *ut_params = &unittest_params;
2196 struct rte_security_capability_idx idx = {
2197 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
2198 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
2200 .domain = RTE_SECURITY_PDCP_MODE_CONTROL,
2203 struct rte_security_capability capabilities[] = {
2205 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
2206 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
2208 .domain = RTE_SECURITY_PDCP_MODE_DATA,
2212 .action = RTE_SECURITY_ACTION_TYPE_NONE,
2216 mock_capabilities_get_exp.device = NULL;
2217 mock_capabilities_get_exp.ret = capabilities;
2219 const struct rte_security_capability *ret;
2220 ret = rte_security_capability_get(&ut_params->ctx, &idx);
2221 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capability_get,
2223 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 1);
2225 return TEST_SUCCESS;
2229 * Test execution of rte_security_capability_get when capabilities table
2230 * contains matching pdcp entry
2233 test_capability_get_pdcp_match(void)
2235 struct security_unittest_params *ut_params = &unittest_params;
2236 struct rte_security_capability_idx idx = {
2237 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
2238 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
2240 .domain = RTE_SECURITY_PDCP_MODE_CONTROL,
2243 struct rte_security_capability capabilities[] = {
2245 .action = RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO,
2248 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
2249 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
2251 .domain = RTE_SECURITY_PDCP_MODE_CONTROL,
2255 .action = RTE_SECURITY_ACTION_TYPE_NONE,
2259 mock_capabilities_get_exp.device = NULL;
2260 mock_capabilities_get_exp.ret = capabilities;
2262 const struct rte_security_capability *ret;
2263 ret = rte_security_capability_get(&ut_params->ctx, &idx);
2264 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capability_get,
2265 ret, &capabilities[1], "%p");
2266 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 1);
2268 return TEST_SUCCESS;
2272 * Declaration of testcases
2274 static struct unit_test_suite security_testsuite = {
2275 .suite_name = "generic security",
2276 .setup = testsuite_setup,
2277 .teardown = testsuite_teardown,
2278 .unit_test_cases = {
2279 TEST_CASE_ST(ut_setup, ut_teardown,
2280 test_session_create_inv_context),
2281 TEST_CASE_ST(ut_setup, ut_teardown,
2282 test_session_create_inv_context_ops),
2283 TEST_CASE_ST(ut_setup, ut_teardown,
2284 test_session_create_inv_context_ops_fun),
2285 TEST_CASE_ST(ut_setup, ut_teardown,
2286 test_session_create_inv_configuration),
2287 TEST_CASE_ST(ut_setup, ut_teardown,
2288 test_session_create_inv_mempool),
2289 TEST_CASE_ST(ut_setup, ut_teardown,
2290 test_session_create_mempool_empty),
2291 TEST_CASE_ST(ut_setup, ut_teardown,
2292 test_session_create_ops_failure),
2293 TEST_CASE_ST(ut_setup, ut_teardown,
2294 test_session_create_success),
2296 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2297 test_session_update_inv_context),
2298 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2299 test_session_update_inv_context_ops),
2300 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2301 test_session_update_inv_context_ops_fun),
2302 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2303 test_session_update_inv_configuration),
2304 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2305 test_session_update_inv_session),
2306 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2307 test_session_update_ops_failure),
2308 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2309 test_session_update_success),
2311 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2312 test_session_get_size_inv_context),
2313 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2314 test_session_get_size_inv_context_ops),
2315 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2316 test_session_get_size_inv_context_ops_fun),
2317 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2318 test_session_get_size_ops_failure),
2319 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2320 test_session_get_size_success),
2322 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2323 test_session_stats_get_inv_context),
2324 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2325 test_session_stats_get_inv_context_ops),
2326 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2327 test_session_stats_get_inv_context_ops_fun),
2328 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2329 test_session_stats_get_inv_stats),
2330 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2331 test_session_stats_get_ops_failure),
2332 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2333 test_session_stats_get_success),
2335 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2336 test_session_destroy_inv_context),
2337 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2338 test_session_destroy_inv_context_ops),
2339 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2340 test_session_destroy_inv_context_ops_fun),
2341 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2342 test_session_destroy_inv_session),
2343 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2344 test_session_destroy_ops_failure),
2345 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2346 test_session_destroy_success),
2348 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2349 test_set_pkt_metadata_inv_context),
2350 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2351 test_set_pkt_metadata_inv_context_ops),
2352 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2353 test_set_pkt_metadata_inv_context_ops_fun),
2354 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2355 test_set_pkt_metadata_inv_session),
2356 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2357 test_set_pkt_metadata_ops_failure),
2358 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2359 test_set_pkt_metadata_success),
2361 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2362 test_get_userdata_inv_context),
2363 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2364 test_get_userdata_inv_context_ops),
2365 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2366 test_get_userdata_inv_context_ops_fun),
2367 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2368 test_get_userdata_ops_failure),
2369 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2370 test_get_userdata_success),
2372 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2373 test_capabilities_get_inv_context),
2374 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2375 test_capabilities_get_inv_context_ops),
2376 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2377 test_capabilities_get_inv_context_ops_fun),
2378 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2379 test_capabilities_get_ops_failure),
2380 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2381 test_capabilities_get_success),
2383 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2384 test_capability_get_inv_context),
2385 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2386 test_capability_get_inv_context_ops),
2387 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2388 test_capability_get_inv_context_ops_fun),
2389 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2390 test_capability_get_inv_idx),
2391 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2392 test_capability_get_ops_failure),
2393 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2394 test_capability_get_empty_table),
2395 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2396 test_capability_get_no_matching_action),
2397 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2398 test_capability_get_no_matching_protocol),
2399 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2400 test_capability_get_no_support_for_macsec),
2401 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2402 test_capability_get_ipsec_mismatch_proto),
2403 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2404 test_capability_get_ipsec_mismatch_mode),
2405 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2406 test_capability_get_ipsec_mismatch_dir),
2407 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2408 test_capability_get_ipsec_match),
2409 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2410 test_capability_get_pdcp_mismatch_domain),
2411 TEST_CASE_ST(ut_setup_with_session, ut_teardown,
2412 test_capability_get_pdcp_match),
2414 TEST_CASES_END() /**< NULL terminate unit test array */
2421 rte_log_set_global_level(RTE_LOG_DEBUG);
2422 rte_log_set_level(RTE_LOGTYPE_EAL, RTE_LOG_DEBUG);
2424 return unit_test_suite_runner(&security_testsuite);
2427 REGISTER_TEST_COMMAND(security_autotest, test_security);