Author: ericwf Date: Wed Jul 25 20:42:25 2018 New Revision: 338000 URL: http://llvm.org/viewvc/llvm-project?rev=338000&view=rev Log: Correct comment about stat truncating st_mtimespec to seconds
Modified: libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp Modified: libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp?rev=338000&r1=337999&r2=338000&view=diff ============================================================================== --- libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp (original) +++ libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp Wed Jul 25 20:42:25 2018 @@ -208,15 +208,11 @@ static const bool SupportsMinTime = [] { static const bool SupportsNanosecondRoundTrip = [] { NanoSec ns(3); - - // Test if the file_time_type period is less than that of nanoseconds. - auto ft_dur = duration_cast<file_time_type::duration>(ns); - if (duration_cast<NanoSec>(ft_dur) != ns) - return false; + static_assert(std::is_same<file_time_type::period, std::nano>::value, ""); // Test that the system call we use to set the times also supports nanosecond // resolution. (utimes does not) - file_time_type ft(ft_dur); + file_time_type ft(ns); { scoped_test_env env; const path p = env.create_file("file", 42); @@ -225,13 +221,14 @@ static const bool SupportsNanosecondRoun } }(); - +// The HFS+ filesystem (used by default before macOS 10.13) stores timestamps at +// a 1-second granularity, and APFS (now the default) at a 1 nanosecond granularity. +// 1-second granularity is also the norm on many of the supported filesystems +// on Linux as well. static const bool WorkaroundStatTruncatesToSeconds = [] { MicroSec micros(3); static_assert(std::is_same<file_time_type::period, std::nano>::value, ""); - // Test for the behavior of OS X 10.11 and older, which truncates the result - // of st_mtimespec to seconds. file_time_type ft(micros); { scoped_test_env env; @@ -594,14 +591,4 @@ TEST_CASE(test_exists_fails) TEST_CHECK_THROW_RESULT(filesystem_error, Checker, last_write_time(file)); } -// Just for sanity ensure that WorkaroundStatTruncatesToSeconds is only -// ever true on Apple platforms. -TEST_CASE(apple_truncates_to_seconds_check) { -#ifndef __APPLE__ - TEST_CHECK(!WorkaroundStatTruncatesToSeconds); -#else - TEST_CHECK(SupportsNanosecondRoundTrip != WorkaroundStatTruncatesToSeconds); -#endif -} - TEST_SUITE_END() _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits