X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=app%2Ftest%2Ftest_cryptodev.c;h=647787d29ff9a7585a69965af51de8254902e041;hb=26e09db6cb5fd9bbf0feb928561af9932694574b;hp=67608ff5ca97d9b890e49c1278504f11be249267;hpb=643e942719407c43da99523bba4424716425d41b;p=dpdk.git diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c index 67608ff5ca..647787d29f 100644 --- a/app/test/test_cryptodev.c +++ b/app/test/test_cryptodev.c @@ -186,12 +186,12 @@ testsuite_setup(void) if (nb_devs < 2) { for (i = nb_devs; i < 2; i++) { ret = rte_eal_vdev_init( - CRYPTODEV_NAME_AESNI_MB_PMD, NULL); + RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL); TEST_ASSERT(ret == 0, "Failed to create instance %u of" " pmd : %s", - i, CRYPTODEV_NAME_AESNI_MB_PMD); + i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)); } } } @@ -203,10 +203,10 @@ testsuite_setup(void) if (nb_devs < 2) { for (i = nb_devs; i < 2; i++) { TEST_ASSERT_SUCCESS(rte_eal_vdev_init( - CRYPTODEV_NAME_AESNI_GCM_PMD, NULL), + RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL), "Failed to create instance %u of" " pmd : %s", - i, CRYPTODEV_NAME_AESNI_GCM_PMD); + i, RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)); } } } @@ -217,10 +217,10 @@ testsuite_setup(void) if (nb_devs < 2) { for (i = nb_devs; i < 2; i++) { TEST_ASSERT_SUCCESS(rte_eal_vdev_init( - CRYPTODEV_NAME_SNOW3G_PMD, NULL), + RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL), "Failed to create instance %u of" " pmd : %s", - i, CRYPTODEV_NAME_SNOW3G_PMD); + i, RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)); } } } @@ -231,10 +231,10 @@ testsuite_setup(void) if (nb_devs < 2) { for (i = nb_devs; i < 2; i++) { TEST_ASSERT_SUCCESS(rte_eal_vdev_init( - CRYPTODEV_NAME_KASUMI_PMD, NULL), + RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL), "Failed to create instance %u of" " pmd : %s", - i, CRYPTODEV_NAME_KASUMI_PMD); + i, RTE_STR(CRYPTODEV_NAME_KASUMI_PMD)); } } } @@ -246,12 +246,12 @@ testsuite_setup(void) if (nb_devs < 2) { for (i = nb_devs; i < 2; i++) { int dev_id = rte_eal_vdev_init( - CRYPTODEV_NAME_NULL_PMD, NULL); + RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL); TEST_ASSERT(dev_id >= 0, "Failed to create instance %u of" " pmd : %s", - i, CRYPTODEV_NAME_NULL_PMD); + i, RTE_STR(CRYPTODEV_NAME_NULL_PMD)); } } } @@ -316,12 +316,12 @@ testsuite_teardown(void) if (ts_params->mbuf_pool != NULL) { RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n", - rte_mempool_count(ts_params->mbuf_pool)); + rte_mempool_avail_count(ts_params->mbuf_pool)); } if (ts_params->op_mpool != NULL) { RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n", - rte_mempool_count(ts_params->op_mpool)); + rte_mempool_avail_count(ts_params->op_mpool)); } } @@ -412,7 +412,7 @@ ut_teardown(void) if (ts_params->mbuf_pool != NULL) RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n", - rte_mempool_count(ts_params->mbuf_pool)); + rte_mempool_avail_count(ts_params->mbuf_pool)); rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats); @@ -2295,7 +2295,7 @@ test_snow3g_encryption(const struct snow3g_test_data *tdata) plaintext_pad_len); memcpy(plaintext, tdata->plaintext.data, plaintext_len); - TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len); + TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len); /* Create SNOW3G operation */ retval = create_snow3g_kasumi_cipher_operation(tdata->iv.data, tdata->iv.len, @@ -2316,7 +2316,7 @@ test_snow3g_encryption(const struct snow3g_test_data *tdata) else ciphertext = plaintext; - TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len); + TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len); /* Validate obuf */ TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( @@ -2368,7 +2368,7 @@ test_snow3g_encryption_oop(const struct snow3g_test_data *tdata) rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len); memcpy(plaintext, tdata->plaintext.data, plaintext_len); - TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len); + TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len); /* Create SNOW3G operation */ retval = create_snow3g_kasumi_cipher_operation_oop(tdata->iv.data, @@ -2390,7 +2390,7 @@ test_snow3g_encryption_oop(const struct snow3g_test_data *tdata) else ciphertext = plaintext; - TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len); + TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len); /* Validate obuf */ TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( @@ -2549,7 +2549,7 @@ static int test_snow3g_decryption(const struct snow3g_test_data *tdata) ciphertext_pad_len); memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len); - TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len); + TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len); /* Create SNOW3G operation */ retval = create_snow3g_kasumi_cipher_operation(tdata->iv.data, tdata->iv.len, @@ -2569,7 +2569,7 @@ static int test_snow3g_decryption(const struct snow3g_test_data *tdata) else plaintext = ciphertext; - TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len); + TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len); /* Validate obuf */ TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext, @@ -2622,7 +2622,7 @@ static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata) rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len); memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len); - TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len); + TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len); /* Create SNOW3G operation */ retval = create_snow3g_kasumi_cipher_operation_oop(tdata->iv.data, @@ -2643,7 +2643,7 @@ static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata) else plaintext = ciphertext; - TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len); + TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len); /* Validate obuf */ TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext, @@ -2689,7 +2689,7 @@ test_snow3g_authenticated_encryption(const struct snow3g_test_data *tdata) plaintext_pad_len); memcpy(plaintext, tdata->plaintext.data, plaintext_len); - TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len); + TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len); /* Create SNOW3G operation */ retval = create_snow3g_kasumi_cipher_hash_operation(tdata->digest.data, @@ -2717,7 +2717,7 @@ test_snow3g_authenticated_encryption(const struct snow3g_test_data *tdata) else ciphertext = plaintext; - TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len); + TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len); /* Validate obuf */ TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( @@ -2774,7 +2774,7 @@ test_snow3g_encrypted_authentication(const struct snow3g_test_data *tdata) plaintext_pad_len); memcpy(plaintext, tdata->plaintext.data, plaintext_len); - TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len); + TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len); /* Create SNOW3G operation */ retval = create_snow3g_kasumi_auth_cipher_operation( @@ -2805,7 +2805,7 @@ test_snow3g_encrypted_authentication(const struct snow3g_test_data *tdata) ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) + plaintext_pad_len + tdata->aad.len + tdata->iv.len; - TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len); + TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len); /* Validate obuf */ TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( @@ -3002,6 +3002,7 @@ create_gcm_session(uint8_t dev_id, enum rte_crypto_cipher_operation op, ut_params->cipher_xform.next = NULL; ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM; + ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE; ut_params->cipher_xform.cipher.op = op; ut_params->cipher_xform.cipher.key.data = cipher_key; ut_params->cipher_xform.cipher.key.length = key_len; @@ -3471,12 +3472,19 @@ test_multi_session(void) /* * free mbuf - both obuf and ibuf are usually the same, - * but rte copes even if we call free twice + * so check if they point at the same address is necessary, + * to avoid freeing the mbuf twice. */ if (ut_params->obuf) { rte_pktmbuf_free(ut_params->obuf); + if (ut_params->ibuf == ut_params->obuf) + ut_params->ibuf = 0; ut_params->obuf = 0; } + if (ut_params->ibuf) { + rte_pktmbuf_free(ut_params->ibuf); + ut_params->ibuf = 0; + } } /* Next session create should fail */ @@ -4156,10 +4164,6 @@ test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/) gbl_cryptodev_type = RTE_CRYPTODEV_QAT_SYM_PMD; return unit_test_suite_runner(&cryptodev_qat_testsuite); } -static struct test_command cryptodev_qat_cmd = { - .command = "cryptodev_qat_autotest", - .callback = test_cryptodev_qat, -}; static int test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/) @@ -4169,11 +4173,6 @@ test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/) return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite); } -static struct test_command cryptodev_aesni_mb_cmd = { - .command = "cryptodev_aesni_mb_autotest", - .callback = test_cryptodev_aesni_mb, -}; - static int test_cryptodev_aesni_gcm(void) { @@ -4182,11 +4181,6 @@ test_cryptodev_aesni_gcm(void) return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite); } -static struct test_command cryptodev_aesni_gcm_cmd = { - .command = "cryptodev_aesni_gcm_autotest", - .callback = test_cryptodev_aesni_gcm, -}; - static int test_cryptodev_null(void) { @@ -4195,11 +4189,6 @@ test_cryptodev_null(void) return unit_test_suite_runner(&cryptodev_null_testsuite); } -static struct test_command cryptodev_null_cmd = { - .command = "cryptodev_null_autotest", - .callback = test_cryptodev_null, -}; - static int test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/) { @@ -4208,11 +4197,6 @@ test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/) return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite); } -static struct test_command cryptodev_sw_snow3g_cmd = { - .command = "cryptodev_sw_snow3g_autotest", - .callback = test_cryptodev_sw_snow3g, -}; - static int test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/) { @@ -4221,14 +4205,9 @@ test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/) return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite); } -static struct test_command cryptodev_sw_kasumi_cmd = { - .command = "cryptodev_sw_kasumi_autotest", - .callback = test_cryptodev_sw_kasumi, -}; - -REGISTER_TEST_COMMAND(cryptodev_qat_cmd); -REGISTER_TEST_COMMAND(cryptodev_aesni_mb_cmd); -REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_cmd); -REGISTER_TEST_COMMAND(cryptodev_null_cmd); -REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_cmd); -REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_cmd); +REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat); +REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb); +REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm); +REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null); +REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g); +REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);