Boost logo

Boost Users :

Subject: [Boost-users] [Test]
From: Merrill Cornish (merrill.cornish_at_[hidden])
Date: 2015-06-02 14:44:42


I'm get a SIGEGV segmentation fault /only/ when trying to register a
test manually. Everything works just fine if I use auto registration.
All compiles and links in both cases are without error. I know almost
nothing about using gdb, but I was able to see the segment violation
message shown below.

I'm running Boost 1.58.0; Windows 7.1 64-bit; MinGW 4.9.2 64-bit;
Eclipse Luna; CDT 8.6.0

In my TestMain.cpp

#define BOOST_TEST_ALTERNATIVE_INIT_API
#define BOOST_TEST_NO_MAIN
#include "boost/test/unit_test.hpp"

extern void Operand_Default_Constructor_Test();
bool init_unit_test() {
     framework::master_test_suite().p_name.value = "DiGSE Master Test";
framework::master_test_suite().add(BOOST_TEST_CASE(&Operand_Default_Constructor_Test));
     return true;
}

int main(int argc, char* argv[]) {
     return boost::unit_test::unit_test_main(&init_unit_test, argc, argv);
}

It compiles and links without error. However, executing it gives this
SIGEGV fault:

Program received signal SIGSEGV, Segmentation fault.
0x000000006b405a12 in boost::unit_test::framework::get (id=1,
     t=boost::unit_test::tut_suite) at ./boost/test/impl/framework.ipp:388
388 if( (res->p_type & t) == 0 )

The failing snippet is part of a test that would throw internal_error(),
but the if test itself seems to fail.

     if( (res->p_type & t) == 0 )
         throw internal_error( "Invalid test unit type" );

If the Operand_Default_Constructor_Test test is changed from

void Operand_Default_Constructor_Test()

to

BOOST_AUTO_TEST_CASE(Operand_Default_Constructor_Test)

and the contents of init_unit_test() are removed, it works just fine
with automatic registration. And the automatic registration is
certainly the easiest way; but I was holding out hope for being able to
specify test ordering.

Merrill Cornish



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net