libt2n: (gerd) make sure no exception is thrown in command_client constructor, fix...
[libt2n] / test / reconnect.cpp
index 9e64a8e..394ba25 100644 (file)
@@ -52,13 +52,19 @@ class test_reconnect : public TestFixture
 
     CPPUNIT_TEST_SUITE_END();
 
+    pid_t child_pid;
+
     public:
 
     void setUp()
     { }
 
     void tearDown()
-    { }
+    {
+        // make sure the server-child is dead before the next test runs
+        kill(child_pid,SIGKILL);
+        sleep(1);
+    }
 
     void send_raw_socket(string hello_string, socket_server* ss, int conn_id)
     {
@@ -71,9 +77,7 @@ class test_reconnect : public TestFixture
 
     void simple_reconnect()
     {
-        pid_t pid;
-
-        switch(pid=fork())
+        switch(child_pid=fork())
         {
             case -1:
             {
@@ -144,9 +148,7 @@ class test_reconnect : public TestFixture
 
     void reconnect_with_close()
     {
-        pid_t pid;
-
-        switch(pid=fork())
+        switch(child_pid=fork())
         {
             case -1:
             {
@@ -222,9 +224,7 @@ class test_reconnect : public TestFixture
 
     void reconnect_buffer_complete()
     {
-        pid_t pid;
-
-        switch(pid=fork())
+        switch(child_pid=fork())
         {
             case -1:
             {
@@ -290,11 +290,9 @@ class test_reconnect : public TestFixture
 
     void reconnect_buffer_several_complete()
     {
-        pid_t pid;
-
         const int packets=3;
 
-        switch(pid=fork())
+        switch(child_pid=fork())
         {
             case -1:
             {
@@ -380,9 +378,7 @@ class test_reconnect : public TestFixture
 
     void reconnect_buffer_no_incomplete1()
     {
-        pid_t pid;
-
-        switch(pid=fork())
+        switch(child_pid=fork())
         {
             case -1:
             {
@@ -458,9 +454,7 @@ class test_reconnect : public TestFixture
 
     void reconnect_buffer_no_incomplete2()
     {
-        pid_t pid;
-
-        switch(pid=fork())
+        switch(child_pid=fork())
         {
             case -1:
             {