X-Git-Url: http://developer.intra2net.com/git/?p=libt2n;a=blobdiff_plain;f=test%2Fhello.cpp;h=80bfec6814a687031f121cf194118d78b8387c6b;hp=a0cc532aed892e9bb54bfaf99b7e69c30651809e;hb=fc922d87a02a9c171b9d95c4b40b8ae85f0fadc0;hpb=04d86ba4ad4f14ab08f38804e772ec46a8ac92b0 diff --git a/test/hello.cpp b/test/hello.cpp index a0cc532..80bfec6 100644 --- a/test/hello.cpp +++ b/test/hello.cpp @@ -51,7 +51,8 @@ class test_hello : public TestFixture CPPUNIT_TEST(BadVersion); CPPUNIT_TEST(SeparatorMissing); CPPUNIT_TEST(WrongByteOrder); - CPPUNIT_TEST(OtherServer); + CPPUNIT_TEST(OtherServerBig); + CPPUNIT_TEST(OtherServerSmall); CPPUNIT_TEST_SUITE_END(); @@ -353,7 +354,7 @@ class test_hello : public TestFixture } } - void OtherServer() + void OtherServerBig() { pid_t pid; @@ -407,6 +408,60 @@ class test_hello : public TestFixture } } + void OtherServerSmall() + { + pid_t pid; + + switch(pid=fork()) + { + case -1: + { + CPPUNIT_FAIL("fork error"); + break; + } + case 0: + // child + { + socket_server ss("./socket"); + + ostringstream hello; + // hmm, we got the wrong socket + hello << "READY"; + + ss.add_callback(new_connection,bind(&test_hello::send_raw_socket, boost::ref(*this), hello.str(),&ss, _1)); + + // max 3 sec + for (int i=0; i < 3; i++) + ss.fill_buffer(1000000); + // don't call atexit and stuff + _exit(0); + } + + default: + // parent + { + string data; + + // wait till server is up + sleep(1); + socket_client_connection sc("./socket"); + + string errormsg; + + try + { + command_client cc(sc); + } + catch(t2n_version_mismatch &e) + { errormsg=e.what(); } + catch(...) + { throw; } + + CPPUNIT_ASSERT_EQUAL(string("illegal hello received (T2N)"),errormsg); + } + } + } + }; CPPUNIT_TEST_SUITE_REGISTRATION(test_hello);