Get test executables compiling on Windows.
Many of the test executables use pthreads directly. This isn't
portable on Windows, so this patch converts these test to use
C++11 threads and mutexes. Since Windows' implementation of
std::thread classes throw and catch from header files, this patch
also disables exceptions when compiling with clang on Windows.
Reviewed by: Todd Fiala, Ed Maste
Differential Revision: http://reviews.llvm.org/D4816
llvm-svn: 215562
diff --git a/lldb/test/expression_command/call-restarts/TestCallThatRestarts.py b/lldb/test/expression_command/call-restarts/TestCallThatRestarts.py
index 6cc98ee..fca9c3d 100644
--- a/lldb/test/expression_command/call-restarts/TestCallThatRestarts.py
+++ b/lldb/test/expression_command/call-restarts/TestCallThatRestarts.py
@@ -30,6 +30,7 @@
@dwarf_test
@skipIfLinux # llvm.org/pr19246: intermittent failure
@skipIfDarwin # llvm.org/pr19246: intermittent failure
+ @skipIfWindows # Test relies on signals, unsupported on Windows
def test_with_dwarf(self):
"""Test calling std::String member function."""
self.buildDwarf()
diff --git a/lldb/test/expression_command/timeout/Makefile b/lldb/test/expression_command/timeout/Makefile
index 1cd6782..c9cff41 100644
--- a/lldb/test/expression_command/timeout/Makefile
+++ b/lldb/test/expression_command/timeout/Makefile
@@ -1,5 +1,5 @@
LEVEL = ../../make
-C_SOURCES := wait-a-while.c
+CXX_SOURCES := wait-a-while.cpp
include $(LEVEL)/Makefile.rules
diff --git a/lldb/test/expression_command/timeout/TestCallWithTimeout.py b/lldb/test/expression_command/timeout/TestCallWithTimeout.py
index aeb6834..304b8fd 100644
--- a/lldb/test/expression_command/timeout/TestCallWithTimeout.py
+++ b/lldb/test/expression_command/timeout/TestCallWithTimeout.py
@@ -15,7 +15,7 @@
# Call super's setUp().
TestBase.setUp(self)
- self.main_source = "wait-a-while.c"
+ self.main_source = "wait-a-while.cpp"
self.main_source_spec = lldb.SBFileSpec (self.main_source)
diff --git a/lldb/test/expression_command/timeout/wait-a-while.c b/lldb/test/expression_command/timeout/wait-a-while.c
deleted file mode 100644
index a233f8d..0000000
--- a/lldb/test/expression_command/timeout/wait-a-while.c
+++ /dev/null
@@ -1,41 +0,0 @@
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/time.h>
-#include <stdint.h>
-
-int
-wait_a_while (useconds_t interval)
-{
- int num_times = 0;
- int return_value = 1;
-
- struct timeval start_time;
- gettimeofday(&start_time, NULL);
- uint64_t target = start_time.tv_sec * 1000000 + start_time.tv_usec + interval;
-
- while (1)
- {
- num_times++;
- return_value = usleep (interval);
- if (return_value != 0)
- {
- struct timeval now;
- gettimeofday(&now, NULL);
- interval = target - (now.tv_sec * 1000000 + now.tv_usec);
- }
- else
- break;
- }
- return num_times;
-}
-
-int
-main (int argc, char **argv)
-{
- printf ("stop here in main.\n");
- int num_times = wait_a_while (argc * 1000);
- printf ("Done, took %d times.\n", num_times);
-
- return 0;
-
-}
diff --git a/lldb/test/expression_command/timeout/wait-a-while.cpp b/lldb/test/expression_command/timeout/wait-a-while.cpp
new file mode 100644
index 0000000..8403030
--- /dev/null
+++ b/lldb/test/expression_command/timeout/wait-a-while.cpp
@@ -0,0 +1,31 @@
+#include <stdio.h>
+#include <stdint.h>
+
+#include <chrono>
+#include <thread>
+
+
+int
+wait_a_while (int microseconds)
+{
+ int num_times = 0;
+
+ while (1)
+ {
+ num_times++;
+ std::this_thread::sleep_for(std::chrono::microseconds(microseconds));
+ break;
+ }
+ return num_times;
+}
+
+int
+main (int argc, char **argv)
+{
+ printf ("stop here in main.\n");
+ int num_times = wait_a_while (argc * 1000);
+ printf ("Done, took %d times.\n", num_times);
+
+ return 0;
+
+}