Boost logo

Boost-Commit :

From: igaztanaga_at_[hidden]
Date: 2007-08-25 15:07:34


Author: igaztanaga
Date: 2007-08-25 15:07:32 EDT (Sat, 25 Aug 2007)
New Revision: 38950
URL: http://svn.boost.org/trac/boost/changeset/38950

Log:
#1211: Interprocess tests hang when run in parallel
#1080 boost::interprocess win32 global file mapping issue
Added:
   trunk/libs/interprocess/test/get_process_id_name.hpp (contents, props changed)
Text files modified:
   trunk/libs/interprocess/test/check_equal_containers.hpp | 6 +++++-
   trunk/libs/interprocess/test/data_test.cpp | 10 +++++-----
   trunk/libs/interprocess/test/deque_test.cpp | 4 ++--
   trunk/libs/interprocess/test/dummy_test_allocator.hpp | 31 +++++++++++++++----------------
   trunk/libs/interprocess/test/expand_bwd_test_allocator.hpp | 33 +++++++++++++++------------------
   trunk/libs/interprocess/test/file_mapping_test.cpp | 14 +++++++-------
   trunk/libs/interprocess/test/flat_tree_test.cpp | 5 +++++
   trunk/libs/interprocess/test/intrusive_ptr_test.cpp | 16 ----------------
   trunk/libs/interprocess/test/list_test.hpp | 4 ++--
   9 files changed, 56 insertions(+), 67 deletions(-)

Modified: trunk/libs/interprocess/test/check_equal_containers.hpp
==============================================================================
--- trunk/libs/interprocess/test/check_equal_containers.hpp (original)
+++ trunk/libs/interprocess/test/check_equal_containers.hpp 2007-08-25 15:07:32 EDT (Sat, 25 Aug 2007)
@@ -32,9 +32,13 @@
 
    typename MyShmCont::iterator itshm(shmcont->begin()), itshmend(shmcont->end());
    typename MyStdCont::iterator itstd(stdcont->begin());
+ if((typename MyShmCont::size_type)std::distance(itshm, itshmend) != shmcont->size()){
+ return false;
+ }
    for(; itshm != itshmend; ++itshm, ++itstd){
       value_type val(*itstd);
- if(*itshm != val)
+ const value_type &v = *itshm;
+ if(v != val)
          return false;
    }
    return true;

Modified: trunk/libs/interprocess/test/data_test.cpp
==============================================================================
--- trunk/libs/interprocess/test/data_test.cpp (original)
+++ trunk/libs/interprocess/test/data_test.cpp 2007-08-25 15:07:32 EDT (Sat, 25 Aug 2007)
@@ -18,17 +18,17 @@
 #include <functional>
 #include <string>
 #include "print_container.hpp"
