Change license from LGPL to GPL version 2 + linking exception. This fixes C++ templat...
[libt2n] / test / wrapper.cpp
index 8a7c16d..49041d8 100644 (file)
@@ -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 <sys/types.h>
 #include <unistd.h>
 #include <errno.h>
@@ -257,18 +272,24 @@ class test_wrapper : public TestFixture
             case 0:
             // child
             {
-                int i=0;
-                while(i < 10 && !kill_server)
+                try
                 {
-                    close_server=false;
-
-                    socket_server ss("./socket");
-                    group_command_server<cmd_group_x> cs(ss);
-                    ss.set_logging(&logstream,debug);
-
-                    // max 10 sec
-                    for (; !close_server && !kill_server && i < 10; i++)
-                        cs.handle(1000000);
+                    int i=0;
+                    while(i < 10 && !kill_server)
+                    {
+                        close_server=false;
+
+                        socket_server ss("./socket");
+                        group_command_server<cmd_group_x> cs(ss);
+                        ss.set_logging(&logstream,debug);
+
+                        // max 10 sec
+                        for (; !close_server && !kill_server && i < 10; i++)
+                            cs.handle(1000000);
+                    }
+                } catch(...)
+                {
+                    std::cerr << "exception in child. ignoring\n";
                 }
 
                 // don't call atexit and stuff
@@ -489,18 +510,24 @@ class test_wrapper_noserver : public TestFixture
             case 0:
             // child
             {
-                int i=0;
-                while(i < 10 && !kill_server)
+                try
                 {
-                    close_server=false;
-
-                    socket_server ss("./socket");
-                    group_command_server<cmd_group_x> cs(ss);
-                    ss.set_logging(&logstream,debug);
-
-                    // max 10 sec
-                    for (; !close_server && !kill_server && i < 10; i++)
-                        cs.handle(1000000);
+                    int i=0;
+                    while(i < 10 && !kill_server)
+                    {
+                        close_server=false;
+
+                        socket_server ss("./socket");
+                        group_command_server<cmd_group_x> cs(ss);
+                        ss.set_logging(&logstream,debug);
+
+                        // max 10 sec
+                        for (; !close_server && !kill_server && i < 10; i++)
+                            cs.handle(1000000);
+                    }
+                } catch(...)
+                {
+                    std::cerr << "exception in child. ignoring\n";
                 }
 
                 // don't call atexit and stuff
@@ -544,18 +571,25 @@ class test_wrapper_noserver : public TestFixture
             case 0:
             // child
             {
-                socket_server ss("./socket");
+                try
+                {
+                    socket_server ss("./socket");
+
+                    // server sends garbage
 
-                // server sends garbage
+                    ostringstream hello;
+                    hello << "XYZ 123";
 
-                ostringstream hello;
-                hello << "XYZ 123";
+                    ss.add_callback(new_connection,bind(&test_wrapper_noserver::send_hello, boost::ref(*this), hello.str(),&ss, _1));
 
-                ss.add_callback(new_connection,bind(&test_wrapper_noserver::send_hello, boost::ref(*this), hello.str(),&ss, _1));
+                    // max 10 sec
+                    for (int i=0; i < 10; i++)
+                        ss.fill_buffer(1000000);
+                } catch(...)
+                {
+                    std::cerr << "exception in child. ignoring\n";
+                }
 
-                // max 10 sec
-                for (int i=0; i < 10; i++)
-                    ss.fill_buffer(1000000);
                 // don't call atexit and stuff
                 _exit(0);
             }