1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved 3 */ 4 5 #include <rte_errno.h> 6 #include <rte_log.h> 7 #include <rte_memory.h> 8 #include <rte_mempool.h> 9 #include <rte_ether.h> 10 #include <rte_security.h> 11 #include <rte_security_driver.h> 12 13 /* Before including rte_test.h file you can define 14 * RTE_TEST_TRACE_FAILURE(_file, _line, _func) macro to better trace/debug test 15 * failures. Mostly useful in development phase. 16 */ 17 #ifndef RTE_TEST_TRACE_FAILURE 18 #define RTE_TEST_TRACE_FAILURE(_file, _line, _func) \ 19 RTE_LOG(DEBUG, EAL, "in %s:%d %s\n", _file, _line, _func) 20 #endif 21 22 #include <rte_test.h> 23 #include "test.h" 24 25 /** 26 * Security 27 * ======= 28 * 29 * Basic unit tests of the librte_security API. 30 * 31 * Structure of the file: 32 * - macros for making tests more readable; 33 * - mockup structures and functions for rte_security_ops; 34 * - test suite and test cases setup and teardown functions; 35 * - tests functions; 36 * - declaration of testcases. 37 */ 38 39 40 /** 41 * Macros 42 * 43 * Set of macros for making tests easier to read. 44 */ 45 46 /** 47 * Verify condition inside mocked up function. 48 * Mockup function cannot return a test error, so the failure 49 * of assertion increases counter and print logs. 50 * The counter can be verified later to check if test case should fail. 51 * 52 * @param fail_counter fail counter 53 * @param cond condition expected to be true 54 * @param msg printf style formatting string for custom message 55 */ 56 #define MOCK_TEST_ASSERT(fail_counter, cond, msg, ...) do { \ 57 if (!(cond)) { \ 58 fail_counter++; \ 59 RTE_LOG(DEBUG, EAL, "Test assert %s line %d failed: " \ 60 msg "\n", __func__, __LINE__, \ 61 ##__VA_ARGS__); \ 62 RTE_TEST_TRACE_FAILURE(__FILE__, __LINE__, __func__); \ 63 } \ 64 } while (0) 65 66 /** 67 * Verify equality condition inside mocked up function. 68 * Mockup function cannot return a test error, so the failure 69 * of assertion increases counter and print logs. 70 * The counter can be verified later to check if test case should fail. 71 * 72 * @param fail_counter fail counter 73 * @param a first value of comparison 74 * @param b second value of comparison 75 * @param msg printf style formatting string for custom message 76 */ 77 #define MOCK_TEST_ASSERT_EQUAL(fail_counter, a, b, msg, ...) \ 78 MOCK_TEST_ASSERT(fail_counter, (a) == (b), msg, ##__VA_ARGS__) 79 80 /** 81 * Verify not null condition inside mocked up function. 82 * Mockup function cannot return a test error, so the failure 83 * of assertion increases counter and print logs. 84 * The counter can be verified later to check if test case should fail. 85 * 86 * @param fail_counter fail counter 87 * @param val value expected not to be NULL 88 * @param msg printf style formatting string for custom message 89 */ 90 #define MOCK_TEST_ASSERT_NOT_NULL(fail_counter, val, msg, ...) \ 91 MOCK_TEST_ASSERT(fail_counter, (val) != NULL, msg, ##__VA_ARGS__) 92 93 94 /** 95 * Verify if parameter of the mocked up function matches expected value. 96 * The expected value is stored in data structure in the field matching 97 * parameter name. 98 * 99 * @param data structure with expected values 100 * @param parameter name of the parameter (both field and parameter name) 101 * @param spec printf style spec for parameter 102 */ 103 #define MOCK_TEST_ASSERT_PARAMETER(data, parameter, spec) \ 104 MOCK_TEST_ASSERT_EQUAL(data.failed, data.parameter, parameter, \ 105 "Expecting parameter %s to be " spec \ 106 " but it's " spec, RTE_STR(parameter), \ 107 data.parameter, parameter) 108 109 /** 110 * Wrap for MOCK_TEST_ASSERT_PARAMETER macro for pointer type parameters. 111 * 112 * @param data structure with expected values 113 * @param parameter name of the parameter (both field and parameter name) 114 */ 115 #define MOCK_TEST_ASSERT_POINTER_PARAMETER(data, parameter) \ 116 MOCK_TEST_ASSERT_PARAMETER(data, parameter, "%p") 117 118 /** 119 * Wrap for MOCK_TEST_ASSERT_PARAMETER macro for uint64_t type parameters. 120 * 121 * @param data structure with expected values 122 * @param parameter name of the parameter (both field and parameter name) 123 */ 124 #define MOCK_TEST_ASSERT_U64_PARAMETER(data, parameter) \ 125 MOCK_TEST_ASSERT_PARAMETER(data, parameter, "%" PRIu64) 126 127 /** 128 * Verify number of calls of the mocked up function 129 * and check if there were any fails during execution. 130 * The fails statistics inside mocked up functions are collected 131 * as "failed" field in mockup structures. 132 * 133 * @param mock_data structure with statistics (called, failed) 134 * @param exp_calls expected number of mockup function calls 135 */ 136 #define TEST_ASSERT_MOCK_CALLS(mock_data, exp_calls) do { \ 137 TEST_ASSERT_EQUAL(exp_calls, mock_data.called, \ 138 "Expecting sub op to be called %d times, " \ 139 "but it's called %d times", \ 140 exp_calls, mock_data.called); \ 141 TEST_ASSERT_EQUAL(0, mock_data.failed, \ 142 "Expecting sub op asserts not to fail, " \ 143 "but they're failed %d times", \ 144 mock_data.failed); \ 145 } while (0) 146 147 /** 148 * Assert tested function result match expected value 149 * 150 * @param f_name name of tested function 151 * @param f_ret value returned by the function 152 * @param exp_ret expected returned value 153 * @param fmt printf style format for returned value 154 */ 155 #define TEST_ASSERT_MOCK_FUNCTION_CALL_RET(f_name, f_ret, exp_ret, fmt) \ 156 TEST_ASSERT_EQUAL(exp_ret, f_ret, "Expecting " RTE_STR(f_name) \ 157 " to return " fmt ", but it returned " fmt \ 158 "\n", exp_ret, f_ret) 159 160 /** 161 * Assert tested function result is not NULL 162 * 163 * @param f_name name of tested function 164 * @param f_ret value returned by the function 165 */ 166 #define TEST_ASSERT_MOCK_FUNCTION_CALL_NOT_NULL(f_name, f_ret) \ 167 TEST_ASSERT_NOT_NULL(f_ret, "Expecting " RTE_STR(f_name) \ 168 " to return not NULL\n") 169 170 /** 171 * Verify that sess_cnt counter value matches expected 172 * 173 * @param expected_sessions_count expected counter value 174 */ 175 #define TEST_ASSERT_SESSION_COUNT(expected_sessions_count) do { \ 176 struct security_unittest_params *ut_params = &unittest_params; \ 177 TEST_ASSERT_EQUAL(expected_sessions_count, \ 178 ut_params->ctx.sess_cnt, \ 179 "Expecting session counter to be %u," \ 180 " but it's %u", expected_sessions_count, \ 181 ut_params->ctx.sess_cnt); \ 182 } while (0) 183 184 /** 185 * Verify usage of mempool by checking if number of allocated objects matches 186 * expectations. The mempool is used to manage objects for sessions data. 187 * A single object is acquired from mempool during session_create 188 * and put back in session_destroy. 189 * 190 * @param expected_mempool_usage expected number of used mempool objects 191 */ 192 #define TEST_ASSERT_MEMPOOL_USAGE(expected_mempool_usage) do { \ 193 struct security_testsuite_params *ts_params = &testsuite_params;\ 194 unsigned int mempool_usage; \ 195 mempool_usage = rte_mempool_in_use_count( \ 196 ts_params->session_mpool); \ 197 TEST_ASSERT_EQUAL(expected_mempool_usage, mempool_usage, \ 198 "Expecting %u mempool allocations, " \ 199 "but there are %u allocated objects", \ 200 expected_mempool_usage, mempool_usage); \ 201 } while (0) 202 203 /** 204 * Verify usage of mempool by checking if number of allocated objects matches 205 * expectations. The mempool is used to manage objects for sessions priv data. 206 * A single object is acquired from mempool during session_create 207 * and put back in session_destroy. 208 * 209 * @param expected_priv_mp_usage expected number of used priv mp objects 210 */ 211 #define TEST_ASSERT_PRIV_MP_USAGE(expected_priv_mp_usage) do { \ 212 struct security_testsuite_params *ts_params = &testsuite_params;\ 213 unsigned int priv_mp_usage; \ 214 priv_mp_usage = rte_mempool_in_use_count( \ 215 ts_params->session_priv_mpool); \ 216 TEST_ASSERT_EQUAL(expected_priv_mp_usage, priv_mp_usage, \ 217 "Expecting %u priv mempool allocations, " \ 218 "but there are %u allocated objects", \ 219 expected_priv_mp_usage, priv_mp_usage); \ 220 } while (0) 221 222 /** 223 * Mockup structures and functions for rte_security_ops; 224 * 225 * Set of structures for controlling mockup functions calls. 226 * Every mockup function X has its corresponding X_data structure 227 * and an instance of that structure X_exp. 228 * Structure contains parameters that a mockup function is expected 229 * to be called with, a value to return (.ret) and 2 statistics: 230 * .called (number of times the mockup function was called) 231 * and .failed (number of assertion fails during mockup function call). 232 * 233 * Mockup functions verify that the parameters they are called with match 234 * expected values. The expected values should be stored in corresponding 235 * structures prior to mockup functions call. Every failure of such 236 * verification increases .failed counter. Every call of mockup function 237 * increases .called counter. Function returns value stored in .ret field 238 * of the structure. 239 * In case of some parameters in some functions the expected value is unknown 240 * and cannot be determined prior to call. Such parameters are stored 241 * in structure and can be compared or analyzed later in test case code. 242 * 243 * Below structures and functions follow the rules just described. 244 * Additional remarks and exceptions are added in comments. 245 */ 246 247 /** 248 * session_create mockup 249 * 250 * Verified parameters: device, conf, mp. 251 * Saved, not verified parameters: sess. 252 */ 253 static struct mock_session_create_data { 254 void *device; 255 struct rte_security_session_conf *conf; 256 struct rte_security_session *sess; 257 struct rte_mempool *mp; 258 struct rte_mempool *priv_mp; 259 260 int ret; 261 262 int called; 263 int failed; 264 } mock_session_create_exp = {NULL, NULL, NULL, NULL, NULL, 0, 0, 0}; 265 266 static int 267 mock_session_create(void *device, 268 struct rte_security_session_conf *conf, 269 struct rte_security_session *sess, 270 struct rte_mempool *priv_mp) 271 { 272 void *sess_priv; 273 int ret; 274 275 mock_session_create_exp.called++; 276 277 MOCK_TEST_ASSERT_POINTER_PARAMETER(mock_session_create_exp, device); 278 MOCK_TEST_ASSERT_POINTER_PARAMETER(mock_session_create_exp, conf); 279 MOCK_TEST_ASSERT_POINTER_PARAMETER(mock_session_create_exp, priv_mp); 280 281 if (mock_session_create_exp.ret == 0) { 282 ret = rte_mempool_get(priv_mp, &sess_priv); 283 TEST_ASSERT_EQUAL(0, ret, 284 "priv mempool does not have enough objects"); 285 286 set_sec_session_private_data(sess, sess_priv); 287 mock_session_create_exp.sess = sess; 288 } 289 290 return mock_session_create_exp.ret; 291 } 292 293 /** 294 * session_update mockup 295 * 296 * Verified parameters: device, sess, conf. 297 */ 298 static struct mock_session_update_data { 299 void *device; 300 struct rte_security_session *sess; 301 struct rte_security_session_conf *conf; 302 303 int ret; 304 305 int called; 306 int failed; 307 } mock_session_update_exp = {NULL, NULL, NULL, 0, 0, 0}; 308 309 static int 310 mock_session_update(void *device, 311 struct rte_security_session *sess, 312 struct rte_security_session_conf *conf) 313 { 314 mock_session_update_exp.called++; 315 316 MOCK_TEST_ASSERT_POINTER_PARAMETER(mock_session_update_exp, device); 317 MOCK_TEST_ASSERT_POINTER_PARAMETER(mock_session_update_exp, sess); 318 MOCK_TEST_ASSERT_POINTER_PARAMETER(mock_session_update_exp, conf); 319 320 return mock_session_update_exp.ret; 321 } 322 323 /** 324 * session_get_size mockup 325 * 326 * Verified parameters: device. 327 */ 328 static struct mock_session_get_size_data { 329 void *device; 330 331 unsigned int ret; 332 333 int called; 334 int failed; 335 } mock_session_get_size_exp = {NULL, 0U, 0, 0}; 336 337 static unsigned int 338 mock_session_get_size(void *device) 339 { 340 mock_session_get_size_exp.called++; 341 342 MOCK_TEST_ASSERT_POINTER_PARAMETER(mock_session_get_size_exp, device); 343 344 return mock_session_get_size_exp.ret; 345 } 346 347 /** 348 * session_stats_get mockup 349 * 350 * Verified parameters: device, sess, stats. 351 */ 352 static struct mock_session_stats_get_data { 353 void *device; 354 struct rte_security_session *sess; 355 struct rte_security_stats *stats; 356 357 int ret; 358 359 int called; 360 int failed; 361 } mock_session_stats_get_exp = {NULL, NULL, NULL, 0, 0, 0}; 362 363 static int 364 mock_session_stats_get(void *device, 365 struct rte_security_session *sess, 366 struct rte_security_stats *stats) 367 { 368 mock_session_stats_get_exp.called++; 369 370 MOCK_TEST_ASSERT_POINTER_PARAMETER(mock_session_stats_get_exp, device); 371 MOCK_TEST_ASSERT_POINTER_PARAMETER(mock_session_stats_get_exp, sess); 372 MOCK_TEST_ASSERT_POINTER_PARAMETER(mock_session_stats_get_exp, stats); 373 374 return mock_session_stats_get_exp.ret; 375 } 376 377 /** 378 * session_destroy mockup 379 * 380 * Verified parameters: device, sess. 381 */ 382 static struct mock_session_destroy_data { 383 void *device; 384 struct rte_security_session *sess; 385 386 int ret; 387 388 int called; 389 int failed; 390 } mock_session_destroy_exp = {NULL, NULL, 0, 0, 0}; 391 392 static int 393 mock_session_destroy(void *device, struct rte_security_session *sess) 394 { 395 void *sess_priv = get_sec_session_private_data(sess); 396 397 mock_session_destroy_exp.called++; 398 if ((mock_session_destroy_exp.ret == 0) && (sess_priv != NULL)) { 399 rte_mempool_put(rte_mempool_from_obj(sess_priv), sess_priv); 400 set_sec_session_private_data(sess, NULL); 401 } 402 MOCK_TEST_ASSERT_POINTER_PARAMETER(mock_session_destroy_exp, device); 403 MOCK_TEST_ASSERT_POINTER_PARAMETER(mock_session_destroy_exp, sess); 404 405 return mock_session_destroy_exp.ret; 406 } 407 408 /** 409 * set_pkt_metadata mockup 410 * 411 * Verified parameters: device, sess, m, params. 412 */ 413 static struct mock_set_pkt_metadata_data { 414 void *device; 415 struct rte_security_session *sess; 416 struct rte_mbuf *m; 417 void *params; 418 419 int ret; 420 421 int called; 422 int failed; 423 } mock_set_pkt_metadata_exp = {NULL, NULL, NULL, NULL, 0, 0, 0}; 424 425 static int 426 mock_set_pkt_metadata(void *device, 427 struct rte_security_session *sess, 428 struct rte_mbuf *m, 429 void *params) 430 { 431 mock_set_pkt_metadata_exp.called++; 432 433 MOCK_TEST_ASSERT_POINTER_PARAMETER(mock_set_pkt_metadata_exp, device); 434 MOCK_TEST_ASSERT_POINTER_PARAMETER(mock_set_pkt_metadata_exp, sess); 435 MOCK_TEST_ASSERT_POINTER_PARAMETER(mock_set_pkt_metadata_exp, m); 436 MOCK_TEST_ASSERT_POINTER_PARAMETER(mock_set_pkt_metadata_exp, params); 437 438 return mock_set_pkt_metadata_exp.ret; 439 } 440 441 /** 442 * capabilities_get mockup 443 * 444 * Verified parameters: device. 445 */ 446 static struct mock_capabilities_get_data { 447 void *device; 448 449 struct rte_security_capability *ret; 450 451 int called; 452 int failed; 453 } mock_capabilities_get_exp = {NULL, NULL, 0, 0}; 454 455 static const struct rte_security_capability * 456 mock_capabilities_get(void *device) 457 { 458 mock_capabilities_get_exp.called++; 459 460 MOCK_TEST_ASSERT_POINTER_PARAMETER(mock_capabilities_get_exp, device); 461 462 return mock_capabilities_get_exp.ret; 463 } 464 465 /** 466 * empty_ops 467 * 468 * is an empty security operations set (all function pointers set to NULL) 469 */ 470 struct rte_security_ops empty_ops = { NULL }; 471 472 /** 473 * mock_ops 474 * 475 * is a security operations set using mockup functions 476 */ 477 struct rte_security_ops mock_ops = { 478 .session_create = mock_session_create, 479 .session_update = mock_session_update, 480 .session_get_size = mock_session_get_size, 481 .session_stats_get = mock_session_stats_get, 482 .session_destroy = mock_session_destroy, 483 .set_pkt_metadata = mock_set_pkt_metadata, 484 .capabilities_get = mock_capabilities_get, 485 }; 486 487 488 /** 489 * Test suite and test cases setup and teardown functions. 490 */ 491 492 /** 493 * struct security_testsuite_params defines parameters initialized once 494 * for whole tests suite. 495 * Currently the only stored parameter is session_mpool a mempool created 496 * once in testsuite_setup and released in testsuite_teardown. 497 * The instance of this structure is stored in testsuite_params variable. 498 */ 499 static struct security_testsuite_params { 500 struct rte_mempool *session_mpool; 501 struct rte_mempool *session_priv_mpool; 502 } testsuite_params = { NULL }; 503 504 /** 505 * struct security_unittest_params defines parameters initialized 506 * for every test case. The parameters are initialized in ut_setup 507 * or ut_setup_with_session (depending on the testcase) 508 * and released in ut_teardown. 509 * The instance of this structure is stored in unittest_params variable. 510 */ 511 static struct security_unittest_params { 512 struct rte_security_ctx ctx; 513 struct rte_security_session_conf conf; 514 struct rte_security_session *sess; 515 } unittest_params = { 516 .ctx = { 517 .device = NULL, 518 .ops = &mock_ops, 519 .sess_cnt = 0, 520 }, 521 .sess = NULL, 522 }; 523 524 #define SECURITY_TEST_MEMPOOL_NAME "SecurityTestMp" 525 #define SECURITY_TEST_PRIV_MEMPOOL_NAME "SecurityTestPrivMp" 526 #define SECURITY_TEST_MEMPOOL_SIZE 15 527 #define SECURITY_TEST_SESSION_OBJ_SZ sizeof(struct rte_security_session) 528 #define SECURITY_TEST_SESSION_PRIV_OBJ_SZ 64 529 530 /** 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. 534 */ 535 static int 536 testsuite_setup(void) 537 { 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_OBJ_SZ, 543 0, 0, NULL, NULL, NULL, NULL, 544 SOCKET_ID_ANY, 0); 545 TEST_ASSERT_NOT_NULL(ts_params->session_mpool, 546 "Cannot create mempool %s\n", rte_strerror(rte_errno)); 547 548 ts_params->session_priv_mpool = rte_mempool_create( 549 SECURITY_TEST_PRIV_MEMPOOL_NAME, 550 SECURITY_TEST_MEMPOOL_SIZE, 551 SECURITY_TEST_SESSION_PRIV_OBJ_SZ, 552 0, 0, NULL, NULL, NULL, NULL, 553 SOCKET_ID_ANY, 0); 554 if (ts_params->session_priv_mpool == NULL) { 555 RTE_LOG(ERR, USER1, "TestCase %s() line %d failed (null): " 556 "Cannot create priv mempool %s\n", 557 __func__, __LINE__, rte_strerror(rte_errno)); 558 rte_mempool_free(ts_params->session_mpool); 559 ts_params->session_mpool = NULL; 560 return TEST_FAILED; 561 } 562 563 return TEST_SUCCESS; 564 } 565 566 /** 567 * testsuite_teardown releases test suite wide parameters. 568 */ 569 static void 570 testsuite_teardown(void) 571 { 572 struct security_testsuite_params *ts_params = &testsuite_params; 573 if (ts_params->session_mpool) { 574 rte_mempool_free(ts_params->session_mpool); 575 ts_params->session_mpool = NULL; 576 } 577 if (ts_params->session_priv_mpool) { 578 rte_mempool_free(ts_params->session_priv_mpool); 579 ts_params->session_priv_mpool = NULL; 580 } 581 } 582 583 /** 584 * ut_setup initializes test case parameters to default values. 585 * It resets also any .called and .failed statistics of mockup functions 586 * usage. 587 */ 588 static int 589 ut_setup(void) 590 { 591 struct security_unittest_params *ut_params = &unittest_params; 592 ut_params->ctx.device = NULL; 593 ut_params->ctx.ops = &mock_ops; 594 ut_params->ctx.sess_cnt = 0; 595 ut_params->sess = NULL; 596 597 mock_session_create_exp.called = 0; 598 mock_session_update_exp.called = 0; 599 mock_session_get_size_exp.called = 0; 600 mock_session_stats_get_exp.called = 0; 601 mock_session_destroy_exp.called = 0; 602 mock_set_pkt_metadata_exp.called = 0; 603 mock_capabilities_get_exp.called = 0; 604 605 mock_session_create_exp.failed = 0; 606 mock_session_update_exp.failed = 0; 607 mock_session_get_size_exp.failed = 0; 608 mock_session_stats_get_exp.failed = 0; 609 mock_session_destroy_exp.failed = 0; 610 mock_set_pkt_metadata_exp.failed = 0; 611 mock_capabilities_get_exp.failed = 0; 612 613 return TEST_SUCCESS; 614 } 615 616 /** 617 * destroy_session_with_check is a helper function releasing session 618 * created with rte_security_session_create and stored in test case parameters. 619 * It's used both to release sessions created in test cases' bodies 620 * which are assigned to ut_params->sess 621 * as well as sessions created in ut_setup_with_session. 622 */ 623 static int 624 destroy_session_with_check(void) 625 { 626 struct security_unittest_params *ut_params = &unittest_params; 627 if (ut_params->sess != NULL) { 628 /* Assure that mockup function for destroy operation is set. */ 629 ut_params->ctx.ops = &mock_ops; 630 631 mock_session_destroy_exp.device = NULL; 632 mock_session_destroy_exp.sess = ut_params->sess; 633 mock_session_destroy_exp.ret = 0; 634 mock_session_destroy_exp.called = 0; 635 mock_session_destroy_exp.failed = 0; 636 637 int ret = rte_security_session_destroy(&ut_params->ctx, 638 ut_params->sess); 639 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_destroy, 640 ret, 0, "%d"); 641 TEST_ASSERT_MOCK_CALLS(mock_session_destroy_exp, 1); 642 643 ut_params->sess = NULL; 644 } 645 return TEST_SUCCESS; 646 } 647 648 /** 649 * ut_teardown releases test case parameters. 650 */ 651 static void 652 ut_teardown(void) 653 { 654 destroy_session_with_check(); 655 } 656 657 /** 658 * ut_setup_with_session initializes test case parameters by 659 * - calling standard ut_setup, 660 * - creating a session that can be used in test case. 661 */ 662 static int 663 ut_setup_with_session(void) 664 { 665 struct security_unittest_params *ut_params = &unittest_params; 666 struct security_testsuite_params *ts_params = &testsuite_params; 667 struct rte_security_session *sess; 668 669 int ret = ut_setup(); 670 if (ret != TEST_SUCCESS) 671 return ret; 672 673 mock_session_create_exp.device = NULL; 674 mock_session_create_exp.conf = &ut_params->conf; 675 mock_session_create_exp.mp = ts_params->session_mpool; 676 mock_session_create_exp.priv_mp = ts_params->session_priv_mpool; 677 mock_session_create_exp.ret = 0; 678 679 sess = rte_security_session_create(&ut_params->ctx, &ut_params->conf, 680 ts_params->session_mpool, 681 ts_params->session_priv_mpool); 682 TEST_ASSERT_MOCK_FUNCTION_CALL_NOT_NULL(rte_security_session_create, 683 sess); 684 TEST_ASSERT_EQUAL(sess, mock_session_create_exp.sess, 685 "Expecting session_create to be called with %p sess" 686 " parameter, but it's called %p sess parameter", 687 sess, mock_session_create_exp.sess); 688 TEST_ASSERT_MOCK_CALLS(mock_session_create_exp, 1); 689 690 /* 691 * Store created session in test case parameters, so it can be released 692 * after test case in ut_teardown by destroy_session_with_check. 693 */ 694 ut_params->sess = sess; 695 696 return TEST_SUCCESS; 697 } 698 699 700 /** 701 * Test functions 702 * 703 * Each test function is related to a single test case. 704 * They are arranged by tested rte_security API function 705 * and by rte_security execution paths sequence in code. 706 */ 707 708 /** 709 * rte_security_session_create tests 710 */ 711 712 /** 713 * Test execution of rte_security_session_create with NULL instance 714 */ 715 static int 716 test_session_create_inv_context(void) 717 { 718 struct security_testsuite_params *ts_params = &testsuite_params; 719 struct security_unittest_params *ut_params = &unittest_params; 720 struct rte_security_session *sess; 721 722 sess = rte_security_session_create(NULL, &ut_params->conf, 723 ts_params->session_mpool, 724 ts_params->session_priv_mpool); 725 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_create, 726 sess, NULL, "%p"); 727 TEST_ASSERT_MOCK_CALLS(mock_session_create_exp, 0); 728 TEST_ASSERT_MEMPOOL_USAGE(0); 729 TEST_ASSERT_PRIV_MP_USAGE(0); 730 TEST_ASSERT_SESSION_COUNT(0); 731 732 return TEST_SUCCESS; 733 } 734 735 /** 736 * Test execution of rte_security_session_create with invalid 737 * security operations structure (NULL) 738 */ 739 static int 740 test_session_create_inv_context_ops(void) 741 { 742 struct security_testsuite_params *ts_params = &testsuite_params; 743 struct security_unittest_params *ut_params = &unittest_params; 744 struct rte_security_session *sess; 745 746 ut_params->ctx.ops = NULL; 747 748 sess = rte_security_session_create(&ut_params->ctx, &ut_params->conf, 749 ts_params->session_mpool, 750 ts_params->session_priv_mpool); 751 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_create, 752 sess, NULL, "%p"); 753 TEST_ASSERT_MOCK_CALLS(mock_session_create_exp, 0); 754 TEST_ASSERT_MEMPOOL_USAGE(0); 755 TEST_ASSERT_PRIV_MP_USAGE(0); 756 TEST_ASSERT_SESSION_COUNT(0); 757 758 return TEST_SUCCESS; 759 } 760 761 /** 762 * Test execution of rte_security_session_create with empty 763 * security operations 764 */ 765 static int 766 test_session_create_inv_context_ops_fun(void) 767 { 768 struct security_testsuite_params *ts_params = &testsuite_params; 769 struct security_unittest_params *ut_params = &unittest_params; 770 struct rte_security_session *sess; 771 772 ut_params->ctx.ops = &empty_ops; 773 774 sess = rte_security_session_create(&ut_params->ctx, &ut_params->conf, 775 ts_params->session_mpool, 776 ts_params->session_priv_mpool); 777 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_create, 778 sess, NULL, "%p"); 779 TEST_ASSERT_MOCK_CALLS(mock_session_create_exp, 0); 780 TEST_ASSERT_MEMPOOL_USAGE(0); 781 TEST_ASSERT_PRIV_MP_USAGE(0); 782 TEST_ASSERT_SESSION_COUNT(0); 783 784 return TEST_SUCCESS; 785 } 786 787 /** 788 * Test execution of rte_security_session_create with NULL conf parameter 789 */ 790 static int 791 test_session_create_inv_configuration(void) 792 { 793 struct security_testsuite_params *ts_params = &testsuite_params; 794 struct security_unittest_params *ut_params = &unittest_params; 795 struct rte_security_session *sess; 796 797 sess = rte_security_session_create(&ut_params->ctx, NULL, 798 ts_params->session_mpool, 799 ts_params->session_priv_mpool); 800 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_create, 801 sess, NULL, "%p"); 802 TEST_ASSERT_MOCK_CALLS(mock_session_create_exp, 0); 803 TEST_ASSERT_MEMPOOL_USAGE(0); 804 TEST_ASSERT_PRIV_MP_USAGE(0); 805 TEST_ASSERT_SESSION_COUNT(0); 806 807 return TEST_SUCCESS; 808 } 809 810 /** 811 * Test execution of rte_security_session_create with NULL session 812 * mempool 813 */ 814 static int 815 test_session_create_inv_mempool(void) 816 { 817 struct security_unittest_params *ut_params = &unittest_params; 818 struct security_testsuite_params *ts_params = &testsuite_params; 819 struct rte_security_session *sess; 820 821 sess = rte_security_session_create(&ut_params->ctx, &ut_params->conf, 822 NULL, ts_params->session_priv_mpool); 823 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_create, 824 sess, NULL, "%p"); 825 TEST_ASSERT_MOCK_CALLS(mock_session_create_exp, 0); 826 TEST_ASSERT_MEMPOOL_USAGE(0); 827 TEST_ASSERT_PRIV_MP_USAGE(0); 828 TEST_ASSERT_SESSION_COUNT(0); 829 830 return TEST_SUCCESS; 831 } 832 833 /** 834 * Test execution of rte_security_session_create with NULL session 835 * priv mempool 836 */ 837 static int 838 test_session_create_inv_sess_priv_mempool(void) 839 { 840 struct security_unittest_params *ut_params = &unittest_params; 841 struct security_testsuite_params *ts_params = &testsuite_params; 842 struct rte_security_session *sess; 843 844 sess = rte_security_session_create(&ut_params->ctx, &ut_params->conf, 845 ts_params->session_mpool, NULL); 846 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_create, 847 sess, NULL, "%p"); 848 TEST_ASSERT_MOCK_CALLS(mock_session_create_exp, 0); 849 TEST_ASSERT_MEMPOOL_USAGE(0); 850 TEST_ASSERT_PRIV_MP_USAGE(0); 851 TEST_ASSERT_SESSION_COUNT(0); 852 853 return TEST_SUCCESS; 854 } 855 856 /** 857 * Test execution of rte_security_session_create in case when mempool 858 * is fully used and no object can be got from it 859 */ 860 static int 861 test_session_create_mempool_empty(void) 862 { 863 struct security_testsuite_params *ts_params = &testsuite_params; 864 struct security_unittest_params *ut_params = &unittest_params; 865 struct rte_security_session *tmp[SECURITY_TEST_MEMPOOL_SIZE]; 866 void *tmp1[SECURITY_TEST_MEMPOOL_SIZE]; 867 struct rte_security_session *sess; 868 869 /* Get all available objects from mempool. */ 870 int i, ret; 871 for (i = 0; i < SECURITY_TEST_MEMPOOL_SIZE; ++i) { 872 ret = rte_mempool_get(ts_params->session_mpool, 873 (void **)(&tmp[i])); 874 TEST_ASSERT_EQUAL(0, ret, 875 "Expect getting %d object from mempool" 876 " to succeed", i); 877 ret = rte_mempool_get(ts_params->session_priv_mpool, 878 (void **)(&tmp1[i])); 879 TEST_ASSERT_EQUAL(0, ret, 880 "Expect getting %d object from priv mempool" 881 " to succeed", i); 882 } 883 TEST_ASSERT_MEMPOOL_USAGE(SECURITY_TEST_MEMPOOL_SIZE); 884 TEST_ASSERT_PRIV_MP_USAGE(SECURITY_TEST_MEMPOOL_SIZE); 885 886 sess = rte_security_session_create(&ut_params->ctx, &ut_params->conf, 887 ts_params->session_mpool, 888 ts_params->session_priv_mpool); 889 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_create, 890 sess, NULL, "%p"); 891 TEST_ASSERT_MOCK_CALLS(mock_session_create_exp, 0); 892 TEST_ASSERT_MEMPOOL_USAGE(SECURITY_TEST_MEMPOOL_SIZE); 893 TEST_ASSERT_PRIV_MP_USAGE(SECURITY_TEST_MEMPOOL_SIZE); 894 TEST_ASSERT_SESSION_COUNT(0); 895 896 /* Put objects back to the pool. */ 897 for (i = 0; i < SECURITY_TEST_MEMPOOL_SIZE; ++i) { 898 rte_mempool_put(ts_params->session_mpool, 899 (void *)(tmp[i])); 900 rte_mempool_put(ts_params->session_priv_mpool, 901 (tmp1[i])); 902 } 903 TEST_ASSERT_MEMPOOL_USAGE(0); 904 TEST_ASSERT_PRIV_MP_USAGE(0); 905 906 return TEST_SUCCESS; 907 } 908 909 /** 910 * Test execution of rte_security_session_create when session_create 911 * security operation fails 912 */ 913 static int 914 test_session_create_ops_failure(void) 915 { 916 struct security_testsuite_params *ts_params = &testsuite_params; 917 struct security_unittest_params *ut_params = &unittest_params; 918 struct rte_security_session *sess; 919 920 mock_session_create_exp.device = NULL; 921 mock_session_create_exp.conf = &ut_params->conf; 922 mock_session_create_exp.mp = ts_params->session_mpool; 923 mock_session_create_exp.priv_mp = ts_params->session_priv_mpool; 924 mock_session_create_exp.ret = -1; /* Return failure status. */ 925 926 sess = rte_security_session_create(&ut_params->ctx, &ut_params->conf, 927 ts_params->session_mpool, 928 ts_params->session_priv_mpool); 929 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_create, 930 sess, NULL, "%p"); 931 TEST_ASSERT_MOCK_CALLS(mock_session_create_exp, 1); 932 TEST_ASSERT_MEMPOOL_USAGE(0); 933 TEST_ASSERT_PRIV_MP_USAGE(0); 934 TEST_ASSERT_SESSION_COUNT(0); 935 936 return TEST_SUCCESS; 937 } 938 939 /** 940 * Test execution of rte_security_session_create in successful execution path 941 */ 942 static int 943 test_session_create_success(void) 944 { 945 struct security_testsuite_params *ts_params = &testsuite_params; 946 struct security_unittest_params *ut_params = &unittest_params; 947 struct rte_security_session *sess; 948 949 mock_session_create_exp.device = NULL; 950 mock_session_create_exp.conf = &ut_params->conf; 951 mock_session_create_exp.mp = ts_params->session_mpool; 952 mock_session_create_exp.priv_mp = ts_params->session_priv_mpool; 953 mock_session_create_exp.ret = 0; /* Return success status. */ 954 955 sess = rte_security_session_create(&ut_params->ctx, &ut_params->conf, 956 ts_params->session_mpool, 957 ts_params->session_priv_mpool); 958 TEST_ASSERT_MOCK_FUNCTION_CALL_NOT_NULL(rte_security_session_create, 959 sess); 960 TEST_ASSERT_EQUAL(sess, mock_session_create_exp.sess, 961 "Expecting session_create to be called with %p sess" 962 " parameter, but it's called %p sess parameter", 963 sess, mock_session_create_exp.sess); 964 TEST_ASSERT_MOCK_CALLS(mock_session_create_exp, 1); 965 TEST_ASSERT_MEMPOOL_USAGE(1); 966 TEST_ASSERT_PRIV_MP_USAGE(1); 967 TEST_ASSERT_SESSION_COUNT(1); 968 969 /* 970 * Store created session in test case parameters, so it can be released 971 * after test case in ut_teardown by destroy_session_with_check. 972 */ 973 ut_params->sess = sess; 974 975 return TEST_SUCCESS; 976 } 977 978 979 /** 980 * rte_security_session_update tests 981 */ 982 983 /** 984 * Test execution of rte_security_session_update with NULL instance 985 */ 986 static int 987 test_session_update_inv_context(void) 988 { 989 struct security_unittest_params *ut_params = &unittest_params; 990 991 int ret = rte_security_session_update(NULL, ut_params->sess, 992 &ut_params->conf); 993 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_update, 994 ret, -EINVAL, "%d"); 995 TEST_ASSERT_MOCK_CALLS(mock_session_update_exp, 0); 996 997 return TEST_SUCCESS; 998 } 999 1000 /** 1001 * Test execution of rte_security_session_update with invalid 1002 * security operations structure (NULL) 1003 */ 1004 static int 1005 test_session_update_inv_context_ops(void) 1006 { 1007 struct security_unittest_params *ut_params = &unittest_params; 1008 ut_params->ctx.ops = NULL; 1009 1010 int ret = rte_security_session_update(&ut_params->ctx, ut_params->sess, 1011 &ut_params->conf); 1012 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_update, 1013 ret, -EINVAL, "%d"); 1014 TEST_ASSERT_MOCK_CALLS(mock_session_update_exp, 0); 1015 1016 return TEST_SUCCESS; 1017 } 1018 1019 /** 1020 * Test execution of rte_security_session_update with empty 1021 * security operations 1022 */ 1023 static int 1024 test_session_update_inv_context_ops_fun(void) 1025 { 1026 struct security_unittest_params *ut_params = &unittest_params; 1027 ut_params->ctx.ops = &empty_ops; 1028 1029 int ret = rte_security_session_update(&ut_params->ctx, ut_params->sess, 1030 &ut_params->conf); 1031 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_update, 1032 ret, -ENOTSUP, "%d"); 1033 TEST_ASSERT_MOCK_CALLS(mock_session_update_exp, 0); 1034 1035 return TEST_SUCCESS; 1036 } 1037 1038 /** 1039 * Test execution of rte_security_session_update with NULL conf parameter 1040 */ 1041 static int 1042 test_session_update_inv_configuration(void) 1043 { 1044 struct security_unittest_params *ut_params = &unittest_params; 1045 1046 int ret = rte_security_session_update(&ut_params->ctx, ut_params->sess, 1047 NULL); 1048 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_update, 1049 ret, -EINVAL, "%d"); 1050 TEST_ASSERT_MOCK_CALLS(mock_session_update_exp, 0); 1051 1052 return TEST_SUCCESS; 1053 } 1054 1055 /** 1056 * Test execution of rte_security_session_update with NULL sess parameter 1057 */ 1058 static int 1059 test_session_update_inv_session(void) 1060 { 1061 struct security_unittest_params *ut_params = &unittest_params; 1062 1063 int ret = rte_security_session_update(&ut_params->ctx, NULL, 1064 &ut_params->conf); 1065 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_update, 1066 ret, -EINVAL, "%d"); 1067 TEST_ASSERT_MOCK_CALLS(mock_session_update_exp, 0); 1068 1069 return TEST_SUCCESS; 1070 } 1071 1072 /** 1073 * Test execution of rte_security_session_update when session_update 1074 * security operation fails 1075 */ 1076 static int 1077 test_session_update_ops_failure(void) 1078 { 1079 struct security_unittest_params *ut_params = &unittest_params; 1080 1081 mock_session_update_exp.device = NULL; 1082 mock_session_update_exp.sess = ut_params->sess; 1083 mock_session_update_exp.conf = &ut_params->conf; 1084 mock_session_update_exp.ret = -1; /* Return failure status. */ 1085 1086 int ret = rte_security_session_update(&ut_params->ctx, ut_params->sess, 1087 &ut_params->conf); 1088 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_update, 1089 ret, -1, "%d"); 1090 TEST_ASSERT_MOCK_CALLS(mock_session_update_exp, 1); 1091 1092 return TEST_SUCCESS; 1093 } 1094 1095 /** 1096 * Test execution of rte_security_session_update in successful execution path 1097 */ 1098 static int 1099 test_session_update_success(void) 1100 { 1101 struct security_unittest_params *ut_params = &unittest_params; 1102 1103 mock_session_update_exp.device = NULL; 1104 mock_session_update_exp.sess = ut_params->sess; 1105 mock_session_update_exp.conf = &ut_params->conf; 1106 mock_session_update_exp.ret = 0; /* Return success status. */ 1107 1108 int ret = rte_security_session_update(&ut_params->ctx, ut_params->sess, 1109 &ut_params->conf); 1110 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_update, 1111 ret, 0, "%d"); 1112 TEST_ASSERT_MOCK_CALLS(mock_session_update_exp, 1); 1113 1114 return TEST_SUCCESS; 1115 } 1116 1117 1118 /** 1119 * rte_security_session_get_size tests 1120 */ 1121 1122 /** 1123 * Test execution of rte_security_session_get_size with NULL instance 1124 */ 1125 static int 1126 test_session_get_size_inv_context(void) 1127 { 1128 unsigned int ret = rte_security_session_get_size(NULL); 1129 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_get_size, 1130 ret, 0, "%u"); 1131 TEST_ASSERT_MOCK_CALLS(mock_session_get_size_exp, 0); 1132 1133 return TEST_SUCCESS; 1134 } 1135 1136 /** 1137 * Test execution of rte_security_session_get_size with invalid 1138 * security operations structure (NULL) 1139 */ 1140 static int 1141 test_session_get_size_inv_context_ops(void) 1142 { 1143 struct security_unittest_params *ut_params = &unittest_params; 1144 ut_params->ctx.ops = NULL; 1145 1146 unsigned int ret = rte_security_session_get_size(&ut_params->ctx); 1147 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_get_size, 1148 ret, 0, "%u"); 1149 TEST_ASSERT_MOCK_CALLS(mock_session_get_size_exp, 0); 1150 1151 return TEST_SUCCESS; 1152 } 1153 1154 /** 1155 * Test execution of rte_security_session_get_size with empty 1156 * security operations 1157 */ 1158 static int 1159 test_session_get_size_inv_context_ops_fun(void) 1160 { 1161 struct security_unittest_params *ut_params = &unittest_params; 1162 ut_params->ctx.ops = &empty_ops; 1163 1164 unsigned int ret = rte_security_session_get_size(&ut_params->ctx); 1165 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_get_size, 1166 ret, 0, "%u"); 1167 TEST_ASSERT_MOCK_CALLS(mock_session_get_size_exp, 0); 1168 1169 return TEST_SUCCESS; 1170 } 1171 1172 /** 1173 * Test execution of rte_security_session_get_size when session_get_size 1174 * security operation fails 1175 */ 1176 static int 1177 test_session_get_size_ops_failure(void) 1178 { 1179 struct security_unittest_params *ut_params = &unittest_params; 1180 1181 mock_session_get_size_exp.device = NULL; 1182 mock_session_get_size_exp.ret = 0; 1183 1184 unsigned int ret = rte_security_session_get_size(&ut_params->ctx); 1185 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_get_size, 1186 ret, 0, "%u"); 1187 TEST_ASSERT_MOCK_CALLS(mock_session_get_size_exp, 1); 1188 1189 return TEST_SUCCESS; 1190 } 1191 1192 /** 1193 * Test execution of rte_security_session_get_size in successful execution path 1194 */ 1195 static int 1196 test_session_get_size_success(void) 1197 { 1198 struct security_unittest_params *ut_params = &unittest_params; 1199 1200 mock_session_get_size_exp.device = NULL; 1201 mock_session_get_size_exp.ret = 1024; 1202 1203 unsigned int ret = rte_security_session_get_size(&ut_params->ctx); 1204 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_get_size, 1205 ret, 1024U, "%u"); 1206 TEST_ASSERT_MOCK_CALLS(mock_session_get_size_exp, 1); 1207 1208 return TEST_SUCCESS; 1209 } 1210 1211 1212 /** 1213 * rte_security_session_stats_get tests 1214 */ 1215 1216 /** 1217 * Test execution of rte_security_session_stats_get with NULL instance 1218 */ 1219 static int 1220 test_session_stats_get_inv_context(void) 1221 { 1222 struct security_unittest_params *ut_params = &unittest_params; 1223 struct rte_security_stats stats; 1224 1225 int ret = rte_security_session_stats_get(NULL, ut_params->sess, &stats); 1226 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_stats_get, 1227 ret, -EINVAL, "%d"); 1228 TEST_ASSERT_MOCK_CALLS(mock_session_stats_get_exp, 0); 1229 1230 return TEST_SUCCESS; 1231 } 1232 1233 /** 1234 * Test execution of rte_security_session_stats_get with invalid 1235 * security operations structure (NULL) 1236 */ 1237 static int 1238 test_session_stats_get_inv_context_ops(void) 1239 { 1240 struct security_unittest_params *ut_params = &unittest_params; 1241 struct rte_security_stats stats; 1242 ut_params->ctx.ops = NULL; 1243 1244 int ret = rte_security_session_stats_get(&ut_params->ctx, 1245 ut_params->sess, &stats); 1246 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_stats_get, 1247 ret, -EINVAL, "%d"); 1248 TEST_ASSERT_MOCK_CALLS(mock_session_stats_get_exp, 0); 1249 1250 return TEST_SUCCESS; 1251 } 1252 1253 /** 1254 * Test execution of rte_security_session_stats_get with empty 1255 * security operations 1256 */ 1257 static int 1258 test_session_stats_get_inv_context_ops_fun(void) 1259 { 1260 struct security_unittest_params *ut_params = &unittest_params; 1261 struct rte_security_stats stats; 1262 ut_params->ctx.ops = &empty_ops; 1263 1264 int ret = rte_security_session_stats_get(&ut_params->ctx, 1265 ut_params->sess, &stats); 1266 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_stats_get, 1267 ret, -ENOTSUP, "%d"); 1268 TEST_ASSERT_MOCK_CALLS(mock_session_stats_get_exp, 0); 1269 1270 return TEST_SUCCESS; 1271 } 1272 1273 /** 1274 * Test execution of rte_security_session_stats_get with NULL stats parameter 1275 */ 1276 static int 1277 test_session_stats_get_inv_stats(void) 1278 { 1279 struct security_unittest_params *ut_params = &unittest_params; 1280 1281 int ret = rte_security_session_stats_get(&ut_params->ctx, 1282 ut_params->sess, NULL); 1283 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_stats_get, 1284 ret, -EINVAL, "%d"); 1285 TEST_ASSERT_MOCK_CALLS(mock_session_stats_get_exp, 0); 1286 1287 return TEST_SUCCESS; 1288 } 1289 1290 /** 1291 * Test execution of rte_security_session_stats_get when session_stats_get 1292 * security operation fails 1293 */ 1294 static int 1295 test_session_stats_get_ops_failure(void) 1296 { 1297 struct security_unittest_params *ut_params = &unittest_params; 1298 struct rte_security_stats stats; 1299 1300 mock_session_stats_get_exp.device = NULL; 1301 mock_session_stats_get_exp.sess = ut_params->sess; 1302 mock_session_stats_get_exp.stats = &stats; 1303 mock_session_stats_get_exp.ret = -1; 1304 1305 int ret = rte_security_session_stats_get(&ut_params->ctx, 1306 ut_params->sess, &stats); 1307 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_stats_get, 1308 ret, -1, "%d"); 1309 TEST_ASSERT_MOCK_CALLS(mock_session_stats_get_exp, 1); 1310 1311 return TEST_SUCCESS; 1312 } 1313 1314 /** 1315 * Test execution of rte_security_session_stats_get in successful execution 1316 * path 1317 */ 1318 static int 1319 test_session_stats_get_success(void) 1320 { 1321 struct security_unittest_params *ut_params = &unittest_params; 1322 struct rte_security_stats stats; 1323 1324 mock_session_stats_get_exp.device = NULL; 1325 mock_session_stats_get_exp.sess = ut_params->sess; 1326 mock_session_stats_get_exp.stats = &stats; 1327 mock_session_stats_get_exp.ret = 0; 1328 1329 int ret = rte_security_session_stats_get(&ut_params->ctx, 1330 ut_params->sess, &stats); 1331 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_stats_get, 1332 ret, 0, "%d"); 1333 TEST_ASSERT_MOCK_CALLS(mock_session_stats_get_exp, 1); 1334 1335 return TEST_SUCCESS; 1336 } 1337 1338 1339 /** 1340 * rte_security_session_destroy tests 1341 */ 1342 1343 /** 1344 * Test execution of rte_security_session_destroy with NULL instance 1345 */ 1346 static int 1347 test_session_destroy_inv_context(void) 1348 { 1349 struct security_unittest_params *ut_params = &unittest_params; 1350 1351 TEST_ASSERT_MEMPOOL_USAGE(1); 1352 TEST_ASSERT_PRIV_MP_USAGE(1); 1353 TEST_ASSERT_SESSION_COUNT(1); 1354 1355 int ret = rte_security_session_destroy(NULL, ut_params->sess); 1356 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_destroy, 1357 ret, -EINVAL, "%d"); 1358 TEST_ASSERT_MOCK_CALLS(mock_session_destroy_exp, 0); 1359 TEST_ASSERT_MEMPOOL_USAGE(1); 1360 TEST_ASSERT_PRIV_MP_USAGE(1); 1361 TEST_ASSERT_SESSION_COUNT(1); 1362 1363 return TEST_SUCCESS; 1364 } 1365 1366 /** 1367 * Test execution of rte_security_session_destroy with invalid 1368 * security operations structure (NULL) 1369 */ 1370 static int 1371 test_session_destroy_inv_context_ops(void) 1372 { 1373 struct security_unittest_params *ut_params = &unittest_params; 1374 ut_params->ctx.ops = NULL; 1375 1376 TEST_ASSERT_MEMPOOL_USAGE(1); 1377 TEST_ASSERT_PRIV_MP_USAGE(1); 1378 TEST_ASSERT_SESSION_COUNT(1); 1379 1380 int ret = rte_security_session_destroy(&ut_params->ctx, 1381 ut_params->sess); 1382 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_destroy, 1383 ret, -EINVAL, "%d"); 1384 TEST_ASSERT_MOCK_CALLS(mock_session_destroy_exp, 0); 1385 TEST_ASSERT_MEMPOOL_USAGE(1); 1386 TEST_ASSERT_PRIV_MP_USAGE(1); 1387 TEST_ASSERT_SESSION_COUNT(1); 1388 1389 return TEST_SUCCESS; 1390 } 1391 1392 /** 1393 * Test execution of rte_security_session_destroy with empty 1394 * security operations 1395 */ 1396 static int 1397 test_session_destroy_inv_context_ops_fun(void) 1398 { 1399 struct security_unittest_params *ut_params = &unittest_params; 1400 ut_params->ctx.ops = &empty_ops; 1401 1402 TEST_ASSERT_MEMPOOL_USAGE(1); 1403 TEST_ASSERT_PRIV_MP_USAGE(1); 1404 TEST_ASSERT_SESSION_COUNT(1); 1405 1406 int ret = rte_security_session_destroy(&ut_params->ctx, 1407 ut_params->sess); 1408 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_destroy, 1409 ret, -ENOTSUP, "%d"); 1410 TEST_ASSERT_MOCK_CALLS(mock_session_destroy_exp, 0); 1411 TEST_ASSERT_MEMPOOL_USAGE(1); 1412 TEST_ASSERT_PRIV_MP_USAGE(1); 1413 TEST_ASSERT_SESSION_COUNT(1); 1414 1415 return TEST_SUCCESS; 1416 } 1417 1418 /** 1419 * Test execution of rte_security_session_destroy with NULL sess parameter 1420 */ 1421 static int 1422 test_session_destroy_inv_session(void) 1423 { 1424 struct security_unittest_params *ut_params = &unittest_params; 1425 1426 TEST_ASSERT_MEMPOOL_USAGE(1); 1427 TEST_ASSERT_PRIV_MP_USAGE(1); 1428 TEST_ASSERT_SESSION_COUNT(1); 1429 1430 int ret = rte_security_session_destroy(&ut_params->ctx, NULL); 1431 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_destroy, 1432 ret, -EINVAL, "%d"); 1433 TEST_ASSERT_MOCK_CALLS(mock_session_destroy_exp, 0); 1434 TEST_ASSERT_MEMPOOL_USAGE(1); 1435 TEST_ASSERT_PRIV_MP_USAGE(1); 1436 TEST_ASSERT_SESSION_COUNT(1); 1437 1438 return TEST_SUCCESS; 1439 } 1440 1441 /** 1442 * Test execution of rte_security_session_destroy when session_destroy 1443 * security operation fails 1444 */ 1445 static int 1446 test_session_destroy_ops_failure(void) 1447 { 1448 struct security_unittest_params *ut_params = &unittest_params; 1449 1450 mock_session_destroy_exp.device = NULL; 1451 mock_session_destroy_exp.sess = ut_params->sess; 1452 mock_session_destroy_exp.ret = -1; 1453 1454 TEST_ASSERT_MEMPOOL_USAGE(1); 1455 TEST_ASSERT_PRIV_MP_USAGE(1); 1456 TEST_ASSERT_SESSION_COUNT(1); 1457 1458 int ret = rte_security_session_destroy(&ut_params->ctx, 1459 ut_params->sess); 1460 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_destroy, 1461 ret, -1, "%d"); 1462 TEST_ASSERT_MOCK_CALLS(mock_session_destroy_exp, 1); 1463 TEST_ASSERT_MEMPOOL_USAGE(1); 1464 TEST_ASSERT_PRIV_MP_USAGE(1); 1465 TEST_ASSERT_SESSION_COUNT(1); 1466 1467 return TEST_SUCCESS; 1468 } 1469 1470 /** 1471 * Test execution of rte_security_session_destroy in successful execution path 1472 */ 1473 static int 1474 test_session_destroy_success(void) 1475 { 1476 struct security_unittest_params *ut_params = &unittest_params; 1477 1478 mock_session_destroy_exp.device = NULL; 1479 mock_session_destroy_exp.sess = ut_params->sess; 1480 mock_session_destroy_exp.ret = 0; 1481 TEST_ASSERT_MEMPOOL_USAGE(1); 1482 TEST_ASSERT_PRIV_MP_USAGE(1); 1483 TEST_ASSERT_SESSION_COUNT(1); 1484 1485 int ret = rte_security_session_destroy(&ut_params->ctx, 1486 ut_params->sess); 1487 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_session_destroy, 1488 ret, 0, "%d"); 1489 TEST_ASSERT_MOCK_CALLS(mock_session_destroy_exp, 1); 1490 TEST_ASSERT_MEMPOOL_USAGE(0); 1491 TEST_ASSERT_PRIV_MP_USAGE(0); 1492 TEST_ASSERT_SESSION_COUNT(0); 1493 1494 /* 1495 * Remove session from test case parameters, so it won't be destroyed 1496 * during test case teardown. 1497 */ 1498 ut_params->sess = NULL; 1499 1500 return TEST_SUCCESS; 1501 } 1502 1503 1504 /** 1505 * rte_security_set_pkt_metadata tests 1506 */ 1507 1508 /** 1509 * Test execution of rte_security_set_pkt_metadata with NULL instance 1510 */ 1511 static int 1512 test_set_pkt_metadata_inv_context(void) 1513 { 1514 #ifdef RTE_DEBUG 1515 struct security_unittest_params *ut_params = &unittest_params; 1516 struct rte_mbuf m; 1517 int params; 1518 1519 int ret = rte_security_set_pkt_metadata(NULL, ut_params->sess, &m, 1520 ¶ms); 1521 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_set_pkt_metadata, 1522 ret, -EINVAL, "%d"); 1523 TEST_ASSERT_MOCK_CALLS(mock_set_pkt_metadata_exp, 0); 1524 1525 return TEST_SUCCESS; 1526 #else 1527 return TEST_SKIPPED; 1528 #endif 1529 } 1530 1531 /** 1532 * Test execution of rte_security_set_pkt_metadata with invalid 1533 * security operations structure (NULL) 1534 */ 1535 static int 1536 test_set_pkt_metadata_inv_context_ops(void) 1537 { 1538 #ifdef RTE_DEBUG 1539 struct security_unittest_params *ut_params = &unittest_params; 1540 struct rte_mbuf m; 1541 int params; 1542 ut_params->ctx.ops = NULL; 1543 1544 int ret = rte_security_set_pkt_metadata(&ut_params->ctx, 1545 ut_params->sess, &m, ¶ms); 1546 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_set_pkt_metadata, 1547 ret, -EINVAL, "%d"); 1548 TEST_ASSERT_MOCK_CALLS(mock_set_pkt_metadata_exp, 0); 1549 1550 return TEST_SUCCESS; 1551 #else 1552 return TEST_SKIPPED; 1553 #endif 1554 } 1555 1556 /** 1557 * Test execution of rte_security_set_pkt_metadata with empty 1558 * security operations 1559 */ 1560 static int 1561 test_set_pkt_metadata_inv_context_ops_fun(void) 1562 { 1563 struct security_unittest_params *ut_params = &unittest_params; 1564 struct rte_mbuf m; 1565 int params; 1566 ut_params->ctx.ops = &empty_ops; 1567 1568 int ret = rte_security_set_pkt_metadata(&ut_params->ctx, 1569 ut_params->sess, &m, ¶ms); 1570 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_set_pkt_metadata, 1571 ret, -ENOTSUP, "%d"); 1572 TEST_ASSERT_MOCK_CALLS(mock_set_pkt_metadata_exp, 0); 1573 1574 return TEST_SUCCESS; 1575 } 1576 1577 /** 1578 * Test execution of rte_security_set_pkt_metadata with NULL sess parameter 1579 */ 1580 static int 1581 test_set_pkt_metadata_inv_session(void) 1582 { 1583 #ifdef RTE_DEBUG 1584 struct security_unittest_params *ut_params = &unittest_params; 1585 struct rte_mbuf m; 1586 int params; 1587 1588 int ret = rte_security_set_pkt_metadata(&ut_params->ctx, NULL, 1589 &m, ¶ms); 1590 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_set_pkt_metadata, 1591 ret, -EINVAL, "%d"); 1592 TEST_ASSERT_MOCK_CALLS(mock_set_pkt_metadata_exp, 0); 1593 1594 return TEST_SUCCESS; 1595 #else 1596 return TEST_SKIPPED; 1597 #endif 1598 } 1599 1600 /** 1601 * Test execution of rte_security_set_pkt_metadata when set_pkt_metadata 1602 * security operation fails 1603 */ 1604 static int 1605 test_set_pkt_metadata_ops_failure(void) 1606 { 1607 struct security_unittest_params *ut_params = &unittest_params; 1608 struct rte_mbuf m; 1609 int params; 1610 1611 mock_set_pkt_metadata_exp.device = NULL; 1612 mock_set_pkt_metadata_exp.sess = ut_params->sess; 1613 mock_set_pkt_metadata_exp.m = &m; 1614 mock_set_pkt_metadata_exp.params = ¶ms; 1615 mock_set_pkt_metadata_exp.ret = -1; 1616 1617 int ret = rte_security_set_pkt_metadata(&ut_params->ctx, 1618 ut_params->sess, &m, ¶ms); 1619 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_set_pkt_metadata, 1620 ret, -1, "%d"); 1621 TEST_ASSERT_MOCK_CALLS(mock_set_pkt_metadata_exp, 1); 1622 1623 return TEST_SUCCESS; 1624 } 1625 1626 /** 1627 * Test execution of rte_security_set_pkt_metadata in successful execution path 1628 */ 1629 static int 1630 test_set_pkt_metadata_success(void) 1631 { 1632 struct security_unittest_params *ut_params = &unittest_params; 1633 struct rte_mbuf m; 1634 int params; 1635 1636 mock_set_pkt_metadata_exp.device = NULL; 1637 mock_set_pkt_metadata_exp.sess = ut_params->sess; 1638 mock_set_pkt_metadata_exp.m = &m; 1639 mock_set_pkt_metadata_exp.params = ¶ms; 1640 mock_set_pkt_metadata_exp.ret = 0; 1641 1642 int ret = rte_security_set_pkt_metadata(&ut_params->ctx, 1643 ut_params->sess, &m, ¶ms); 1644 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_set_pkt_metadata, 1645 ret, 0, "%d"); 1646 TEST_ASSERT_MOCK_CALLS(mock_set_pkt_metadata_exp, 1); 1647 1648 return TEST_SUCCESS; 1649 } 1650 1651 /** 1652 * rte_security_capabilities_get tests 1653 */ 1654 1655 /** 1656 * Test execution of rte_security_capabilities_get with NULL instance 1657 */ 1658 static int 1659 test_capabilities_get_inv_context(void) 1660 { 1661 const struct rte_security_capability *ret; 1662 ret = rte_security_capabilities_get(NULL); 1663 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capabilities_get, 1664 ret, NULL, "%p"); 1665 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 0); 1666 1667 return TEST_SUCCESS; 1668 } 1669 1670 /** 1671 * Test execution of rte_security_capabilities_get with invalid 1672 * security operations structure (NULL) 1673 */ 1674 static int 1675 test_capabilities_get_inv_context_ops(void) 1676 { 1677 struct security_unittest_params *ut_params = &unittest_params; 1678 ut_params->ctx.ops = NULL; 1679 1680 const struct rte_security_capability *ret; 1681 ret = rte_security_capabilities_get(&ut_params->ctx); 1682 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capabilities_get, 1683 ret, NULL, "%p"); 1684 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 0); 1685 1686 return TEST_SUCCESS; 1687 } 1688 1689 /** 1690 * Test execution of rte_security_capabilities_get with empty 1691 * security operations 1692 */ 1693 static int 1694 test_capabilities_get_inv_context_ops_fun(void) 1695 { 1696 struct security_unittest_params *ut_params = &unittest_params; 1697 ut_params->ctx.ops = &empty_ops; 1698 1699 const struct rte_security_capability *ret; 1700 ret = rte_security_capabilities_get(&ut_params->ctx); 1701 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capabilities_get, 1702 ret, NULL, "%p"); 1703 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 0); 1704 1705 return TEST_SUCCESS; 1706 } 1707 1708 /** 1709 * Test execution of rte_security_capabilities_get when capabilities_get 1710 * security operation fails 1711 */ 1712 static int 1713 test_capabilities_get_ops_failure(void) 1714 { 1715 struct security_unittest_params *ut_params = &unittest_params; 1716 1717 mock_capabilities_get_exp.device = NULL; 1718 mock_capabilities_get_exp.ret = NULL; 1719 1720 const struct rte_security_capability *ret; 1721 ret = rte_security_capabilities_get(&ut_params->ctx); 1722 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capabilities_get, 1723 ret, NULL, "%p"); 1724 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 1); 1725 1726 return TEST_SUCCESS; 1727 } 1728 1729 /** 1730 * Test execution of rte_security_capabilities_get in successful execution path 1731 */ 1732 static int 1733 test_capabilities_get_success(void) 1734 { 1735 struct security_unittest_params *ut_params = &unittest_params; 1736 struct rte_security_capability capabilities; 1737 1738 mock_capabilities_get_exp.device = NULL; 1739 mock_capabilities_get_exp.ret = &capabilities; 1740 1741 const struct rte_security_capability *ret; 1742 ret = rte_security_capabilities_get(&ut_params->ctx); 1743 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capabilities_get, 1744 ret, &capabilities, "%p"); 1745 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 1); 1746 1747 return TEST_SUCCESS; 1748 } 1749 1750 1751 /** 1752 * rte_security_capability_get tests 1753 */ 1754 1755 /** 1756 * Test execution of rte_security_capability_get with NULL instance 1757 */ 1758 static int 1759 test_capability_get_inv_context(void) 1760 { 1761 struct rte_security_capability_idx idx; 1762 1763 const struct rte_security_capability *ret; 1764 ret = rte_security_capability_get(NULL, &idx); 1765 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capability_get, 1766 ret, NULL, "%p"); 1767 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 0); 1768 1769 return TEST_SUCCESS; 1770 } 1771 1772 /** 1773 * Test execution of rte_security_capability_get with invalid 1774 * security operations structure (NULL) 1775 */ 1776 static int 1777 test_capability_get_inv_context_ops(void) 1778 { 1779 struct security_unittest_params *ut_params = &unittest_params; 1780 struct rte_security_capability_idx idx; 1781 ut_params->ctx.ops = NULL; 1782 1783 const struct rte_security_capability *ret; 1784 ret = rte_security_capability_get(&ut_params->ctx, &idx); 1785 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capability_get, 1786 ret, NULL, "%p"); 1787 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 0); 1788 1789 return TEST_SUCCESS; 1790 } 1791 1792 /** 1793 * Test execution of rte_security_capability_get with empty 1794 * security operations 1795 */ 1796 static int 1797 test_capability_get_inv_context_ops_fun(void) 1798 { 1799 struct security_unittest_params *ut_params = &unittest_params; 1800 struct rte_security_capability_idx idx; 1801 ut_params->ctx.ops = &empty_ops; 1802 1803 const struct rte_security_capability *ret; 1804 ret = rte_security_capability_get(&ut_params->ctx, &idx); 1805 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capability_get, 1806 ret, NULL, "%p"); 1807 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 0); 1808 1809 return TEST_SUCCESS; 1810 } 1811 1812 /** 1813 * Test execution of rte_security_capability_get with NULL idx parameter 1814 */ 1815 static int 1816 test_capability_get_inv_idx(void) 1817 { 1818 struct security_unittest_params *ut_params = &unittest_params; 1819 1820 const struct rte_security_capability *ret; 1821 ret = rte_security_capability_get(&ut_params->ctx, NULL); 1822 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capability_get, 1823 ret, NULL, "%p"); 1824 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 0); 1825 1826 return TEST_SUCCESS; 1827 } 1828 1829 /** 1830 * Test execution of rte_security_capability_get when capabilities_get 1831 * security operation fails 1832 */ 1833 static int 1834 test_capability_get_ops_failure(void) 1835 { 1836 struct security_unittest_params *ut_params = &unittest_params; 1837 struct rte_security_capability_idx idx; 1838 1839 mock_capabilities_get_exp.device = NULL; 1840 mock_capabilities_get_exp.ret = NULL; 1841 1842 const struct rte_security_capability *ret; 1843 ret = rte_security_capability_get(&ut_params->ctx, &idx); 1844 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capability_get, 1845 ret, NULL, "%p"); 1846 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 1); 1847 1848 return TEST_SUCCESS; 1849 } 1850 1851 /** 1852 * Test execution of rte_security_capability_get when capabilities table 1853 * is empty (contains only RTE_SECURITY_ACTION_TYPE_NONE ending entry) 1854 */ 1855 static int 1856 test_capability_get_empty_table(void) 1857 { 1858 struct security_unittest_params *ut_params = &unittest_params; 1859 struct rte_security_capability_idx idx; 1860 struct rte_security_capability capabilities[] = { 1861 { 1862 .action = RTE_SECURITY_ACTION_TYPE_NONE, 1863 }, 1864 }; 1865 1866 mock_capabilities_get_exp.device = NULL; 1867 mock_capabilities_get_exp.ret = capabilities; 1868 1869 const struct rte_security_capability *ret; 1870 ret = rte_security_capability_get(&ut_params->ctx, &idx); 1871 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capability_get, 1872 ret, NULL, "%p"); 1873 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 1); 1874 1875 return TEST_SUCCESS; 1876 } 1877 1878 /** 1879 * Test execution of rte_security_capability_get when capabilities table 1880 * does not contain entry with matching action 1881 */ 1882 static int 1883 test_capability_get_no_matching_action(void) 1884 { 1885 struct security_unittest_params *ut_params = &unittest_params; 1886 struct rte_security_capability_idx idx = { 1887 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, 1888 }; 1889 struct rte_security_capability capabilities[] = { 1890 { 1891 .action = RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO, 1892 }, 1893 { 1894 .action = RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL, 1895 }, 1896 { 1897 .action = RTE_SECURITY_ACTION_TYPE_NONE, 1898 }, 1899 }; 1900 1901 mock_capabilities_get_exp.device = NULL; 1902 mock_capabilities_get_exp.ret = capabilities; 1903 1904 const struct rte_security_capability *ret; 1905 ret = rte_security_capability_get(&ut_params->ctx, &idx); 1906 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capability_get, 1907 ret, NULL, "%p"); 1908 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 1); 1909 1910 return TEST_SUCCESS; 1911 } 1912 1913 /** 1914 * Test execution of rte_security_capability_get when capabilities table 1915 * does not contain entry with matching protocol 1916 */ 1917 static int 1918 test_capability_get_no_matching_protocol(void) 1919 { 1920 struct security_unittest_params *ut_params = &unittest_params; 1921 struct rte_security_capability_idx idx = { 1922 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, 1923 .protocol = RTE_SECURITY_PROTOCOL_IPSEC, 1924 }; 1925 struct rte_security_capability capabilities[] = { 1926 { 1927 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, 1928 .protocol = RTE_SECURITY_PROTOCOL_MACSEC, 1929 }, 1930 { 1931 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, 1932 .protocol = RTE_SECURITY_PROTOCOL_PDCP, 1933 }, 1934 { 1935 .action = RTE_SECURITY_ACTION_TYPE_NONE, 1936 }, 1937 }; 1938 1939 mock_capabilities_get_exp.device = NULL; 1940 mock_capabilities_get_exp.ret = capabilities; 1941 1942 const struct rte_security_capability *ret; 1943 ret = rte_security_capability_get(&ut_params->ctx, &idx); 1944 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capability_get, 1945 ret, NULL, "%p"); 1946 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 1); 1947 1948 return TEST_SUCCESS; 1949 } 1950 1951 /** 1952 * Test execution of rte_security_capability_get when macsec protocol 1953 * is searched and capabilities table contain proper entry. 1954 * However macsec records search is not supported in rte_security. 1955 */ 1956 static int 1957 test_capability_get_no_support_for_macsec(void) 1958 { 1959 struct security_unittest_params *ut_params = &unittest_params; 1960 struct rte_security_capability_idx idx = { 1961 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, 1962 .protocol = RTE_SECURITY_PROTOCOL_MACSEC, 1963 }; 1964 struct rte_security_capability capabilities[] = { 1965 { 1966 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, 1967 .protocol = RTE_SECURITY_PROTOCOL_MACSEC, 1968 }, 1969 { 1970 .action = RTE_SECURITY_ACTION_TYPE_NONE, 1971 }, 1972 }; 1973 1974 mock_capabilities_get_exp.device = NULL; 1975 mock_capabilities_get_exp.ret = capabilities; 1976 1977 const struct rte_security_capability *ret; 1978 ret = rte_security_capability_get(&ut_params->ctx, &idx); 1979 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capability_get, 1980 ret, NULL, "%p"); 1981 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 1); 1982 1983 return TEST_SUCCESS; 1984 } 1985 1986 /** 1987 * Test execution of rte_security_capability_get when capabilities table 1988 * does not contain entry with matching ipsec proto field 1989 */ 1990 static int 1991 test_capability_get_ipsec_mismatch_proto(void) 1992 { 1993 struct security_unittest_params *ut_params = &unittest_params; 1994 struct rte_security_capability_idx idx = { 1995 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, 1996 .protocol = RTE_SECURITY_PROTOCOL_IPSEC, 1997 .ipsec = { 1998 .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP, 1999 }, 2000 }; 2001 struct rte_security_capability capabilities[] = { 2002 { 2003 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, 2004 .protocol = RTE_SECURITY_PROTOCOL_IPSEC, 2005 .ipsec = { 2006 .proto = RTE_SECURITY_IPSEC_SA_PROTO_AH, 2007 }, 2008 }, 2009 { 2010 .action = RTE_SECURITY_ACTION_TYPE_NONE, 2011 }, 2012 }; 2013 2014 mock_capabilities_get_exp.device = NULL; 2015 mock_capabilities_get_exp.ret = capabilities; 2016 2017 const struct rte_security_capability *ret; 2018 ret = rte_security_capability_get(&ut_params->ctx, &idx); 2019 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capability_get, 2020 ret, NULL, "%p"); 2021 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 1); 2022 2023 return TEST_SUCCESS; 2024 } 2025 2026 /** 2027 * Test execution of rte_security_capability_get when capabilities table 2028 * does not contain entry with matching ipsec mode field 2029 */ 2030 static int 2031 test_capability_get_ipsec_mismatch_mode(void) 2032 { 2033 struct security_unittest_params *ut_params = &unittest_params; 2034 struct rte_security_capability_idx idx = { 2035 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, 2036 .protocol = RTE_SECURITY_PROTOCOL_IPSEC, 2037 .ipsec = { 2038 .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP, 2039 .mode = RTE_SECURITY_IPSEC_SA_MODE_TRANSPORT, 2040 }, 2041 }; 2042 struct rte_security_capability capabilities[] = { 2043 { 2044 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, 2045 .protocol = RTE_SECURITY_PROTOCOL_IPSEC, 2046 .ipsec = { 2047 .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP, 2048 .mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL, 2049 }, 2050 }, 2051 { 2052 .action = RTE_SECURITY_ACTION_TYPE_NONE, 2053 }, 2054 }; 2055 2056 mock_capabilities_get_exp.device = NULL; 2057 mock_capabilities_get_exp.ret = capabilities; 2058 2059 const struct rte_security_capability *ret; 2060 ret = rte_security_capability_get(&ut_params->ctx, &idx); 2061 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capability_get, 2062 ret, NULL, "%p"); 2063 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 1); 2064 2065 return TEST_SUCCESS; 2066 } 2067 2068 /** 2069 * Test execution of rte_security_capability_get when capabilities table 2070 * does not contain entry with matching ipsec direction field 2071 */ 2072 static int 2073 test_capability_get_ipsec_mismatch_dir(void) 2074 { 2075 struct security_unittest_params *ut_params = &unittest_params; 2076 struct rte_security_capability_idx idx = { 2077 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, 2078 .protocol = RTE_SECURITY_PROTOCOL_IPSEC, 2079 .ipsec = { 2080 .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP, 2081 .mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL, 2082 .direction = RTE_SECURITY_IPSEC_SA_DIR_EGRESS, 2083 }, 2084 }; 2085 struct rte_security_capability capabilities[] = { 2086 { 2087 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, 2088 .protocol = RTE_SECURITY_PROTOCOL_IPSEC, 2089 .ipsec = { 2090 .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP, 2091 .mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL, 2092 .direction = RTE_SECURITY_IPSEC_SA_DIR_INGRESS, 2093 }, 2094 }, 2095 { 2096 .action = RTE_SECURITY_ACTION_TYPE_NONE, 2097 }, 2098 }; 2099 2100 mock_capabilities_get_exp.device = NULL; 2101 mock_capabilities_get_exp.ret = capabilities; 2102 2103 const struct rte_security_capability *ret; 2104 ret = rte_security_capability_get(&ut_params->ctx, &idx); 2105 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capability_get, 2106 ret, NULL, "%p"); 2107 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 1); 2108 2109 return TEST_SUCCESS; 2110 } 2111 2112 /** 2113 * Test execution of rte_security_capability_get when capabilities table 2114 * contains matching ipsec entry 2115 */ 2116 static int 2117 test_capability_get_ipsec_match(void) 2118 { 2119 struct security_unittest_params *ut_params = &unittest_params; 2120 struct rte_security_capability_idx idx = { 2121 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, 2122 .protocol = RTE_SECURITY_PROTOCOL_IPSEC, 2123 .ipsec = { 2124 .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP, 2125 .mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL, 2126 .direction = RTE_SECURITY_IPSEC_SA_DIR_INGRESS, 2127 }, 2128 }; 2129 struct rte_security_capability capabilities[] = { 2130 { 2131 .action = RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO, 2132 }, 2133 { 2134 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, 2135 .protocol = RTE_SECURITY_PROTOCOL_IPSEC, 2136 .ipsec = { 2137 .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP, 2138 .mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL, 2139 .direction = RTE_SECURITY_IPSEC_SA_DIR_INGRESS, 2140 }, 2141 }, 2142 { 2143 .action = RTE_SECURITY_ACTION_TYPE_NONE, 2144 }, 2145 }; 2146 2147 mock_capabilities_get_exp.device = NULL; 2148 mock_capabilities_get_exp.ret = capabilities; 2149 2150 const struct rte_security_capability *ret; 2151 ret = rte_security_capability_get(&ut_params->ctx, &idx); 2152 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capability_get, 2153 ret, &capabilities[1], "%p"); 2154 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 1); 2155 2156 return TEST_SUCCESS; 2157 } 2158 2159 /** 2160 * Test execution of rte_security_capability_get when capabilities table 2161 * does not contain entry with matching pdcp domain field 2162 */ 2163 static int 2164 test_capability_get_pdcp_mismatch_domain(void) 2165 { 2166 struct security_unittest_params *ut_params = &unittest_params; 2167 struct rte_security_capability_idx idx = { 2168 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, 2169 .protocol = RTE_SECURITY_PROTOCOL_PDCP, 2170 .pdcp = { 2171 .domain = RTE_SECURITY_PDCP_MODE_CONTROL, 2172 }, 2173 }; 2174 struct rte_security_capability capabilities[] = { 2175 { 2176 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, 2177 .protocol = RTE_SECURITY_PROTOCOL_PDCP, 2178 .pdcp = { 2179 .domain = RTE_SECURITY_PDCP_MODE_DATA, 2180 }, 2181 }, 2182 { 2183 .action = RTE_SECURITY_ACTION_TYPE_NONE, 2184 }, 2185 }; 2186 2187 mock_capabilities_get_exp.device = NULL; 2188 mock_capabilities_get_exp.ret = capabilities; 2189 2190 const struct rte_security_capability *ret; 2191 ret = rte_security_capability_get(&ut_params->ctx, &idx); 2192 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capability_get, 2193 ret, NULL, "%p"); 2194 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 1); 2195 2196 return TEST_SUCCESS; 2197 } 2198 2199 /** 2200 * Test execution of rte_security_capability_get when capabilities table 2201 * contains matching pdcp entry 2202 */ 2203 static int 2204 test_capability_get_pdcp_match(void) 2205 { 2206 struct security_unittest_params *ut_params = &unittest_params; 2207 struct rte_security_capability_idx idx = { 2208 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, 2209 .protocol = RTE_SECURITY_PROTOCOL_PDCP, 2210 .pdcp = { 2211 .domain = RTE_SECURITY_PDCP_MODE_CONTROL, 2212 }, 2213 }; 2214 struct rte_security_capability capabilities[] = { 2215 { 2216 .action = RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO, 2217 }, 2218 { 2219 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, 2220 .protocol = RTE_SECURITY_PROTOCOL_PDCP, 2221 .pdcp = { 2222 .domain = RTE_SECURITY_PDCP_MODE_CONTROL, 2223 }, 2224 }, 2225 { 2226 .action = RTE_SECURITY_ACTION_TYPE_NONE, 2227 }, 2228 }; 2229 2230 mock_capabilities_get_exp.device = NULL; 2231 mock_capabilities_get_exp.ret = capabilities; 2232 2233 const struct rte_security_capability *ret; 2234 ret = rte_security_capability_get(&ut_params->ctx, &idx); 2235 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capability_get, 2236 ret, &capabilities[1], "%p"); 2237 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 1); 2238 2239 return TEST_SUCCESS; 2240 } 2241 2242 /** 2243 * Test execution of rte_security_capability_get when capabilities table 2244 * does not contain entry with matching DOCSIS direction field 2245 */ 2246 static int 2247 test_capability_get_docsis_mismatch_direction(void) 2248 { 2249 struct security_unittest_params *ut_params = &unittest_params; 2250 struct rte_security_capability_idx idx = { 2251 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, 2252 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS, 2253 .docsis = { 2254 .direction = RTE_SECURITY_DOCSIS_DOWNLINK 2255 }, 2256 }; 2257 struct rte_security_capability capabilities[] = { 2258 { 2259 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, 2260 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS, 2261 .docsis = { 2262 .direction = RTE_SECURITY_DOCSIS_UPLINK 2263 }, 2264 }, 2265 { 2266 .action = RTE_SECURITY_ACTION_TYPE_NONE, 2267 }, 2268 }; 2269 2270 mock_capabilities_get_exp.device = NULL; 2271 mock_capabilities_get_exp.ret = capabilities; 2272 2273 const struct rte_security_capability *ret; 2274 ret = rte_security_capability_get(&ut_params->ctx, &idx); 2275 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capability_get, 2276 ret, NULL, "%p"); 2277 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 1); 2278 2279 return TEST_SUCCESS; 2280 } 2281 2282 /** 2283 * Test execution of rte_security_capability_get when capabilities table 2284 * contains matching DOCSIS entry 2285 */ 2286 static int 2287 test_capability_get_docsis_match(void) 2288 { 2289 struct security_unittest_params *ut_params = &unittest_params; 2290 struct rte_security_capability_idx idx = { 2291 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, 2292 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS, 2293 .docsis = { 2294 .direction = RTE_SECURITY_DOCSIS_UPLINK 2295 }, 2296 }; 2297 struct rte_security_capability capabilities[] = { 2298 { 2299 .action = RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO, 2300 }, 2301 { 2302 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, 2303 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS, 2304 .docsis = { 2305 .direction = RTE_SECURITY_DOCSIS_UPLINK 2306 }, 2307 }, 2308 { 2309 .action = RTE_SECURITY_ACTION_TYPE_NONE, 2310 }, 2311 }; 2312 2313 mock_capabilities_get_exp.device = NULL; 2314 mock_capabilities_get_exp.ret = capabilities; 2315 2316 const struct rte_security_capability *ret; 2317 ret = rte_security_capability_get(&ut_params->ctx, &idx); 2318 TEST_ASSERT_MOCK_FUNCTION_CALL_RET(rte_security_capability_get, 2319 ret, &capabilities[1], "%p"); 2320 TEST_ASSERT_MOCK_CALLS(mock_capabilities_get_exp, 1); 2321 2322 return TEST_SUCCESS; 2323 } 2324 2325 /** 2326 * Declaration of testcases 2327 */ 2328 static struct unit_test_suite security_testsuite = { 2329 .suite_name = "generic security", 2330 .setup = testsuite_setup, 2331 .teardown = testsuite_teardown, 2332 .unit_test_cases = { 2333 TEST_CASE_ST(ut_setup, ut_teardown, 2334 test_session_create_inv_context), 2335 TEST_CASE_ST(ut_setup, ut_teardown, 2336 test_session_create_inv_context_ops), 2337 TEST_CASE_ST(ut_setup, ut_teardown, 2338 test_session_create_inv_context_ops_fun), 2339 TEST_CASE_ST(ut_setup, ut_teardown, 2340 test_session_create_inv_configuration), 2341 TEST_CASE_ST(ut_setup, ut_teardown, 2342 test_session_create_inv_mempool), 2343 TEST_CASE_ST(ut_setup, ut_teardown, 2344 test_session_create_inv_sess_priv_mempool), 2345 TEST_CASE_ST(ut_setup, ut_teardown, 2346 test_session_create_mempool_empty), 2347 TEST_CASE_ST(ut_setup, ut_teardown, 2348 test_session_create_ops_failure), 2349 TEST_CASE_ST(ut_setup, ut_teardown, 2350 test_session_create_success), 2351 2352 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2353 test_session_update_inv_context), 2354 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2355 test_session_update_inv_context_ops), 2356 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2357 test_session_update_inv_context_ops_fun), 2358 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2359 test_session_update_inv_configuration), 2360 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2361 test_session_update_inv_session), 2362 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2363 test_session_update_ops_failure), 2364 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2365 test_session_update_success), 2366 2367 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2368 test_session_get_size_inv_context), 2369 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2370 test_session_get_size_inv_context_ops), 2371 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2372 test_session_get_size_inv_context_ops_fun), 2373 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2374 test_session_get_size_ops_failure), 2375 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2376 test_session_get_size_success), 2377 2378 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2379 test_session_stats_get_inv_context), 2380 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2381 test_session_stats_get_inv_context_ops), 2382 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2383 test_session_stats_get_inv_context_ops_fun), 2384 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2385 test_session_stats_get_inv_stats), 2386 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2387 test_session_stats_get_ops_failure), 2388 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2389 test_session_stats_get_success), 2390 2391 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2392 test_session_destroy_inv_context), 2393 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2394 test_session_destroy_inv_context_ops), 2395 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2396 test_session_destroy_inv_context_ops_fun), 2397 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2398 test_session_destroy_inv_session), 2399 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2400 test_session_destroy_ops_failure), 2401 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2402 test_session_destroy_success), 2403 2404 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2405 test_set_pkt_metadata_inv_context), 2406 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2407 test_set_pkt_metadata_inv_context_ops), 2408 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2409 test_set_pkt_metadata_inv_context_ops_fun), 2410 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2411 test_set_pkt_metadata_inv_session), 2412 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2413 test_set_pkt_metadata_ops_failure), 2414 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2415 test_set_pkt_metadata_success), 2416 2417 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2418 test_capabilities_get_inv_context), 2419 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2420 test_capabilities_get_inv_context_ops), 2421 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2422 test_capabilities_get_inv_context_ops_fun), 2423 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2424 test_capabilities_get_ops_failure), 2425 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2426 test_capabilities_get_success), 2427 2428 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2429 test_capability_get_inv_context), 2430 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2431 test_capability_get_inv_context_ops), 2432 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2433 test_capability_get_inv_context_ops_fun), 2434 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2435 test_capability_get_inv_idx), 2436 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2437 test_capability_get_ops_failure), 2438 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2439 test_capability_get_empty_table), 2440 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2441 test_capability_get_no_matching_action), 2442 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2443 test_capability_get_no_matching_protocol), 2444 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2445 test_capability_get_no_support_for_macsec), 2446 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2447 test_capability_get_ipsec_mismatch_proto), 2448 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2449 test_capability_get_ipsec_mismatch_mode), 2450 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2451 test_capability_get_ipsec_mismatch_dir), 2452 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2453 test_capability_get_ipsec_match), 2454 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2455 test_capability_get_pdcp_mismatch_domain), 2456 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2457 test_capability_get_pdcp_match), 2458 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2459 test_capability_get_docsis_mismatch_direction), 2460 TEST_CASE_ST(ut_setup_with_session, ut_teardown, 2461 test_capability_get_docsis_match), 2462 2463 TEST_CASES_END() /**< NULL terminate unit test array */ 2464 } 2465 }; 2466 2467 static int 2468 test_security(void) 2469 { 2470 rte_log_set_global_level(RTE_LOG_DEBUG); 2471 rte_log_set_level(RTE_LOGTYPE_EAL, RTE_LOG_DEBUG); 2472 2473 return unit_test_suite_runner(&security_testsuite); 2474 } 2475 2476 REGISTER_TEST_COMMAND(security_autotest, test_security); 2477