aboutsummaryrefslogtreecommitdiff
path: root/tests/unit/test-crypto-hash.c
diff options
context:
space:
mode:
authorDaniel P. Berrangé <berrange@redhat.com>2021-06-25 18:48:41 +0100
committerDaniel P. Berrangé <berrange@redhat.com>2021-07-14 14:15:52 +0100
commit7ea450b0f02f83637794af4991f0b684608d6a25 (patch)
tree18f3d0859640d2e3e0ee6ac53fe5e4cda6c1567b /tests/unit/test-crypto-hash.c
parent295736cfc82ae9019cd647ef012a71f4e277e864 (diff)
downloadqemu-7ea450b0f02f83637794af4991f0b684608d6a25.zip
qemu-7ea450b0f02f83637794af4991f0b684608d6a25.tar.gz
qemu-7ea450b0f02f83637794af4991f0b684608d6a25.tar.bz2
crypto: use &error_fatal in crypto tests
Using error_fatal provides better diagnostics when tests failed, than using asserts, because we see the text of the error message. Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Diffstat (limited to 'tests/unit/test-crypto-hash.c')
-rw-r--r--tests/unit/test-crypto-hash.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/tests/unit/test-crypto-hash.c b/tests/unit/test-crypto-hash.c
index ce7d0ab..1f4abb8 100644
--- a/tests/unit/test-crypto-hash.c
+++ b/tests/unit/test-crypto-hash.c
@@ -104,7 +104,7 @@ static void test_hash_alloc(void)
strlen(INPUT_TEXT),
&result,
&resultlen,
- NULL);
+ &error_fatal);
g_assert(ret == 0);
g_assert(resultlen == expected_lens[i]);
@@ -139,7 +139,7 @@ static void test_hash_prealloc(void)
strlen(INPUT_TEXT),
&result,
&resultlen,
- NULL);
+ &error_fatal);
g_assert(ret == 0);
g_assert(resultlen == expected_lens[i]);
@@ -176,7 +176,7 @@ static void test_hash_iov(void)
iov, 3,
&result,
&resultlen,
- NULL);
+ &error_fatal);
g_assert(ret == 0);
g_assert(resultlen == expected_lens[i]);
for (j = 0; j < resultlen; j++) {
@@ -210,7 +210,7 @@ static void test_hash_digest(void)
INPUT_TEXT,
strlen(INPUT_TEXT),
&digest,
- NULL);
+ &error_fatal);
g_assert(ret == 0);
g_assert_cmpstr(digest, ==, expected_outputs[i]);
g_free(digest);
@@ -234,7 +234,7 @@ static void test_hash_base64(void)
INPUT_TEXT,
strlen(INPUT_TEXT),
&digest,
- NULL);
+ &error_fatal);
g_assert(ret == 0);
g_assert_cmpstr(digest, ==, expected_outputs_b64[i]);
g_free(digest);
@@ -243,7 +243,8 @@ static void test_hash_base64(void)
int main(int argc, char **argv)
{
- g_assert(qcrypto_init(NULL) == 0);
+ int ret = qcrypto_init(&error_fatal);
+ g_assert(ret == 0);
g_test_init(&argc, &argv, NULL);
g_test_add_func("/crypto/hash/iov", test_hash_iov);