aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2011-05-15 20:22:44 -0400
committerNick Mathewson <nickm@torproject.org>2011-05-15 20:22:44 -0400
commit4ac8ff9c9f182b6202200480f8fc4689da659331 (patch)
treec7817f2cc0755ff989df49b85abde0763bbb4bf2 /src/test
parentf2c170218238a38a0106acb1a7428b514ce979ca (diff)
parentede102fd4675af8ac4060767f0348f3c93617e80 (diff)
downloadtor-4ac8ff9c9f182b6202200480f8fc4689da659331.tar.gz
tor-4ac8ff9c9f182b6202200480f8fc4689da659331.zip
Merge remote-tracking branch 'origin/maint-0.2.2'
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test_util.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c
index ee2d455b29..d338bbac9c 100644
--- a/src/test/test_util.c
+++ b/src/test/test_util.c
@@ -1208,6 +1208,35 @@ test_util_listdir(void *ptr)
}
}
+static void
+test_util_parent_dir(void *ptr)
+{
+ char *cp;
+ (void)ptr;
+
+#define T(input,expect_ok,output) \
+ do { \
+ int ok; \
+ cp = tor_strdup(input); \
+ ok = get_parent_directory(cp); \
+ tt_int_op(ok, ==, expect_ok); \
+ if (ok==0) \
+ tt_str_op(cp, ==, output); \
+ tor_free(cp); \
+ } while (0);
+
+ T("/home/wombat/knish", 0, "/home/wombat");
+ T("/home/wombat/knish/", 0, "/home/wombat");
+ T("./home/wombat/knish/", 0, "./home/wombat");
+ T("./wombat", 0, ".");
+ T("", -1, "");
+ T("/", -1, "");
+ T("////", -1, "");
+
+ done:
+ tor_free(cp);
+}
+
#ifdef MS_WINDOWS
static void
test_util_load_win_lib(void *ptr)
@@ -1495,6 +1524,7 @@ struct testcase_t util_tests[] = {
UTIL_TEST(find_str_at_start_of_line, 0),
UTIL_TEST(asprintf, 0),
UTIL_TEST(listdir, 0),
+ UTIL_TEST(parent_dir, 0),
#ifdef MS_WINDOWS
UTIL_TEST(load_win_lib, 0),
#endif