From cfade19b1cfc64f01ec8883fd11bd594e01f76de Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Wed, 27 Mar 2013 17:07:12 +0100 Subject: [PATCH] Don't try to simulate variadic macro arguments * We're not ready to jump headlong into C99 * Explicitly assemble the arguments to test_check_directory() macro https://bugs.freedesktop.org/show_bug.cgi?id=62819 --- tools/tests/test-openssl.c | 8 ++++---- tools/tests/test-pem.c | 4 ++-- tools/tests/test-save.c | 20 ++++++++++---------- tools/tests/test-x509.c | 4 ++-- tools/tests/test.c | 18 +++++++++--------- tools/tests/test.h | 5 ++--- 6 files changed, 29 insertions(+), 30 deletions(-) diff --git a/tools/tests/test-openssl.c b/tools/tests/test-openssl.c index 77df109..d071e65 100644 --- a/tools/tests/test-openssl.c +++ b/tools/tests/test-openssl.c @@ -605,11 +605,11 @@ test_directory (CuTest *tc) ret = p11_extract_openssl_directory (test.iter, &test.ex); CuAssertIntEquals (tc, true, ret); - test_check_directory (tc, test.directory, ("Custom_Label.pem", "Custom_Label.1.pem", + test_check_directory (tc, test.directory, test_set ("Custom_Label.pem", "Custom_Label.1.pem", #ifdef OS_UNIX - "e5662767.1", "e5662767.0", "590d426f.1", "590d426f.0", + "e5662767.1", "e5662767.0", "590d426f.1", "590d426f.0", #endif - NULL)); + NULL)); test_check_file (tc, test.directory, "Custom_Label.pem", SRCDIR "/files/cacert3-trusted-server-alias.pem"); test_check_file (tc, test.directory, "Custom_Label.1.pem", @@ -642,7 +642,7 @@ test_directory_empty (CuTest *tc) ret = p11_extract_openssl_directory (test.iter, &test.ex); CuAssertIntEquals (tc, true, ret); - test_check_directory (tc, test.directory, (NULL, NULL)); + test_check_directory (tc, test.directory, test_set (NULL, NULL)); teardown (tc); } diff --git a/tools/tests/test-pem.c b/tools/tests/test-pem.c index 5c19455..49d4339 100644 --- a/tools/tests/test-pem.c +++ b/tools/tests/test-pem.c @@ -210,7 +210,7 @@ test_directory (CuTest *tc) ret = p11_extract_pem_directory (test.iter, &test.ex); CuAssertIntEquals (tc, true, ret); - test_check_directory (tc, test.directory, ("Cacert3_Here.pem", "Cacert3_Here.1.pem", NULL)); + test_check_directory (tc, test.directory, test_set ("Cacert3_Here.pem", "Cacert3_Here.1.pem", NULL)); test_check_file (tc, test.directory, "Cacert3_Here.pem", SRCDIR "/files/cacert3.pem"); test_check_file (tc, test.directory, "Cacert3_Here.1.pem", SRCDIR "/files/cacert3.pem"); @@ -236,7 +236,7 @@ test_directory_empty (CuTest *tc) ret = p11_extract_pem_directory (test.iter, &test.ex); CuAssertIntEquals (tc, true, ret); - test_check_directory (tc, test.directory, (NULL, NULL)); + test_check_directory (tc, test.directory, test_set (NULL, NULL)); teardown (tc); } diff --git a/tools/tests/test-save.c b/tools/tests/test-save.c index 32713ee..ffe9bdc 100644 --- a/tools/tests/test-save.c +++ b/tools/tests/test-save.c @@ -304,7 +304,7 @@ test_directory_empty (CuTest *tc) ret = p11_save_finish_directory (dir, true); CuAssertIntEquals (tc, true, ret); - test_check_directory (tc, subdir, (NULL, NULL)); + test_check_directory (tc, subdir, test_set (NULL, NULL)); CuAssertTrue (tc, rmdir (subdir) >= 0); free (subdir); @@ -346,11 +346,11 @@ test_directory_files (CuTest *tc) ret = p11_save_finish_directory (dir, true); CuAssertIntEquals (tc, true, ret); - test_check_directory (tc, subdir, ("blah.cer", "file.txt", + test_check_directory (tc, subdir, test_set ("blah.cer", "file.txt", #ifdef OS_UNIX - "link.ext", + "link.ext", #endif - NULL)); + NULL)); test_check_file (tc, subdir, "blah.cer", SRCDIR "/files/cacert3.der"); test_check_data (tc, subdir, "file.txt", test_text, strlen (test_text)); #ifdef OS_UNIX @@ -420,13 +420,13 @@ test_directory_dups (CuTest *tc) ret = p11_save_finish_directory (dir, true); CuAssertIntEquals (tc, true, ret); - test_check_directory (tc, subdir, ("file.txt", "file.1.txt", "file.2.txt", - "no-ext", "no-ext.1", - "with-num.0", "with-num.1", + test_check_directory (tc, subdir, test_set ("file.txt", "file.1.txt", "file.2.txt", + "no-ext", "no-ext.1", + "with-num.0", "with-num.1", #ifdef OS_UNIX - "link.0", "link.1", + "link.0", "link.1", #endif - NULL)); + NULL)); test_check_data (tc, subdir, "file.txt", test_text, 5); test_check_data (tc, subdir, "file.1.txt", test_text, 10); test_check_data (tc, subdir, "file.2.txt", test_text, 15); @@ -519,7 +519,7 @@ test_directory_overwrite (CuTest *tc) ret = p11_save_finish_directory (dir, true); CuAssertIntEquals (tc, true, ret); - test_check_directory (tc, subdir, ("blah.cer", "file.txt", "file.1.txt", NULL)); + test_check_directory (tc, subdir, test_set ("blah.cer", "file.txt", "file.1.txt", NULL)); test_check_data (tc, subdir, "blah.cer", test_cacert3_ca_der, sizeof (test_cacert3_ca_der)); test_check_data (tc, subdir, "file.txt", test_text, strlen (test_text)); test_check_data (tc, subdir, "file.1.txt", test_text, 10); diff --git a/tools/tests/test-x509.c b/tools/tests/test-x509.c index 7cf9787..afdf822 100644 --- a/tools/tests/test-x509.c +++ b/tools/tests/test-x509.c @@ -220,7 +220,7 @@ test_directory (CuTest *tc) ret = p11_extract_x509_directory (test.iter, &test.ex); CuAssertIntEquals (tc, true, ret); - test_check_directory (tc, test.directory, ("Cacert3_Here.cer", "Cacert3_Here.1.cer", NULL)); + test_check_directory (tc, test.directory, test_set ("Cacert3_Here.cer", "Cacert3_Here.1.cer", NULL)); test_check_file (tc, test.directory, "Cacert3_Here.cer", SRCDIR "/files/cacert3.der"); test_check_file (tc, test.directory, "Cacert3_Here.1.cer", SRCDIR "/files/cacert3.der"); @@ -246,7 +246,7 @@ test_directory_empty (CuTest *tc) ret = p11_extract_x509_directory (test.iter, &test.ex); CuAssertIntEquals (tc, true, ret); - test_check_directory (tc, test.directory, (NULL, NULL)); + test_check_directory (tc, test.directory, test_set (NULL, NULL)); teardown (tc); } diff --git a/tools/tests/test.c b/tools/tests/test.c index 9407817..9b7f220 100644 --- a/tools/tests/test.c +++ b/tools/tests/test.c @@ -149,25 +149,25 @@ test_check_symlink_msg (CuTest *tc, #endif /* OS_UNIX */ p11_dict * -test_check_directory_files (const char *file, - ...) +test_set (const char *str, + ...) { - p11_dict *files; + p11_dict *set; va_list va; - files = p11_dict_new (p11_dict_str_hash, p11_dict_str_equal, NULL, NULL); + set = p11_dict_new (p11_dict_str_hash, p11_dict_str_equal, NULL, NULL); - va_start (va, file); + va_start (va, str); - while (file != NULL) { - if (!p11_dict_set (files, (void *)file, (void *)file)) + while (str != NULL) { + if (!p11_dict_set (set, (void *)str, (void *)str)) return_val_if_reached (NULL); - file = va_arg (va, const char *); + str = va_arg (va, const char *); } va_end (va); - return files; + return set; } void diff --git a/tools/tests/test.h b/tools/tests/test.h index de2bdc1..1b90eb1 100644 --- a/tools/tests/test.h +++ b/tools/tests/test.h @@ -231,7 +231,7 @@ void test_check_symlink_msg (CuTest *tc, #endif /* OS_UNIX */ -p11_dict * test_check_directory_files (const char *file, +p11_dict * test_set (const char *file, ...) GNUC_NULL_TERMINATED; void test_check_directory_msg (CuTest *tc, @@ -254,7 +254,6 @@ void test_check_directory_msg (CuTest *tc, #endif /* OS_UNIX */ #define test_check_directory(tc, directory, files) \ - (test_check_directory_msg (tc, __FILE__, __LINE__, directory, \ - test_check_directory_files files)) + (test_check_directory_msg (tc, __FILE__, __LINE__, directory, files)) #endif /* TEST_COMMON_H_ */ -- 1.8.1.4