Boost logo

Boost :

From: Benoit Sigoure (tsuna_at_[hidden])
Date: 2008-01-07 03:05:07


On Dec 18, 2007, at 11:16 AM, Benoit Sigoure wrote:

> On Dec 18, 2007, at 10:50 AM, Jens Seidel wrote:
>
>> 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.)
>
>
> Hmm I was going to fix this today but now that you're raising this
> issue here, I'll wait to have a better insight of the situation
> before taking action.

Hi guys,
so I'm about to fix my BOOST_TEST macro that tests whether
Boost.Tests can be used and linked against. Hubert Figuiere
contributed the following fix. He suggested that I add:
   using boost::unit_test::test_suite;
   test_suite* init_unit_test_suite(int argc, char ** argv)
   {
     return NULL;
   }
Before my `main' (which reads: int main() { BOOST_CHECK(2 == 2);
return 0; })

He said that this fixed the macro for Boost 1.33.1. Can anyone
confirm the fix? I tested it on a Debian with 1.33.1 and it worked.
I didn't find any clear conclusion in this thread and I must admit
that I find this fix utterly awkward, so I'd be grateful if someone
could explain it to me.

In case anyone wants to test the patch, I attached it. If you have Git:
   git clone git://repo.or.cz/boost.m4.git # You can use http:// if
you're stuck behind a nazi firewall
   cd boost.m4
   git am 0001-Fix-the-test-for-Boost.Test.patch

If you don't have Git:
   wget 'http://repo.or.cz/w/boost.m4.git?
a=snapshot;h=59d8d8fd;sf=tgz' -O boost.m4.tgz
   tar xfz boost.m4.tgz
   cd boost.m4
   patch -p1 < 0001-Fix-the-test-for-Boost.Test.patch

Then in both cases, run:
   ./bootstrap
   ./configure -C
   make check TESTSUITEFLAGS='20 21'

If you have Boost < 1.34 installed (which would be great to test with
an older version of Boost such as 1.33.1), you need to change line 29
of configure.ac to this:
   BOOST_REQUIRE()
to drop the minimum version requirement. Otherwise configure will
fail (because it will try to find Boost >= 1.34). Don't forget to re-
run ./bootstrap if you change configure.ac.

Cheers,

-- 
Benoit Sigoure aka Tsuna
EPITA Research and Development Laboratory



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