[Box Backup-commit] COMMIT r939 - box/chris/merge/test/basicserver

subversion at fluffy.co.uk subversion at fluffy.co.uk
Sat Sep 2 12:09:42 BST 2006


Author: chris
Date: 2006-09-02 12:09:41 +0100 (Sat, 02 Sep 2006)
New Revision: 939

Modified:
   box/chris/merge/test/basicserver/testbasicserver.cpp
Log:
Revert to trunk


Modified: box/chris/merge/test/basicserver/testbasicserver.cpp
===================================================================
--- box/chris/merge/test/basicserver/testbasicserver.cpp	2006-09-02 11:09:08 UTC (rev 938)
+++ box/chris/merge/test/basicserver/testbasicserver.cpp	2006-09-02 11:09:41 UTC (rev 939)
@@ -31,6 +31,7 @@
 
 #include "MemLeakFindOn.h"
 
+
 #define SERVER_LISTEN_PORT	2003
 
 // in ms
@@ -61,14 +62,10 @@
 
 void testservers_pause_before_reply()
 {
-#ifdef WIN32
-	Sleep(COMMS_SERVER_WAIT_BEFORE_REPLYING);
-#else
-	struct timespec t;
-	t.tv_sec = 0;
-	t.tv_nsec = COMMS_SERVER_WAIT_BEFORE_REPLYING * 1000 * 1000;	// convert to ns
-	::nanosleep(&t, NULL);
-#endif
+	 struct timespec t;
+	 t.tv_sec = 0;
+	 t.tv_nsec = COMMS_SERVER_WAIT_BEFORE_REPLYING * 1000 * 1000;	// convert to ns
+	 ::nanosleep(&t, NULL);
 }
 
 #define LARGE_DATA_BLOCK_SIZE 19870
@@ -430,138 +427,84 @@
 		}
 	}
 
