boost::test timeouts and auto test suites

I have been searching documentation and mailing lists and not coming up with an answer on this. Within a BOOST_FIXTURE_TEST_CASE can i set a timeout for individual tests? I'm using 1.31.1 and I am aware that a test_unit has a property "p_timeout." I just don't know how to get to it. I'm using BOOST_AUTO_TEST_MAIN, BOOST_AUTO_TEST_SUITE, and a series of BOOST_FIXTURE_TEST_CASE objects. Maybe that's just too much auto :) --Chris ALL INFORMATION PROVIDED IS RIT PROPRIETARY - ALL RIGHTS RESERVED. -- Christopher Piggott Sr. Staff Engineer Systems Modernization and Sustainment Center Mailstop 78-1220 Rochester Institute of Technology 133 Lomb Memorial Drive Rochester, NY 14523 (585) 475-4664

Christopher E Piggott
Within a BOOST_FIXTURE_TEST_CASE can i set a timeout for individual tests? I'm using 1.31.1 and I am aware that a test_unit has a property "p_timeout." I just don't know how to get to it. I'm using BOOST_AUTO_TEST_MAIN, BOOST_AUTO_TEST_SUITE, and a series of BOOST_FIXTURE_TEST_CASE objects. Maybe that's just too much auto :)
No. you will have to use manual registration to specify timeout value. Gennadiy

That's too bad, I like the automatic registration facility because it is less error-prone ... It doesn't allow you to write test cases and not notice that they never get called.
How hard would it be for me to fake it? I wonder if there's some preprocessor trickery that could keep a list, e.g.
#define MY_TEST_CASE( function_name ) \
#define TEMP LISTOFTESTS, function_name \
#undef LISTOFTESTS \
#define LISTOFTESTS TEMP \
#undef TEMP \
BOOST_CLASS_TEST_CASE(function_name())
Well I know that obviously won't work but you get the idea ... To wind up with a list that looks like:
function1, function2, function3,
Which I can then use in an initialized array, and have my test_suite automatically add all of them.
Possible? Good approach or bad?
-----Original Message-----
From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Gennadiy Rozental
Sent: Thursday, April 17, 2008 1:26 PM
To: boost-users@lists.boost.org
Subject: Re: [Boost-users] boost::test timeouts and auto test suites
Christopher E Piggott
Within a BOOST_FIXTURE_TEST_CASE can i set a timeout for individual tests? I'm using 1.31.1 and I am aware that a test_unit has a property "p_timeout." I just don't know how to get to it. I'm using BOOST_AUTO_TEST_MAIN, BOOST_AUTO_TEST_SUITE, and a series of BOOST_FIXTURE_TEST_CASE objects. Maybe that's just too much auto :)
No. you will have to use manual registration to specify timeout value. Gennadiy _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

"Christopher E Piggott"
That's too bad, I like the automatic registration facility because it is less error-prone It doesn't allow you to write test cases and not notice that they never get called.
Yes. That was one of the main drivers to implement it.
How hard would it be for me to fake it? I wonder if there's some preprocessor trickery that could keep a list, e.g.
#define MY_TEST_CASE( function_name ) \ #define TEMP LISTOFTESTS, function_name \ #undef LISTOFTESTS \ #define LISTOFTESTS TEMP \ #undef TEMP \ BOOST_CLASS_TEST_CASE(function_name())
Well I know that obviously won't work but you get the idea ... To wind up with a list that looks like:
function1, function2, function3,
Which I can then use in an initialized array, and have my test_suite automatically add all of them. Possible? Good approach or bad?
You might be able to do somehing relying on static variables, not macros. In 1.35.0 you should be able change the test unit properties in global fixture, so you can add timeout postfactum. Gennadiy
participants (2)
-
Christopher E Piggott
-
Gennadiy Rozental