-#include "get_compiler_name.hpp"
+#include "get_process_id_name.hpp"
 
 using namespace boost::interprocess;
 
 int main ()
 {
    const int memsize = 65536;
- std::string compiler_name;
- test::get_compiler_name(compiler_name);
- const char *const shMemName = compiler_name.c_str();
- std::string filename (test::get_compiler_name());
+ std::string process_name;
+ test::get_process_id_name(process_name);
+ const char *const shMemName = process_name.c_str();
+ std::string filename (test::get_process_id_name());
    filename += "_file";
 
    try{

Modified: trunk/libs/interprocess/test/deque_test.cpp
==============================================================================
--- trunk/libs/interprocess/test/deque_test.cpp (original)
+++ trunk/libs/interprocess/test/deque_test.cpp 2007-08-25 15:07:32 EDT (Sat, 25 Aug 2007)
@@ -29,7 +29,7 @@
 #include <boost/interprocess/detail/move.hpp>
 #include <boost/interprocess/detail/mpl.hpp>
 #include <string>
-#include "get_compiler_name.hpp"
+#include "get_process_id_name.hpp"
 
 //***************************************************************//
 // //
@@ -96,7 +96,7 @@
    typedef deque<IntType, shmem_allocator_t> MyShmDeque;
    typedef std::deque<int> MyStdDeque;
    const int Memsize = 65536;
- const char *const shMemName = test::get_compiler_name();
+ const char *const shMemName = test::get_process_id_name();
    const int max = 100;
 
    try{

Modified: trunk/libs/interprocess/test/dummy_test_allocator.hpp
==============================================================================
--- trunk/libs/interprocess/test/dummy_test_allocator.hpp (original)
+++ trunk/libs/interprocess/test/dummy_test_allocator.hpp 2007-08-25 15:07:32 EDT (Sat, 25 Aug 2007)
@@ -30,9 +30,8 @@
 #include <stdexcept>
 #include <assert.h>
 
-/*!\file
- Describes an allocator to test expand capabilities
-*/
+//!\file
+//!Describes an allocator to test expand capabilities
 
 namespace boost {
 namespace interprocess {
@@ -71,15 +70,15 @@
    struct rebind
    { typedef dummy_test_allocator<T2> other; };
 
- /*!Default constructor. Never throws*/
+ //!Default constructor. Never throws
    dummy_test_allocator()
    {}
 
- /*!Constructor from other dummy_test_allocator. Never throws*/
+ //!Constructor from other dummy_test_allocator. Never throws
    dummy_test_allocator(const dummy_test_allocator &other)
    {}
 
- /*!Constructor from related dummy_test_allocator. Never throws*/
+ //!Constructor from related dummy_test_allocator. Never throws
    template<class T2>
    dummy_test_allocator(const dummy_test_allocator<T2> &other)
    {}
@@ -118,31 +117,31 @@
                          size_type &, const pointer & = 0)
    { return std::pair<pointer, bool>(0, true); }
 
- /*!Returns maximum the number of objects the previously allocated memory
- pointed by p can hold.*/
+ //!Returns maximum the number of objects the previously allocated memory
+ //!pointed by p can hold.
    size_type size(const pointer &) const
    { return 0; }
 
- /*!Allocates just one object. Memory allocated with this function
- must be deallocated only with deallocate_one().
- Throws boost::interprocess::bad_alloc if there is no enough memory*/
+ //!Allocates just one object. Memory allocated with this function
+ //!must be deallocated only with deallocate_one().
+ //!Throws boost::interprocess::bad_alloc if there is no enough memory
    pointer allocate_one()
    { return pointer(0); }
 
- /*!Deallocates memory previously allocated with allocate_one().
- You should never use deallocate_one to deallocate memory allocated
- with other functions different from allocate_one(). Never throws*/
+ //!Deallocates memory previously allocated with allocate_one().
+ //!You should never use deallocate_one to deallocate memory allocated
+ //!with other functions different from allocate_one(). Never throws
    void deallocate_one(const pointer &)
    {}
 };
 
-/*!Equality test for same type of dummy_test_allocator*/
+//!Equality test for same type of dummy_test_allocator
 template<class T> inline
 bool operator==(const dummy_test_allocator<T> &alloc1,
                 const dummy_test_allocator<T> &alloc2)
 { return false; }
 
-/*!Inequality test for same type of dummy_test_allocator*/
+//!Inequality test for same type of dummy_test_allocator
 template<class T> inline
 bool operator!=(const dummy_test_allocator<T> &alloc1,
                 const dummy_test_allocator<T> &alloc2)

Modified: trunk/libs/interprocess/test/expand_bwd_test_allocator.hpp
==============================================================================
--- trunk/libs/interprocess/test/expand_bwd_test_allocator.hpp (original)
+++ trunk/libs/interprocess/test/expand_bwd_test_allocator.hpp 2007-08-25 15:07:32 EDT (Sat, 25 Aug 2007)
@@ -30,14 +30,11 @@
 #include <stdexcept>
 #include <assert.h>
 
-/*!\file
- Describes an allocator to test expand capabilities
-*/
+//!\file
+//!Describes an allocator to test expand capabilities
 
 namespace boost {
-
 namespace interprocess {
-
 namespace test {
 
 //This allocator just allows two allocations. The first one will return
@@ -73,17 +70,17 @@
    struct rebind
    { typedef expand_bwd_test_allocator<T2> other; };
 
- /*!Constructor from the segment manager. Never throws*/
+ //!Constructor from the segment manager. Never throws
    expand_bwd_test_allocator(T *buffer, size_type size, difference_type offset)
       : mp_buffer(buffer), m_size(size)
       , m_offset(offset), m_allocations(0){ }
 
- /*!Constructor from other expand_bwd_test_allocator. Never throws*/
+ //!Constructor from other expand_bwd_test_allocator. Never throws
    expand_bwd_test_allocator(const expand_bwd_test_allocator &other)
       : mp_buffer(other.mp_buffer), m_size(other.m_size)
       , m_offset(other.m_offset), m_allocations(0){ }
 
- /*!Constructor from related expand_bwd_test_allocator. Never throws*/
+ //!Constructor from related expand_bwd_test_allocator. Never throws
    template<class T2>
    expand_bwd_test_allocator(const expand_bwd_test_allocator<T2> &other)
       : mp_buffer(other.mp_buffer), m_size(other.m_size)
@@ -153,20 +150,20 @@
       return std::pair<pointer, bool>(0, true);
    }
 
- /*!Returns maximum the number of objects the previously allocated memory
- pointed by p can hold.*/
+ //!Returns maximum the number of objects the previously allocated memory
+ //!pointed by p can hold.
    size_type size(const pointer &p) const
    { (void)p; return m_size; }
 
- /*!Allocates just one object. Memory allocated with this function
- must be deallocated only with deallocate_one().
- Throws boost::interprocess::bad_alloc if there is no enough memory*/
+ //!Allocates just one object. Memory allocated with this function
+ //!must be deallocated only with deallocate_one().
+ //!Throws boost::interprocess::bad_alloc if there is no enough memory
    pointer allocate_one()
    { return this->allocate(1); }
 
- /*!Deallocates memory previously allocated with allocate_one().
- You should never use deallocate_one to deallocate memory allocated
- with other functions different from allocate_one(). Never throws*/
+ //!Deallocates memory previously allocated with allocate_one().
+ //!You should never use deallocate_one to deallocate memory allocated
+ //!with other functions different from allocate_one(). Never throws
    void deallocate_one(const pointer &p)
    { return this->deallocate(p, 1); }
 
@@ -176,13 +173,13 @@
    char m_allocations;
 };
 
-/*!Equality test for same type of expand_bwd_test_allocator*/
+//!Equality test for same type of expand_bwd_test_allocator
 template<class T> inline
 bool operator==(const expand_bwd_test_allocator<T> &alloc1,
                 const expand_bwd_test_allocator<T> &alloc2)
 { return false; }
 
-/*!Inequality test for same type of expand_bwd_test_allocator*/
+//!Inequality test for same type of expand_bwd_test_allocator
 template<class T> inline
 bool operator!=(const expand_bwd_test_allocator<T> &alloc1,
                 const expand_bwd_test_allocator<T> &alloc2)

Modified: trunk/libs/interprocess/test/file_mapping_test.cpp
==============================================================================
--- trunk/libs/interprocess/test/file_mapping_test.cpp (original)
+++ trunk/libs/interprocess/test/file_mapping_test.cpp 2007-08-25 15:07:32 EDT (Sat, 25 Aug 2007)
@@ -16,7 +16,7 @@
 #include <memory>
 #include <cstdio>
 #include <string>
-#include "get_compiler_name.hpp"
+#include "get_process_id_name.hpp"
 
 using namespace boost::interprocess;
 
@@ -26,14 +26,14 @@
       const std::size_t FileSize = 99999*2;
       {
          //Create file with given size
- std::ofstream file(test::get_compiler_name(), std::ios::binary | std::ios::trunc);
+ std::ofstream file(test::get_process_id_name(), std::ios::binary | std::ios::trunc);
          file.seekp(static_cast<std::streamoff>(FileSize-1));
          file.write("", 1);
       }
 
       {
          //Create a file mapping
- file_mapping mapping(test::get_compiler_name(), read_write);
+ file_mapping mapping(test::get_process_id_name(), read_write);
          //Create two mapped regions, one half of the file each
          mapped_region region (mapping
                               ,read_write
@@ -66,7 +66,7 @@
       //See if the pattern is correct in the file
       {
          //Open the file
- std::ifstream file(test::get_compiler_name(), std::ios::binary);
+ std::ifstream file(test::get_process_id_name(), std::ios::binary);
 
          //Create a memory buffer
          std::auto_ptr<unsigned char> memory (new unsigned char [FileSize/2 +1]);
@@ -103,7 +103,7 @@
       //Now check the pattern mapping a single read only mapped_region
       {
          //Create a file mapping
- file_mapping mapping(test::get_compiler_name(), read_only);
+ file_mapping mapping(test::get_process_id_name(), read_only);
 
          //Create a single regions, mapping all the file
          mapped_region region (mapping
@@ -122,11 +122,11 @@
       }
    }
    catch(std::exception &exc){
- std::remove(test::get_compiler_name());
+ std::remove(test::get_process_id_name());
       std::cout << "Unhandled exception: " << exc.what() << std::endl;
       throw;
    }
- std::remove(test::get_compiler_name());
+ std::remove(test::get_process_id_name());
    return 0;
 }
 

Modified: trunk/libs/interprocess/test/flat_tree_test.cpp
==============================================================================
--- trunk/libs/interprocess/test/flat_tree_test.cpp (original)
+++ trunk/libs/interprocess/test/flat_tree_test.cpp 2007-08-25 15:07:32 EDT (Sat, 25 Aug 2007)
@@ -120,6 +120,7 @@
                   ,MyStdSet
                   ,MyShmMultiSet
                   ,MyStdMultiSet>()){
+ std::cout << "Error in set_test<MyShmSet>" << std::endl;
       return 1;
    }
    if (0 != set_test<my_managed_shared_memory
@@ -127,6 +128,7 @@
                   ,MyStdSet
                   ,MyMovableShmMultiSet
                   ,MyStdMultiSet>()){
+ std::cout << "Error in set_test<MyMovableShmSet>" << std::endl;
       return 1;
    }
 
@@ -135,6 +137,7 @@
                   ,MyStdSet
                   ,MyMoveCopyShmMultiSet
                   ,MyStdMultiSet>()){
+ std::cout << "Error in set_test<MyMoveCopyShmSet>" << std::endl;
       return 1;
    }
 
@@ -143,6 +146,7 @@
                   ,MyStdMap
                   ,MyShmMultiMap
                   ,MyStdMultiMap>()){
+ std::cout << "Error in set_test<MyShmMap>" << std::endl;
       return 1;
    }
 
@@ -159,6 +163,7 @@
                   ,MyStdMap
                   ,MyMoveCopyShmMultiMap
                   ,MyStdMultiMap>()){
+ std::cout << "Error in set_test<MyMoveCopyShmMap>" << std::endl;
       return 1;
    }
 

Added: trunk/libs/interprocess/test/get_process_id_name.hpp
==============================================================================
--- (empty file)
+++ trunk/libs/interprocess/test/get_process_id_name.hpp 2007-08-25 15:07:32 EDT (Sat, 25 Aug 2007)
@@ -0,0 +1,50 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Ion Gaztanaga 2004-2007. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/interprocess for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_INTERPROCESS_GET_PROCESS_ID_NAME_HPP
+#define BOOST_INTERPROCESS_GET_PROCESS_ID_NAME_HPP
+
+#include <boost/config.hpp>
+#include <string>
+#include <algorithm>
+#include <sstream>
+#include <boost/interprocess/detail/os_thread_functions.hpp>
+
+namespace boost{
+namespace interprocess{
+namespace test{
+
+inline void get_process_id_name(std::string &str)
+{
+ std::stringstream sstr;
+ sstr << "process_" << boost::interprocess::detail::get_current_process_id();
+ str = sstr.str();
+}
+
+inline const char *get_process_id_name()
+{
+ static std::string str;
+ get_process_id_name(str);
+ return str.c_str();
+}
+
+inline const char *add_to_process_id_name(const char *name)
+{
+ static std::string str;
+ get_process_id_name(str);
+ str += name;
+ return str.c_str();
+}
+
+} //namespace test{
+} //namespace interprocess{
+} //namespace boost{
+
+#endif //#ifndef BOOST_INTERPROCESS_GET_PROCESS_ID_NAME_HPP

Modified: trunk/libs/interprocess/test/intrusive_ptr_test.cpp
==============================================================================
--- trunk/libs/interprocess/test/intrusive_ptr_test.cpp (original)
+++ trunk/libs/interprocess/test/intrusive_ptr_test.cpp 2007-08-25 15:07:32 EDT (Sat, 25 Aug 2007)
@@ -19,22 +19,6 @@
 #include <algorithm>
 #include <functional>
 
-#if defined(BOOST_MSVC)
-
-#pragma warning(disable: 4786) // identifier truncated in debug info
-#pragma warning(disable: 4710) // function not inlined
-#pragma warning(disable: 4711) // function selected for automatic inline expansion
-#pragma warning(disable: 4514) // unreferenced inline removed
-#pragma warning(disable: 4355) // 'this' : used in base member initializer list
-#pragma warning(disable: 4511) // copy constructor could not be generated
-#pragma warning(disable: 4512) // assignment operator could not be generated
-
-#if (BOOST_MSVC >= 1310)
-#pragma warning(disable: 4675) // resolved overload found with Koenig lookup
-#endif
-
-#endif
-
 typedef boost::interprocess::offset_ptr<void> VP;
 
 namespace N

Modified: trunk/libs/interprocess/test/list_test.hpp
==============================================================================
--- trunk/libs/interprocess/test/list_test.hpp (original)
+++ trunk/libs/interprocess/test/list_test.hpp 2007-08-25 15:07:32 EDT (Sat, 25 Aug 2007)
@@ -21,7 +21,7 @@
 #include <boost/interprocess/detail/move.hpp>
 #include <boost/interprocess/detail/move_iterator.hpp>
 #include <string>
-#include "get_compiler_name.hpp"
+#include "get_process_id_name.hpp"
 
 namespace boost{
 namespace interprocess{
@@ -94,7 +94,7 @@
    typedef std::list<int> MyStdList;
    typedef typename MyShmList::value_type IntType;
    const int memsize = 65536;
- const char *const shMemName = test::get_compiler_name();
+ const char *const shMemName = test::get_process_id_name();
    const int max = 100;
    typedef push_data_function<DoublyLinked> push_data_t;
 


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