myserver-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myserver-commit] [SCM] GNU MyServer branch, master, updated. 0_9_1-6-ge


From: Giuseppe Scrivano
Subject: [myserver-commit] [SCM] GNU MyServer branch, master, updated. 0_9_1-6-geeff856
Date: Sat, 26 Dec 2009 01:35:17 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU MyServer".

The branch, master has been updated
       via  eeff85669ae3ac91ffa774d7194a8e1e3845c1bb (commit)
      from  9e432c8c4838ad5c6633ca37183e49162df2a5df (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------


commit eeff85669ae3ac91ffa774d7194a8e1e3845c1bb
Author: Giuseppe Scrivano <address@hidden>
Date:   Sat Dec 26 02:35:11 2009 +0100

    Use a timeout value when the socket is read

diff --git a/myserver/tests/test_socket.cpp b/myserver/tests/test_socket.cpp
index 024cce0..bd4259e 100644
--- a/myserver/tests/test_socket.cpp
+++ b/myserver/tests/test_socket.cpp
@@ -24,6 +24,7 @@
 
 #include "../include/base/socket/socket.h"
 #include "../include/base/thread/thread.h"
+#include "../include/base/utility.h"
 
 extern "C"
 {
@@ -44,38 +45,38 @@ class TestSocket : public CppUnit::TestFixture
   Socket *obj;
   ThreadID tid;
 
-  CPPUNIT_TEST_SUITE ( TestSocket );
+  CPPUNIT_TEST_SUITE (TestSocket);
 
-  CPPUNIT_TEST ( testGethostname );
-  CPPUNIT_TEST ( testRecv );
-  CPPUNIT_TEST ( testGetLocalIPsList );
+  CPPUNIT_TEST (testGethostname);
+  CPPUNIT_TEST (testRecv);
+  CPPUNIT_TEST (testGetLocalIPsList);
 
-  CPPUNIT_TEST_SUITE_END ( );
+  CPPUNIT_TEST_SUITE_END ();
 
 public:
 
-  void setUp ( )
+  void setUp ()
   {
-    CPPUNIT_ASSERT_EQUAL ( Socket::startupSocketLib ( ), 0 );
+    CPPUNIT_ASSERT_EQUAL (Socket::startupSocketLib (), 0);
 
     obj = new Socket;
   }
 
-  void tearDown ( )
+  void tearDown ()
   {
     delete obj;
   }
 
-  void testGethostname ( )
+  void testGethostname ()
   {
     int len = HOST_NAME_MAX;
     char host[HOST_NAME_MAX];
-    int status = obj->gethostname ( host, len );
+    int status = obj->gethostname (host, len);
 
-    CPPUNIT_ASSERT_EQUAL ( status, 0 );
+    CPPUNIT_ASSERT_EQUAL (status, 0);
   }
 
-  void testRecv ( )
+  void testRecv ()
   {
     ThreadID tid;
     int optvalReuseAddr = 1;
@@ -85,76 +86,78 @@ public:
     int status;
 
     ((sockaddr_in*) (&sockIn))->sin_family = AF_INET;
-    ((sockaddr_in*) (&sockIn))->sin_addr.s_addr = inet_addr ( "127.0.0.1" );
-    ((sockaddr_in*) (&sockIn))->sin_port = htons ( port );
+    ((sockaddr_in*) (&sockIn))->sin_addr.s_addr = inet_addr ("127.0.0.1");
+    ((sockaddr_in*) (&sockIn))->sin_port = htons (port);
 
-    socklen_t sockInLen = sizeof ( sockaddr_in );
+    socklen_t sockInLen = sizeof (sockaddr_in);
 
-    CPPUNIT_ASSERT ( obj->socket ( AF_INET, SOCK_STREAM, 0 ) != -1 );
+    CPPUNIT_ASSERT (obj->socket (AF_INET, SOCK_STREAM, 0) != -1);
 
-    CPPUNIT_ASSERT ( obj->setsockopt ( SOL_SOCKET, SO_REUSEADDR,
+    CPPUNIT_ASSERT (obj->setsockopt (SOL_SOCKET, SO_REUSEADDR,
                                       (const char*) &optvalReuseAddr,
-                                      sizeof (optvalReuseAddr) ) != -1 );
+                                      sizeof (optvalReuseAddr)) != -1);
 
     /* If the port is used by another program, try a few others.  */
-    if ( ( status = obj->bind ( &sockIn, sockInLen ) ) != 0 )
-      while ( ++port < 28000 )
+    if ((status = obj->bind (&sockIn, sockInLen)) != 0)
+      while (++port < 28000)
         {
-          ((sockaddr_in*) (&sockIn))->sin_port = htons ( port );
-          if ( ( status = obj->bind ( &sockIn, sockInLen ) ) == 0 )
+          ((sockaddr_in*) (&sockIn))->sin_port = htons (port);
+          if ((status = obj->bind (&sockIn, sockInLen)) == 0)
             break;
         }
 
-    CPPUNIT_ASSERT ( status != -1 );
+    CPPUNIT_ASSERT (status != -1);
 
-    CPPUNIT_ASSERT ( obj->listen ( 1 ) != -1 );
+    CPPUNIT_ASSERT (obj->listen (1) != -1);
 
-    CPPUNIT_ASSERT_EQUAL ( Thread::create ( &tid, testRecvClient, &port ), 0 );
+    CPPUNIT_ASSERT_EQUAL (Thread::create (&tid, testRecvClient, &port), 0);
 
-    Socket s = obj->accept ( &sockIn, &sockInLen );
+    CPPUNIT_ASSERT (obj->dataOnRead (5));
 
-    status = int ( s.getHandle ( ) );
+    Socket s = obj->accept (&sockIn, &sockInLen);
 
-    if ( status < 0 )
-      CPPUNIT_ASSERT ( status != -1 );
+    status = int (s.getHandle ());
 
-    CPPUNIT_ASSERT ( s.bytesToRead ( ) >= 0 );
+    if (status < 0)
+      CPPUNIT_ASSERT (status != -1);
+
+    CPPUNIT_ASSERT (s.bytesToRead () >= 0);
 
     int bufLen = 8;
     char buf[bufLen];
-    memset ( buf, 0, bufLen );
+    memset (buf, 0, bufLen);
 
-    status = s.recv ( buf, bufLen, 0 );
+    status = s.recv (buf, bufLen, 0);
 
     s.send ("a", 1, 0);
 
-    CPPUNIT_ASSERT ( !strcmp (buf, "ehlo"));
-    CPPUNIT_ASSERT ( status >= 0 || status == -2 );
+    CPPUNIT_ASSERT (!strcmp (buf, "ehlo"));
+    CPPUNIT_ASSERT (status >= 0 || status == -2);
 
-    Thread::join ( tid );
+    Thread::join (tid);
 
-    CPPUNIT_ASSERT ( obj->close ( ) != -1 );
+    CPPUNIT_ASSERT (obj->close () != -1);
   }
 
-  void testGetLocalIPsList ( )
+  void testGetLocalIPsList ()
   {
-    int status = obj->socket ( AF_INET, SOCK_STREAM, 0 );
+    int status = obj->socket (AF_INET, SOCK_STREAM, 0);
 
-    CPPUNIT_ASSERT ( status != -1 );
+    CPPUNIT_ASSERT (status != -1);
 
     string out;
 
-    status = obj->getLocalIPsList ( out );
+    status = obj->getLocalIPsList (out);
 
-    CPPUNIT_ASSERT ( status != -1 );
+    CPPUNIT_ASSERT (status != -1);
 
-    status = obj->close ( );
+    status = obj->close ();
 
-    CPPUNIT_ASSERT ( status != -1 );
+    CPPUNIT_ASSERT (status != -1);
   }
 };
 
-CPPUNIT_TEST_SUITE_REGISTRATION ( TestSocket );
+CPPUNIT_TEST_SUITE_REGISTRATION (TestSocket);
 
 static DEFINE_THREAD (testRecvClient, pParam)
 {
@@ -165,23 +168,23 @@ static DEFINE_THREAD (testRecvClient, pParam)
   int port = *((int*)pParam);
   int status;
 
-  CPPUNIT_ASSERT ( obj2->socket ( AF_INET, SOCK_STREAM, 0 ) != -1 );
+  CPPUNIT_ASSERT (obj2->socket (AF_INET, SOCK_STREAM, 0) != -1);
 
-  CPPUNIT_ASSERT ( obj2->connect ( host, port ) != -1 );
+  CPPUNIT_ASSERT (obj2->connect (host, port) != -1);
 
   int bufLen = 8;
   char buf[bufLen];
-  memset ( buf, 0, bufLen );
-  strcpy ( buf, "ehlo" );
+  memset (buf, 0, bufLen);
+  strcpy (buf, "ehlo");
 
-  CPPUNIT_ASSERT ( obj2->send ( buf, strlen ( buf ), 0 ) != -1 );
+  CPPUNIT_ASSERT (obj2->send (buf, strlen (buf), 0) != -1);
 
   /* To sync.  */
-  CPPUNIT_ASSERT ( obj2->recv ( buf, bufLen, 0 ) != -1 );
+  CPPUNIT_ASSERT (obj2->recv (buf, bufLen, 0, MYSERVER_SEC (5)) != -1);
 
-  CPPUNIT_ASSERT ( obj2->shutdown ( SD_BOTH ) != -1 );
+  CPPUNIT_ASSERT (obj2->shutdown (SD_BOTH) != -1);
 
-  CPPUNIT_ASSERT ( obj2->close ( ) != -1 );
+  CPPUNIT_ASSERT (obj2->close () != -1);
 
   delete obj2;
   obj2 = NULL;

-----------------------------------------------------------------------

Summary of changes:
 myserver/tests/test_socket.cpp |  107 ++++++++++++++++++++-------------------
 1 files changed, 55 insertions(+), 52 deletions(-)


hooks/post-receive
-- 
GNU MyServer




reply via email to

[Prev in Thread] Current Thread [Next in Thread]