CPPUNIT_TEST(CommandTimeout);
CPPUNIT_TEST(CommandSlowResponse);
CPPUNIT_TEST(DisconnectOnWrite);
+ CPPUNIT_TEST(WriteTwice);
CPPUNIT_TEST(DisconnectOnRead);
CPPUNIT_TEST(BreakAccept);
}
}
+ 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;