]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
var-expand-crypt: Split test into two
authorAki Tuomi <aki.tuomi@open-xchange.com>
Sun, 17 Nov 2024 11:00:03 +0000 (13:00 +0200)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Fri, 17 Jan 2025 08:40:00 +0000 (10:40 +0200)
src/plugins/var-expand-crypt/test-var-expand-crypt.c

index bac1505928e03bf4ddc6d2ef6b6c851dd9355f1b..1728359bfad95c97509a34f22456b48f63ba5292 100644 (file)
@@ -12,6 +12,21 @@ struct module;
 extern void var_expand_crypt_init(struct module *module);
 extern void var_expand_crypt_deinit(void);
 
+static struct var_expand_table table[] = {
+       { .key = "iv", .value = "98b3b40a48ca40f998b3b40a48ca40f9" },
+       { .key = "key", .value = "cc2981c8f38aea59cc2981c8f38aea59" },
+       {
+               .key = "encrypted_raw",
+               .value = "46b58741763fe22598014be26331a082" },
+       {
+               .key = "encrypted",
+               .value = "98b3b40a48ca40f998b3b40a48ca40f9$46b58741763fe22598014be26331a082$"
+       },
+       { .key = "decrypted", .value = "hello, world" },
+       { .key = "encrypted2", .value = NULL },
+       { NULL, NULL, NULL }
+};
+
 static void test_var_expand_crypt_init(void)
 {
        var_expand_crypt_init(NULL);
@@ -19,20 +34,6 @@ static void test_var_expand_crypt_init(void)
 
 static void test_var_expand_crypt(void)
 {
-       struct var_expand_table table[] = {
-               { .key = "iv", .value = "98b3b40a48ca40f998b3b40a48ca40f9" },
-               { .key = "key", .value = "cc2981c8f38aea59cc2981c8f38aea59" },
-               {
-                       .key = "encrypted_raw",
-                       .value = "46b58741763fe22598014be26331a082" },
-               {
-                       .key = "encrypted",
-                       .value = "98b3b40a48ca40f998b3b40a48ca40f9$46b58741763fe22598014be26331a082$"
-               },
-               { .key = "decrypted", .value = "hello, world" },
-               { .key = "encrypted2", .value = NULL },
-               { NULL, NULL, NULL }
-       };
        const struct var_expand_params params = {
                .table = table,
        };
@@ -90,13 +91,19 @@ static void test_var_expand_crypt(void)
        } T_END;
 
        test_end();
+}
 
+static void test_var_expand_crypt_random(void)
+{
        test_begin("var_expand_crypt_random");
 
        string_t *input = t_str_new(32);
        string_t *output = t_str_new(32);
+       const struct var_expand_params params = {
+               .table = table,
+       };
 
-       for (i = 0; i < 1000; i++) {
+       for (unsigned int i = 0; i < 1000; i++) {
                const char *error;
                str_truncate(input, 0);
                str_truncate(output, 0);
@@ -125,6 +132,7 @@ int main(void)
        static void (*const test_functions[])(void) = {
                test_var_expand_crypt_init,
                test_var_expand_crypt,
+               test_var_expand_crypt_random,
                test_var_expand_crypt_deinit,
                NULL
        };