From: Jens Seidel (jensseidel_at_[hidden])
Date: 2007-12-20 11:16:35
I know it may no longer fit on this list but as I started here let's not
move the list ...
I read most of the new documentation but to make it short: I still fail
to use unit tests. It worked in the past but after a lot of changes
in Boost.Tests it is now unusable for me.
On Wed, Dec 19, 2007 at 10:02:39AM +0100, Jens Seidel wrote:
> On Tue, Dec 18, 2007 at 03:46:29PM +0000, Gennadiy Rozental wrote:
> > Jens Seidel <jensseidel <at> users.sf.net> writes:
> > > 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.)
Benoit: Have fun updating boost.m4.
Additionally you have now to care about incompatible differences in recent
versions, different handling depending on linkage and probably more. It
will be interesting to see you solving this for all possibilities :-)
> > > * 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.
> > It's not a bug. It's a feature. ;) Starting 1.34.1 main() doesn't reside in
> > shared libs.
> > In any case Boost.Test supports
> > what you want. In many, many cases you don't need init_.. function anymore and
> > boost test provides a way for users to get away without it and function main()
> > as well both with static and shared library usage variant of the UTF. If you
> OK. This is probably preferred.
But now I wonder why I should make a lot of incompatibles changes? I
want my program and all tests beeing able to compile everywhere with
(nearly) all versions of Boost.
Using some small code parts condionally depending on autotools system
and Boost tests (version of boost, shared library is available?, ...)
would be acceptable but I'm no willing to make major changes to my code.
> > prefer to define main youself and invoke init function you can do it as well
> > with shared library variant.
> > Please look for more details here:
> > http://www.patmedia.net/~rogeeff/html/index.html
> > Please let me know if there is any issues still.
I read again carefully the documentation (http://www.patmedia.net/~rogeeff/html)
which exists in parallel to http://www.boost.org/libs/test/doc and can confirm
that the problem that main() is not found still exists!
Including the header boost/test/included/unit_test.hpp *once* per binary seems
to work but normal using of boost/test/unit_test.hpp together with an additional
still leads to a missing main() function. I get since 1.34.1:
/usr/lib/gcc/i486-linux-gnu/4.2.3/../../../../lib/crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
collect2: ld returned 1 exit status
I defined also a dummy main function (just to make the linker happy as I
assumed the tests are maybe started in the contructor of a static variable) but
my test is not called. Even calling init_unit_test_suite() from main() does not
I also defined BOOST_TEST_DYN_LINK on the comandline to ensure that all code
uses it. Same result! Defining addionally BOOST_TEST_MAIN results in a
a proper empty test with the output
"Test setup error: test tree is empty"
I thought I have also seen a conflict with my own init_unit_test_suite()
implementation if I define BOOST_TEST_MAIN but cannot reproduce it.
A question: Would it be save to define BOOST_TEST_DYN_LINK also for static
linkage? I hope so as I have never, really never used different code depending
on linker options.
Even after renaming my main
test_suite* init_unit_test_suite(int, char *)
(but only for dynamic linkage?) as noticed on
I fail as usual.
Short: In the past it was so simple:
test_suite* init_unit_test_suite(int, char *)
test_suite *test = BOOST_TEST_SUITE("Master test suite");
Now I use
* Additional autoconf code to define HAVE_UNIT_TEST_LIB if the (shared?) library is
#include <config.h> // HAVE_UNIT_TEST_LIB
# define BOOST_TEST_DYN_LINK
# include <boost/test/unit_test.hpp>
# include <boost/test/included/unit_test.hpp>
// my old init_unit_test_suite code
int main(int argc, char *argv)
I'm now really tired and stoped. A more or less easy to use
library (I had to follow only same advises on
is now more or less unusable. The code depends on the linkage,
the documentation can be found outside of the boost.org domain,
the required information is wrong and incomplete and addionally
scattered across multiple pages such as
(and all referenced sub pages)
To show you that I really read (at least up to UTF) the documenation I mention
a few errors in it:
* "provide provide"
* "link with libunit_test_framework.lib"
that's platform specific!!!
* "The reasons for this error is that in your implementation you should
specify second argument of init_unit_test_suite exactly as in a
specification, i.e.: char* ."
s/as in a specification/as in the specification/ (I first read e.g.
instead of i.e. which confused me even more, maybe you should avoid "i.e.".)
* "Finish update for CLA support"
What is CLA?
* Remove two or three full stops in the enumeration
* "Better Unicode support (reports and log in wostream)"
Sorry, I don't see any relation of wostream and Unicode!
You mean UTF16 encoding? UTF8 should work fine with both
ostream and wostream, right?
* "Also The Execution Monitor"
* Page misses a "next" link to
* Link to libs/test/execution_monitor.cpp does not work
* "wraps a several system headers"
* "other then include boost/test/minimal.hpp"
* "This approach is are similar" (belongs to folded text for example 4)
* "why testing worth the effort"
* "As a result my test suite became to look like this:"
Wrong example!!! data_access_test() was expected
* "Alternatively in you can employ"
* "with the static library or single-header variants of the UTF requires the
specific function specification."
Check this! s/specification/signature/, s/specific/original/?
Per accident (used wrong browser window) I read also partely the old
* s/messy a error/messy error/
* "The framework" ... "provides function main() that initialize the framework"
* Example file "unit_test_example1.cpp" does not exist on your server (error 404).
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk