From 5792cf42b7779b3709cdae1598d388a47bfb446a Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Sat, 5 Jan 2019 21:18:10 +0000 Subject: [PATCH] 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. llvm-svn: 350478 --- .../fs.op.last_write_time/last_write_time.pass.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp index 11152e6..bf0096a 100644 --- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp +++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp @@ -125,7 +125,7 @@ TimeSpec LastAccessTime(path const& p) { return GetTimes(p).access; } TimeSpec LastWriteTime(path const& p) { return GetTimes(p).write; } -std::pair 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 GetSymlinkTimes(path const& p) { 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 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)); } -- 2.7.4