Boost logo

Boost :

Subject: [boost] [boost.test] Customized test suite gives SIGSEGV when setup fails
From: Markus Schöpflin (markus.schoepflin_at_[hidden])
Date: 2008-09-12 10:29:40


Hello,

I'm getting a SIGSEGV when trying the following with Boost 1.35.0 and gcc
4.1.2:

---%<---
#define BOOST_TEST_ALTERNATIVE_INIT_API
#include <boost/test/included/unit_test.hpp>
using namespace boost::unit_test;

struct my_test_suite : public test_suite
{
   my_test_suite()
     :
     test_suite("my_test_suite")
   {
     throw std::runtime_error("runtime_error");
   }
};

bool init_unit_test()
{
   test_suite *test = BOOST_TEST_SUITE("");
   test->add(new my_test_suite());
   framework::master_test_suite().add(test);
   return false;
}
---%<---

When run in the gdb, I get the following output:

---%<---
(gdb) run
Starting program: a.out
Test setup error: std::runtime_error: runtime_error

Program received signal SIGSEGV, Segmentation fault.
0x0806e2fa in ~framework_impl (this=0x8089740)
     at boost/test/impl/framework.ipp:126
126 delete (test_suite const*)tu.second;
--->%---

The code in question has been ported from an old Boost.Test version to 1.35.

When looking at the documentation for Boost.Test (1.36, as this seems more
in sync with Boost.Test 1.35) I'm unsure that custom test suites are still
supported in this way.

What I need to do is to set up and tear down a database connection at the
start/end of a test suite execution. Is there some other way for this?

TIA,
Markus


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk