forked from boostorg/system
Major upgrade to Boost.Config symbol visibility macros for shared libraries, based on patches from Jürgen Hunold with mods by Beman Dawes. Upgrade Boost.System to use the new visibility macros. Fixes #3697 and provides foundation for fixing 2114, 2309, etc.
[SVN r62140]
This commit is contained in:
1 parent
ae67c86d2b
commit
2bb0075e3f
13 files changed
+193
-70
No files matched your search
+13
-3
@@ -12,6 +12,12 @@ project
|
||||
<library>/boost/system//boost_system
|
||||
<toolset>msvc:<asynch-exceptions>on
|
||||
;
|
||||
|
||||
lib throw_test
|
||||
: throw_test.cpp
|
||||
: <link>shared:<define>BOOST_SYSTEM_DYN_LINK=1
|
||||
;
|
||||
|
||||
|
||||
test-suite "system"
|
||||
: [ run error_code_test.cpp
|
||||
@@ -21,21 +27,25 @@ project
|
||||
<link>static
|
||||
]
|
||||
[ run error_code_test.cpp
|
||||
: : : : error_code_test_dll
|
||||
: : : <link>shared : error_code_test_shared
|
||||
]
|
||||
[ run error_code_user_test.cpp
|
||||
: : : <link>static
|
||||
]
|
||||
[ run error_code_user_test.cpp
|
||||
: : : : error_code_user_test_dll
|
||||
: : : <link>shared : error_code_user_test_shared
|
||||
]
|
||||
[ run system_error_test.cpp
|
||||
: : : <link>static
|
||||
]
|
||||
[ run system_error_test.cpp
|
||||
: : : : system_error_test_dll
|
||||
: : : <link>shared : system_error_test_shared
|
||||
]
|
||||
[ run dynamic_link_test.cpp throw_test
|
||||
: : : <link>shared : throw_test_shared
|
||||
]
|
||||
[ run initialization_test.cpp
|
||||
: : : <link>shared : initialization_test_shared
|
||||
]
|
||||
[ run header_only_test.cpp
|
||||
: : : <link>static
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
// dynamic_link_test.cpp -------------------------------------------------------------//
|
||||
|
||||
// Copyright Beman Dawes 2010
|
||||
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
// Library home page is www.boost.org/libs/system
|
||||
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
// Dynamic link libraries (DLL's), also know as dynamic shared objects (DSO's),
|
||||
// can cause symbol visability problems unless carefully configured. One of the
|
||||
// manifestations, particularly with GCC, is that a system_error exception thrown from
|
||||
// a DLL or DSO is not caught.
|
||||
//
|
||||
// The purpose of this program is to test for that error.
|
||||
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
#include <boost/system/system_error.hpp>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace system
|
||||
{
|
||||
BOOST_SYSTEM_DECL void throw_test();
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
try
|
||||
{
|
||||
boost::system::throw_test();
|
||||
}
|
||||
catch (const boost::system::system_error& ex)
|
||||
{
|
||||
std::cout << " caught boost::system::system_error as expected\n";
|
||||
std::cout << " what() reports " << ex.what() << '\n';
|
||||
return 0;
|
||||
}
|
||||
|
||||
catch (const std::runtime_error& ex)
|
||||
{
|
||||
std::cout << " error: caught std::runtime_error instead of boost::system::system_error\n";
|
||||
std::cout << " what() reports " << ex.what() << '\n';
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::cout << " error: failed to catch boost::system::system_error\n";
|
||||
return 1;
|
||||
}
|
||||
@@ -59,6 +59,12 @@ namespace
|
||||
int main( int, char ** )
|
||||
{
|
||||
|
||||
std::cout << "Conversion use cases...\n";
|
||||
error_condition x1( errc::file_exists );
|
||||
//error_code x2( errc::file_exists ); // should fail to compile
|
||||
make_error_code(errc::file_exists);
|
||||
make_error_condition(errc::file_exists);
|
||||
|
||||
std::cout << "General tests...\n";
|
||||
// unit tests:
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include <boost/cerrno.hpp>
|
||||
#include <string>
|
||||
#include <cstdio>
|
||||
#include <boost/test/minimal.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
#ifdef BOOST_POSIX_API
|
||||
# include <sys/stat.h>
|
||||
@@ -264,7 +264,7 @@ namespace lib4
|
||||
//
|
||||
// void check_success(const boost::system::error_code& ec, bool expect)
|
||||
// {
|
||||
// BOOST_CHECK( (ec == boost::system::posix::success) == expect );
|
||||
// BOOST_TEST( (ec == boost::system::posix::success) == expect );
|
||||
// if (ec == boost::system::posix::success)
|
||||
// std::cout << "yes... " << (expect ? "ok" : "fail") << '\n';
|
||||
// else
|
||||
@@ -273,7 +273,7 @@ namespace lib4
|
||||
//
|
||||
// void check_permission_denied(const boost::system::error_code& ec, bool expect)
|
||||
// {
|
||||
// BOOST_CHECK( (ec == boost::system::posix::permission_denied) == expect );
|
||||
// BOOST_TEST( (ec == boost::system::posix::permission_denied) == expect );
|
||||
// if (ec == boost::system::posix::permission_denied)
|
||||
// std::cout << "yes... " << (expect ? "ok" : "fail") << '\n';
|
||||
// else
|
||||
@@ -282,7 +282,7 @@ namespace lib4
|
||||
//
|
||||
// void check_out_of_memory(const boost::system::error_code& ec, bool expect)
|
||||
// {
|
||||
// BOOST_CHECK( (ec == boost::system::posix::not_enough_memory) == expect );
|
||||
// BOOST_TEST( (ec == boost::system::posix::not_enough_memory) == expect );
|
||||
// if (ec == boost::system::posix::not_enough_memory)
|
||||
// std::cout << "yes... " << (expect ? "ok" : "fail") << '\n';
|
||||
// else
|
||||
@@ -337,7 +337,7 @@ namespace lib4
|
||||
|
||||
// ------------------------------------------------------------------------ //
|
||||
|
||||
int test_main( int, char *[] )
|
||||
int main( int, char *[] )
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
|
||||
@@ -346,35 +346,35 @@ int test_main( int, char *[] )
|
||||
ec = my_mkdir( "/no-such-file-or-directory/will-not-succeed" );
|
||||
std::cout << "ec.value() is " << ec.value() << '\n';
|
||||
|
||||
BOOST_CHECK( ec );
|
||||
BOOST_CHECK( ec == boost::system::posix::no_such_file_or_directory );
|
||||
BOOST_CHECK( ec.category() == boost::system::system_category );
|
||||
BOOST_TEST( ec );
|
||||
BOOST_TEST( ec == boost::system::posix::no_such_file_or_directory );
|
||||
BOOST_TEST( ec.category() == boost::system::system_category );
|
||||
|
||||
// Library 2 tests:
|
||||
|
||||
ec = my_remove( "/no-such-file-or-directory" );
|
||||
std::cout << "ec.value() is " << ec.value() << '\n';
|
||||
|
||||
BOOST_CHECK( ec );
|
||||
BOOST_CHECK( ec == boost::system::posix::no_such_file_or_directory );
|
||||
BOOST_CHECK( ec.category() == boost::system::posix_category );
|
||||
BOOST_TEST( ec );
|
||||
BOOST_TEST( ec == boost::system::posix::no_such_file_or_directory );
|
||||
BOOST_TEST( ec.category() == boost::system::posix_category );
|
||||
|
||||
// Library 3 tests:
|
||||
|
||||
ec = boost::lib3::boo_boo;
|
||||
std::cout << "ec.value() is " << ec.value() << '\n';
|
||||
|
||||
BOOST_CHECK( ec );
|
||||
BOOST_CHECK( ec == boost::lib3::boo_boo );
|
||||
BOOST_CHECK( ec.value() == boost::lib3::boo_boo );
|
||||
BOOST_CHECK( ec.category() == boost::lib3::lib3_error_category );
|
||||
BOOST_TEST( ec );
|
||||
BOOST_TEST( ec == boost::lib3::boo_boo );
|
||||
BOOST_TEST( ec.value() == boost::lib3::boo_boo );
|
||||
BOOST_TEST( ec.category() == boost::lib3::lib3_error_category );
|
||||
|
||||
BOOST_CHECK( ec == boost::system::posix::io_error );
|
||||
BOOST_TEST( ec == boost::system::posix::io_error );
|
||||
|
||||
boost::system::error_code ec3( boost::lib3::boo_boo+100,
|
||||
boost::lib3::lib3_error_category );
|
||||
BOOST_CHECK( ec3.category() == boost::lib3::lib3_error_category );
|
||||
BOOST_CHECK( ec3.default_error_condition().category()
|
||||
BOOST_TEST( ec3.category() == boost::lib3::lib3_error_category );
|
||||
BOOST_TEST( ec3.default_error_condition().category()
|
||||
== boost::lib3::lib3_error_category );
|
||||
|
||||
// Library 4 tests:
|
||||
@@ -382,16 +382,16 @@ int test_main( int, char *[] )
|
||||
ec = lib4::boo_boo;
|
||||
std::cout << "ec.value() is " << ec.value() << '\n';
|
||||
|
||||
BOOST_CHECK( ec );
|
||||
BOOST_CHECK( ec == lib4::boo_boo );
|
||||
BOOST_CHECK( ec.value() == lib4::boo_boo.value() );
|
||||
BOOST_CHECK( ec.category() == lib4::lib4_error_category );
|
||||
BOOST_TEST( ec );
|
||||
BOOST_TEST( ec == lib4::boo_boo );
|
||||
BOOST_TEST( ec.value() == lib4::boo_boo.value() );
|
||||
BOOST_TEST( ec.category() == lib4::lib4_error_category );
|
||||
|
||||
BOOST_CHECK( ec == boost::system::posix::io_error );
|
||||
BOOST_TEST( ec == boost::system::posix::io_error );
|
||||
|
||||
boost::system::error_code ec4( lib4::boo_boo.value()+100,
|
||||
lib4::lib4_error_category );
|
||||
BOOST_CHECK( ec4.default_error_condition().category()
|
||||
BOOST_TEST( ec4.default_error_condition().category()
|
||||
== lib4::lib4_error_category );
|
||||
|
||||
// Test 3
|
||||
|
||||
@@ -13,11 +13,10 @@
|
||||
|
||||
#define BOOST_ERROR_CODE_HEADER_ONLY
|
||||
|
||||
#include <boost/test/minimal.hpp>
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/system/error_code.hpp>
|
||||
|
||||
int test_main( int, char*[] )
|
||||
int main( int, char*[] )
|
||||
{
|
||||
boost::system::error_code ec( 0, boost::system::system_category );
|
||||
return 0;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
// This test verifiies that the error_category vtable does not suffer from
|
||||
// order-of-initialization problems.
|
||||
|
||||
#include <boost/test/minimal.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/system/error_code.hpp>
|
||||
|
||||
struct foo
|
||||
@@ -22,7 +22,7 @@ struct foo
|
||||
}
|
||||
} f;
|
||||
|
||||
int test_main( int, char ** )
|
||||
int main( int, char ** )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
#include <boost/config/warning_disable.hpp>
|
||||
|
||||
#include <boost/test/minimal.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/system/system_error.hpp>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
@@ -36,8 +36,8 @@ namespace
|
||||
int v, const char * str )
|
||||
{
|
||||
std::cout << "test " << desc << "\n what() returns \"" << ex.what() << "\"\n";
|
||||
BOOST_CHECK( ex.code().value() == v );
|
||||
BOOST_CHECK( ex.code().category() == system_category );
|
||||
BOOST_TEST( ex.code().value() == v );
|
||||
BOOST_TEST( ex.code().category() == system_category );
|
||||
# ifdef BOOST_WINDOWS_API
|
||||
LANGID language_id;
|
||||
# if !defined(__MINGW32__) && !defined(__CYGWIN__)
|
||||
@@ -48,7 +48,7 @@ namespace
|
||||
// std::cout << "GetUserDefaultUILanguage() returns " << language_id << '\n';
|
||||
if ( language_id == 0x0409 ) // English (United States)
|
||||
{
|
||||
BOOST_CHECK( std::string( ex.what() ) == str );
|
||||
BOOST_TEST( std::string( ex.what() ) == str );
|
||||
if ( std::string( ex.what() ) != str )
|
||||
std::cout << "expected \"" << str << "\", but what() returned \""
|
||||
<< ex.what() << "\"\n";
|
||||
@@ -59,7 +59,7 @@ namespace
|
||||
const boost::uint_least32_t uvalue = 2u;
|
||||
}
|
||||
|
||||
int test_main( int, char *[] )
|
||||
int main( int, char *[] )
|
||||
{
|
||||
// all constructors, in the same order as they appear in the header:
|
||||
|
||||
|
||||
@@ -7,13 +7,13 @@
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../../../../.."
|
||||
PreprocessorDefinitions="BOOST_ALL_NO_LIB"
|
||||
PreprocessorDefinitions="BOOST_ALL_NO_LIB;BOOST_ALL_DYN_LINK"
|
||||
ExceptionHandling="2"
|
||||
WarningLevel="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
Description="Executing test $(TargetName).exe..."
|
||||
CommandLine=""$(TargetDir)\$(TargetName).exe" --result_code=no --report_level=no"
|
||||
Description=""
|
||||
CommandLine=""
|
||||
/>
|
||||
</VisualStudioPropertySheet>
|
||||
@@ -86,6 +86,8 @@
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
Description="Executing test $(TargetName).exe..."
|
||||
CommandLine=""$(TargetDir)\$(TargetName).exe" --result_code=no --report_level=no"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
@@ -161,6 +163,8 @@
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
Description="Executing test $(TargetName).exe..."
|
||||
CommandLine=""$(TargetDir)\$(TargetName).exe" --result_code=no --report_level=no"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
@@ -172,10 +176,6 @@
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\..\src\error_code.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\error_code_test.cpp"
|
||||
>
|
||||
|
||||
@@ -2,8 +2,27 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 10.00
|
||||
# Visual C++ Express 2008
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "error_code_test", "error_code_test\error_code_test.vcproj", "{81960557-E9A9-4E81-AC96-9E11C33CB058}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{22892211-A1F3-435B-8B97-A12E8772599E} = {22892211-A1F3-435B-8B97-A12E8772599E}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "system_error_test", "system_error_test\system_error_test.vcproj", "{CBD12E59-99E5-4F35-9B66-0554D0FBDB76}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{22892211-A1F3-435B-8B97-A12E8772599E} = {22892211-A1F3-435B-8B97-A12E8772599E}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dynamic_link_test", "dynamic_link_test\dynamic_link_test.vcproj", "{AD186B11-9132-48A9-9F24-3522C2310B0D}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{F6D9B408-84A3-405A-93ED-DE5AA8CF84D7} = {F6D9B408-84A3-405A-93ED-DE5AA8CF84D7}
|
||||
{22892211-A1F3-435B-8B97-A12E8772599E} = {22892211-A1F3-435B-8B97-A12E8772599E}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "system_dll", "system_dll\system_dll.vcproj", "{22892211-A1F3-435B-8B97-A12E8772599E}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "throw_test_dll", "throw_test_dll\throw_test_dll.vcproj", "{F6D9B408-84A3-405A-93ED-DE5AA8CF84D7}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{22892211-A1F3-435B-8B97-A12E8772599E} = {22892211-A1F3-435B-8B97-A12E8772599E}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@@ -19,6 +38,18 @@ Global
|
||||
{CBD12E59-99E5-4F35-9B66-0554D0FBDB76}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{CBD12E59-99E5-4F35-9B66-0554D0FBDB76}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{CBD12E59-99E5-4F35-9B66-0554D0FBDB76}.Release|Win32.Build.0 = Release|Win32
|
||||
{AD186B11-9132-48A9-9F24-3522C2310B0D}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{AD186B11-9132-48A9-9F24-3522C2310B0D}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{AD186B11-9132-48A9-9F24-3522C2310B0D}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{AD186B11-9132-48A9-9F24-3522C2310B0D}.Release|Win32.Build.0 = Release|Win32
|
||||
{22892211-A1F3-435B-8B97-A12E8772599E}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{22892211-A1F3-435B-8B97-A12E8772599E}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{22892211-A1F3-435B-8B97-A12E8772599E}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{22892211-A1F3-435B-8B97-A12E8772599E}.Release|Win32.Build.0 = Release|Win32
|
||||
{F6D9B408-84A3-405A-93ED-DE5AA8CF84D7}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{F6D9B408-84A3-405A-93ED-DE5AA8CF84D7}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{F6D9B408-84A3-405A-93ED-DE5AA8CF84D7}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{F6D9B408-84A3-405A-93ED-DE5AA8CF84D7}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
// throw_test.cpp --------------------------------------------------------===========-//
|
||||
|
||||
// Copyright Beman Dawes 2010
|
||||
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
// Library home page is www.boost.org/libs/system
|
||||
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
// See dynamic_link_test.cpp comments for use case.
|
||||
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
// define BOOST_SYSTEM_SOURCE so that <boost/system/config.hpp> knows
|
||||
// the library is being built (possibly exporting rather than importing code)
|
||||
#define BOOST_SYSTEM_SOURCE
|
||||
|
||||
#include <boost/system/system_error.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace system
|
||||
{
|
||||
BOOST_SYSTEM_DECL void throw_test()
|
||||
{
|
||||
throw system_error(9999, get_system_category(), "boo boo");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user