weimingz updated this revision to Diff 132089.
weimingz added a comment.
Herald added a subscriber: hintonda.

Disable tests that depend on random_device. 
filesystem tests rely on random_device as seed to create random path. Although 
it's possible to avoid the random_device but if the build target has no 
random_device, it's very possible that neither filesystem nor other seeding 
device like clock is available.


Repository:
  rCXX libc++

https://reviews.llvm.org/D41316

Files:
  CMakeLists.txt
  include/__config_site.in
  include/random
  src/random.cpp
  test/libcxx/experimental/filesystem/lit.local.cfg
  test/std/experimental/filesystem/lit.local.cfg
  test/std/numerics/rand/rand.device/lit.local.cfg

Index: test/std/numerics/rand/rand.device/lit.local.cfg
===================================================================
--- /dev/null
+++ test/std/numerics/rand/rand.device/lit.local.cfg
@@ -0,0 +1,3 @@
+# Disable all of the random device tests if the correct feature is not available.
+if 'libcpp-has-no-random-device' in config.available_features:
+  config.unsupported = True
Index: test/std/experimental/filesystem/lit.local.cfg
===================================================================
--- test/std/experimental/filesystem/lit.local.cfg
+++ test/std/experimental/filesystem/lit.local.cfg
@@ -1,3 +1,7 @@
 # Disable all of the filesystem tests if the correct feature is not available.
 if 'c++filesystem' not in config.available_features:
   config.unsupported = True
+
+# filesystem_test_helper uses random_device to generate random path.
+if 'libcpp-has-no-random-device' in config.available_features:
+  config.unsupported = True
Index: test/libcxx/experimental/filesystem/lit.local.cfg
===================================================================
--- test/libcxx/experimental/filesystem/lit.local.cfg
+++ test/libcxx/experimental/filesystem/lit.local.cfg
@@ -1,3 +1,7 @@
 # Disable all of the filesystem tests if the correct feature is not available.
 if 'c++filesystem' not in config.available_features:
   config.unsupported = True
+
+# filesystem_test_helper uses random_device to generate random path.
+if 'libcpp-has-no-random-device' in config.available_features:
+  config.unsupported = True
Index: src/random.cpp
===================================================================
--- src/random.cpp
+++ src/random.cpp
@@ -8,6 +8,7 @@
 //===----------------------------------------------------------------------===//
 
 #include <__config>
+#ifndef _LIBCPP_HAS_NO_RANDOM_DEVICE
 
 #if defined(_LIBCPP_USING_WIN32_RANDOM)
 // Must be defined before including stdlib.h to enable rand_s().
@@ -177,3 +178,4 @@
 }
 
 _LIBCPP_END_NAMESPACE_STD
+#endif // _LIBCPP_HAS_NO_RANDOM_DEVICE
Index: include/random
===================================================================
--- include/random
+++ include/random
@@ -3476,6 +3476,7 @@
 
 typedef shuffle_order_engine<minstd_rand0, 256>                         knuth_b;
 
+#ifndef _LIBCPP_HAS_NO_RANDOM_DEVICE
 // random_device
 
 class _LIBCPP_TYPE_VIS random_device
@@ -3511,6 +3512,7 @@
     random_device(const random_device&); // = delete;
     random_device& operator=(const random_device&); // = delete;
 };
+#endif // _LIBCPP_HAS_NO_RANDOM_DEVICE
 
 // seed_seq
 
Index: include/__config_site.in
===================================================================
--- include/__config_site.in
+++ include/__config_site.in
@@ -20,6 +20,7 @@
 #cmakedefine _LIBCPP_HAS_NO_THREADS
 #cmakedefine _LIBCPP_HAS_NO_MONOTONIC_CLOCK
 #cmakedefine _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
+#cmakedefine _LIBCPP_HAS_NO_RANDOM_DEVICE
 #cmakedefine _LIBCPP_HAS_MUSL_LIBC
 #cmakedefine _LIBCPP_HAS_THREAD_API_PTHREAD
 #cmakedefine _LIBCPP_HAS_THREAD_API_EXTERNAL
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -71,6 +71,7 @@
 option(LIBCXX_ENABLE_FILESYSTEM "Build filesystem as part of libc++experimental.a"
     ${ENABLE_FILESYSTEM_DEFAULT})
 option(LIBCXX_INCLUDE_TESTS "Build the libc++ tests." ${LLVM_INCLUDE_TESTS})
+option(LIBCXX_ENABLE_RANDOM_DEVICE "Build random_device class" On)
 
 # Benchmark options -----------------------------------------------------------
 option(LIBCXX_INCLUDE_BENCHMARKS "Build the libc++ benchmarks and their dependancies" ON)
@@ -629,6 +630,7 @@
 config_define_if_not(LIBCXX_ENABLE_THREADS _LIBCPP_HAS_NO_THREADS)
 config_define_if_not(LIBCXX_ENABLE_MONOTONIC_CLOCK _LIBCPP_HAS_NO_MONOTONIC_CLOCK)
 config_define_if_not(LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS)
+config_define_if_not(LIBCXX_ENABLE_RANDOM_DEVICE _LIBCPP_HAS_NO_RANDOM_DEVICE)
 
 config_define_if(LIBCXX_HAS_PTHREAD_API _LIBCPP_HAS_THREAD_API_PTHREAD)
 config_define_if(LIBCXX_HAS_EXTERNAL_THREAD_API _LIBCPP_HAS_THREAD_API_EXTERNAL)
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to