Thrift-2029:Port C++ tests to Windows
Client: cpp
Patch: Ben Craig
Updates cpp tests to work with windows and c++11
diff --git a/test/threads/ThreadsClient.cpp b/test/threads/ThreadsClient.cpp
index 70b08ad..9306a3f 100644
--- a/test/threads/ThreadsClient.cpp
+++ b/test/threads/ThreadsClient.cpp
@@ -28,6 +28,9 @@
#include <thrift/concurrency/Monitor.h>
#include <thrift/concurrency/ThreadManager.h>
#include <thrift/concurrency/PlatformThreadFactory.h>
+#if _WIN32
+ #include <thrift/windows/TWinsockSingleton.h>
+#endif
using boost::shared_ptr;
using namespace apache::thrift;
@@ -37,6 +40,9 @@
using namespace apache::thrift::concurrency;
int main(int argc, char **argv) {
+#if _WIN32
+ transport::TWinsockSingleton::create();
+#endif
int port = 9090;
std::string host = "localhost";
diff --git a/test/threads/ThreadsServer.cpp b/test/threads/ThreadsServer.cpp
index 9c1a7d9..a267c3b 100644
--- a/test/threads/ThreadsServer.cpp
+++ b/test/threads/ThreadsServer.cpp
@@ -29,6 +29,9 @@
#include <thrift/concurrency/Monitor.h>
#include <thrift/concurrency/ThreadManager.h>
#include <thrift/concurrency/PlatformThreadFactory.h>
+#if _WIN32
+ #include <thrift/windows/TWinsockSingleton.h>
+#endif
using boost::shared_ptr;
using namespace apache::thrift;
@@ -85,11 +88,12 @@
protected:
void go2sleep(int thread, int seconds) {
Monitor m;
+ Synchronized s(m);
for (int i = 0; i < seconds; ++i) {
fprintf(stderr, "Thread %d: sleep %d\n", thread, i);
try {
m.wait(1000);
- } catch(TimedOutException& e) {
+ } catch(const TimedOutException&) {
}
}
fprintf(stderr, "THREAD %d DONE\n", thread);
@@ -101,6 +105,9 @@
};
int main(int argc, char **argv) {
+#if _WIN32
+ transport::TWinsockSingleton::create();
+#endif
int port = 9090;
shared_ptr<ThreadsTestHandler> handler(new ThreadsTestHandler());
shared_ptr<TProcessor> processor(new ThreadsTestProcessor(handler));