Skip to content

Commit 99b9110

Browse files
committed
Merge pull request #297 from deanberris/0.11-devel
Proper fix for MIME roundtrip test failures in dynamic build mode.
2 parents 1de5540 + c412314 commit 99b9110

File tree

3 files changed

+24
-22
lines changed

3 files changed

+24
-22
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ if(CPP-NETLIB_BUILD_SHARED_LIBS OR BUILD_SHARED_LIBS)
1212
message ("Linking boost testing libs dynamically...")
1313
set(Boost_USE_STATIC_LIBS OFF)
1414
set(CPP-NETLIB_BUILD_SHARED_LIBS ON)
15+
set(BUILD_SHARED_LIBS ON)
1516
add_definitions(-DBOOST_TEST_DYN_LINK)
1617
else()
1718
set(Boost_USE_STATIC_LIBS ON)
@@ -25,7 +26,6 @@ find_package( OpenSSL )
2526
find_package( Threads )
2627
set(CMAKE_VERBOSE_MAKEFILE true)
2728

28-
set(BUILD_SHARED_LIBS ON)
2929
set(CPPNETLIB_VERSION_MAJOR 0) # MUST bump this whenever we make ABI-incompatible changes
3030
set(CPPNETLIB_VERSION_MINOR 10)
3131
set(CPPNETLIB_VERSION_PATCH 1)

libs/mime/test/CMakeLists.txt

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,10 @@
11
include_directories(${CPP-NETLIB_SOURCE_DIR})
2-
find_package ( Boost 1.41.0 COMPONENTS unit_test_framework )
32
file ( COPY TestMessages DESTINATION ${CMAKE_CURRENT_BINARY_DIR} )
43

5-
option( CPP-NETLIB_BUILD_SHARED_LIBS "Build cpp-netlib as shared libraries." OFF )
6-
7-
if(CPP-NETLIB_BUILD_SHARED_LIBS OR BUILD_SHARED_LIBS)
8-
message ("Linking boost testing libs dynamically...")
9-
set(Boost_USE_STATIC_LIBS OFF)
10-
set(CPP-NETLIB_BUILD_SHARED_LIBS ON)
11-
add_definitions(-DBOOST_TEST_DYN_LINK)
12-
else()
13-
set(Boost_USE_STATIC_LIBS ON)
14-
set(CPP-NETLIB_BUILD_SHARED_LIBS OFF)
15-
set(BUILD_SHARED_LIBS OFF)
16-
endif()
17-
18-
set ( Boost_USE_MULTITHREADED ON )
19-
204
if ( Boost_FOUND )
215
add_executable ( mime-roundtrip mime-roundtrip.cpp )
22-
target_link_libraries ( mime-roundtrip ${Boost_LIBRARIES} )
6+
target_link_libraries ( mime-roundtrip ${Boost_LIBRARIES}
7+
${CMAKE_THREAD_LIBS_INIT})
238
add_test ( mime-roundtrip mime-roundtrip )
249
endif ()
2510

libs/mime/test/mime-roundtrip.cpp

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
#include <boost/mime.hpp>
1313
#include <boost/bind.hpp>
1414

15-
#define BOOST_TEST_MODULE MIME Roundtrip
15+
#ifdef BOOST_TEST_DYN_LINK
16+
#define BOOST_TEST_ALTERNATIVE_INIT_API
17+
#endif
1618
#include <boost/test/included/unit_test.hpp>
1719

1820
#include <fstream>
@@ -73,16 +75,20 @@ namespace {
7375
BOOST_CHECK_EQUAL ( readfile ( fileName ), from_mime ( mp ));
7476
}
7577

76-
void test_expected_parse_fail ( const char *fileName ) {
78+
void test_expected_parse_fail ( const char *) {
7779
}
7880

7981
}
8082

8183

8284
using namespace boost::unit_test;
8385

86+
#ifdef BOOST_TEST_DYN_LINK
87+
bool init_unit_test()
88+
#else
8489
test_suite*
85-
init_unit_test_suite( int argc, char* argv[] )
90+
init_unit_test_suite( int, char** )
91+
#endif
8692
{
8793
framework::master_test_suite().add ( BOOST_TEST_CASE( boost::bind ( test_roundtrip, "TestMessages/00000001" )));
8894
framework::master_test_suite().add ( BOOST_TEST_CASE( boost::bind ( test_roundtrip, "TestMessages/00000019" )));
@@ -94,5 +100,16 @@ init_unit_test_suite( int argc, char* argv[] )
94100

95101
// test cases that fail
96102
// framework::master_test_suite().add ( BOOST_TEST_CASE( boost::bind ( test_roundtrip, "TestMessages/0019-NoBoundary" )));
97-
return 0;
103+
return
104+
#ifdef BOOST_TEST_DYN_LINK
105+
true;
106+
#else
107+
0;
108+
#endif
98109
}
110+
111+
#ifdef BOOST_TEST_DYN_LINK
112+
int main(int argc, char* argv[]) {
113+
return unit_test_main(&init_unit_test, argc, argv);
114+
}
115+
#endif

0 commit comments

Comments
 (0)