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