Instead of using the previous RTE_APP_TEST_DEBUG macro,
to dump memory when it was enabled (with rte_hexdump),
a new TEST_HEXDUMP is defined, which will call rte_hexdump
if RTE_LOG_LEVEL is set to RTE_LOG_DEBUG.
Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>
#define _TEST_H_
#include <stddef.h>
#include <sys/queue.h>
#define _TEST_H_
#include <stddef.h>
#include <sys/queue.h>
#define TEST_SUCCESS (0)
#define TEST_FAILED (-1)
#define TEST_SUCCESS (0)
#define TEST_FAILED (-1)
#define TEST_CASES_END() { NULL, NULL, NULL, NULL, NULL, 0 }
#define TEST_CASES_END() { NULL, NULL, NULL, NULL, NULL, 0 }
+#if RTE_LOG_LEVEL >= RTE_LOG_DEBUG
+#define TEST_HEXDUMP(file, title, buf, len) rte_hexdump(file, title, buf, len)
+#else
+#define TEST_HEXDUMP(file, title, buf, len) do {} while (0)
+#endif
+
struct unit_test_suite {
const char *suite_name;
int (*setup)(void);
struct unit_test_suite {
const char *suite_name;
int (*setup)(void);
struct crypto_unittest_params *ut_params = &unittest_params;
memcpy(hash_key, key, key_len);
struct crypto_unittest_params *ut_params = &unittest_params;
memcpy(hash_key, key, key_len);
-#ifdef RTE_APP_TEST_DEBUG
- rte_hexdump(stdout, "key:", key, key_len);
-#endif
+
+ TEST_HEXDUMP(stdout, "key:", key, key_len);
+
/* Setup Authentication Parameters */
ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
ut_params->auth_xform.next = NULL;
/* Setup Authentication Parameters */
ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
ut_params->auth_xform.next = NULL;
ut_params->cipher_xform.cipher.key.data = cipher_key;
ut_params->cipher_xform.cipher.key.length = key_len;
ut_params->cipher_xform.cipher.key.data = cipher_key;
ut_params->cipher_xform.cipher.key.length = key_len;
-#ifdef RTE_APP_TEST_DEBUG
- rte_hexdump(stdout, "key:", key, key_len);
-#endif
+ TEST_HEXDUMP(stdout, "key:", key, key_len);
+
/* Create Crypto session */
ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
&ut_params->
/* Create Crypto session */
ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
&ut_params->
ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
ut_params->cipher_xform.cipher.key.length = key_len;
ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
ut_params->cipher_xform.cipher.key.length = key_len;
-#ifdef RTE_APP_TEST_DEBUG
- rte_hexdump(stdout, "key:", key, key_len);
-#endif
+ TEST_HEXDUMP(stdout, "key:", key, key_len);
+
/* Create Crypto session*/
ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
&ut_params->cipher_xform);
/* Create Crypto session*/
ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
&ut_params->cipher_xform);
ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
ut_params->cipher_xform.cipher.key.length = key_len;
ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
ut_params->cipher_xform.cipher.key.length = key_len;
-#ifdef RTE_APP_TEST_DEBUG
- rte_hexdump(stdout, "key:", key, key_len);
-#endif
+ TEST_HEXDUMP(stdout, "key:", key, key_len);
+
/* Create Crypto session*/
ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
&ut_params->auth_xform);
/* Create Crypto session*/
ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
&ut_params->auth_xform);
memset(sym_op->auth.aad.data, 0, aad_buffer_len);
rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
memset(sym_op->auth.aad.data, 0, aad_buffer_len);
rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
-#ifdef RTE_APP_TEST_DEBUG
- rte_hexdump(stdout, "aad:",
+ TEST_HEXDUMP(stdout, "aad:",
sym_op->auth.aad.data, aad_len);
sym_op->auth.aad.data, aad_len);
/* digest */
sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
/* digest */
sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
else
rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
else
rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
-#ifdef RTE_APP_TEST_DEBUG
- rte_hexdump(stdout, "digest:",
+ TEST_HEXDUMP(stdout, "digest:",
sym_op->auth.digest.data,
sym_op->auth.digest.length);
sym_op->auth.digest.data,
sym_op->auth.digest.length);
sym_op->auth.data.length = auth_len;
sym_op->auth.data.offset = auth_offset;
sym_op->auth.data.length = auth_len;
sym_op->auth.data.offset = auth_offset;
memset(sym_op->auth.aad.data, 0, aad_buffer_len);
rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
memset(sym_op->auth.aad.data, 0, aad_buffer_len);
rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
-#ifdef RTE_APP_TEST_DEBUG
- rte_hexdump(stdout, "aad:",
+ TEST_HEXDUMP(stdout, "aad:",
sym_op->auth.aad.data, aad_len);
sym_op->auth.aad.data, aad_len);
/* digest */
sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
/* digest */
sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
else
rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
else
rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
- #ifdef RTE_APP_TEST_DEBUG
- rte_hexdump(stdout, "digest:",
+ TEST_HEXDUMP(stdout, "digest:",
sym_op->auth.digest.data,
sym_op->auth.digest.length);
sym_op->auth.digest.data,
sym_op->auth.digest.length);
sym_op->auth.data.length = auth_len;
sym_op->auth.data.offset = auth_offset;
sym_op->auth.data.length = auth_len;
sym_op->auth.data.offset = auth_offset;
memset(sym_op->auth.digest.data, 0, auth_tag_len);
memset(sym_op->auth.digest.data, 0, auth_tag_len);
- #ifdef RTE_APP_TEST_DEBUG
- rte_hexdump(stdout, "digest:",
+ TEST_HEXDUMP(stdout, "digest:",
sym_op->auth.digest.data,
sym_op->auth.digest.length);
sym_op->auth.digest.data,
sym_op->auth.digest.length);
/* iv */
iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
/* iv */
iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
memset(sym_op->auth.aad.data, 0, aad_buffer_len);
rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
memset(sym_op->auth.aad.data, 0, aad_buffer_len);
rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
-#ifdef RTE_APP_TEST_DEBUG
- rte_hexdump(stdout, "aad:",
+ TEST_HEXDUMP(stdout, "aad:",
sym_op->auth.aad.data, aad_len);
sym_op->auth.aad.data, aad_len);
sym_op->cipher.data.length = cipher_len;
sym_op->cipher.data.offset = auth_offset + cipher_offset;
sym_op->cipher.data.length = cipher_len;
sym_op->cipher.data.offset = auth_offset + cipher_offset;
plaintext_pad_len);
memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
plaintext_pad_len);
memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
-#ifdef RTE_APP_TEST_DEBUG
- rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
-#endif
+ TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
+
/* Create SNOW3G operation */
retval = create_snow3g_cipher_operation(tdata->iv.data, tdata->iv.len,
tdata->validCipherLenInBits.len,
/* Create SNOW3G operation */
retval = create_snow3g_cipher_operation(tdata->iv.data, tdata->iv.len,
tdata->validCipherLenInBits.len,
lastByteMask = lastByteMask << (8 - lastByteValidBits);
(*(ciphertext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;
lastByteMask = lastByteMask << (8 - lastByteValidBits);
(*(ciphertext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;
-#ifdef RTE_APP_TEST_DEBUG
- rte_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
-#endif
+ TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
+
/* Validate obuf */
TEST_ASSERT_BUFFERS_ARE_EQUAL(
ciphertext,
/* Validate obuf */
TEST_ASSERT_BUFFERS_ARE_EQUAL(
ciphertext,
memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
-#ifdef RTE_APP_TEST_DEBUG
- rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
-#endif
+ TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
+
/* Create SNOW3G operation */
retval = create_snow3g_cipher_operation_oop(tdata->iv.data,
tdata->iv.len,
/* Create SNOW3G operation */
retval = create_snow3g_cipher_operation_oop(tdata->iv.data,
tdata->iv.len,
lastByteMask = lastByteMask << (8 - lastByteValidBits);
(*(ciphertext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;
lastByteMask = lastByteMask << (8 - lastByteValidBits);
(*(ciphertext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;
-#ifdef RTE_APP_TEST_DEBUG
- rte_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
-#endif
+ TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
+
/* Validate obuf */
TEST_ASSERT_BUFFERS_ARE_EQUAL(
ciphertext,
/* Validate obuf */
TEST_ASSERT_BUFFERS_ARE_EQUAL(
ciphertext,
ciphertext_pad_len);
memcpy(ciphertext, tdata->ciphertext.data, tdata->ciphertext.len >> 3);
ciphertext_pad_len);
memcpy(ciphertext, tdata->ciphertext.data, tdata->ciphertext.len >> 3);
-#ifdef RTE_APP_TEST_DEBUG
- rte_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
-#endif
+ TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
+
/* Create SNOW3G operation */
retval = create_snow3g_cipher_operation(tdata->iv.data, tdata->iv.len,
tdata->validCipherLenInBits.len,
/* Create SNOW3G operation */
retval = create_snow3g_cipher_operation(tdata->iv.data, tdata->iv.len,
tdata->validCipherLenInBits.len,
lastByteMask = lastByteMask << (8 - lastByteValidBits);
(*(ciphertext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;
lastByteMask = lastByteMask << (8 - lastByteValidBits);
(*(ciphertext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;
-#ifdef RTE_APP_TEST_DEBUG
- rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
-#endif
+ TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
+
/* Validate obuf */
TEST_ASSERT_BUFFERS_ARE_EQUAL(plaintext,
tdata->plaintext.data,
/* Validate obuf */
TEST_ASSERT_BUFFERS_ARE_EQUAL(plaintext,
tdata->plaintext.data,
memcpy(ciphertext, tdata->ciphertext.data, tdata->ciphertext.len >> 3);
memcpy(ciphertext, tdata->ciphertext.data, tdata->ciphertext.len >> 3);
-#ifdef RTE_APP_TEST_DEBUG
- rte_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
-#endif
+ TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
+
/* Create SNOW3G operation */
retval = create_snow3g_cipher_operation_oop(tdata->iv.data,
tdata->iv.len,
/* Create SNOW3G operation */
retval = create_snow3g_cipher_operation_oop(tdata->iv.data,
tdata->iv.len,
lastByteMask = lastByteMask << (8 - lastByteValidBits);
(*(plaintext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;
lastByteMask = lastByteMask << (8 - lastByteValidBits);
(*(plaintext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;
-#ifdef RTE_APP_TEST_DEBUG
- rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
-#endif
+ TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
+
/* Validate obuf */
TEST_ASSERT_BUFFERS_ARE_EQUAL(plaintext,
tdata->plaintext.data,
/* Validate obuf */
TEST_ASSERT_BUFFERS_ARE_EQUAL(plaintext,
tdata->plaintext.data,
plaintext_pad_len);
memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len >> 3);
plaintext_pad_len);
memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len >> 3);
-#ifdef RTE_APP_TEST_DEBUG
- rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
-#endif
+ TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
/* Create SNOW3G operation */
retval = create_snow3g_cipher_hash_operation(tdata->digest.data,
/* Create SNOW3G operation */
retval = create_snow3g_cipher_hash_operation(tdata->digest.data,
lastByteMask = lastByteMask << (8-lastByteValidBits);
(*(ciphertext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;
lastByteMask = lastByteMask << (8-lastByteValidBits);
(*(ciphertext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;
-#ifdef RTE_APP_TEST_DEBUG
- rte_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
-#endif
+ TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
+
/* Validate obuf */
TEST_ASSERT_BUFFERS_ARE_EQUAL(
ciphertext,
/* Validate obuf */
TEST_ASSERT_BUFFERS_ARE_EQUAL(
ciphertext,
plaintext_pad_len);
memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len >> 3);
plaintext_pad_len);
memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len >> 3);
-#ifdef RTE_APP_TEST_DEBUG
- rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
-#endif
+ TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
/* Create SNOW3G operation */
retval = create_snow3g_auth_cipher_operation(
/* Create SNOW3G operation */
retval = create_snow3g_auth_cipher_operation(
(*(ciphertext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;
ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
+ plaintext_pad_len + tdata->aad.len + tdata->iv.len;
(*(ciphertext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;
ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
+ plaintext_pad_len + tdata->aad.len + tdata->iv.len;
- #ifdef RTE_APP_TEST_DEBUG
- rte_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
-#endif
+ TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
+
/* Validate obuf */
TEST_ASSERT_BUFFERS_ARE_EQUAL(
ciphertext,
/* Validate obuf */
TEST_ASSERT_BUFFERS_ARE_EQUAL(
ciphertext,
ut_params->cipher_xform.cipher.key.data = cipher_key;
ut_params->cipher_xform.cipher.key.length = key_len;
ut_params->cipher_xform.cipher.key.data = cipher_key;
ut_params->cipher_xform.cipher.key.length = key_len;
-#ifdef RTE_APP_TEST_DEBUG
- rte_hexdump(stdout, "key:", key, key_len);
-#endif
+ TEST_HEXDUMP(stdout, "key:", key, key_len);
+
/* Setup Authentication Parameters */
ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
ut_params->auth_xform.next = NULL;
/* Setup Authentication Parameters */
ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
ut_params->auth_xform.next = NULL;
if (op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
if (op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
-#ifdef RTE_APP_TEST_DEBUG
- rte_hexdump(stdout, "digest:",
+ TEST_HEXDUMP(stdout, "digest:",
sym_op->auth.digest.data,
sym_op->auth.digest.length);
sym_op->auth.digest.data,
sym_op->auth.digest.length);
memset(sym_op->auth.aad.data, 0, aad_buffer_len);
rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
memset(sym_op->auth.aad.data, 0, aad_buffer_len);
rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
-#ifdef RTE_APP_TEST_DEBUG
- rte_hexdump(stdout, "iv:", sym_op->cipher.iv.data, iv_pad_len);
- rte_hexdump(stdout, "aad:",
+ TEST_HEXDUMP(stdout, "iv:", sym_op->cipher.iv.data, iv_pad_len);
+ TEST_HEXDUMP(stdout, "aad:",
sym_op->auth.aad.data, aad_len);
sym_op->auth.aad.data, aad_len);
sym_op->cipher.data.length = data_len;
sym_op->cipher.data.offset = aad_buffer_len + iv_pad_len;
sym_op->cipher.data.length = data_len;
sym_op->cipher.data.offset = aad_buffer_len + iv_pad_len;
plaintext_pad_len);
memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
plaintext_pad_len);
memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
-#ifdef RTE_APP_TEST_DEBUG
- rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
-#endif
+ TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
+
/* Create GCM opertaion */
retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT,
tdata->auth_tag.data, tdata->auth_tag.len,
/* Create GCM opertaion */
retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT,
tdata->auth_tag.data, tdata->auth_tag.len,
auth_tag = plaintext + plaintext_pad_len;
}
auth_tag = plaintext + plaintext_pad_len;
}
-#ifdef RTE_APP_TEST_DEBUG
- rte_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
- rte_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
-#endif
+ TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
+ TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
+
/* Validate obuf */
TEST_ASSERT_BUFFERS_ARE_EQUAL(
ciphertext,
/* Validate obuf */
TEST_ASSERT_BUFFERS_ARE_EQUAL(
ciphertext,
ciphertext_pad_len);
memcpy(ciphertext, tdata->ciphertext.data, tdata->ciphertext.len);
ciphertext_pad_len);
memcpy(ciphertext, tdata->ciphertext.data, tdata->ciphertext.len);
-#ifdef RTE_APP_TEST_DEBUG
- rte_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
-#endif
+ TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
+
/* Create GCM opertaion */
retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT,
tdata->auth_tag.data, tdata->auth_tag.len,
/* Create GCM opertaion */
retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT,
tdata->auth_tag.data, tdata->auth_tag.len,
else
plaintext = ciphertext;
else
plaintext = ciphertext;
-#ifdef RTE_APP_TEST_DEBUG
- rte_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
-#endif
+ TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
+
/* Validate obuf */
TEST_ASSERT_BUFFERS_ARE_EQUAL(
plaintext,
/* Validate obuf */
TEST_ASSERT_BUFFERS_ARE_EQUAL(
plaintext,
-#ifdef RTE_APP_TEST_DEBUG
- rte_hexdump(stdout, "m_src:",
+ TEST_HEXDUMP(stdout, "m_src:",
rte_pktmbuf_mtod(sym_op->m_src, uint8_t *), buf_len);
if (t->feature_mask & AES_TEST_FEATURE_OOP)
rte_pktmbuf_mtod(sym_op->m_src, uint8_t *), buf_len);
if (t->feature_mask & AES_TEST_FEATURE_OOP)
- rte_hexdump(stdout, "m_dst:",
+ TEST_HEXDUMP(stdout, "m_dst:",
rte_pktmbuf_mtod(sym_op->m_dst, uint8_t *),
buf_len);
rte_pktmbuf_mtod(sym_op->m_dst, uint8_t *),
buf_len);
/* Verify results */
if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
/* Verify results */
if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {