]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Restitute a successful stat call to this test case.
authordana koch <dsk@google.com>
Sat, 15 Feb 2014 10:48:58 +0000 (21:48 +1100)
committerNick Mathewson <nickm@torproject.org>
Mon, 17 Feb 2014 22:55:40 +0000 (22:55 +0000)
Since the first stat call is made for it to deliberately fail, and we
reference st.st_mode without st having valid data, st.st_mode can contain
garbage and cause chmod to fail with EINVAL. We rerun stat and ensure it
succeeded.

Also make use of tt_abort_perror, to properly convey failure reasons to
the user.

src/test/test_config.c

index 678357d8eb2c2c7003cc57f9616fe072dd38492a..3a1e6cb78ad6ee1945c6a4a470ff039ffb9a90f8 100644 (file)
@@ -221,12 +221,17 @@ test_config_check_or_create_data_subdir(void *arg)
   // and is private to the user.
   test_assert(!check_or_create_data_subdir(subdir));
 
+  r = stat(subpath, &st);
+  if (r) {
+    tt_abort_perror("stat");
+  }
+
 #if !defined (_WIN32) || defined (WINCE)
   group_permission = st.st_mode | 0070;
   r = chmod(subpath, group_permission);
 
   if (r) {
-    test_fail_msg("Changing permissions for the subdirectory failed.");
+    tt_abort_perror("chmod");
   }
 
   // If the directory exists, but its mode is too permissive