Re: [Boost-users] Boost Unit Testing of DLL's

Tyler Weston
If you add a "delay load" flag for the boost UTF DLL, you should be able to ship testing code in your DLL without providing the UTF DLL to customers. This instructs the compiler to only look for the UTF DLL when the testing framework attempts to make a call. As long as your users don't try to call your test hooks, it should work out. http://msdn.microsoft.com/en-us/library/yx9zd12s%28v=VS.90%29.aspx
This will not work if OP using auto test cases. These are generated at startup and will require UTF dll. Gennadiy

Hi,
Based on the answers which clearly stated that it would not work with delay loading the UTF DLL I tried to modify the Boost UTF implementation to get it working.
The code you see below is probably not following the Boost guidelines but it made it possible for us to use the UTF with delay loading of the UTF dll.
CHANGES APPLIED TO boost_1_46_1\boost\config\auto_link.hpp:
//////////////////////////////////////////////////////////
// Original implementation
//////////////////////////////////////////////////////////
#ifdef BOOST_AUTO_LINK_TAGGED
# pragma comment(lib, BOOST_LIB_PREFIX BOOST_STRINGIZE(BOOST_LIB_NAME) BOOST_LIB_THREAD_OPT BOOST_LIB_RT_OPT ".lib")
# ifdef BOOST_LIB_DIAGNOSTIC
# pragma message ("Linking to lib file: " BOOST_LIB_PREFIX BOOST_STRINGIZE(BOOST_LIB_NAME) "-" BOOST_LIB_TOOLSET BOOST_LIB_THREAD_OPT BOOST_LIB_RT_OPT "-" BOOST_LIB_VERSION ".lib")
# endif
#elif defined(BOOST_AUTO_LINK_NOMANGLE)
# pragma comment(lib, BOOST_STRINGIZE(BOOST_LIB_NAME) ".lib")
# ifdef BOOST_LIB_DIAGNOSTIC
# pragma message ("Linking to lib file: " BOOST_STRINGIZE(BOOST_LIB_NAME) ".lib")
# endif
#else
# pragma comment(lib, BOOST_LIB_PREFIX BOOST_STRINGIZE(BOOST_LIB_NAME) "-" BOOST_LIB_TOOLSET BOOST_LIB_THREAD_OPT BOOST_LIB_RT_OPT "-" BOOST_LIB_VERSION ".lib")
# ifdef BOOST_LIB_DIAGNOSTIC
# pragma message ("Linking to lib file: " BOOST_LIB_PREFIX BOOST_STRINGIZE(BOOST_LIB_NAME) "-" BOOST_LIB_TOOLSET BOOST_LIB_THREAD_OPT BOOST_LIB_RT_OPT "-" BOOST_LIB_VERSION ".lib")
# endif
#endif
//////////////////////////////////////////////////////////
// Modified implementation
// We need a function which can check if the UTF lib
// functionality can be used this is implemented in the
// new function HasBoostLib
//////////////////////////////////////////////////////////
#ifdef BOOST_AUTO_LINK_TAGGED
# define BOOST_LIB_PATH BOOST_LIB_PREFIX BOOST_STRINGIZE(BOOST_LIB_NAME) BOOST_LIB_THREAD_OPT BOOST_LIB_RT_OPT
#elif defined(BOOST_AUTO_LINK_NOMANGLE)
# define BOOST_LIB_PATH BOOST_STRINGIZE(BOOST_LIB_NAME)
#else
# define BOOST_LIB_PATH BOOST_LIB_PREFIX BOOST_STRINGIZE(BOOST_LIB_NAME) "-" BOOST_LIB_TOOLSET BOOST_LIB_THREAD_OPT BOOST_LIB_RT_OPT "-" BOOST_LIB_VERSION
#endif
# pragma comment(lib, BOOST_LIB_PATH ".lib")
# ifdef BOOST_LIB_DIAGNOSTIC
# pragma message ("Linking to lib file: " BOOST_LIB_PATH ".lib")
# endif
static bool HasBoostLib()
{
#ifdef BOOST_DYN_LINK
static bool Available = LoadLibrary(BOOST_LIB_PATH ".dll") != NULL;
return(Available);
#else
return(true);
#endif
}
CHANGES APPLIED TO boost_1_46_1\boost\unit_test.hpp:
//////////////////////////////////////////////////////////
// Original implementation
//////////////////////////////////////////////////////////
#include

Johan Doré
Hi, Based on the answers which clearly stated that it would not work with delay
loading the UTF DLL I tried to modify the Boost UTF implementation to get it working.
The code you see below is probably not following the Boost guidelines but it made it possible for us to use the UTF with delay loading of the UTF dll.
These are massive changes. You can submit a new ticket with a patch. I'll consider it, but I must say I am still not convinced that the problem warrants any action. Why can't you just ship it with UTF dll? Gennadiy

Dear Gennadiy
I just uploaded the code in case someone was interested in seeing a possible workaround, and I wasn't expecting it to be added to the native Boost UTF.
In addition if Lazy/Delay loading is ever going to be supported in the "real" Boost UTF it would require much more than what I uploaded in the previous mail.
I agree that we could just ship the required UTF DLL. Personally I do however prefer to ship only what is needed and with the above implementation we save some overhead on initializing the UTF when it is not needed.
Best regards
Johan
-----Original Message-----
From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Gennadiy Rozental
Sent: 31. maj 2011 05:53
To: boost-users@lists.boost.org
Subject: Re: [Boost-users] Boost Unit Testing of DLL's
Johan Doré
Hi, Based on the answers which clearly stated that it would not work with delay
loading the UTF DLL I tried to modify the Boost UTF implementation to get it working.
The code you see below is probably not following the Boost guidelines but it made it possible for us to use the UTF with delay loading of the UTF dll.
These are massive changes. You can submit a new ticket with a patch. I'll consider it, but I must say I am still not convinced that the problem warrants any action. Why can't you just ship it with UTF dll? Gennadiy _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Gennadiy Rozental
-
Johan Doré