replace zero-length arrays with flexible ones
[dpdk.git] / app / test / test_cryptodev_blockcipher.c
index d342c7b..4944591 100644 (file)
@@ -2,6 +2,8 @@
  * Copyright(c) 2015-2017 Intel Corporation
  */
 
+#ifndef RTE_EXEC_ENV_WINDOWS
+
 #include <rte_common.h>
 #include <rte_hexdump.h>
 #include <rte_mbuf.h>
@@ -11,7 +13,6 @@
 
 #include <rte_crypto.h>
 #include <rte_cryptodev.h>
-#include <rte_cryptodev_pmd.h>
 
 #include "test.h"
 #include "test_cryptodev.h"
@@ -36,7 +37,8 @@ verify_algo_support(const struct blockcipher_test_case *t,
                if (capability == NULL)
                        return -1;
 
-               if (cap_idx.algo.cipher != RTE_CRYPTO_CIPHER_NULL)
+               if (cap_idx.algo.cipher != RTE_CRYPTO_CIPHER_NULL &&
+                               !(t->test_data->wrapped_key))
                        ret = rte_cryptodev_sym_capability_check_cipher(capability,
                                                        tdata->cipher_key.len,
                                                        tdata->iv.len);
@@ -145,6 +147,12 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t,
 
                nb_segs = 3;
        }
+       if (!!(feat_flags & RTE_CRYPTODEV_FF_CIPHER_WRAPPED_KEY) ^
+               tdata->wrapped_key) {
+               snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
+                       "SKIPPED");
+               return TEST_SKIPPED;
+       }
 
        if (global_api_test_type == CRYPTODEV_RAW_API_TEST &&
                !(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP)) {
@@ -260,7 +268,10 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t,
                }
                memset(obuf->buf_addr, dst_pattern, obuf->buf_len);
 
-               buf_p = rte_pktmbuf_append(obuf, buf_len + pad_len);
+               if (t->op_mask & BLOCKCIPHER_TEST_OP_DIGEST_ENCRYPTED)
+                       buf_p = rte_pktmbuf_append(obuf, buf_len + pad_len);
+               else
+                       buf_p = rte_pktmbuf_append(obuf, buf_len);
                if (!buf_p) {
                        snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
                                "FAILED: %s", __LINE__,
@@ -450,6 +461,7 @@ iterate:
                cipher_xform->cipher.key.data = cipher_key;
                cipher_xform->cipher.key.length = tdata->cipher_key.len;
                cipher_xform->cipher.iv.offset = IV_OFFSET;
+               cipher_xform->cipher.dataunit_len = tdata->xts_dataunit_len;
 
                if (tdata->crypto_algo == RTE_CRYPTO_CIPHER_NULL)
                        cipher_xform->cipher.iv.length = 0;
@@ -795,20 +807,16 @@ error_exit:
                        rte_cryptodev_sym_session_clear(dev_id, sess);
                        rte_cryptodev_sym_session_free(sess);
                }
-               if (cipher_xform)
-                       rte_free(cipher_xform);
-               if (auth_xform)
-                       rte_free(auth_xform);
+               rte_free(cipher_xform);
+               rte_free(auth_xform);
        }
 
        if (op)
                rte_crypto_op_free(op);
 
-       if (obuf)
-               rte_pktmbuf_free(obuf);
+       rte_pktmbuf_free(obuf);
 
-       if (ibuf)
-               rte_pktmbuf_free(ibuf);
+       rte_pktmbuf_free(ibuf);
 
        return status;
 }
@@ -1176,7 +1184,7 @@ build_blockcipher_test_suite(enum blockcipher_test_type test_type)
                ts_setup = authonly_setup;
                break;
        default:
-               break;
+               return NULL;
        }
 
        ts = calloc(1, sizeof(struct unit_test_suite) +
@@ -1211,3 +1219,5 @@ free_blockcipher_test_suite(struct unit_test_suite *ts)
 {
        free(ts);
 }
+
+#endif /* !RTE_EXEC_ENV_WINDOWS */