From 8894575935e9c3ead5ed27674f85eb4911cb85d8 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sat, 2 Sep 2006 11:09:41 +0000 Subject: Revert to trunk --- test/basicserver/testbasicserver.cpp | 99 ++++-------------------------------- 1 file changed, 11 insertions(+), 88 deletions(-) diff --git a/test/basicserver/testbasicserver.cpp b/test/basicserver/testbasicserver.cpp index 1403df42..f5185b96 100644 --- a/test/basicserver/testbasicserver.cpp +++ b/test/basicserver/testbasicserver.cpp @@ -31,6 +31,7 @@ #include "MemLeakFindOn.h" + #define SERVER_LISTEN_PORT 2003 // in ms @@ -61,14 +62,10 @@ void basicdaemon::Run() 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 @@ int test(int argc, const char *argv[]) } } -#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 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 @@ int test(int argc, const char *argv[]) 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 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 @@ int test(int argc, const char *argv[]) // 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 @@ int test(int argc, const char *argv[]) TEST_THAT(KillServer(pid)); ::sleep(1); TEST_THAT(!ServerIsAlive(pid)); -#ifndef WIN32 TestRemoteProcessMemLeaks("test-srv4.memleaks"); -#endif } } -- cgit v1.2.3