Boost logo

Boost Users :

Subject: Re: [Boost-users] [Test] Test cases in static libraries
From: Jérémy Coulon (jeremy.coulon_at_[hidden])
Date: 2011-10-05 13:39:27


Le 04/10/2011 22:34, Gennadiy Rozental a écrit :
> Jérémy Coulon<jeremy.coulon<at> free.fr> writes:
>
>> Hi all,
>>
>> I'm currently converting cppunit tests to Boost.Test.
>> Boost test auto-registration is awesome !
>>
>> I'm now facing a problem and need help from Boost community.
>>
>> mytest -> libFoo.so -> libBar.a
>>
>> Let's say I have a dynamic library Foo which depends on a static library
>> Bar.
>> I created an executable mytest which uses Foo library. It doesn't know
>> about Bar library.
>>
>> So far, I successfully created test cases in mytest for Foo library
>> using the public library interface (exported symbols).
>> I just figured out how to create test cases inside Foo library (for
>> internal non-exported classes) using console_test_runner utility.
> I am confused. So, you have Foo tests both inside the library and outside?
Yes. I am using Visual Studio 2008. So I have to deal with dllimport /
dllexport.
Some tests (what I call "functionnal tests") are using only exported
symbols from Foo, so I write them outside the library.
However some other tests ("unit tests") are using non-exported symbols
from Foo, so I have to write them inside the library.

>
>> Question: how do I test code inside Bar static library ?
> I would imagine they are being run when you use console_test_runner. Since the
> library statically linked into Foo, all test units should be registered once
> static initializers are executed.
Unfortunatly, it looks like Visual Studio is optimizing out code of Bar
that is never referenced by Foo.
The following thread seems to be the same problem I have but I don't
really understand the proposed solution :
http://stackoverflow.com/questions/4877990/boost-test-tests-on-a-static-library

> Gennadiy
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net