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:
{
case 0:
// child
{
- socket_server ss("./socket");
- group_command_server<cmd_group_a> cs(ss);
+ try
+ {
+ socket_server ss("./socket");
+ group_command_server<cmd_group_a> 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);
// wait till server is up
sleep(1);
socket_client_connection sc("./socket");
- command_client cc(sc);
+ command_client cc(&sc);
result_container rc;
cc.send_command(new testfunc4a_cmd("hello"),rc);
void WrongGroup()
{
- pid_t pid;
-
- switch(pid=fork())
+ switch(child_pid=fork())
{
case -1:
{
case 0:
// child
{
- socket_server ss("./socket");
- group_command_server<cmd_group_b> cs(ss);
+ try
+ {
+ socket_server ss("./socket");
+ group_command_server<cmd_group_b> 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);
// wait till server is up
sleep(1);
socket_client_connection sc("./socket");
- command_client cc(sc);
+ command_client cc(&sc);
result_container rc;
cc.send_command(new testfunc4a_cmd("hello"),rc);