[libcxx] r350478 - Fix flaky symlink access time test.

Eric Fiselier eric at efcs.ca
Sat Jan 5 13:18:10 PST 2019


Author: ericwf
Date: Sat Jan  5 13:18:10 2019
New Revision: 350478

URL: http://llvm.org/viewvc/llvm-project?rev=350478&view=rev
Log:
Fix flaky symlink access time test.

last_write_time(sym, new_time) changes the modification time of the file
referenced by the symlink. But reading through the symlink may change the
symlinks's access time.

This meant the previous test that checked that the symlinks access
time was unchanged was incorrect and made the test flaky.

This patch removes this test (there really is no non-flaky way
to test that the new access time coorisponds to the time at which
the symlink was last dereferenced). This should unflake the test.

Modified:
    libcxx/trunk/test/std/input.output/filesystems/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp

Modified: libcxx/trunk/test/std/input.output/filesystems/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/filesystems/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp?rev=350478&r1=350477&r2=350478&view=diff
==============================================================================
--- libcxx/trunk/test/std/input.output/filesystems/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp (original)
+++ libcxx/trunk/test/std/input.output/filesystems/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp Sat Jan  5 13:18:10 2019
@@ -125,7 +125,7 @@ TimeSpec LastAccessTime(path const& p) {
 
 TimeSpec LastWriteTime(path const& p) { return GetTimes(p).write; }
 
-std::pair<TimeSpec, TimeSpec> GetSymlinkTimes(path const& p) {
+Times GetSymlinkTimes(path const& p) {
   StatT st;
   if (::lstat(p.c_str(), &st) == -1) {
     std::error_code ec(errno, std::generic_category());
@@ -136,7 +136,10 @@ std::pair<TimeSpec, TimeSpec> GetSymlink
         std::exit(EXIT_FAILURE);
 #endif
     }
-    return {extract_atime(st), extract_mtime(st)};
+    Times res;
+    res.access = extract_atime(st);
+    res.write = extract_mtime(st);
+    return res;
 }
 
 namespace {
@@ -500,9 +503,8 @@ TEST_CASE(last_write_time_symlink_test)
 
     TEST_CHECK(CompareTime(LastWriteTime(file), new_time));
     TEST_CHECK(CompareTime(LastAccessTime(sym), old_times.access));
-    std::pair<TimeSpec, TimeSpec> sym_times = GetSymlinkTimes(sym);
-    TEST_CHECK(CompareTime(sym_times.first, old_sym_times.first));
-    TEST_CHECK(CompareTime(sym_times.second, old_sym_times.second));
+    Times sym_times = GetSymlinkTimes(sym);
+    TEST_CHECK(CompareTime(sym_times.write, old_sym_times.write));
 }
 
 




More information about the libcxx-commits mailing list