Modify

Opened 6 years ago

Closed 2 months ago

#5563 closed Bugs (fixed)

using a test macro in a global fixture crashes Boost.Test

Reported by: m.champlon@… Owned by: Raffi Enficiaud
Milestone: Boost 1.65.0 Component: test
Version: Boost 1.42.0 Severity: Problem
Keywords: Cc:

Description

Using a failing macro (such as BOOST_FAIL) from the constructor (or destructor) of a global fixture crashes the test application, for instance (using vc80 and boost 1.42) :

#define BOOST_AUTO_TEST_MAIN #include <boost/test/auto_unit_test.hpp> #define BOOST_LIB_NAME boost_unit_test_framework #include <boost/config/auto_link.hpp>

struct fixture {

fixture() {

BOOST_FAIL( "oups" );

} ~fixture() {

BOOST_FAIL( "oups" );

}

}; BOOST_GLOBAL_FIXTURE( fixture );

BOOST_AUTO_TEST_CASE( some_test ) { }

The problem lies in compiler_log_formatter.ipp around line 40 :

const_string test_phase_identifier() {

return framework::is_initialized()

? const_string( framework::current_test_case().p_name.get() ) : BOOST_TEST_L( "Test setup" );

}

because calling framework::current_test_case() is wrong in this case. Maybe the solution would be to add another state in framework along m_is_initialized and m_test_in_progress ? I would love to provide a patch but I wasn't able to make bjam build and run the tests...

Thanks, MAT.

Attachments (0)

Change History (15)

comment:1 Changed 6 years ago by Gennadiy Rozental

Resolution: fixed
Status: newclosed

(In [75035]) avoid crash if testing tool is used in global fixture Fixes #5563

comment:2 Changed 5 years ago by m.champlon@…

Hi,

As of 26/05/2012 the fix hasn't been merge to the release branch...

MAT.

comment:3 Changed 2 years ago by Raffi Enficiaud

Milestone: To Be DeterminedBoost 1.59.0

comment:4 Changed 2 years ago by Jim King <jim.king@…>

Was the solution to this issue to make it impossible to use assertion checks within a global fixture? I find that to be pretty useful, and having moved from boost 1.53 to 1.59 I find I'm having to rewrite a lot of tests so they don't fail with an exception of:

throw std::runtime_error( "can't use testing tools outside of test case implementation" );

these tests never crashed before. Further, the patch that was provided does not provide a test that proves either if the issue existed before or whether it is fixed now.

comment:5 Changed 2 years ago by Raffi Enficiaud

If I am not mistaken, the solution was to make it possible to use assertions and exceptions in global fixture (obviously not in the fixture dtor). If this is not working, please post the snippet and we will investigate.

comment:6 Changed 2 years ago by Raffi Enficiaud

Ok, now I think I understand: the fix is to avoid the crash. There is a bug either in the implementation or in the documentation of 1.59.

comment:7 Changed 2 years ago by Raffi Enficiaud

Resolution: fixed
Status: closedreopened

comment:8 Changed 2 years ago by Raffi Enficiaud

Owner: changed from Gennadiy Rozental to Raffi Enficiaud
Status: reopenednew

comment:9 Changed 10 months ago by Raffi Enficiaud

Several major issues appeared while I was digging deeper into this issue:

  • test assertions in fixture dtor that stop the execution of the test crash the application in all case because of an exception in a dtor
  • test assertions in fixture ctor are currently not supported but not mentioned in the documentation. This limitation is mainly due to the order of initialization of the different components of the test framework.

comment:10 Changed 10 months ago by Raffi Enficiaud

Milestone: Boost 1.59.0To Be Determined

comment:11 Changed 10 months ago by Raffi Enficiaud

Status: newassigned

comment:12 Changed 3 months ago by Raffi Enficiaud

Milestone: To Be DeterminedBoost 1.65.0

comment:13 Changed 3 months ago by Raffi Enficiaud

Fix pushed to develop rev ea9d9b9a8ea3f9aceb71cce41d48c820f05b2fdc

comment:14 Changed 3 months ago by Raffi Enficiaud

See #11962 for the explanations of the fix.

comment:15 Changed 2 months ago by Raffi Enficiaud

Resolution: fixed
Status: assignedclosed

In master, rev 3d13638c412ac357f178e99a99bf44dfd756c057

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Raffi Enficiaud.
The resolution will be deleted.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.