Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r58518 - trunk/libs/serialization/test
From: ramey_at_[hidden]
Date: 2009-12-23 13:28:48


Author: ramey
Date: 2009-12-23 13:28:48 EST (Wed, 23 Dec 2009)
New Revision: 58518
URL: http://svn.boost.org/trac/boost/changeset/58518

Log:
Fix plugin test/demo
Text files modified:
   trunk/libs/serialization/test/test_dll_plugin.cpp | 47 +++++++++++++++++++++++++++++++++++----
   1 files changed, 42 insertions(+), 5 deletions(-)

Modified: trunk/libs/serialization/test/test_dll_plugin.cpp
==============================================================================
--- trunk/libs/serialization/test/test_dll_plugin.cpp (original)
+++ trunk/libs/serialization/test/test_dll_plugin.cpp 2009-12-23 13:28:48 EST (Wed, 23 Dec 2009)
@@ -29,12 +29,8 @@
 #include <boost/archive/archive_exception.hpp>
 
 // for now, only test with simple text and polymorphic archive
-#define BOOST_ARCHIVE_TEST polymorphic_text_archive.hpp
 #include "test_tools.hpp"
 
-#include <boost/archive/polymorphic_text_oarchive.hpp>
-#include <boost/archive/polymorphic_text_iarchive.hpp>
-
 #include <boost/serialization/base_object.hpp>
 #include <boost/serialization/export.hpp>
 #include <boost/serialization/type_info_implementation.hpp>
@@ -52,10 +48,19 @@
     void serialize(Archive &ar, const unsigned int /* file_version */){
         ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(polymorphic_base);
     }
+ const char * get_key() const{
+ return
+ boost::serialization::type_info_implementation<
+ polymorphic_derived1
+ >::type::get_const_instance().get_key();
+ }
 public:
     virtual ~polymorphic_derived1(){}
 };
 
+// This class is derived from polymorphic_base which uses the no_rtti system
+// rather than the typeid system. This system uses the exported name as the
+// type identifier key. This MUST be exported!!!
 BOOST_CLASS_EXPORT(polymorphic_derived1)
 
 // MWerks users can do this to make their code work
@@ -101,6 +106,7 @@
     // don't need these any more - don't leak memory
     delete rb1;
     // note delete original handle - not runtime cast one !!!
+ //delete rb2;
     d2_eti->destroy(rd2);
 }
 
@@ -146,6 +152,8 @@
     delete rb2;
 }
 
+#ifdef BOOST_WINDOWS
+
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 
@@ -157,7 +165,10 @@
 
     HINSTANCE hDLL; // Handle to DLL
     hDLL = LoadLibrary("dll_polymorphic_derived2.dll");
- assert(0 != hDLL);
+ BOOST_CHECK_MESSAGE((0 != hDLL), "Failed to find/load dll_polymorphic_derived2" );
+ if(0 == hDLL)
+ return EXIT_FAILURE;
+
     save_exported(testfile);
     load_exported(testfile);
     FreeLibrary(hDLL);
@@ -166,4 +177,30 @@
     return EXIT_SUCCESS;
 }
 
+#else // presume *nix
+
+#include <dlfcn.h>
+
+int
+test_main( int /* argc */, char* /* argv */[] )
+{
+ const char * testfile = boost::archive::tmpnam(NULL);
+ BOOST_REQUIRE(NULL != testfile);
+
+ void * hDLL; // Handle to DLL
+ hDLL = dlopen("dll_polymorphic_derived2.so", RTLD_NOW | RTLD_GLOBAL);
+ BOOST_CHECK_MESSAGE((0 != hDLL), "Failed to find/load dll_polymorphic_derived2" );
+ if(0 == hDLL)
+ return EXIT_FAILURE;
+
+ save_exported(testfile);
+ load_exported(testfile);
+ dlclose(hDLL);
+
+ std::remove(testfile);
+ return EXIT_SUCCESS;
+}
+
+#endif
+
 // EOF


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk