diff options
author | Nick Mathewson <nickm@torproject.org> | 2014-11-07 08:54:03 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2014-11-07 08:54:44 -0500 |
commit | 85a76cd4ebdb8f7face1e5deb5fa0d9f8612f31b (patch) | |
tree | b2c192b541f1ce793ccc1cfc2ca163985485bc72 /src/test/test_checkdir.c | |
parent | 68af1e7e9be8bef82b4574ac0934310af71a764b (diff) | |
download | tor-85a76cd4ebdb8f7face1e5deb5fa0d9f8612f31b.tar.gz tor-85a76cd4ebdb8f7face1e5deb5fa0d9f8612f31b.zip |
test_checkdir.c: try to make it pass on windows
also fix memory-leak on failing tests.
Diffstat (limited to 'src/test/test_checkdir.c')
-rw-r--r-- | src/test/test_checkdir.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/test/test_checkdir.c b/src/test/test_checkdir.c index 185e5fbef1..4bbccfc88b 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) \ |