summaryrefslogtreecommitdiff
path: root/tools/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tools/tests')
-rw-r--r--tools/tests/test-save.c25
-rw-r--r--tools/tests/test.c8
2 files changed, 17 insertions, 16 deletions
diff --git a/tools/tests/test-save.c b/tools/tests/test-save.c
index 88d1ecd..cd6cb44 100644
--- a/tools/tests/test-save.c
+++ b/tools/tests/test-save.c
@@ -304,7 +304,7 @@ test_directory_empty (CuTest *tc)
test_check_directory (tc, subdir, (NULL, NULL));
- rmdir (subdir);
+ CuAssertTrue (tc, rmdir (subdir) >= 0);
free (subdir);
teardown (tc);
@@ -355,7 +355,7 @@ test_directory_files (CuTest *tc)
test_check_symlink (tc, subdir, "link.ext", "/the/destination");
#endif
- rmdir (subdir);
+ CuAssertTrue (tc, rmdir (subdir) >= 0);
free (subdir);
teardown (tc);
@@ -437,7 +437,7 @@ test_directory_dups (CuTest *tc)
test_check_symlink (tc, subdir, "link.1", "/destination2");
#endif
- rmdir (subdir);
+ CuAssertTrue (tc, rmdir (subdir) >= 0);
free (subdir);
teardown (tc);
@@ -487,18 +487,15 @@ 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 */
- write_zero_file (tc, subdir, "file.txt");
- write_zero_file (tc, subdir, "another-file");
- write_zero_file (tc, subdir, "third-file");
+ dir = p11_save_open_directory (subdir, 0);
+ ret = p11_save_write_and_finish (p11_save_open_file_in (dir, "file", ".txt", NULL), "", 0) &&
+ p11_save_write_and_finish (p11_save_open_file_in (dir, "another-file", NULL, NULL), "", 0) &&
+ p11_save_write_and_finish (p11_save_open_file_in (dir, "third-file", NULL, NULL), "", 0) &&
+ p11_save_finish_directory (dir, true);
+ CuAssertTrue (tc, ret && dir);
+ /* Now the actual test, using the same directory */
dir = p11_save_open_directory (subdir, P11_SAVE_OVERWRITE);
CuAssertPtrNotNull (tc, dir);
@@ -525,7 +522,7 @@ test_directory_overwrite (CuTest *tc)
test_check_data (tc, subdir, "file.txt", test_text, strlen (test_text));
test_check_data (tc, subdir, "file.1.txt", test_text, 10);
- rmdir (subdir);
+ CuAssertTrue (tc, rmdir (subdir) >= 0);
free (subdir);
teardown (tc);
diff --git a/tools/tests/test.c b/tools/tests/test.c
index 56e65cd..9407817 100644
--- a/tools/tests/test.c
+++ b/tools/tests/test.c
@@ -116,7 +116,7 @@ test_check_data_msg (CuTest *tc,
if (filelen != reflen || memcmp (filedata, refdata, reflen) != 0)
CuFail_Line (tc, file, line, "File contents not as expected", filename);
- unlink (filename);
+ CuAssert_Line (tc, file, line, "couldn't remove file", unlink (filename) >= 0);
free (filename);
free (filedata);
}
@@ -142,7 +142,7 @@ test_check_symlink_msg (CuTest *tc,
CuAssertStrEquals_LineMsg (tc, file, line, "symlink contents wrong", destination, buf);
- unlink (filename);
+ CuAssert_Line (tc, file, line, "couldn't remove symlink", unlink (filename) >= 0);
free (filename);
}
@@ -197,6 +197,10 @@ test_check_directory_msg (CuTest *tc,
closedir (dir);
+#if OS_UNIX
+ CuAssert_Line (tc, file, line, "couldn't chown directory", chmod (directory, S_IRWXU) >= 0);
+#endif
+
p11_dict_iterate (files, &iter);
while (p11_dict_next (&iter, (void **)&name, NULL))
CuFail_Line (tc, file, line, "Couldn't find file in directory", name);