Boost logo

Boost :

From: Jens Seidel (jensseidel_at_[hidden])
Date: 2007-12-18 04:50:23


Hi,

I would like to know why Boost's unit test framework requires that the
user defines init_unit_test_suite(int, char**) (or with char *[]
argument???) instead of main().

I recently had again some trouble because of it:
 * It broke the general autoconf test in boost.m4 as the existance of
   a Boost library can normally easily be tested by using boost code
   in main() and not init_unit_test_suite(). (Will probably be fixed
   soon in boost.m4.)
 * According to http://lists.boost.org/Archives/boost/2007/05/121601.php
   linkers don't look into libraries (either static or dynamic) to
   find main so that unit tests cannot be cimpiled as shared library.
 * I noticed that Debian's Boost library doesn't work for me as main()
   is not found in the shared library (but in the static one). I found
   now beside my bug report
   http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=456863
   also
   http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=432921
   which mainly refers to the link above.

I'm not sure whether my problem is an error in Debian's packages
or not but I ask why is main handled differently in Boost.test?
Wouldn't it be sufficient to ask the user simple to start
init_unit_test_suite() from a user specified main() to make most
problems go away? Maybe it would be even OK to just start
init_unit_test_suite() in the constructor of a static variable
(yes, I know that the initialisation order may cause trouble with
other static data).

http://www.boost.org/libs/test/doc/faq.html doesn't explain it!

I will now use ifdef's to easily allow using
boost/test/included/unit_test.hpp as alternative to the library.

Jens


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