[libcxx] r273054 - Get filesystem tests passing for single-threaded configurations.

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 17 14:44:27 PDT 2016


Author: ericwf
Date: Fri Jun 17 16:44:26 2016
New Revision: 273054

URL: http://llvm.org/viewvc/llvm-project?rev=273054&view=rev
Log:
Get filesystem tests passing for single-threaded configurations.

Modified:
    libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.copy_file/copy_file.pass.cpp
    libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.copy_symlink/copy_symlink.pass.cpp
    libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.create_directories/create_directories.pass.cpp
    libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.create_directory/create_directory.pass.cpp
    libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.create_directory/create_directory_with_attributes.pass.cpp
    libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
    libcxx/trunk/test/support/filesystem_test_helper.hpp

Modified: libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.copy_file/copy_file.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.copy_file/copy_file.pass.cpp?rev=273054&r1=273053&r2=273054&view=diff
==============================================================================
--- libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.copy_file/copy_file.pass.cpp (original)
+++ libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.copy_file/copy_file.pass.cpp Fri Jun 17 16:44:26 2016
@@ -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;

Modified: libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.copy_symlink/copy_symlink.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.copy_symlink/copy_symlink.pass.cpp?rev=273054&r1=273053&r2=273054&view=diff
==============================================================================
--- libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.copy_symlink/copy_symlink.pass.cpp (original)
+++ libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.copy_symlink/copy_symlink.pass.cpp Fri Jun 17 16:44:26 2016
@@ -17,8 +17,6 @@
 
 #include <experimental/filesystem>
 #include <type_traits>
-#include <chrono>
-#include <thread>
 #include <cassert>
 
 #include "test_macros.h"

Modified: libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.create_directories/create_directories.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.create_directories/create_directories.pass.cpp?rev=273054&r1=273053&r2=273054&view=diff
==============================================================================
--- libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.create_directories/create_directories.pass.cpp (original)
+++ libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.create_directories/create_directories.pass.cpp Fri Jun 17 16:44:26 2016
@@ -16,8 +16,6 @@
 
 #include <experimental/filesystem>
 #include <type_traits>
-#include <chrono>
-#include <thread>
 #include <cassert>
 
 #include "test_macros.h"

Modified: libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.create_directory/create_directory.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.create_directory/create_directory.pass.cpp?rev=273054&r1=273053&r2=273054&view=diff
==============================================================================
--- libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.create_directory/create_directory.pass.cpp (original)
+++ libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.create_directory/create_directory.pass.cpp Fri Jun 17 16:44:26 2016
@@ -18,8 +18,6 @@
 
 #include <experimental/filesystem>
 #include <type_traits>
-#include <chrono>
-#include <thread>
 #include <cassert>
 
 #include "test_macros.h"

Modified: libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.create_directory/create_directory_with_attributes.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.create_directory/create_directory_with_attributes.pass.cpp?rev=273054&r1=273053&r2=273054&view=diff
==============================================================================
--- libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.create_directory/create_directory_with_attributes.pass.cpp (original)
+++ libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.create_directory/create_directory_with_attributes.pass.cpp Fri Jun 17 16:44:26 2016
@@ -16,8 +16,6 @@
 
 #include <experimental/filesystem>
 #include <type_traits>
-#include <chrono>
-#include <thread>
 #include <cassert>
 
 #include "test_macros.h"

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=273054&r1=273053&r2=273054&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 Fri Jun 17 16:44:26 2016
@@ -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_en
     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);

Modified: libcxx/trunk/test/support/filesystem_test_helper.hpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/filesystem_test_helper.hpp?rev=273054&r1=273053&r2=273054&view=diff
==============================================================================
--- libcxx/trunk/test/support/filesystem_test_helper.hpp (original)
+++ libcxx/trunk/test/support/filesystem_test_helper.hpp Fri Jun 17 16:44:26 2016
@@ -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 */




More information about the cfe-commits mailing list