test/crypto: add tests for virtio-crypto
[dpdk.git] / test / test / test_cryptodev.c
index d1d7925..2f31ec9 100644 (file)
@@ -1819,6 +1819,25 @@ test_AES_cipheronly_qat_all(void)
        return TEST_SUCCESS;
 }
 
+static int
+test_AES_cipheronly_virtio_all(void)
+{
+       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->valid_devs[0],
+               rte_cryptodev_driver_id_get(
+               RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD)),
+               BLKCIPHER_AES_CIPHERONLY_TYPE);
+
+       TEST_ASSERT_EQUAL(status, 0, "Test failed");
+
+       return TEST_SUCCESS;
+}
+
 static int
 test_AES_chain_dpaa_sec_all(void)
 {
@@ -8879,6 +8898,18 @@ static struct unit_test_suite cryptodev_qat_testsuite  = {
        }
 };
 
+static struct unit_test_suite cryptodev_virtio_testsuite = {
+       .suite_name = "Crypto VIRTIO Unit Test Suite",
+       .setup = testsuite_setup,
+       .teardown = testsuite_teardown,
+       .unit_test_cases = {
+               TEST_CASE_ST(ut_setup, ut_teardown,
+                               test_AES_cipheronly_virtio_all),
+
+               TEST_CASES_END() /**< NULL terminate unit test array */
+       }
+};
+
 static struct unit_test_suite cryptodev_aesni_mb_testsuite  = {
        .suite_name = "Crypto Device AESNI MB Unit Test Suite",
        .setup = testsuite_setup,
@@ -9807,6 +9838,22 @@ test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
        return unit_test_suite_runner(&cryptodev_qat_testsuite);
 }
 
+static int
+test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
+{
+       gbl_driver_id = rte_cryptodev_driver_id_get(
+                       RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
+
+       if (gbl_driver_id == -1) {
+               RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
+                               "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
+                               "in config file to run this testsuite.\n");
+               return TEST_FAILED;
+       }
+
+       return unit_test_suite_runner(&cryptodev_virtio_testsuite);
+}
+
 static int
 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
 {
@@ -10040,3 +10087,4 @@ REGISTER_TEST_COMMAND(cryptodev_sw_mrvl_autotest, test_cryptodev_mrvl);
 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
+REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);