Get filesystem tests passing for single-threaded configurations.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273054 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier 2016-06-17 21:44:26 +00:00
parent 841798ce01
commit 40d9e09d89
7 changed files with 14 additions and 14 deletions

View File

@ -20,7 +20,6 @@
#include <experimental/filesystem>
#include <type_traits>
#include <chrono>
#include <thread>
#include <cassert>
#include "test_macros.h"
@ -109,10 +108,10 @@ TEST_CASE(copy_file)
using Sec = std::chrono::seconds;
const path older = env.create_file("older_file", 1);
std::this_thread::sleep_for(Sec(2));
SleepFor(Sec(2));
const path from = env.create_file("update_from", 55);
std::this_thread::sleep_for(Sec(2));
SleepFor(Sec(2));
const path newer = env.create_file("newer_file", 2);
std::error_code ec;

View File

@ -17,8 +17,6 @@
#include <experimental/filesystem>
#include <type_traits>
#include <chrono>
#include <thread>
#include <cassert>
#include "test_macros.h"

View File

@ -16,8 +16,6 @@
#include <experimental/filesystem>
#include <type_traits>
#include <chrono>
#include <thread>
#include <cassert>
#include "test_macros.h"

View File

@ -18,8 +18,6 @@
#include <experimental/filesystem>
#include <type_traits>
#include <chrono>
#include <thread>
#include <cassert>
#include "test_macros.h"

View File

@ -16,8 +16,6 @@
#include <experimental/filesystem>
#include <type_traits>
#include <chrono>
#include <thread>
#include <cassert>
#include "test_macros.h"

View File

@ -21,11 +21,9 @@
#include <experimental/filesystem>
#include <type_traits>
#include <chrono>
#include <thread>
#include <fstream>
#include <iostream>
#include <cstdlib>
#include <cassert>
#include "test_macros.h"
#include "rapid-cxx-test.hpp"
@ -140,7 +138,7 @@ TEST_CASE(get_last_write_time_dynamic_env_test)
file_time_type dtime = last_write_time(dir);
TEST_CHECK(Clock::to_time_t(dtime) == dir_write_time);
std::this_thread::sleep_for(Sec(2));
SleepFor(Sec(2));
// update file and add a file to the directory. Make sure the times increase.
std::ofstream of(file, std::ofstream::app);

View File

@ -7,6 +7,7 @@
#include <string>
#include <fstream>
#include <random>
#include <chrono>
namespace fs = std::experimental::filesystem;
@ -367,4 +368,14 @@ inline std::error_code GetTestEC() {
return std::make_error_code(std::errc::address_family_not_supported);
}
// Provide our own Sleep routine since std::this_thread::sleep_for is not
// available in single-threaded mode.
void SleepFor(std::chrono::seconds dur) {
using namespace std::chrono;
const auto curr_time = system_clock::now();
auto wake_time = curr_time + dur;
while (system_clock::now() < wake_time)
;
}
#endif /* FILESYSTEM_TEST_HELPER_HPP */