commit 85a76cd4ebdb8f7face1e5deb5fa0d9f8612f31b
Author: Nick Mathewson <nickm(a)torproject.org>
Date: Fri Nov 7 08:54:03 2014 -0500
test_checkdir.c: try to make it pass on windows
also fix memory-leak on failing tests.
---
src/test/test_checkdir.c | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/src/test/test_checkdir.c b/src/test/test_checkdir.c
index 185e5fb..4bbccfc 100644
--- a/src/test/test_checkdir.c
+++ b/src/test/test_checkdir.c
@@ -10,6 +10,9 @@
#ifdef _WIN32
#define mkdir(a,b) mkdir(a)
+#define tt_int_op_nowin(a,op,b) do { (void)(a); (void)(b); } while (0)
+#else
+#define tt_int_op_nowin(a,op,b) tt_int_op((a),op,(b))
#endif
/** Run unit tests for private dir permission enforcement logic. */
@@ -19,7 +22,7 @@ test_checkdir_perms(void *testdata)
(void)testdata;
or_options_t *options = get_options_mutable();
const char *subdir = "test_checkdir";
- char *testdir;
+ char *testdir = NULL;
cpd_check_t cpd_chkopts;
cpd_check_t unix_create_opts;
cpd_check_t unix_verify_optsmask;
@@ -36,7 +39,7 @@ test_checkdir_perms(void *testdata)
unix_verify_optsmask = 0077;
tt_int_op(0, ==, check_private_dir(testdir, cpd_chkopts, NULL));
tt_int_op(0, ==, stat(testdir, &st));
- tt_int_op(0, ==, (st.st_mode & unix_verify_optsmask));
+ tt_int_op_nowin(0, ==, (st.st_mode & unix_verify_optsmask));
tor_free(testdir);
/* test: create new dir, CPD_GROUP_OK option set. */
@@ -45,7 +48,7 @@ test_checkdir_perms(void *testdata)
unix_verify_optsmask = 0077;
tt_int_op(0, ==, check_private_dir(testdir, cpd_chkopts, NULL));
tt_int_op(0, ==, stat(testdir, &st));
- tt_int_op(0, ==, (st.st_mode & unix_verify_optsmask));
+ tt_int_op_nowin(0, ==, (st.st_mode & unix_verify_optsmask));
tor_free(testdir);
/* test: should get an error on existing dir with
@@ -62,7 +65,7 @@ test_checkdir_perms(void *testdata)
unix_verify_optsmask = 0027;
tt_int_op(0, ==, check_private_dir(testdir, cpd_chkopts, NULL));
tt_int_op(0, ==, stat(testdir, &st));
- tt_int_op(0, ==, (st.st_mode & unix_verify_optsmask));
+ tt_int_op_nowin(0, ==, (st.st_mode & unix_verify_optsmask));
tor_free(testdir);
/* test: check existing dir created with defaults,
@@ -75,7 +78,7 @@ test_checkdir_perms(void *testdata)
tt_int_op(0, ==, mkdir(testdir, unix_create_opts));
tt_int_op(0, ==, check_private_dir(testdir, cpd_chkopts, NULL));
tt_int_op(0, ==, stat(testdir, &st));
- tt_int_op(0, ==, (st.st_mode & unix_verify_optsmask));
+ tt_int_op_nowin(0, ==, (st.st_mode & unix_verify_optsmask));
tor_free(testdir);
/* test: check existing dir created with defaults,
@@ -87,7 +90,7 @@ test_checkdir_perms(void *testdata)
cpd_chkopts = CPD_GROUP_OK;
tt_int_op(0, ==, check_private_dir(testdir, cpd_chkopts, NULL));
tt_int_op(0, ==, stat(testdir, &st));
- tt_int_op(0, ==, (st.st_mode & unix_verify_optsmask));
+ tt_int_op_nowin(0, ==, (st.st_mode & unix_verify_optsmask));
tor_free(testdir);
/* test: check existing dir created with defaults,
@@ -99,7 +102,7 @@ test_checkdir_perms(void *testdata)
cpd_chkopts = CPD_GROUP_READ;
tt_int_op(0, ==, check_private_dir(testdir, cpd_chkopts, NULL));
tt_int_op(0, ==, stat(testdir, &st));
- tt_int_op(0, ==, (st.st_mode & unix_verify_optsmask));
+ tt_int_op_nowin(0, ==, (st.st_mode & unix_verify_optsmask));
tor_free(testdir);
/* test: check existing dir created with CPD_GROUP_READ,
@@ -111,7 +114,7 @@ test_checkdir_perms(void *testdata)
cpd_chkopts = CPD_GROUP_OK;
tt_int_op(0, ==, check_private_dir(testdir, cpd_chkopts, NULL));
tt_int_op(0, ==, stat(testdir, &st));
- tt_int_op(0, ==, (st.st_mode & unix_verify_optsmask));
+ tt_int_op_nowin(0, ==, (st.st_mode & unix_verify_optsmask));
tor_free(testdir);
/* test: check existing dir created with CPD_GROUP_READ,
@@ -121,11 +124,11 @@ test_checkdir_perms(void *testdata)
unix_verify_optsmask = 0027;
tt_int_op(0, ==, check_private_dir(testdir, cpd_chkopts, NULL));
tt_int_op(0, ==, stat(testdir, &st));
- tt_int_op(0, ==, (st.st_mode & unix_verify_optsmask));
- tor_free(testdir);
+ tt_int_op_nowin(0, ==, (st.st_mode & unix_verify_optsmask));
done:
- ;
+ tor_free(testdir);
+
}
#define CHECKDIR(name,flags) \