diff options
author | Stef Walter <stefw@gnome.org> | 2013-03-03 10:03:40 +0100 |
---|---|---|
committer | Stef Walter <stefw@gnome.org> | 2013-03-03 10:07:18 +0100 |
commit | 6c55425a7de23a71d0abc3137f0015e878188bae (patch) | |
tree | e5183f130ea90cce0a11637afb9e40d09556aac3 /tools/tests | |
parent | 3acf285916968a05ea42b3ef0f9654a33e308da7 (diff) |
Windows doesn't support symlinks, chmod, or atomic renames
* Don't create symlinks on windows
* No atomic renames, so delete and then rename
* Make sure to close files before unlinking on windows
* No chmod permissions on windows
Diffstat (limited to 'tools/tests')
-rw-r--r-- | tools/tests/test-openssl.c | 7 | ||||
-rw-r--r-- | tools/tests/test-save.c | 26 | ||||
-rw-r--r-- | tools/tests/test.c | 4 | ||||
-rw-r--r-- | tools/tests/test.h | 8 |
4 files changed, 42 insertions, 3 deletions
diff --git a/tools/tests/test-openssl.c b/tools/tests/test-openssl.c index d242b50..bce9be6 100644 --- a/tools/tests/test-openssl.c +++ b/tools/tests/test-openssl.c @@ -599,15 +599,20 @@ test_directory (CuTest *tc) CuAssertIntEquals (tc, true, ret); test_check_directory (tc, test.directory, ("Custom_Label.pem", "Custom_Label.1.pem", - "e5662767.1", "e5662767.0", "590d426f.1", "590d426f.0", NULL)); +#ifdef OS_UNIX + "e5662767.1", "e5662767.0", "590d426f.1", "590d426f.0", +#endif + NULL)); test_check_file (tc, test.directory, "Custom_Label.pem", SRCDIR "/files/cacert3-trusted-client-server-alias.pem"); test_check_file (tc, test.directory, "Custom_Label.1.pem", SRCDIR "/files/cacert3-trusted-alias.pem"); +#ifdef OS_UNIX test_check_symlink (tc, test.directory, "e5662767.0", "Custom_Label.pem"); test_check_symlink (tc, test.directory, "e5662767.1", "Custom_Label.1.pem"); test_check_symlink (tc, test.directory, "590d426f.0", "Custom_Label.pem"); test_check_symlink (tc, test.directory, "590d426f.1", "Custom_Label.1.pem"); +#endif teardown (tc); } diff --git a/tools/tests/test-save.c b/tools/tests/test-save.c index 743ba88..4ceb4a8 100644 --- a/tools/tests/test-save.c +++ b/tools/tests/test-save.c @@ -71,7 +71,7 @@ static void teardown (CuTest *tc) { if (rmdir (test.directory) < 0) - CuFail (tc, "rmdir() failed"); + CuFail (tc, strerror (errno)); free (test.directory); } @@ -288,16 +288,24 @@ test_directory_files (CuTest *tc) CuAssertIntEquals (tc, true, ret); CuAssertStrEquals (tc, "file.txt", filename); +#ifdef OS_UNIX ret = p11_save_symlink_in (dir, "link", ".ext", "/the/destination"); CuAssertIntEquals (tc, true, ret); +#endif ret = p11_save_finish_directory (dir, true); CuAssertIntEquals (tc, true, ret); - test_check_directory (tc, subdir, ("blah.cer", "file.txt", "link.ext", NULL)); + test_check_directory (tc, subdir, ("blah.cer", "file.txt", +#ifdef OS_UNIX + "link.ext", +#endif + 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 test_check_symlink (tc, subdir, "link.ext", "/the/destination"); +#endif rmdir (subdir); free (subdir); @@ -351,11 +359,13 @@ test_directory_dups (CuTest *tc) test_text, 15); CuAssertIntEquals (tc, true, ret); +#ifdef OS_UNIX ret = p11_save_symlink_in (dir, "link", ".0", "/destination1"); CuAssertIntEquals (tc, true, ret); ret = p11_save_symlink_in (dir, "link", ".0", "/destination2"); CuAssertIntEquals (tc, true, ret); +#endif ret = p11_save_finish_directory (dir, true); CuAssertIntEquals (tc, true, ret); @@ -363,7 +373,9 @@ test_directory_dups (CuTest *tc) test_check_directory (tc, subdir, ("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", +#endif NULL)); test_check_data (tc, subdir, "file.txt", test_text, 5); test_check_data (tc, subdir, "file.1.txt", test_text, 10); @@ -372,8 +384,10 @@ test_directory_dups (CuTest *tc) test_check_data (tc, subdir, "no-ext.1", test_text, 16); test_check_data (tc, subdir, "with-num.0", test_text, 14); test_check_data (tc, subdir, "with-num.1", test_text, 15); +#ifdef OS_UNIX test_check_symlink (tc, subdir, "link.0", "/destination1"); test_check_symlink (tc, subdir, "link.1", "/destination2"); +#endif rmdir (subdir); free (subdir); @@ -392,7 +406,11 @@ test_directory_exists (CuTest *tc) if (asprintf (&subdir, "%s/%s", test.directory, "extract-dir") < 0) CuFail (tc, "asprintf() failed"); +#ifdef OS_UNIX if (mkdir (subdir, S_IRWXU) < 0) +#else + if (mkdir (subdir) < 0) +#endif CuFail (tc, "mkdir() failed"); p11_message_quiet (); @@ -421,7 +439,11 @@ test_directory_overwrite (CuTest *tc) if (asprintf (&subdir, "%s/%s", test.directory, "extract-dir") < 0) CuFail (tc, "asprintf() failed"); +#ifdef OS_UNIX if (mkdir (subdir, S_IRWXU) < 0) +#else + if (mkdir (subdir) < 0) +#endif CuFail (tc, "mkdir() failed"); /* Some initial files into this directory, which get overwritten */ diff --git a/tools/tests/test.c b/tools/tests/test.c index 61fda83..56e65cd 100644 --- a/tools/tests/test.c +++ b/tools/tests/test.c @@ -121,6 +121,8 @@ test_check_data_msg (CuTest *tc, free (filedata); } +#ifdef OS_UNIX + void test_check_symlink_msg (CuTest *tc, const char *file, @@ -144,6 +146,8 @@ test_check_symlink_msg (CuTest *tc, free (filename); } +#endif /* OS_UNIX */ + p11_dict * test_check_directory_files (const char *file, ...) diff --git a/tools/tests/test.h b/tools/tests/test.h index 7cf2492..82b8b2c 100644 --- a/tools/tests/test.h +++ b/tools/tests/test.h @@ -221,6 +221,8 @@ void test_check_data_msg (CuTest *tc, const void *refdata, long reflen); +#ifdef OS_UNIX + void test_check_symlink_msg (CuTest *tc, const char *file, int line, @@ -228,6 +230,8 @@ void test_check_symlink_msg (CuTest *tc, const char *name, const char *destination); +#endif /* OS_UNIX */ + p11_dict * test_check_directory_files (const char *file, ...) GNUC_NULL_TERMINATED; @@ -243,9 +247,13 @@ void test_check_directory_msg (CuTest *tc, #define test_check_data(tc, directory, name, data, length) \ (test_check_data_msg (tc, __FILE__, __LINE__, directory, name, data, length)) +#ifdef OS_UNIX + #define test_check_symlink(tc, directory, name, destination) \ (test_check_symlink_msg (tc, __FILE__, __LINE__, directory, name, destination)) +#endif /* OS_UNIX */ + #define test_check_directory(tc, directory, files) \ (test_check_directory_msg (tc, __FILE__, __LINE__, directory, \ test_check_directory_files files)) |