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.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@350478 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2019-01-05 21:18:10 +00:00
parent 73aa3a8936
commit 936dd3d1ff

View File

@@ -125,7 +125,7 @@ TimeSpec LastAccessTime(path const& p) { return GetTimes(p).access; }
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> 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<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));
}