Use ASSERT_COMPARE in test_suite_md
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
diff --git a/tests/include/test/macros.h b/tests/include/test/macros.h
index 83a48cd..2eba0c1 100644
--- a/tests/include/test/macros.h
+++ b/tests/include/test/macros.h
@@ -168,7 +168,7 @@
#define ASSERT_COMPARE(p1, size1, p2, size2) \
do \
{ \
- TEST_ASSERT((size1) == (size2)); \
+ TEST_EQUAL((size1), (size2)); \
if ((size1) != 0) \
TEST_ASSERT(memcmp((p1), (p2), (size1)) == 0); \
} \
diff --git a/tests/suites/test_suite_md.function b/tests/suites/test_suite_md.function
index f117a2c..27c2063 100644
--- a/tests/suites/test_suite_md.function
+++ b/tests/suites/test_suite_md.function
@@ -141,9 +141,7 @@
TEST_EQUAL(0, mbedtls_md(md_info, src, src_len, output));
- TEST_ASSERT(mbedtls_test_hexcmp(output, hash->x,
- mbedtls_md_get_size(md_info),
- hash->len) == 0);
+ ASSERT_COMPARE(output, mbedtls_md_get_size(md_info), hash->x, hash->len);
}
/* END_CASE */
@@ -159,9 +157,7 @@
TEST_EQUAL(0, mbedtls_md(md_info, src_str->x, src_str->len, output));
- TEST_ASSERT(mbedtls_test_hexcmp(output, hash->x,
- mbedtls_md_get_size(md_info),
- hash->len) == 0);
+ ASSERT_COMPARE(output, mbedtls_md_get_size(md_info), hash->x, hash->len);
}
/* END_CASE */
@@ -196,18 +192,14 @@
TEST_EQUAL(0, mbedtls_md_update(&ctx, src + halfway, src_len - halfway));
TEST_EQUAL(0, mbedtls_md_finish(&ctx, output));
- TEST_ASSERT(mbedtls_test_hexcmp(output, hash->x,
- mbedtls_md_get_size(md_info),
- hash->len) == 0);
+ ASSERT_COMPARE(output, mbedtls_md_get_size(md_info), hash->x, hash->len);
/* Test clone */
memset(output, 0x00, sizeof(output));
TEST_EQUAL(0, mbedtls_md_update(&ctx_copy, src + halfway, src_len - halfway));
TEST_EQUAL(0, mbedtls_md_finish(&ctx_copy, output));
- TEST_ASSERT(mbedtls_test_hexcmp(output, hash->x,
- mbedtls_md_get_size(md_info),
- hash->len) == 0);
+ ASSERT_COMPARE(output, mbedtls_md_get_size(md_info), hash->x, hash->len);
exit:
mbedtls_md_free(&ctx);
@@ -242,18 +234,14 @@
TEST_EQUAL(0, mbedtls_md_update(&ctx, src_str->x + halfway, src_str->len - halfway));
TEST_EQUAL(0, mbedtls_md_finish(&ctx, output));
- TEST_ASSERT(mbedtls_test_hexcmp(output, hash->x,
- mbedtls_md_get_size(md_info),
- hash->len) == 0);
+ ASSERT_COMPARE(output, mbedtls_md_get_size(md_info), hash->x, hash->len);
/* Test clone */
memset(output, 0x00, sizeof(output));
TEST_EQUAL(0, mbedtls_md_update(&ctx_copy, src_str->x + halfway, src_str->len - halfway));
TEST_EQUAL(0, mbedtls_md_finish(&ctx_copy, output));
- TEST_ASSERT(mbedtls_test_hexcmp(output, hash->x,
- mbedtls_md_get_size(md_info),
- hash->len) == 0);
+ ASSERT_COMPARE(output, mbedtls_md_get_size(md_info), hash->x, hash->len);
exit:
mbedtls_md_free(&ctx);
@@ -276,8 +264,7 @@
TEST_EQUAL(0, mbedtls_md_hmac(md_info, key_str->x, key_str->len,
src_str->x, src_str->len, output));
- TEST_ASSERT(mbedtls_test_hexcmp(output, hash->x,
- trunc_size, hash->len) == 0);
+ ASSERT_COMPARE(output, trunc_size, hash->x, hash->len);
}
/* END_CASE */
@@ -305,8 +292,7 @@
TEST_EQUAL(0, mbedtls_md_hmac_update(&ctx, src_str->x + halfway, src_str->len - halfway));
TEST_EQUAL(0, mbedtls_md_hmac_finish(&ctx, output));
- TEST_ASSERT(mbedtls_test_hexcmp(output, hash->x,
- trunc_size, hash->len) == 0);
+ ASSERT_COMPARE(output, trunc_size, hash->x, hash->len);
/* Test again, for reset() */
memset(output, 0x00, sizeof(output));
@@ -316,8 +302,7 @@
TEST_EQUAL(0, mbedtls_md_hmac_update(&ctx, src_str->x + halfway, src_str->len - halfway));
TEST_EQUAL(0, mbedtls_md_hmac_finish(&ctx, output));
- TEST_ASSERT(mbedtls_test_hexcmp(output, hash->x,
- trunc_size, hash->len) == 0);
+ ASSERT_COMPARE(output, trunc_size, hash->x, hash->len);
exit:
mbedtls_md_free(&ctx);
@@ -336,8 +321,6 @@
TEST_EQUAL(0, mbedtls_md_file(md_info, filename, output));
- TEST_ASSERT(mbedtls_test_hexcmp(output, hash->x,
- mbedtls_md_get_size(md_info),
- hash->len) == 0);
+ ASSERT_COMPARE(output, mbedtls_md_get_size(md_info), hash->x, hash->len);
}
/* END_CASE */