X-Git-Url: http://developer.intra2net.com/git/?p=libt2n;a=blobdiff_plain;f=test%2Fcomm.cpp;h=169c1839741dd72a0860d7f40f3fdf0607ae0244;hp=eb4de8c650658c55ec367a1ace46ca4df879cdde;hb=2f90dcbf75fbafbefde8916c6012f0023a90b527;hpb=b604df5f671b5e7abfd37570d76927a6ebd45f98 diff --git a/test/comm.cpp b/test/comm.cpp index eb4de8c..169c183 100644 --- a/test/comm.cpp +++ b/test/comm.cpp @@ -32,6 +32,7 @@ class test_comm : public TestFixture CPPUNIT_TEST(UnixCommToServer); CPPUNIT_TEST(UnixCommToServerAndBack); + CPPUNIT_TEST(UnixCommToServerAndBackBig); CPPUNIT_TEST(IPCommToServer); CPPUNIT_TEST(IPCommToServerAndBack); @@ -156,6 +157,66 @@ class test_comm : public TestFixture } } + void UnixCommToServerAndBackBig() + { + pid_t pid; + + switch(pid=fork()) + { + case -1: + { + CPPUNIT_FAIL("fork error"); + break; + } + case 0: + // child + { + socket_server ss("./socket"); + ss.set_logging(&cerr,debug); + + // max 10 sec + for (int i=0; i < 10; i++) + { + ss.fill_buffer(1000000); + + string data; + unsigned int cid; + + if(ss.get_packet(data,cid)) + { + server_connection* con=ss.get_connection(cid); + + if (data=="QUIT") + break; + + con->write(string().insert(0,100*1024,'y')); + } + } + // don't call atexit and stuff + _exit(0); + } + + default: + // parent + { + string data; + + // wait till server is up + sleep(1); + socket_client_connection sc("./socket"); + + sc.write(string().insert(0,100*1024,'x')); + + while (!sc.get_packet(data)) + sc.fill_buffer(1000000); + + CPPUNIT_ASSERT_EQUAL(string().insert(0,100*1024,'y'),data); + + sc.write("QUIT"); + } + } + } + void IPCommToServer() { pid_t pid;