X-Git-Url: http://developer.intra2net.com/git/?p=libt2n;a=blobdiff_plain;f=test%2Ftimeout.cpp;h=6618ef6b6719b641b382d38e1a2ea3e60789b08a;hp=8bdfa31fd1e55419551d634b376a49569571b108;hb=fb3345ada7ea94225b78994fd50e3de693a2a3d5;hpb=c7857475c8b0f02cac3ce29a617a4d542fa59f37 diff --git a/test/timeout.cpp b/test/timeout.cpp index 8bdfa31..6618ef6 100644 --- a/test/timeout.cpp +++ b/test/timeout.cpp @@ -206,17 +206,9 @@ class test_timeout : public TestFixture string errormsg; - try - { - socket_client_connection sc("./socket"); - command_client cc(sc,1000000,1000000); - } - catch(t2n_transfer_error &e) - { errormsg=e.what(); } - catch(...) - { throw; } + socket_client_connection sc("./socket"); - CPPUNIT_ASSERT_EQUAL(string("error reading from socket : Invalid argument"),errormsg); + CPPUNIT_ASSERT_EQUAL(true,sc.connection::is_closed()); } } } @@ -257,7 +249,7 @@ class test_timeout : public TestFixture try { - command_client cc(sc,1000000,1000000); + command_client cc(&sc,1000000,1000000); } catch(t2n_transfer_error &e) { errormsg=e.what(); } @@ -265,6 +257,8 @@ class test_timeout : public TestFixture { throw; } CPPUNIT_ASSERT_EQUAL(string("timeout exceeded"),errormsg); + + kill(pid,SIGKILL); } } } @@ -318,7 +312,7 @@ class test_timeout : public TestFixture try { - command_client cc(sc,1000000,1000000); + command_client cc(&sc,1000000,1000000); } catch(t2n_transfer_error &e) { errormsg=e.what(); } @@ -326,6 +320,8 @@ class test_timeout : public TestFixture { throw; } CPPUNIT_ASSERT_EQUAL(string("timeout exceeded"),errormsg); + + kill(pid,SIGKILL); } } } @@ -370,7 +366,7 @@ class test_timeout : public TestFixture sleep(1); socket_client_connection sc("./socket"); - command_client cc(sc,1000000,1000000); + command_client cc(&sc,1000000,1000000); result_container rc; string errormsg; @@ -385,6 +381,8 @@ class test_timeout : public TestFixture { throw; } CPPUNIT_ASSERT_EQUAL(string("timeout exceeded"),errormsg); + + kill(pid,SIGKILL); } } } @@ -444,7 +442,7 @@ class test_timeout : public TestFixture sleep(1); socket_client_connection sc("./socket"); - command_client cc(sc,1000000,1000000); + command_client cc(&sc,1000000,1000000); result_container rc; string errormsg; @@ -459,6 +457,8 @@ class test_timeout : public TestFixture { throw; } CPPUNIT_ASSERT_EQUAL(string("timeout exceeded"),errormsg); + + kill(pid,SIGKILL); } } } @@ -511,15 +511,17 @@ class test_timeout : public TestFixture { throw; } CPPUNIT_ASSERT_EQUAL(string("write() returned Broken pipe"),errormsg); + + kill(pid,SIGKILL); } } } void DisconnectOnRead() { - pid_t pid; + pid_t pid1, pid2; - switch(pid=fork()) + switch(pid1=fork()) { case -1: { @@ -563,7 +565,7 @@ class test_timeout : public TestFixture // are we still alive and able to process data? - switch(pid=fork()) + switch(pid2=fork()) { case -1: { @@ -603,13 +605,15 @@ class test_timeout : public TestFixture } } } + kill(pid1,SIGKILL); + kill(pid2,SIGKILL); } void BreakAccept() { - pid_t pid; + pid_t pid1,pid2; - switch(pid=fork()) + switch(pid1=fork()) { case -1: { @@ -653,7 +657,7 @@ class test_timeout : public TestFixture // are we still alive and able to process data? - switch(pid=fork()) + switch(pid2=fork()) { case -1: { @@ -693,6 +697,8 @@ class test_timeout : public TestFixture } } } + kill(pid1,SIGKILL); + kill(pid2,SIGKILL); } };