Monday, January 19, 2009

Don't Use Boost Test

I've been using Boost Test in some production code that I work on. This code has to run and compile on RHEL 5. This should include the test, otherwise the tests aren't very useful. My work environment had been Fedora 7.

I recently updated my work laptop to Fedora 10. I started running my unit tests and noticed that they were failing. In version 1.34.1, the way to create and run tests was changed to what appears to be an incompatible way of setting up and running tests now. Because of the above requirements for RHEL 5 compatibility, this means that I can't rely on Boost Test.

I've been somewhat skeptical of using Boost, this kind of reinforces it for me. From what I can tell, there's been no guarantee of backwards compatibility or I've never read one. Perhaps the other modules/libraries in Boost do provide some kind of statement. The libraries that are scheduled for inclusion in the new C++ standard are probably the most stable.

If anyone can provide any hints how to fix this without adding too many ifdefs, feel free to chime in. I've not been able to use the suggested fixes in the link below.

Here's the error message that I get on link using the old style of Boost Test.
/usr/lib/gcc/i386-redhat-linux/4.3.2/../../../crt1.o: In function `_start': (.text+0x18): undefined reference to `main'

Discussion about changes:
http://archives.free.net.ph/message/20071218.095023.e2639d79.en.html

Here's an example using the new way that actually works.

#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE MyTest
#include < boost/test/unit_test.hpp>

BOOST_AUTO_TEST_CASE( my_test )
{
BOOST_CHECK_EQUAL(2, 2 );
}


Update:I'm still using Boost Test even though it's not backwards compatibility. There's no requirements for testing in the code base that I'm using so I just use the post 1.34 capability. Also, there's no way that I could use another tool associated with the software product that I'm using. The requirement is that the software be available on RHEL 5.

No comments: