Use TEST_EQUAL when applicable in test_suite_md

Backporting note: contextual differences because we don't have
info_from_ctx in 2.28.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
diff --git a/tests/suites/test_suite_md.function b/tests/suites/test_suite_md.function
index a499ca0..c91aba3 100644
--- a/tests/suites/test_suite_md.function
+++ b/tests/suites/test_suite_md.function
@@ -29,9 +29,9 @@
     for (md_type_ptr = mbedtls_md_list(); *md_type_ptr != 0; md_type_ptr++) {
         info = mbedtls_md_info_from_type(*md_type_ptr);
         TEST_ASSERT(info != NULL);
-        TEST_ASSERT(mbedtls_md_setup(&ctx, info, 0) == 0);
-        TEST_ASSERT(mbedtls_md_starts(&ctx) == 0);
-        TEST_ASSERT(mbedtls_md_process(&ctx, buf) == 0);
+        TEST_EQUAL(0, mbedtls_md_setup(&ctx, info, 0));
+        TEST_EQUAL(0, mbedtls_md_starts(&ctx));
+        TEST_EQUAL(0, mbedtls_md_process(&ctx, buf));
         mbedtls_md_free(&ctx);
     }
 
@@ -49,53 +49,51 @@
 
     mbedtls_md_init(&ctx);
 
-    TEST_ASSERT(mbedtls_md_get_size(NULL) == 0);
+    TEST_EQUAL(0, mbedtls_md_get_size(NULL));
     TEST_ASSERT(mbedtls_md_get_type(NULL) == MBEDTLS_MD_NONE);
     TEST_ASSERT(mbedtls_md_get_name(NULL) == NULL);
 
     TEST_ASSERT(mbedtls_md_info_from_string(NULL) == NULL);
 
-    TEST_ASSERT(mbedtls_md_setup(&ctx, NULL, 0) == MBEDTLS_ERR_MD_BAD_INPUT_DATA);
-    TEST_ASSERT(mbedtls_md_setup(NULL, info, 0) == MBEDTLS_ERR_MD_BAD_INPUT_DATA);
+    TEST_EQUAL(mbedtls_md_setup(&ctx, NULL, 0), MBEDTLS_ERR_MD_BAD_INPUT_DATA);
+    TEST_EQUAL(mbedtls_md_setup(NULL, info, 0), MBEDTLS_ERR_MD_BAD_INPUT_DATA);
 
-    TEST_ASSERT(mbedtls_md_starts(NULL) == MBEDTLS_ERR_MD_BAD_INPUT_DATA);
-    TEST_ASSERT(mbedtls_md_starts(&ctx) == MBEDTLS_ERR_MD_BAD_INPUT_DATA);
+    TEST_EQUAL(mbedtls_md_starts(NULL), MBEDTLS_ERR_MD_BAD_INPUT_DATA);
+    TEST_EQUAL(mbedtls_md_starts(&ctx), MBEDTLS_ERR_MD_BAD_INPUT_DATA);
 
-    TEST_ASSERT(mbedtls_md_update(NULL, buf, 1) == MBEDTLS_ERR_MD_BAD_INPUT_DATA);
-    TEST_ASSERT(mbedtls_md_update(&ctx, buf, 1) == MBEDTLS_ERR_MD_BAD_INPUT_DATA);
+    TEST_EQUAL(mbedtls_md_update(NULL, buf, 1), MBEDTLS_ERR_MD_BAD_INPUT_DATA);
+    TEST_EQUAL(mbedtls_md_update(&ctx, buf, 1), MBEDTLS_ERR_MD_BAD_INPUT_DATA);
 
-    TEST_ASSERT(mbedtls_md_finish(NULL, buf) == MBEDTLS_ERR_MD_BAD_INPUT_DATA);
-    TEST_ASSERT(mbedtls_md_finish(&ctx, buf) == MBEDTLS_ERR_MD_BAD_INPUT_DATA);
+    TEST_EQUAL(mbedtls_md_finish(NULL, buf), MBEDTLS_ERR_MD_BAD_INPUT_DATA);
+    TEST_EQUAL(mbedtls_md_finish(&ctx, buf), MBEDTLS_ERR_MD_BAD_INPUT_DATA);
 
-    TEST_ASSERT(mbedtls_md(NULL, buf, 1, buf) == MBEDTLS_ERR_MD_BAD_INPUT_DATA);
+    TEST_EQUAL(mbedtls_md(NULL, buf, 1, buf), MBEDTLS_ERR_MD_BAD_INPUT_DATA);
 
 #if defined(MBEDTLS_FS_IO)
-    TEST_ASSERT(mbedtls_md_file(NULL, "", buf) == MBEDTLS_ERR_MD_BAD_INPUT_DATA);
+    TEST_EQUAL(mbedtls_md_file(NULL, "", buf), MBEDTLS_ERR_MD_BAD_INPUT_DATA);
 #endif
 
-    TEST_ASSERT(mbedtls_md_hmac_starts(NULL, buf, 1)
-                == MBEDTLS_ERR_MD_BAD_INPUT_DATA);
-    TEST_ASSERT(mbedtls_md_hmac_starts(&ctx, buf, 1)
-                == MBEDTLS_ERR_MD_BAD_INPUT_DATA);
+    TEST_EQUAL(mbedtls_md_hmac_starts(NULL, buf, 1),
+               MBEDTLS_ERR_MD_BAD_INPUT_DATA);
+    TEST_EQUAL(mbedtls_md_hmac_starts(&ctx, buf, 1),
+               MBEDTLS_ERR_MD_BAD_INPUT_DATA);
 
-    TEST_ASSERT(mbedtls_md_hmac_update(NULL, buf, 1)
-                == MBEDTLS_ERR_MD_BAD_INPUT_DATA);
-    TEST_ASSERT(mbedtls_md_hmac_update(&ctx, buf, 1)
-                == MBEDTLS_ERR_MD_BAD_INPUT_DATA);
+    TEST_EQUAL(mbedtls_md_hmac_update(NULL, buf, 1),
+               MBEDTLS_ERR_MD_BAD_INPUT_DATA);
+    TEST_EQUAL(mbedtls_md_hmac_update(&ctx, buf, 1),
+               MBEDTLS_ERR_MD_BAD_INPUT_DATA);
 
-    TEST_ASSERT(mbedtls_md_hmac_finish(NULL, buf)
-                == MBEDTLS_ERR_MD_BAD_INPUT_DATA);
-    TEST_ASSERT(mbedtls_md_hmac_finish(&ctx, buf)
-                == MBEDTLS_ERR_MD_BAD_INPUT_DATA);
+    TEST_EQUAL(mbedtls_md_hmac_finish(NULL, buf), MBEDTLS_ERR_MD_BAD_INPUT_DATA);
+    TEST_EQUAL(mbedtls_md_hmac_finish(&ctx, buf), MBEDTLS_ERR_MD_BAD_INPUT_DATA);
 
-    TEST_ASSERT(mbedtls_md_hmac_reset(NULL) == MBEDTLS_ERR_MD_BAD_INPUT_DATA);
-    TEST_ASSERT(mbedtls_md_hmac_reset(&ctx) == MBEDTLS_ERR_MD_BAD_INPUT_DATA);
+    TEST_EQUAL(mbedtls_md_hmac_reset(NULL), MBEDTLS_ERR_MD_BAD_INPUT_DATA);
+    TEST_EQUAL(mbedtls_md_hmac_reset(&ctx), MBEDTLS_ERR_MD_BAD_INPUT_DATA);
 
-    TEST_ASSERT(mbedtls_md_hmac(NULL, buf, 1, buf, 1, buf)
-                == MBEDTLS_ERR_MD_BAD_INPUT_DATA);
+    TEST_EQUAL(mbedtls_md_hmac(NULL, buf, 1, buf, 1, buf),
+               MBEDTLS_ERR_MD_BAD_INPUT_DATA);
 
-    TEST_ASSERT(mbedtls_md_process(NULL, buf) == MBEDTLS_ERR_MD_BAD_INPUT_DATA);
-    TEST_ASSERT(mbedtls_md_process(&ctx, buf) == MBEDTLS_ERR_MD_BAD_INPUT_DATA);
+    TEST_EQUAL(mbedtls_md_process(NULL, buf), MBEDTLS_ERR_MD_BAD_INPUT_DATA);
+    TEST_EQUAL(mbedtls_md_process(&ctx, buf), MBEDTLS_ERR_MD_BAD_INPUT_DATA);
 
     /* Ok, this is not NULL arg but NULL return... */
     TEST_ASSERT(mbedtls_md_info_from_type(MBEDTLS_MD_NONE) == NULL);
@@ -114,9 +112,9 @@
     TEST_ASSERT(md_info != NULL);
     TEST_ASSERT(md_info == mbedtls_md_info_from_string(md_name));
 
-    TEST_ASSERT(mbedtls_md_get_type(md_info) == (mbedtls_md_type_t) md_type);
-    TEST_ASSERT(mbedtls_md_get_size(md_info) == (unsigned char) md_size);
-    TEST_ASSERT(strcmp(mbedtls_md_get_name(md_info), md_name) == 0);
+    TEST_EQUAL(mbedtls_md_get_type(md_info), (mbedtls_md_type_t) md_type);
+    TEST_EQUAL(mbedtls_md_get_size(md_info), (unsigned char) md_size);
+    TEST_EQUAL(0, strcmp(mbedtls_md_get_name(md_info), md_name));
 
     found = 0;
     for (md_type_ptr = mbedtls_md_list(); *md_type_ptr != 0; md_type_ptr++) {
@@ -124,7 +122,7 @@
             found = 1;
         }
     }
-    TEST_ASSERT(found == 1);
+    TEST_EQUAL(found, 1);
 }
 /* END_CASE */
 
@@ -139,7 +137,7 @@
     md_info = mbedtls_md_info_from_type(md_type);
     TEST_ASSERT(md_info != NULL);
 
-    TEST_ASSERT(0 == mbedtls_md(md_info, src, src_len, output));
+    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),
@@ -156,7 +154,7 @@
     md_info = mbedtls_md_info_from_type(md_type);
     TEST_ASSERT(md_info != NULL);
 
-    TEST_ASSERT(0 == mbedtls_md(md_info, src_str->x, src_str->len, output));
+    TEST_EQUAL(0, mbedtls_md(md_info, src_str->x, src_str->len, output));
 
 
     TEST_ASSERT(mbedtls_test_hexcmp(output, hash->x,
@@ -184,16 +182,16 @@
 
     md_info = mbedtls_md_info_from_type(md_type);
     TEST_ASSERT(md_info != NULL);
-    TEST_ASSERT(0 == mbedtls_md_setup(&ctx, md_info, 0));
-    TEST_ASSERT(0 == mbedtls_md_setup(&ctx_copy, md_info, 0));
+    TEST_EQUAL(0, mbedtls_md_setup(&ctx, md_info, 0));
+    TEST_EQUAL(0, mbedtls_md_setup(&ctx_copy, md_info, 0));
 
-    TEST_ASSERT(0 == mbedtls_md_starts(&ctx));
+    TEST_EQUAL(0, mbedtls_md_starts(&ctx));
     TEST_ASSERT(ctx.md_ctx != NULL);
-    TEST_ASSERT(0 == mbedtls_md_update(&ctx, src, halfway));
-    TEST_ASSERT(0 == mbedtls_md_clone(&ctx_copy, &ctx));
+    TEST_EQUAL(0, mbedtls_md_update(&ctx, src, halfway));
+    TEST_EQUAL(0, mbedtls_md_clone(&ctx_copy, &ctx));
 
-    TEST_ASSERT(0 == mbedtls_md_update(&ctx, src + halfway, src_len - halfway));
-    TEST_ASSERT(0 == mbedtls_md_finish(&ctx, output));
+    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);
@@ -201,8 +199,8 @@
     /* Test clone */
     memset(output, 0x00, sizeof(output));
 
-    TEST_ASSERT(0 == mbedtls_md_update(&ctx_copy, src + halfway, src_len - halfway));
-    TEST_ASSERT(0 == mbedtls_md_finish(&ctx_copy, 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);
@@ -226,18 +224,18 @@
 
     md_info = mbedtls_md_info_from_type(md_type);
     TEST_ASSERT(md_info != NULL);
-    TEST_ASSERT(0 == mbedtls_md_setup(&ctx, md_info, 0));
-    TEST_ASSERT(0 == mbedtls_md_setup(&ctx_copy, md_info, 0));
+    TEST_EQUAL(0, mbedtls_md_setup(&ctx, md_info, 0));
+    TEST_EQUAL(0, mbedtls_md_setup(&ctx_copy, md_info, 0));
 
     halfway = src_str->len / 2;
 
-    TEST_ASSERT(0 == mbedtls_md_starts(&ctx));
+    TEST_EQUAL(0, mbedtls_md_starts(&ctx));
     TEST_ASSERT(ctx.md_ctx != NULL);
-    TEST_ASSERT(0 == mbedtls_md_update(&ctx, src_str->x, halfway));
-    TEST_ASSERT(0 == mbedtls_md_clone(&ctx_copy, &ctx));
+    TEST_EQUAL(0, mbedtls_md_update(&ctx, src_str->x, halfway));
+    TEST_EQUAL(0, mbedtls_md_clone(&ctx_copy, &ctx));
 
-    TEST_ASSERT(0 == mbedtls_md_update(&ctx, src_str->x + halfway, src_str->len - halfway));
-    TEST_ASSERT(0 == mbedtls_md_finish(&ctx, output));
+    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);
@@ -245,8 +243,8 @@
     /* Test clone */
     memset(output, 0x00, sizeof(output));
 
-    TEST_ASSERT(0 == mbedtls_md_update(&ctx_copy, src_str->x + halfway, src_str->len - halfway));
-    TEST_ASSERT(0 == mbedtls_md_finish(&ctx_copy, 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);
@@ -269,8 +267,8 @@
     TEST_ASSERT(md_info != NULL);
 
 
-    TEST_ASSERT(mbedtls_md_hmac(md_info, key_str->x, key_str->len, src_str->x, src_str->len,
-                                output) == 0);
+    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);
@@ -290,15 +288,15 @@
 
     md_info = mbedtls_md_info_from_type(md_type);
     TEST_ASSERT(md_info != NULL);
-    TEST_ASSERT(0 == mbedtls_md_setup(&ctx, md_info, 1));
+    TEST_EQUAL(0, mbedtls_md_setup(&ctx, md_info, 1));
 
     halfway = src_str->len / 2;
 
-    TEST_ASSERT(0 == mbedtls_md_hmac_starts(&ctx, key_str->x, key_str->len));
+    TEST_EQUAL(0, mbedtls_md_hmac_starts(&ctx, key_str->x, key_str->len));
     TEST_ASSERT(ctx.md_ctx != NULL);
-    TEST_ASSERT(0 == mbedtls_md_hmac_update(&ctx, src_str->x, halfway));
-    TEST_ASSERT(0 == mbedtls_md_hmac_update(&ctx, src_str->x + halfway, src_str->len - halfway));
-    TEST_ASSERT(0 == mbedtls_md_hmac_finish(&ctx, output));
+    TEST_EQUAL(0, mbedtls_md_hmac_update(&ctx, src_str->x, halfway));
+    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);
@@ -306,10 +304,10 @@
     /* Test again, for reset() */
     memset(output, 0x00, sizeof(output));
 
-    TEST_ASSERT(0 == mbedtls_md_hmac_reset(&ctx));
-    TEST_ASSERT(0 == mbedtls_md_hmac_update(&ctx, src_str->x, halfway));
-    TEST_ASSERT(0 == mbedtls_md_hmac_update(&ctx, src_str->x + halfway, src_str->len - halfway));
-    TEST_ASSERT(0 == mbedtls_md_hmac_finish(&ctx, output));
+    TEST_EQUAL(0, mbedtls_md_hmac_reset(&ctx));
+    TEST_EQUAL(0, mbedtls_md_hmac_update(&ctx, src_str->x, halfway));
+    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);
@@ -329,7 +327,7 @@
     md_info = mbedtls_md_info_from_type(md_type);
     TEST_ASSERT(md_info != NULL);
 
-    TEST_ASSERT(mbedtls_md_file(md_info, filename, output) == 0);
+    TEST_EQUAL(0, mbedtls_md_file(md_info, filename, output));
 
     TEST_ASSERT(mbedtls_test_hexcmp(output, hash->x,
                                     mbedtls_md_get_size(md_info),