[Boost-users] boost::test timeouts and auto test suites

217 views
Skip to first unread message

Christopher E Piggott

unread,
Apr 17, 2008, 11:32:31 AM4/17/08
to boost...@lists.boost.org
 
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
 
 

Gennadiy Rozental

unread,
Apr 17, 2008, 1:25:36 PM4/17/08
to boost...@lists.boost.org
Christopher E Piggott <cepasp <at> rit.edu> writes:
> 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...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users

Christopher E Piggott

unread,
Apr 17, 2008, 5:39:31 PM4/17/08
to boost...@lists.boost.org

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?

Gennadiy Rozental

unread,
May 5, 2008, 1:23:40 AM5/5/08
to boost...@lists.boost.org

> "Christopher E Piggott" <cep...@rit.edu>

>
> 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.

Reply all
Reply to author
Forward
0 new messages