X-Git-Url: http://developer.intra2net.com/git/?p=libt2n;a=blobdiff_plain;f=test%2Fcmdgroup.cpp;h=eee54bf72e74856a342dcd001c737999c13203cb;hp=32f8c6dce63dc80fa34cebcff05f660991862e3e;hb=0995cebb9189b872e8d7e58d8b8122fa00cc9061;hpb=fb3345ada7ea94225b78994fd50e3de693a2a3d5 diff --git a/test/cmdgroup.cpp b/test/cmdgroup.cpp index 32f8c6d..eee54bf 100644 --- a/test/cmdgroup.cpp +++ b/test/cmdgroup.cpp @@ -167,19 +167,23 @@ class test_cmdgroup : public TestFixture CPPUNIT_TEST_SUITE_END(); + pid_t child_pid; + public: void setUp() { } void tearDown() - { } + { + // make sure the server-child is dead before the next test runs + kill(child_pid,SIGKILL); + sleep(1); + } void GroupOk() { - pid_t pid; - - switch(pid=fork()) + switch(child_pid=fork()) { case -1: { @@ -189,12 +193,18 @@ class test_cmdgroup : public TestFixture case 0: // child { - socket_server ss("./socket"); - group_command_server cs(ss); + try + { + socket_server ss("./socket"); + group_command_server cs(ss); - // max 10 sec - for (int i=0; i < 10; i++) - cs.handle(1000000); + // max 10 sec + for (int i=0; i < 10; i++) + cs.handle(1000000); + } catch(...) + { + std::cerr << "exception in child. ignoring\n"; + } // don't call atexit and stuff _exit(0); @@ -220,9 +230,7 @@ class test_cmdgroup : public TestFixture void WrongGroup() { - pid_t pid; - - switch(pid=fork()) + switch(child_pid=fork()) { case -1: { @@ -232,12 +240,18 @@ class test_cmdgroup : public TestFixture case 0: // child { - socket_server ss("./socket"); - group_command_server cs(ss); + try + { + socket_server ss("./socket"); + group_command_server cs(ss); - // max 10 sec - for (int i=0; i < 10; i++) - cs.handle(1000000); + // max 10 sec + for (int i=0; i < 10; i++) + cs.handle(1000000); + } catch(...) + { + std::cerr << "exception in child. ignoring\n"; + } // don't call atexit and stuff _exit(0);