X-Git-Url: http://developer.intra2net.com/git/?p=libt2n;a=blobdiff_plain;f=test%2Ftimeout.cpp;fp=test%2Ftimeout.cpp;h=e194b85bfd17056d9bcf572219af78f6d08d3cc3;hp=7a4e9ed7c9a4d58f5f087aacefb12029c43d0e80;hb=039e52da9b40d0e729360ff0a953dfbddf975b8a;hpb=1bdd13c030b192cd3087eee64a581a0d43766d16 diff --git a/test/timeout.cpp b/test/timeout.cpp index 7a4e9ed..e194b85 100644 --- a/test/timeout.cpp +++ b/test/timeout.cpp @@ -138,6 +138,7 @@ class test_timeout : public TestFixture CPPUNIT_TEST(CommandTimeout); CPPUNIT_TEST(CommandSlowResponse); CPPUNIT_TEST(DisconnectOnWrite); + CPPUNIT_TEST(WriteTwice); CPPUNIT_TEST(DisconnectOnRead); CPPUNIT_TEST(BreakAccept); @@ -495,6 +496,59 @@ class test_timeout : public TestFixture } } + void WriteTwice() + { + switch(child_pid=fork()) + { + case -1: + { + CPPUNIT_FAIL("fork error"); + break; + } + case 0: + // child + { + socket_server ss("./socket"); + + // bail out as soon as we get something + ss.fill_buffer(-1); + // don't call atexit and stuff + _exit(0); + } + + default: + // parent + { + string data; + + // don't kill us on broken pipe + signal(SIGPIPE, SIG_IGN); + + // wait till server is up + sleep(1); + socket_client_connection sc("./socket"); + + string errormsg; + + sc.write("somedata"); + + sleep(1); + + // server should disconnect now + try + { + sc.write("other data"); + } + catch(t2n_transfer_error &e) + { errormsg=e.what(); } + catch(...) + { throw; } + + CPPUNIT_ASSERT_EQUAL(string("write() returned Broken pipe"),errormsg); + } + } + } + void DisconnectOnRead() { pid_t pid2;