Commit 174f1d26 by Jonathan Wakely Committed by Jonathan Wakely

Fix filesystem::last_write_time failure with 32-bit time_t

	* testsuite/27_io/filesystem/operations/last_write_time.cc: Fix
	test failures on targets with 32-bit time_t.

From-SVN: r267811
parent 45a8d80f
2019-01-10 Jonathan Wakely <jwakely@redhat.com> 2019-01-10 Jonathan Wakely <jwakely@redhat.com>
* testsuite/27_io/filesystem/operations/last_write_time.cc: Fix
test failures on targets with 32-bit time_t.
* include/bits/erase_if.h: Define __cpp_lib_erase_if. * include/bits/erase_if.h: Define __cpp_lib_erase_if.
* include/std/deque: Likewise. * include/std/deque: Likewise.
* include/std/forward_list: Likewise. * include/std/forward_list: Likewise.
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
// 15.25 Permissions [fs.op.last_write_time] // 15.25 Permissions [fs.op.last_write_time]
#include <filesystem> #include <filesystem>
#include <limits>
#include <testsuite_fs.h> #include <testsuite_fs.h>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
...@@ -141,14 +142,27 @@ test02() ...@@ -141,14 +142,27 @@ test02()
VERIFY( !ec ); VERIFY( !ec );
VERIFY( approx_equal(last_write_time(f.path), time) ); VERIFY( approx_equal(last_write_time(f.path), time) );
if (std::numeric_limits<std::time_t>::max()
< std::numeric_limits<std::int64_t>::max())
return; // file clock's epoch is out of range for 32-bit time_t
ec = bad_ec; ec = bad_ec;
// The file clock's epoch:
time = time_type(); time = time_type();
last_write_time(f.path, time, ec); last_write_time(f.path, time, ec);
VERIFY( !ec ); VERIFY( !ec );
VERIFY( approx_equal(last_write_time(f.path), time) ); VERIFY( approx_equal(last_write_time(f.path), time) );
ec = bad_ec; ec = bad_ec;
time -= std::chrono::milliseconds(1000 * 60 * 10 + 15); // A time after the epoch
time += std::chrono::milliseconds(1000 * 60 * 10 + 15);
last_write_time(f.path, time, ec);
VERIFY( !ec );
VERIFY( approx_equal(last_write_time(f.path), time) );
ec = bad_ec;
// A time before than the epoch
time -= std::chrono::milliseconds(1000 * 60 * 20 + 15);
last_write_time(f.path, time, ec); last_write_time(f.path, time, ec);
VERIFY( !ec ); VERIFY( !ec );
VERIFY( approx_equal(last_write_time(f.path), time) ); VERIFY( approx_equal(last_write_time(f.path), time) );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment