]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-dcrypt: Check for all the return values in unit tests
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Sun, 19 Jun 2016 19:27:00 +0000 (22:27 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 21 Jun 2016 18:43:07 +0000 (21:43 +0300)
src/lib-dcrypt/test-crypto.c
src/lib-dcrypt/test-stream.c

index d1fb75cafed84156935a59fe27a04c073ab46d4d..afc0c92c4e4f3bfb201768f9c6b4221e58907343 100644 (file)
@@ -134,7 +134,7 @@ void test_cipher_aead_test_vectors(void)
        test_assert(dcrypt_ctx_sym_init(ctx, &error));
        test_assert(dcrypt_ctx_sym_update(ctx, pt->data, pt->used, res, &error));
        test_assert(dcrypt_ctx_sym_final(ctx, res, &error));
-       dcrypt_ctx_sym_get_tag(ctx, tag_res);
+       test_assert(dcrypt_ctx_sym_get_tag(ctx, tag_res));
 
        test_assert(buffer_cmp(ct, res) == TRUE);
        test_assert(buffer_cmp(tag, tag_res) == TRUE);
@@ -205,7 +205,7 @@ void test_load_v1_key(void)
                /* check that key_id matches */
                struct dcrypt_public_key *pubkey = NULL;
                dcrypt_key_convert_private_to_public(pkey, &pubkey);
-               dcrypt_key_store_public(pubkey, DCRYPT_FORMAT_DOVECOT, key_1, NULL);
+               test_assert(dcrypt_key_store_public(pubkey, DCRYPT_FORMAT_DOVECOT, key_1, NULL));
                buffer_set_used_size(key_1, 0);
                dcrypt_key_id_public(pubkey, "sha256", key_1, &error);
                test_assert(strcmp("792caad4d38c9eb2134a0cbc844eae386116de096a0ccafc98479825fc99b6a1", binary_to_hex(key_1->data, key_1->used)) == 0);
@@ -219,9 +219,9 @@ void test_load_v1_key(void)
                        /* check that key_id matches */
                        struct dcrypt_public_key *pubkey = NULL;
                        dcrypt_key_convert_private_to_public(pkey2, &pubkey);
-                       dcrypt_key_store_public(pubkey, DCRYPT_FORMAT_DOVECOT, key_1, NULL);
+                       test_assert(dcrypt_key_store_public(pubkey, DCRYPT_FORMAT_DOVECOT, key_1, NULL));
                        buffer_set_used_size(key_1, 0);
-                       dcrypt_key_id_public_old(pubkey, key_1, &error);
+                       test_assert(dcrypt_key_id_public_old(pubkey, key_1, &error));
                        test_assert(strcmp("7c9a1039ea2e4fed73e81dd3ffc3fa22ea4a28352939adde7bf8ea858b00fa4f", binary_to_hex(key_1->data, key_1->used)) == 0);
 
                        dcrypt_key_free_public(&pubkey);
index 2384ba292464c3762552c58d7819a1f8cfd68d97..9031bd1c35a92aa46b50fe2bb935bb2ef03d7dfd 100644 (file)
@@ -220,10 +220,10 @@ int main(void) {
        dcrypt_initialize("openssl", NULL, NULL);
        random_init();
 
-       dcrypt_key_load_private(&test_v1_kp.priv, DCRYPT_FORMAT_PEM, key_v1_priv, NULL, NULL, NULL);
-       dcrypt_key_load_public(&test_v1_kp.pub, DCRYPT_FORMAT_PEM, key_v1_pub, NULL);
-       dcrypt_key_load_private(&test_v2_kp.priv, DCRYPT_FORMAT_PEM, key_v2_priv, NULL, NULL, NULL);
-       dcrypt_key_load_public(&test_v2_kp.pub, DCRYPT_FORMAT_PEM, key_v2_pub, NULL);
+       test_assert(dcrypt_key_load_private(&test_v1_kp.priv, DCRYPT_FORMAT_PEM, key_v1_priv, NULL, NULL, NULL));
+       test_assert(dcrypt_key_load_public(&test_v1_kp.pub, DCRYPT_FORMAT_PEM, key_v1_pub, NULL));
+       test_assert(dcrypt_key_load_private(&test_v2_kp.priv, DCRYPT_FORMAT_PEM, key_v2_priv, NULL, NULL, NULL));
+       test_assert(dcrypt_key_load_public(&test_v2_kp.pub, DCRYPT_FORMAT_PEM, key_v2_pub, NULL));
 
        static void (*test_functions[])(void) = {
                test_static_v1_input,