-#ifdef WIN32
-	// Under win32 we must initialise the Winsock library
-	// before using sockets
-
-	WSADATA info;
-	TEST_THAT(WSAStartup(0x0101, &info) != SOCKET_ERROR)
-#endif
-
 //printf("SKIPPING TESTS------------------------\n");
 //goto protocolserver;
 
 	// Launch a basic server
 	{
-#ifdef WIN32
-		int pid = LaunchServer("test srv1 testfiles\\srv1.conf", 
-			"testfiles\\srv1.pid");
-#else
-		int pid = LaunchServer("./test srv1 testfiles/srv1.conf", 
-			"testfiles/srv1.pid");
-#endif
-
+		int pid = LaunchServer("./test srv1 testfiles/srv1.conf", "testfiles/srv1.pid");
 		TEST_THAT(pid != -1 && pid != 0);
 		if(pid > 0)
 		{
 			// Check that it's written the expected file
-			TEST_THAT(TestFileExists("testfiles" 
-				DIRECTORY_SEPARATOR "srv1.test1"));
+			TEST_THAT(TestFileExists("testfiles/srv1.test1"));
 			TEST_THAT(ServerIsAlive(pid));
 			// Move the config file over
-#ifdef WIN32
-			TEST_THAT(::unlink("testfiles" DIRECTORY_SEPARATOR 
-				"srv1.conf") != -1);
-#endif
-			TEST_THAT(::rename(
-				"testfiles" DIRECTORY_SEPARATOR "srv1b.conf", 
-				"testfiles" DIRECTORY_SEPARATOR "srv1.conf") 
-				!= -1);
-#ifndef WIN32
+			TEST_THAT(::rename("testfiles/srv1b.conf", "testfiles/srv1.conf") != -1);
 			// Get it to reread the config file
 			TEST_THAT(HUPServer(pid));
 			::sleep(1);
 			TEST_THAT(ServerIsAlive(pid));
 			// Check that new file exists
-			TEST_THAT(TestFileExists("testfiles" 
-				DIRECTORY_SEPARATOR "srv1.test2"));
-#endif // !WIN32
+			TEST_THAT(TestFileExists("testfiles/srv1.test2"));
 			// Kill it off
 			TEST_THAT(KillServer(pid));
-#ifndef WIN32
 			TestRemoteProcessMemLeaks("generic-daemon.memleaks");
-#endif // !WIN32
 		}
 	}
 	
 	// Launch a test forking server
 	{
-#ifdef WIN32
-		int pid = LaunchServer("test srv2 testfiles\\srv2.conf", 
-			"testfiles\\srv2.pid");
-#else
-		int pid = LaunchServer("./test srv2 testfiles/srv2.conf", 
-			"testfiles/srv2.pid");
-#endif
-
+		int pid = LaunchServer("./test srv2 testfiles/srv2.conf", "testfiles/srv2.pid");
 		TEST_THAT(pid != -1 && pid != 0);
 		if(pid > 0)
 		{
 			// Will it restart?
 			TEST_THAT(ServerIsAlive(pid));
-#ifndef WIN32
 			TEST_THAT(HUPServer(pid));
 			::sleep(1);
 			TEST_THAT(ServerIsAlive(pid));
-#endif // !WIN32
 			// Make some connections
 			{
 				SocketStream conn1;
 				conn1.Open(Socket::TypeINET, "localhost", 2003);
-#ifndef WIN32
 				SocketStream conn2;
 				conn2.Open(Socket::TypeUNIX, "testfiles/srv2.sock");
 				SocketStream conn3;
 				conn3.Open(Socket::TypeINET, "localhost", 2003);
-#endif // !WIN32
 				// Quick check that reconnections fail
 				TEST_CHECK_THROWS(conn1.Open(Socket::TypeUNIX, "testfiles/srv2.sock");, ServerException, SocketAlreadyOpen);
 				// Stuff some data around
 				std::vector<IOStream *> conns;
 				conns.push_back(&conn1);
-#ifndef WIN32
 				conns.push_back(&conn2);
 				conns.push_back(&conn3);
-#endif // !WIN32
 				Srv2TestConversations(conns);
 				// Implicit close
 			}
-#ifndef WIN32
 			// HUP again
 			TEST_THAT(HUPServer(pid));
 			::sleep(1);
 			TEST_THAT(ServerIsAlive(pid));
-#endif // !WIN32
 			// Kill it
 			TEST_THAT(KillServer(pid));
 			::sleep(1);
 			TEST_THAT(!ServerIsAlive(pid));
-#ifndef WIN32
 			TestRemoteProcessMemLeaks("test-srv2.memleaks");
-#endif // !WIN32
 		}
 	}
 
 	// Launch a test SSL server
 	{
-#ifdef WIN32
-		int pid = LaunchServer("test srv3 testfiles\\srv3.conf", 
-			"testfiles\\srv3.pid");
-#else
 		int pid = LaunchServer("./test srv3 testfiles/srv3.conf", "testfiles/srv3.pid");
-#endif
 		TEST_THAT(pid != -1 && pid != 0);
 		if(pid > 0)
 		{
 			// Will it restart?
 			TEST_THAT(ServerIsAlive(pid));
-
-#ifndef WIN32
 			TEST_THAT(HUPServer(pid));
 			::sleep(1);
 			TEST_THAT(ServerIsAlive(pid));
-#endif
-
 			// Make some connections
 			{
 				// SSL library
@@ -576,50 +519,36 @@
 
 				SocketStreamTLS conn1;
 				conn1.Open(context, Socket::TypeINET, "localhost", 2003);
-#ifndef WIN32
 				SocketStreamTLS conn2;
 				conn2.Open(context, Socket::TypeUNIX, "testfiles/srv3.sock");
 				SocketStreamTLS conn3;
 				conn3.Open(context, Socket::TypeINET, "localhost", 2003);
-#endif
 				// Quick check that reconnections fail
 				TEST_CHECK_THROWS(conn1.Open(context, Socket::TypeUNIX, "testfiles/srv3.sock");, ServerException, SocketAlreadyOpen);
 				// Stuff some data around
 				std::vector<IOStream *> conns;
 				conns.push_back(&conn1);
-#ifndef WIN32
 				conns.push_back(&conn2);
 				conns.push_back(&conn3);
-#endif
 				Srv2TestConversations(conns);
 				// Implicit close
 			}
-#ifndef WIN32
 			// HUP again
 			TEST_THAT(HUPServer(pid));
 			::sleep(1);
 			TEST_THAT(ServerIsAlive(pid));
-#endif
 			// Kill it
 			TEST_THAT(KillServer(pid));
 			::sleep(1);
 			TEST_THAT(!ServerIsAlive(pid));
-#ifndef WIN32
 			TestRemoteProcessMemLeaks("test-srv3.memleaks");
-#endif
 		}
 	}
 	
 //protocolserver:
 	// Launch a test protocol handling server
 	{
-#ifdef WIN32
-		int pid = LaunchServer("test srv4 testfiles\\srv4.conf", 
-			"testfiles\\srv4.pid");
-#else
-		int pid = LaunchServer("./test srv4 testfiles/srv4.conf", 
-			"testfiles/srv4.pid");
-#endif
+		int pid = LaunchServer("./test srv4 testfiles/srv4.conf", "testfiles/srv4.pid");
 		TEST_THAT(pid != -1 && pid != 0);
 		if(pid > 0)
 		{
@@ -628,11 +557,7 @@
 
 			// Open a connection to it		
 			SocketStream conn;
-#ifdef WIN32
-			conn.Open(Socket::TypeINET, "localhost", 2003);
-#else
 			conn.Open(Socket::TypeUNIX, "testfiles/srv4.sock");
-#endif
 			
 			// Create a protocol
 			TestProtocolClient protocol(conn);
@@ -695,9 +620,7 @@
 			TEST_THAT(KillServer(pid));
 			::sleep(1);
 			TEST_THAT(!ServerIsAlive(pid));
-#ifndef WIN32
 			TestRemoteProcessMemLeaks("test-srv4.memleaks");
-#endif
 		}
 	}
 




More information about the Boxbackup-commit mailing list