]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
expand_filename tests for trailing slash in $HOME
authorEsteban Manchado Velázquez <emanchado@demiurgo.org>
Mon, 20 Feb 2012 21:52:15 +0000 (22:52 +0100)
committerNick Mathewson <nickm@torproject.org>
Fri, 9 Mar 2012 02:16:46 +0000 (21:16 -0500)
src/test/test_util.c

index ecf4db2d4c396a15058477f4a1b384d2bc3dd4c8..c63f97d7f63dad6aaa18ea3b8356e97513e9bc2d 100644 (file)
@@ -588,6 +588,21 @@ test_util_expand_filename(void)
   /* Ideally we'd test ~anotheruser, but that's shady to test (we'd
      have to somehow inject/fake the get_user_homedir call) */
 
+  /* $HOME ending in a trailing slash */
+  setenv("HOME", "/home/itv/", 1);
+
+  str = expand_filename("~");
+  test_streq("/home/itv/", str);
+  tor_free(str);
+
+  str = expand_filename("~/");
+  test_streq("/home/itv/", str);
+  tor_free(str);
+
+  str = expand_filename("~/foo");
+  test_streq("/home/itv/foo", str);
+  tor_free(str);
+
   /* Try with empty $HOME */
 
   setenv("HOME", "", 1);