X-Git-Url: http://developer.intra2net.com/git/?p=libt2n;a=blobdiff_plain;f=test%2Fcmdgroup.cpp;h=6b092ec7bdbbe72dca5d3017b00ca078ff300ffa;hp=32f8c6dce63dc80fa34cebcff05f660991862e3e;hb=19facd8558fe2e32ce843860b40631ebe03ff3cf;hpb=fb3345ada7ea94225b78994fd50e3de693a2a3d5 diff --git a/test/cmdgroup.cpp b/test/cmdgroup.cpp index 32f8c6d..6b092ec 100644 --- a/test/cmdgroup.cpp +++ b/test/cmdgroup.cpp @@ -1,9 +1,24 @@ -/*************************************************************************** - * Copyright (C) 2004 by Intra2net AG * - * info@intra2net.com * - * * - ***************************************************************************/ +/* +Copyright (C) 2004 by Intra2net AG +The software in this package is distributed under the GNU General +Public License version 2 (with a special exception described below). + +A copy of GNU General Public License (GPL) is included in this distribution, +in the file COPYING.GPL. + +As a special exception, if other files instantiate templates or use macros +or inline functions from this file, or you compile this file and link it +with other works to produce a work based on this file, this file +does not by itself cause the resulting work to be covered +by the GNU General Public License. + +However the source code for this file must still be made available +in accordance with section (3) of the GNU General Public License. + +This exception does not invalidate any other reasons why a work based +on this file might be covered by the GNU General Public License. +*/ #include #include #include @@ -167,19 +182,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 +208,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 +245,7 @@ class test_cmdgroup : public TestFixture void WrongGroup() { - pid_t pid; - - switch(pid=fork()) + switch(child_pid=fork()) { case -1: { @@ -232,12 +255,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);