From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D2E49A0548; Fri, 2 Apr 2021 16:25:27 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 995F5141036; Fri, 2 Apr 2021 16:25:03 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id 6FAFC141033 for ; Fri, 2 Apr 2021 16:25:01 +0200 (CEST) IronPort-SDR: jFcXR3EBMwFos1s1uV08vOC8JJCOfngfLADSQsBzewzXq4LKhgOoXFE+6yq2Qu3TPiRCaI+ib2 gKQ6G267kqfw== X-IronPort-AV: E=McAfee;i="6000,8403,9942"; a="192512497" X-IronPort-AV: E=Sophos;i="5.81,300,1610438400"; d="scan'208";a="192512497" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2021 07:25:00 -0700 IronPort-SDR: 8UAv5lMdTDQ9QKXHWA5b+fg+b2Cl0woTG2nm3Z2UDCw/OAw0yOtyjwNILSAySjxAKUfR1EcdR2 7YTlOq5zzTYw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,300,1610438400"; d="scan'208";a="413199645" Received: from silpixa00400355.ir.intel.com (HELO silpixa00400355.ger.corp.intel.com) ([10.237.223.148]) by fmsmga008.fm.intel.com with ESMTP; 02 Apr 2021 07:24:57 -0700 From: Ciara Power To: dev@dpdk.org Cc: declan.doherty@intel.com, gakhil@marvell.com, aconole@redhat.com, hemant.agrawal@nxp.com, anoobj@marvell.com, ruifeng.wang@arm.com, asomalap@amd.com, ajit.khaparde@broadcom.com, g.singh@nxp.com, Ciara Power Date: Fri, 2 Apr 2021 14:24:24 +0000 Message-Id: <20210402142424.1353789-7-ciara.power@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210402142424.1353789-1-ciara.power@intel.com> References: <20210402142424.1353789-1-ciara.power@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 6/6] test/crypto: dynamically build blockcipher suite X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" In the existing implementation, the blockcipher test cases are being run and reported as one test case per type, even though multiple test cases are hidden in each. For example, "test_AES_chain_all" runs 46 test cases. Each blockcipher type should have a testsuite instead. The blockcipher testsuite is dynamically built, depending on the blockcipher type chosen. The testcase struct is modified to allow running a testcase with data, which is used for data required when running each blockcipher testcase. The blockcipher testsuites are added dynamically to parent testsuites as sub-testsuites where needed. Signed-off-by: Ciara Power --- v2: - Squashed release note patch into this patch. - Modified the build blockcipher suite function to use the testcases flexible array, and return a testsuite pointer. --- app/test/test.c | 11 +- app/test/test.h | 16 +- app/test/test_cryptodev.c | 507 +++++++++++++++---------- app/test/test_cryptodev_blockcipher.c | 125 +++--- app/test/test_cryptodev_blockcipher.h | 12 +- doc/guides/rel_notes/release_21_05.rst | 5 + 6 files changed, 407 insertions(+), 269 deletions(-) diff --git a/app/test/test.c b/app/test/test.c index e401de0fdf..6151dbd55b 100644 --- a/app/test/test.c +++ b/app/test/test.c @@ -38,7 +38,8 @@ extern cmdline_parse_ctx_t main_ctx[]; #define FOR_EACH_SUITE_TESTCASE(iter, suite, case) \ for (iter = 0, case = suite->unit_test_cases[0]; \ - suite->unit_test_cases[iter].testcase; \ + suite->unit_test_cases[iter].testcase || \ + suite->unit_test_cases[iter].testcase_with_data; \ iter++, case = suite->unit_test_cases[iter]) #define FOR_EACH_SUITE_TESTSUITE(iter, suite, sub_ts) \ @@ -328,7 +329,13 @@ unit_test_suite_runner(struct unit_test_suite *suite) if (test_success == TEST_SUCCESS) { /* run the test case */ - test_success = tc.testcase(); + if (tc.testcase) + test_success = tc.testcase(); + else if (tc.testcase_with_data) + test_success = tc.testcase_with_data(tc.data); + else + test_success = -ENOTSUP; + if (test_success == TEST_SUCCESS) suite->succeeded++; else if (test_success == TEST_SKIPPED) diff --git a/app/test/test.h b/app/test/test.h index e9bfc365e4..3ec68cada0 100644 --- a/app/test/test.h +++ b/app/test/test.h @@ -108,24 +108,28 @@ struct unit_test_case { int (*setup)(void); void (*teardown)(void); int (*testcase)(void); + int (*testcase_with_data)(const void *data); const char *name; unsigned enabled; + const void *data; }; -#define TEST_CASE(fn) { NULL, NULL, fn, #fn, 1 } +#define TEST_CASE(fn) { NULL, NULL, fn, NULL, #fn, 1, NULL } -#define TEST_CASE_NAMED(name, fn) { NULL, NULL, fn, name, 1 } +#define TEST_CASE_NAMED(name, fn) { NULL, NULL, fn, NULL, name, 1, NULL } #define TEST_CASE_ST(setup, teardown, testcase) \ - { setup, teardown, testcase, #testcase, 1 } + { setup, teardown, testcase, NULL, #testcase, 1, NULL } +#define TEST_CASE_WITH_DATA(setup, teardown, testcase, data) \ + { setup, teardown, NULL, testcase, #testcase, 1, data } -#define TEST_CASE_DISABLED(fn) { NULL, NULL, fn, #fn, 0 } +#define TEST_CASE_DISABLED(fn) { NULL, NULL, fn, NULL, #fn, 0, NULL } #define TEST_CASE_ST_DISABLED(setup, teardown, testcase) \ - { setup, teardown, testcase, #testcase, 0 } + { setup, teardown, testcase, NULL, #testcase, 0, NULL } -#define TEST_CASES_END() { NULL, NULL, NULL, NULL, 0 } +#define TEST_CASES_END() { NULL, NULL, NULL, NULL, NULL, 0, NULL } static inline void debug_hexdump(FILE *file, const char *title, const void *buf, size_t len) diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c index ea751da432..86569d7a3d 100644 --- a/app/test/test_cryptodev.c +++ b/app/test/test_cryptodev.c @@ -103,6 +103,15 @@ struct crypto_unittest_params { for (j = 0; j < num_child_ts; index++, j++) \ parent_ts.unit_test_suites[index] = child_ts[j] +#define ADD_BLOCKCIPHER_TESTSUITE(index, parent_ts, blk_types, num_blk_types) \ + for (j = 0; j < num_blk_types; index++, j++) \ + parent_ts.unit_test_suites[index] = \ + build_blockcipher_test_suite(blk_types[j]) + +#define FREE_BLOCKCIPHER_TESTSUITE(index, parent_ts, num_blk_types) \ + for (j = index; j < index + num_blk_types; j++) \ + free_blockcipher_test_suite(parent_ts.unit_test_suites[j]) + /* * Forward declarations. */ @@ -1921,80 +1930,6 @@ test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess, return TEST_SUCCESS; } -static int -test_blockcipher(enum blockcipher_test_type test_type) -{ - struct crypto_testsuite_params *ts_params = &testsuite_params; - int status; - - status = test_blockcipher_all_tests(ts_params->mbuf_pool, - ts_params->op_mpool, - ts_params->session_mpool, ts_params->session_priv_mpool, - ts_params->valid_devs[0], - test_type); - - if (status == -ENOTSUP) - return status; - - TEST_ASSERT_EQUAL(status, 0, "Test failed"); - - return TEST_SUCCESS; -} - -static int -test_AES_cipheronly_all(void) -{ - return test_blockcipher(BLKCIPHER_AES_CIPHERONLY_TYPE); -} - -static int -test_AES_docsis_all(void) -{ - /* Data-path service does not support DOCSIS yet */ - if (global_api_test_type == CRYPTODEV_RAW_API_TEST) - return -ENOTSUP; - return test_blockcipher(BLKCIPHER_AES_DOCSIS_TYPE); -} - -static int -test_DES_docsis_all(void) -{ - /* Data-path service does not support DOCSIS yet */ - if (global_api_test_type == CRYPTODEV_RAW_API_TEST) - return -ENOTSUP; - return test_blockcipher(BLKCIPHER_DES_DOCSIS_TYPE); -} - -static int -test_DES_cipheronly_all(void) -{ - return test_blockcipher(BLKCIPHER_DES_CIPHERONLY_TYPE); -} - -static int -test_authonly_all(void) -{ - return test_blockcipher(BLKCIPHER_AUTHONLY_TYPE); -} - -static int -test_AES_chain_all(void) -{ - return test_blockcipher(BLKCIPHER_AES_CHAIN_TYPE); -} - -static int -test_3DES_chain_all(void) -{ - return test_blockcipher(BLKCIPHER_3DES_CHAIN_TYPE); -} - -static int -test_3DES_cipheronly_all(void) -{ - return test_blockcipher(BLKCIPHER_3DES_CIPHERONLY_TYPE); -} - /* ***** SNOW 3G Tests ***** */ static int create_wireless_algo_hash_session(uint8_t dev_id, @@ -13362,14 +13297,6 @@ static struct unit_test_suite cryptodev_testsuite = { test_queue_pair_descriptor_setup), TEST_CASE_ST(ut_setup, ut_teardown, test_device_configure_invalid_queue_pair_ids), - TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all), - TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all), - TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all), - TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all), - TEST_CASE_ST(ut_setup, ut_teardown, test_DES_cipheronly_all), - TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_all), - TEST_CASE_ST(ut_setup, ut_teardown, test_DES_docsis_all), - TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all), TEST_CASE_ST(ut_setup, ut_teardown, test_stats), #ifdef RTE_LIB_SECURITY TEST_CASE_ST(ut_setup_security, ut_teardown, @@ -14086,15 +14013,6 @@ static struct unit_test_suite cryptodev_mixed_cipher_hash_testsuite = { } }; -static struct unit_test_suite cryptodev_virtio_sub_testsuite = { - .suite_name = "Crypto VIRTIO Unit Test Suite", - .unit_test_cases = { - TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all), - - TEST_CASES_END() /**< NULL terminate unit test array */ - } -}; - static struct unit_test_suite cryptodev_caam_jr_sub_testsuite = { .suite_name = "Crypto CAAM JR Sub Unit Test Suite", .unit_test_cases = { @@ -14102,38 +14020,6 @@ static struct unit_test_suite cryptodev_caam_jr_sub_testsuite = { test_device_configure_invalid_dev_id), TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session), - TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all), - TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all), - TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all), - TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all), - TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all), - - TEST_CASES_END() /**< NULL terminate unit test array */ - } -}; - -static struct unit_test_suite cryptodev_mrvl_sub_testsuite = { - .suite_name = "Crypto Device Marvell Component Test Suite", - .unit_test_cases = { - TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all), - TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all), - TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all), - TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all), - TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all), - - TEST_CASES_END() /**< NULL terminate unit test array */ - } -}; - -static struct unit_test_suite cryptodev_ccp_sub_testsuite = { - .suite_name = "Crypto Device CCP Unit Test Suite", - .unit_test_cases = { - TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all), - TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all), - TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all), - TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all), - TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all), - TEST_CASES_END() /**< NULL terminate unit test array */ } }; @@ -14141,7 +14027,16 @@ static struct unit_test_suite cryptodev_ccp_sub_testsuite = { static int test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/) { - uint8_t ret, j, i = 0; + uint8_t ret, j, i = 0, blk_start_idx = 0; + const enum blockcipher_test_type blk_suites[] = { + BLKCIPHER_AES_CHAIN_TYPE, + BLKCIPHER_AES_CIPHERONLY_TYPE, + BLKCIPHER_AES_DOCSIS_TYPE, + BLKCIPHER_3DES_CHAIN_TYPE, + BLKCIPHER_3DES_CIPHERONLY_TYPE, + BLKCIPHER_DES_CIPHERONLY_TYPE, + BLKCIPHER_DES_DOCSIS_TYPE, + BLKCIPHER_AUTHONLY_TYPE}; struct unit_test_suite *static_suites[] = { &cryptodev_multi_session_testsuite, &cryptodev_null_testsuite, @@ -14175,11 +14070,13 @@ test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/) return TEST_SKIPPED; } ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) * - RTE_DIM(static_suites)); + (RTE_DIM(blk_suites) + RTE_DIM(static_suites))); + ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites)); ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites)); ret = unit_test_suite_runner(&ts); + FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites)); free(ts.unit_test_suites); return ret; } @@ -14187,9 +14084,11 @@ test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/) static int test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/) { - uint8_t ret, j, i = 0; + uint8_t ret, j, i = 0, blk_start_idx = 0; + const enum blockcipher_test_type blk_suites[] = { + BLKCIPHER_AES_CIPHERONLY_TYPE + }; struct unit_test_suite *static_suites[] = { - &cryptodev_virtio_sub_testsuite, &end_testsuite }; struct unit_test_suite ts = { @@ -14206,11 +14105,13 @@ test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/) return TEST_FAILED; } ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) * - RTE_DIM(static_suites)); + (RTE_DIM(blk_suites) + RTE_DIM(static_suites))); + ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites)); ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites)); ret = unit_test_suite_runner(&ts); + FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites)); free(ts.unit_test_suites); return ret; } @@ -14218,7 +14119,16 @@ test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/) static int test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/) { - uint8_t ret, j, i = 0; + uint8_t ret, j, i = 0, blk_start_idx = 0; + const enum blockcipher_test_type blk_suites[] = { + BLKCIPHER_AES_CHAIN_TYPE, + BLKCIPHER_AES_CIPHERONLY_TYPE, + BLKCIPHER_AES_DOCSIS_TYPE, + BLKCIPHER_3DES_CHAIN_TYPE, + BLKCIPHER_3DES_CIPHERONLY_TYPE, + BLKCIPHER_DES_CIPHERONLY_TYPE, + BLKCIPHER_DES_DOCSIS_TYPE, + BLKCIPHER_AUTHONLY_TYPE}; struct unit_test_suite *static_suites[] = { &cryptodev_multi_session_testsuite, &cryptodev_null_testsuite, @@ -14253,11 +14163,13 @@ test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/) } ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) * - RTE_DIM(static_suites)); + (RTE_DIM(blk_suites) + RTE_DIM(static_suites))); + ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites)); ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites)); ret = unit_test_suite_runner(&ts); + FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites)); free(ts.unit_test_suites); return ret; } @@ -14266,8 +14178,17 @@ static int test_cryptodev_cpu_aesni_mb(void) { int32_t rc; - uint8_t j, i = 0; + uint8_t j, i = 0, blk_start_idx = 0; enum rte_security_session_action_type at; + const enum blockcipher_test_type blk_suites[] = { + BLKCIPHER_AES_CHAIN_TYPE, + BLKCIPHER_AES_CIPHERONLY_TYPE, + BLKCIPHER_AES_DOCSIS_TYPE, + BLKCIPHER_3DES_CHAIN_TYPE, + BLKCIPHER_3DES_CIPHERONLY_TYPE, + BLKCIPHER_DES_CIPHERONLY_TYPE, + BLKCIPHER_DES_DOCSIS_TYPE, + BLKCIPHER_AUTHONLY_TYPE}; struct unit_test_suite *static_suites[] = { &cryptodev_multi_session_testsuite, &cryptodev_null_testsuite, @@ -14302,13 +14223,15 @@ test_cryptodev_cpu_aesni_mb(void) } ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) * - RTE_DIM(static_suites)); + (RTE_DIM(blk_suites) + RTE_DIM(static_suites))); + ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites)); ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites)); at = gbl_action_type; gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO; rc = unit_test_suite_runner(&ts); + FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites)); free(ts.unit_test_suites); gbl_action_type = at; return rc; @@ -14317,7 +14240,16 @@ test_cryptodev_cpu_aesni_mb(void) static int test_cryptodev_openssl(void) { - uint8_t ret, j, i = 0; + uint8_t ret, j, i = 0, blk_start_idx = 0; + const enum blockcipher_test_type blk_suites[] = { + BLKCIPHER_AES_CHAIN_TYPE, + BLKCIPHER_AES_CIPHERONLY_TYPE, + BLKCIPHER_AES_DOCSIS_TYPE, + BLKCIPHER_3DES_CHAIN_TYPE, + BLKCIPHER_3DES_CIPHERONLY_TYPE, + BLKCIPHER_DES_CIPHERONLY_TYPE, + BLKCIPHER_DES_DOCSIS_TYPE, + BLKCIPHER_AUTHONLY_TYPE}; struct unit_test_suite *static_suites[] = { &cryptodev_multi_session_testsuite, &cryptodev_null_testsuite, @@ -14352,11 +14284,13 @@ test_cryptodev_openssl(void) } ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) * - RTE_DIM(static_suites)); + (RTE_DIM(blk_suites) + RTE_DIM(static_suites))); + ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites)); ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites)); ret = unit_test_suite_runner(&ts); + FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites)); free(ts.unit_test_suites); return ret; } @@ -14364,7 +14298,16 @@ test_cryptodev_openssl(void) static int test_cryptodev_aesni_gcm(void) { - uint8_t ret, j, i = 0; + uint8_t ret, j, i = 0, blk_start_idx = 0; + const enum blockcipher_test_type blk_suites[] = { + BLKCIPHER_AES_CHAIN_TYPE, + BLKCIPHER_AES_CIPHERONLY_TYPE, + BLKCIPHER_AES_DOCSIS_TYPE, + BLKCIPHER_3DES_CHAIN_TYPE, + BLKCIPHER_3DES_CIPHERONLY_TYPE, + BLKCIPHER_DES_CIPHERONLY_TYPE, + BLKCIPHER_DES_DOCSIS_TYPE, + BLKCIPHER_AUTHONLY_TYPE}; struct unit_test_suite *static_suites[] = { &cryptodev_multi_session_testsuite, &cryptodev_null_testsuite, @@ -14399,11 +14342,13 @@ test_cryptodev_aesni_gcm(void) } ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) * - RTE_DIM(static_suites)); + (RTE_DIM(blk_suites) + RTE_DIM(static_suites))); + ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites)); ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites)); ret = unit_test_suite_runner(&ts); + FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites)); free(ts.unit_test_suites); return ret; } @@ -14412,8 +14357,17 @@ static int test_cryptodev_cpu_aesni_gcm(void) { int32_t rc; - uint8_t j, i = 0; + uint8_t j, i = 0, blk_start_idx = 0; enum rte_security_session_action_type at; + const enum blockcipher_test_type blk_suites[] = { + BLKCIPHER_AES_CHAIN_TYPE, + BLKCIPHER_AES_CIPHERONLY_TYPE, + BLKCIPHER_AES_DOCSIS_TYPE, + BLKCIPHER_3DES_CHAIN_TYPE, + BLKCIPHER_3DES_CIPHERONLY_TYPE, + BLKCIPHER_DES_CIPHERONLY_TYPE, + BLKCIPHER_DES_DOCSIS_TYPE, + BLKCIPHER_AUTHONLY_TYPE}; struct unit_test_suite *static_suites[] = { &cryptodev_multi_session_testsuite, &cryptodev_null_testsuite, @@ -14448,13 +14402,15 @@ test_cryptodev_cpu_aesni_gcm(void) } ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) * - RTE_DIM(static_suites)); + (RTE_DIM(blk_suites) + RTE_DIM(static_suites))); + ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites)); ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites)); at = gbl_action_type; gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO; rc = unit_test_suite_runner(&ts); + FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites)); free(ts.unit_test_suites); gbl_action_type = at; return rc; @@ -14463,7 +14419,16 @@ test_cryptodev_cpu_aesni_gcm(void) static int test_cryptodev_null(void) { - uint8_t ret, j, i = 0; + uint8_t ret, j, i = 0, blk_start_idx = 0; + const enum blockcipher_test_type blk_suites[] = { + BLKCIPHER_AES_CHAIN_TYPE, + BLKCIPHER_AES_CIPHERONLY_TYPE, + BLKCIPHER_AES_DOCSIS_TYPE, + BLKCIPHER_3DES_CHAIN_TYPE, + BLKCIPHER_3DES_CIPHERONLY_TYPE, + BLKCIPHER_DES_CIPHERONLY_TYPE, + BLKCIPHER_DES_DOCSIS_TYPE, + BLKCIPHER_AUTHONLY_TYPE}; struct unit_test_suite *static_suites[] = { &cryptodev_multi_session_testsuite, &cryptodev_null_testsuite, @@ -14498,11 +14463,13 @@ test_cryptodev_null(void) } ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) * - RTE_DIM(static_suites)); + (RTE_DIM(blk_suites) + RTE_DIM(static_suites))); + ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites)); ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites)); ret = unit_test_suite_runner(&ts); + FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites)); free(ts.unit_test_suites); return ret; } @@ -14510,7 +14477,16 @@ test_cryptodev_null(void) static int test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/) { - uint8_t ret, j, i = 0; + uint8_t ret, j, i = 0, blk_start_idx = 0; + const enum blockcipher_test_type blk_suites[] = { + BLKCIPHER_AES_CHAIN_TYPE, + BLKCIPHER_AES_CIPHERONLY_TYPE, + BLKCIPHER_AES_DOCSIS_TYPE, + BLKCIPHER_3DES_CHAIN_TYPE, + BLKCIPHER_3DES_CIPHERONLY_TYPE, + BLKCIPHER_DES_CIPHERONLY_TYPE, + BLKCIPHER_DES_DOCSIS_TYPE, + BLKCIPHER_AUTHONLY_TYPE}; struct unit_test_suite *static_suites[] = { &cryptodev_multi_session_testsuite, &cryptodev_null_testsuite, @@ -14545,11 +14521,13 @@ test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/) } ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) * - RTE_DIM(static_suites)); + (RTE_DIM(blk_suites) + RTE_DIM(static_suites))); + ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites)); ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites)); ret = unit_test_suite_runner(&ts); + FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites)); free(ts.unit_test_suites); return ret; } @@ -14557,7 +14535,16 @@ test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/) static int test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/) { - uint8_t ret, j, i = 0; + uint8_t ret, j, i = 0, blk_start_idx = 0; + const enum blockcipher_test_type blk_suites[] = { + BLKCIPHER_AES_CHAIN_TYPE, + BLKCIPHER_AES_CIPHERONLY_TYPE, + BLKCIPHER_AES_DOCSIS_TYPE, + BLKCIPHER_3DES_CHAIN_TYPE, + BLKCIPHER_3DES_CIPHERONLY_TYPE, + BLKCIPHER_DES_CIPHERONLY_TYPE, + BLKCIPHER_DES_DOCSIS_TYPE, + BLKCIPHER_AUTHONLY_TYPE}; struct unit_test_suite *static_suites[] = { &cryptodev_multi_session_testsuite, &cryptodev_null_testsuite, @@ -14592,11 +14579,13 @@ test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/) } ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) * - RTE_DIM(static_suites)); + (RTE_DIM(blk_suites) + RTE_DIM(static_suites))); + ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites)); ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites)); ret = unit_test_suite_runner(&ts); + FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites)); free(ts.unit_test_suites); return ret; } @@ -14604,7 +14593,16 @@ test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/) static int test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/) { - uint8_t ret, j, i = 0; + uint8_t ret, j, i = 0, blk_start_idx = 0; + const enum blockcipher_test_type blk_suites[] = { + BLKCIPHER_AES_CHAIN_TYPE, + BLKCIPHER_AES_CIPHERONLY_TYPE, + BLKCIPHER_AES_DOCSIS_TYPE, + BLKCIPHER_3DES_CHAIN_TYPE, + BLKCIPHER_3DES_CIPHERONLY_TYPE, + BLKCIPHER_DES_CIPHERONLY_TYPE, + BLKCIPHER_DES_DOCSIS_TYPE, + BLKCIPHER_AUTHONLY_TYPE}; struct unit_test_suite *static_suites[] = { &cryptodev_multi_session_testsuite, &cryptodev_null_testsuite, @@ -14639,11 +14637,13 @@ test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/) } ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) * - RTE_DIM(static_suites)); + (RTE_DIM(blk_suites) + RTE_DIM(static_suites))); + ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites)); ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites)); ret = unit_test_suite_runner(&ts); + FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites)); free(ts.unit_test_suites); return ret; } @@ -14651,7 +14651,16 @@ test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/) static int test_cryptodev_armv8(void) { - uint8_t ret, j, i = 0; + uint8_t ret, j, i = 0, blk_start_idx = 0; + const enum blockcipher_test_type blk_suites[] = { + BLKCIPHER_AES_CHAIN_TYPE, + BLKCIPHER_AES_CIPHERONLY_TYPE, + BLKCIPHER_AES_DOCSIS_TYPE, + BLKCIPHER_3DES_CHAIN_TYPE, + BLKCIPHER_3DES_CIPHERONLY_TYPE, + BLKCIPHER_DES_CIPHERONLY_TYPE, + BLKCIPHER_DES_DOCSIS_TYPE, + BLKCIPHER_AUTHONLY_TYPE}; struct unit_test_suite *static_suites[] = { &cryptodev_multi_session_testsuite, &cryptodev_null_testsuite, @@ -14686,11 +14695,13 @@ test_cryptodev_armv8(void) } ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) * - RTE_DIM(static_suites)); + (RTE_DIM(blk_suites) + RTE_DIM(static_suites))); + ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites)); ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites)); ret = unit_test_suite_runner(&ts); + FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites)); free(ts.unit_test_suites); return ret; } @@ -14698,7 +14709,13 @@ test_cryptodev_armv8(void) static int test_cryptodev_mrvl(void) { - uint8_t ret, j, i = 0; + uint8_t ret, j, i = 0, blk_start_idx = 0; + const enum blockcipher_test_type blk_suites[] = { + BLKCIPHER_AES_CHAIN_TYPE, + BLKCIPHER_AES_CIPHERONLY_TYPE, + BLKCIPHER_3DES_CHAIN_TYPE, + BLKCIPHER_3DES_CIPHERONLY_TYPE, + BLKCIPHER_AUTHONLY_TYPE}; struct unit_test_suite *static_suites[] = { &cryptodev_multi_session_testsuite, &cryptodev_null_testsuite, @@ -14716,7 +14733,6 @@ test_cryptodev_mrvl(void) &cryptodev_mixed_cipher_hash_testsuite, &cryptodev_negative_hmac_sha1_testsuite, &cryptodev_testsuite, - &cryptodev_mrvl_sub_testsuite, &end_testsuite }; struct unit_test_suite ts = { @@ -14734,11 +14750,13 @@ test_cryptodev_mrvl(void) } ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) * - RTE_DIM(static_suites)); + (RTE_DIM(blk_suites) + RTE_DIM(static_suites))); + ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites)); ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites)); ret = unit_test_suite_runner(&ts); + FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites)); free(ts.unit_test_suites); return ret; } @@ -14748,54 +14766,31 @@ test_cryptodev_mrvl(void) static int test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/) { - uint8_t ret, j, i = 0; + uint8_t ret, sched_i, j, i = 0, blk_start_idx = 0; + const enum blockcipher_test_type blk_suites[] = { + BLKCIPHER_AES_CHAIN_TYPE, + BLKCIPHER_AES_CIPHERONLY_TYPE, + BLKCIPHER_AUTHONLY_TYPE + }; static struct unit_test_suite scheduler_multicore = { .suite_name = "Scheduler Multicore Unit Test Suite", .setup = scheduler_multicore_testsuite_setup, - .teardown = scheduler_mode_testsuite_teardown, - .unit_test_cases = { - TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all), - TEST_CASE_ST(ut_setup, ut_teardown, - test_AES_cipheronly_all), - TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all), - TEST_CASES_END() - } + .teardown = scheduler_mode_testsuite_teardown }; static struct unit_test_suite scheduler_round_robin = { .suite_name = "Scheduler Round Robin Unit Test Suite", .setup = scheduler_roundrobin_testsuite_setup, - .teardown = scheduler_mode_testsuite_teardown, - .unit_test_cases = { - TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all), - TEST_CASE_ST(ut_setup, ut_teardown, - test_AES_cipheronly_all), - TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all), - TEST_CASES_END() - } + .teardown = scheduler_mode_testsuite_teardown }; static struct unit_test_suite scheduler_failover = { .suite_name = "Scheduler Failover Unit Test Suite", .setup = scheduler_failover_testsuite_setup, - .teardown = scheduler_mode_testsuite_teardown, - .unit_test_cases = { - TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all), - TEST_CASE_ST(ut_setup, ut_teardown, - test_AES_cipheronly_all), - TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all), - TEST_CASES_END() - } + .teardown = scheduler_mode_testsuite_teardown }; static struct unit_test_suite scheduler_pkt_size_distr = { .suite_name = "Scheduler Pkt Size Distr Unit Test Suite", .setup = scheduler_pkt_size_distr_testsuite_setup, - .teardown = scheduler_mode_testsuite_teardown, - .unit_test_cases = { - TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all), - TEST_CASE_ST(ut_setup, ut_teardown, - test_AES_cipheronly_all), - TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all), - TEST_CASES_END() - } + .teardown = scheduler_mode_testsuite_teardown }; struct unit_test_suite *sched_mode_suites[] = { &scheduler_multicore, @@ -14840,6 +14835,16 @@ test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/) return TEST_SKIPPED; } + for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) { + uint8_t blk_i = 0; + sched_mode_suites[sched_i]->unit_test_suites = malloc(sizeof + (struct unit_test_suite *) * + (RTE_DIM(blk_suites) + 1)); + ADD_BLOCKCIPHER_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]), + blk_suites, RTE_DIM(blk_suites)); + sched_mode_suites[sched_i]->unit_test_suites[blk_i] = &end_testsuite; + } + ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) * (RTE_DIM(static_suites) + RTE_DIM(sched_mode_suites))); ADD_STATIC_TESTSUITE(i, ts, sched_mode_suites, @@ -14847,6 +14852,12 @@ test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/) ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites)); ret = unit_test_suite_runner(&ts); + for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) { + FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, + (*sched_mode_suites[sched_i]), + RTE_DIM(blk_suites)); + free(sched_mode_suites[sched_i]->unit_test_suites); + } free(ts.unit_test_suites); return ret; } @@ -14858,7 +14869,16 @@ REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler); static int test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/) { - uint8_t ret, j, i = 0; + uint8_t ret, j, i = 0, blk_start_idx = 0; + const enum blockcipher_test_type blk_suites[] = { + BLKCIPHER_AES_CHAIN_TYPE, + BLKCIPHER_AES_CIPHERONLY_TYPE, + BLKCIPHER_AES_DOCSIS_TYPE, + BLKCIPHER_3DES_CHAIN_TYPE, + BLKCIPHER_3DES_CIPHERONLY_TYPE, + BLKCIPHER_DES_CIPHERONLY_TYPE, + BLKCIPHER_DES_DOCSIS_TYPE, + BLKCIPHER_AUTHONLY_TYPE}; struct unit_test_suite *static_suites[] = { &cryptodev_multi_session_testsuite, &cryptodev_null_testsuite, @@ -14893,11 +14913,13 @@ test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/) } ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) * - RTE_DIM(static_suites)); + (RTE_DIM(blk_suites) + RTE_DIM(static_suites))); + ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites)); ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites)); ret = unit_test_suite_runner(&ts); + FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites)); free(ts.unit_test_suites); return ret; } @@ -14905,7 +14927,16 @@ test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/) static int test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/) { - uint8_t ret, j, i = 0; + uint8_t ret, j, i = 0, blk_start_idx = 0; + const enum blockcipher_test_type blk_suites[] = { + BLKCIPHER_AES_CHAIN_TYPE, + BLKCIPHER_AES_CIPHERONLY_TYPE, + BLKCIPHER_AES_DOCSIS_TYPE, + BLKCIPHER_3DES_CHAIN_TYPE, + BLKCIPHER_3DES_CIPHERONLY_TYPE, + BLKCIPHER_DES_CIPHERONLY_TYPE, + BLKCIPHER_DES_DOCSIS_TYPE, + BLKCIPHER_AUTHONLY_TYPE}; struct unit_test_suite *static_suites[] = { &cryptodev_multi_session_testsuite, &cryptodev_null_testsuite, @@ -14940,11 +14971,13 @@ test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/) } ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) * - RTE_DIM(static_suites)); + (RTE_DIM(blk_suites) + RTE_DIM(static_suites))); + ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites)); ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites)); ret = unit_test_suite_runner(&ts); + FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites)); free(ts.unit_test_suites); return ret; } @@ -14952,11 +14985,16 @@ test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/) static int test_cryptodev_ccp(void) { - uint8_t ret, j, i = 0; + uint8_t ret, j, i = 0, blk_start_idx = 0; + const enum blockcipher_test_type blk_suites[] = { + BLKCIPHER_AES_CHAIN_TYPE, + BLKCIPHER_AES_CIPHERONLY_TYPE, + BLKCIPHER_3DES_CHAIN_TYPE, + BLKCIPHER_3DES_CIPHERONLY_TYPE, + BLKCIPHER_AUTHONLY_TYPE}; struct unit_test_suite *static_suites[] = { &cryptodev_multi_session_testsuite, &cryptodev_negative_hmac_sha1_testsuite, - &cryptodev_ccp_sub_testsuite, &end_testsuite }; struct unit_test_suite ts = { @@ -14974,11 +15012,13 @@ test_cryptodev_ccp(void) } ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) * - RTE_DIM(static_suites)); + (RTE_DIM(blk_suites) + RTE_DIM(static_suites))); + ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites)); ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites)); ret = unit_test_suite_runner(&ts); + FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites)); free(ts.unit_test_suites); return ret; } @@ -14986,7 +15026,16 @@ test_cryptodev_ccp(void) static int test_cryptodev_octeontx(void) { - uint8_t ret, j, i = 0; + uint8_t ret, j, i = 0, blk_start_idx = 0; + const enum blockcipher_test_type blk_suites[] = { + BLKCIPHER_AES_CHAIN_TYPE, + BLKCIPHER_AES_CIPHERONLY_TYPE, + BLKCIPHER_AES_DOCSIS_TYPE, + BLKCIPHER_3DES_CHAIN_TYPE, + BLKCIPHER_3DES_CIPHERONLY_TYPE, + BLKCIPHER_DES_CIPHERONLY_TYPE, + BLKCIPHER_DES_DOCSIS_TYPE, + BLKCIPHER_AUTHONLY_TYPE}; struct unit_test_suite *static_suites[] = { &cryptodev_multi_session_testsuite, &cryptodev_null_testsuite, @@ -15021,11 +15070,13 @@ test_cryptodev_octeontx(void) } ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) * - RTE_DIM(static_suites)); + (RTE_DIM(blk_suites) + RTE_DIM(static_suites))); + ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites)); ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites)); ret = unit_test_suite_runner(&ts); + FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites)); free(ts.unit_test_suites); return ret; } @@ -15033,7 +15084,16 @@ test_cryptodev_octeontx(void) static int test_cryptodev_octeontx2(void) { - uint8_t ret, j, i = 0; + uint8_t ret, j, i = 0, blk_start_idx = 0; + const enum blockcipher_test_type blk_suites[] = { + BLKCIPHER_AES_CHAIN_TYPE, + BLKCIPHER_AES_CIPHERONLY_TYPE, + BLKCIPHER_AES_DOCSIS_TYPE, + BLKCIPHER_3DES_CHAIN_TYPE, + BLKCIPHER_3DES_CIPHERONLY_TYPE, + BLKCIPHER_DES_CIPHERONLY_TYPE, + BLKCIPHER_DES_DOCSIS_TYPE, + BLKCIPHER_AUTHONLY_TYPE}; struct unit_test_suite *static_suites[] = { &cryptodev_multi_session_testsuite, &cryptodev_null_testsuite, @@ -15068,11 +15128,13 @@ test_cryptodev_octeontx2(void) } ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) * - RTE_DIM(static_suites)); + (RTE_DIM(blk_suites) + RTE_DIM(static_suites))); + ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites)); ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites)); ret = unit_test_suite_runner(&ts); + FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites)); free(ts.unit_test_suites); return ret; } @@ -15080,7 +15142,13 @@ test_cryptodev_octeontx2(void) static int test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/) { - uint8_t ret, j, i = 0; + uint8_t ret, j, i = 0, blk_start_idx = 0; + const enum blockcipher_test_type blk_suites[] = { + BLKCIPHER_AES_CHAIN_TYPE, + BLKCIPHER_AES_CIPHERONLY_TYPE, + BLKCIPHER_3DES_CHAIN_TYPE, + BLKCIPHER_3DES_CIPHERONLY_TYPE, + BLKCIPHER_AUTHONLY_TYPE}; struct unit_test_suite *static_suites[] = { &cryptodev_caam_jr_sub_testsuite, &end_testsuite @@ -15100,11 +15168,13 @@ test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/) } ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) * - RTE_DIM(static_suites)); + (RTE_DIM(blk_suites) + RTE_DIM(static_suites))); + ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites)); ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites)); ret = unit_test_suite_runner(&ts); + FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites)); free(ts.unit_test_suites); return ret; } @@ -15112,7 +15182,16 @@ test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/) static int test_cryptodev_nitrox(void) { - uint8_t ret, j, i = 0; + uint8_t ret, j, i = 0, blk_start_idx = 0; + const enum blockcipher_test_type blk_suites[] = { + BLKCIPHER_AES_CHAIN_TYPE, + BLKCIPHER_AES_CIPHERONLY_TYPE, + BLKCIPHER_AES_DOCSIS_TYPE, + BLKCIPHER_3DES_CHAIN_TYPE, + BLKCIPHER_3DES_CIPHERONLY_TYPE, + BLKCIPHER_DES_CIPHERONLY_TYPE, + BLKCIPHER_DES_DOCSIS_TYPE, + BLKCIPHER_AUTHONLY_TYPE}; struct unit_test_suite *static_suites[] = { &cryptodev_multi_session_testsuite, &cryptodev_null_testsuite, @@ -15147,11 +15226,13 @@ test_cryptodev_nitrox(void) } ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) * - RTE_DIM(static_suites)); + (RTE_DIM(blk_suites) + RTE_DIM(static_suites))); + ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites)); ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites)); ret = unit_test_suite_runner(&ts); + FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites)); free(ts.unit_test_suites); return ret; } @@ -15159,7 +15240,16 @@ test_cryptodev_nitrox(void) static int test_cryptodev_bcmfs(void) { - uint8_t ret, j, i = 0; + uint8_t ret, j, i = 0, blk_start_idx = 0; + const enum blockcipher_test_type blk_suites[] = { + BLKCIPHER_AES_CHAIN_TYPE, + BLKCIPHER_AES_CIPHERONLY_TYPE, + BLKCIPHER_AES_DOCSIS_TYPE, + BLKCIPHER_3DES_CHAIN_TYPE, + BLKCIPHER_3DES_CIPHERONLY_TYPE, + BLKCIPHER_DES_CIPHERONLY_TYPE, + BLKCIPHER_DES_DOCSIS_TYPE, + BLKCIPHER_AUTHONLY_TYPE}; struct unit_test_suite *static_suites[] = { &cryptodev_multi_session_testsuite, &cryptodev_null_testsuite, @@ -15194,11 +15284,13 @@ test_cryptodev_bcmfs(void) } ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) * - RTE_DIM(static_suites)); + (RTE_DIM(blk_suites) + RTE_DIM(static_suites))); + ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites)); ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites)); ret = unit_test_suite_runner(&ts); + FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites)); free(ts.unit_test_suites); return ret; } @@ -15207,7 +15299,14 @@ static int test_cryptodev_qat_raw_api(void /*argv __rte_unused, int argc __rte_unused*/) { int ret; - uint8_t j, i = 0; + uint8_t j, i = 0, blk_start_idx = 0; + const enum blockcipher_test_type blk_suites[] = { + BLKCIPHER_AES_CHAIN_TYPE, + BLKCIPHER_AES_CIPHERONLY_TYPE, + BLKCIPHER_3DES_CHAIN_TYPE, + BLKCIPHER_3DES_CIPHERONLY_TYPE, + BLKCIPHER_DES_CIPHERONLY_TYPE, + BLKCIPHER_AUTHONLY_TYPE}; struct unit_test_suite *static_suites[] = { &cryptodev_multi_session_testsuite, &cryptodev_null_testsuite, @@ -15242,11 +15341,13 @@ test_cryptodev_qat_raw_api(void /*argv __rte_unused, int argc __rte_unused*/) } ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) * - RTE_DIM(static_suites)); + (RTE_DIM(blk_suites) + RTE_DIM(static_suites))); + ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites)); ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites)); global_api_test_type = CRYPTODEV_RAW_API_TEST; ret = unit_test_suite_runner(&ts); + FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites)); free(ts.unit_test_suites); global_api_test_type = CRYPTODEV_API_TEST; diff --git a/app/test/test_cryptodev_blockcipher.c b/app/test/test_cryptodev_blockcipher.c index 8e168724be..9c844c6bd2 100644 --- a/app/test/test_cryptodev_blockcipher.c +++ b/app/test/test_cryptodev_blockcipher.c @@ -738,82 +738,105 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t, return status; } -int -test_blockcipher_all_tests(struct rte_mempool *mbuf_pool, - struct rte_mempool *op_mpool, - struct rte_mempool *sess_mpool, - struct rte_mempool *sess_priv_mpool, - uint8_t dev_id, - enum blockcipher_test_type test_type) +static int +blockcipher_test_case_run(const void *data) { - int status, overall_status = TEST_SUCCESS; - uint32_t i, test_index = 0; + const struct blockcipher_test_case *tc_data = data; + int status; char test_msg[BLOCKCIPHER_TEST_MSG_LEN + 1]; - uint32_t n_test_cases = 0; - const struct blockcipher_test_case *tcs = NULL; + + status = test_blockcipher_one_case(tc_data, + p_testsuite_params->mbuf_pool, + p_testsuite_params->op_mpool, + p_testsuite_params->session_mpool, + p_testsuite_params->session_priv_mpool, + p_testsuite_params->valid_devs[0], + test_msg); + return status; +} + +struct unit_test_suite * +build_blockcipher_test_suite(enum blockcipher_test_type test_type) +{ + int i, n_test_cases = 0; + struct unit_test_suite *ts; + const char *ts_name = NULL; + const struct blockcipher_test_case *blk_tcs; + struct unit_test_case *tc; switch (test_type) { case BLKCIPHER_AES_CHAIN_TYPE: - n_test_cases = sizeof(aes_chain_test_cases) / - sizeof(aes_chain_test_cases[0]); - tcs = aes_chain_test_cases; + n_test_cases = RTE_DIM(aes_chain_test_cases); + blk_tcs = aes_chain_test_cases; + ts_name = "AES Chain"; break; case BLKCIPHER_AES_CIPHERONLY_TYPE: - n_test_cases = sizeof(aes_cipheronly_test_cases) / - sizeof(aes_cipheronly_test_cases[0]); - tcs = aes_cipheronly_test_cases; + n_test_cases = RTE_DIM(aes_cipheronly_test_cases); + blk_tcs = aes_cipheronly_test_cases; + ts_name = "AES Cipher Only"; break; case BLKCIPHER_AES_DOCSIS_TYPE: - n_test_cases = sizeof(aes_docsis_test_cases) / - sizeof(aes_docsis_test_cases[0]); - tcs = aes_docsis_test_cases; + n_test_cases = RTE_DIM(aes_docsis_test_cases); + blk_tcs = aes_docsis_test_cases; + ts_name = "AES Docsis"; break; case BLKCIPHER_3DES_CHAIN_TYPE: - n_test_cases = sizeof(triple_des_chain_test_cases) / - sizeof(triple_des_chain_test_cases[0]); - tcs = triple_des_chain_test_cases; + n_test_cases = RTE_DIM(triple_des_chain_test_cases); + blk_tcs = triple_des_chain_test_cases; + ts_name = "3DES Chain"; break; case BLKCIPHER_3DES_CIPHERONLY_TYPE: - n_test_cases = sizeof(triple_des_cipheronly_test_cases) / - sizeof(triple_des_cipheronly_test_cases[0]); - tcs = triple_des_cipheronly_test_cases; + n_test_cases = RTE_DIM(triple_des_cipheronly_test_cases); + blk_tcs = triple_des_cipheronly_test_cases; + ts_name = "3DES Cipher Only"; break; case BLKCIPHER_DES_CIPHERONLY_TYPE: - n_test_cases = sizeof(des_cipheronly_test_cases) / - sizeof(des_cipheronly_test_cases[0]); - tcs = des_cipheronly_test_cases; + n_test_cases = RTE_DIM(des_cipheronly_test_cases); + blk_tcs = des_cipheronly_test_cases; + ts_name = "DES Cipher Only"; break; case BLKCIPHER_DES_DOCSIS_TYPE: - n_test_cases = sizeof(des_docsis_test_cases) / - sizeof(des_docsis_test_cases[0]); - tcs = des_docsis_test_cases; + n_test_cases = RTE_DIM(des_docsis_test_cases); + blk_tcs = des_docsis_test_cases; + ts_name = "DES Docsis"; break; case BLKCIPHER_AUTHONLY_TYPE: - n_test_cases = sizeof(hash_test_cases) / - sizeof(hash_test_cases[0]); - tcs = hash_test_cases; + n_test_cases = RTE_DIM(hash_test_cases); + blk_tcs = hash_test_cases; + ts_name = "Auth Only"; break; default: break; } - for (i = 0; i < n_test_cases; i++) { - const struct blockcipher_test_case *tc = &tcs[i]; - - status = test_blockcipher_one_case(tc, mbuf_pool, op_mpool, - sess_mpool, sess_priv_mpool, dev_id, - test_msg); - - printf(" %u) TestCase %s %s\n", test_index ++, - tc->test_descr, test_msg); + ts = calloc(1, sizeof(struct unit_test_suite) + + (sizeof(struct unit_test_case) * (n_test_cases + 1))); + ts->suite_name = ts_name; - if (status == TEST_FAILED) { - overall_status = status; - - if (tc->feature_mask & BLOCKCIPHER_TEST_FEATURE_STOPPER) - break; - } + for (i = 0; i < n_test_cases; i++) { + tc = &ts->unit_test_cases[i]; + tc->name = blk_tcs[i].test_descr; + tc->enabled = 1; + tc->setup = ut_setup; + tc->teardown = ut_teardown; + tc->testcase = NULL; + tc->testcase_with_data = blockcipher_test_case_run; + tc->data = &blk_tcs[i]; } + tc = &ts->unit_test_cases[i]; + tc->name = NULL; + tc->enabled = 0; + tc->setup = NULL; + tc->teardown = NULL; + tc->testcase = NULL; + tc->testcase_with_data = NULL; + tc->data = NULL; + + return ts; +} - return overall_status; +void +free_blockcipher_test_suite(struct unit_test_suite *ts) +{ + free(ts); } diff --git a/app/test/test_cryptodev_blockcipher.h b/app/test/test_cryptodev_blockcipher.h index 8990716844..ad2a4fd61b 100644 --- a/app/test/test_cryptodev_blockcipher.h +++ b/app/test/test_cryptodev_blockcipher.h @@ -89,12 +89,10 @@ struct blockcipher_test_data { unsigned int auth_offset; }; -int -test_blockcipher_all_tests(struct rte_mempool *mbuf_pool, - struct rte_mempool *op_mpool, - struct rte_mempool *sess_mpool, - struct rte_mempool *sess_priv_mpool, - uint8_t dev_id, - enum blockcipher_test_type test_type); +struct unit_test_suite * +build_blockcipher_test_suite(enum blockcipher_test_type test_type); + +void +free_blockcipher_test_suite(struct unit_test_suite *ts); #endif /* TEST_CRYPTODEV_BLOCKCIPHER_H_ */ diff --git a/doc/guides/rel_notes/release_21_05.rst b/doc/guides/rel_notes/release_21_05.rst index 19cec62c73..cf1fbb5533 100644 --- a/doc/guides/rel_notes/release_21_05.rst +++ b/doc/guides/rel_notes/release_21_05.rst @@ -126,6 +126,11 @@ New Features * Added command to display Rx queue used descriptor count. ``show port (port_id) rxq (queue_id) desc used count`` +* **Added sub-testsuite support.** + + * The unit test suite struct now supports having either a nested + list of sub-testsuites, or a list of testcases as before. + Removed Items ------------- -- 2.25.1