From: khizmax Date: Tue, 12 Jan 2016 20:44:07 +0000 (+0300) Subject: Moved stack unit test to gtest framework X-Git-Tag: v2.2.0~427 X-Git-Url: http://plrg.eecs.uci.edu/git/?p=libcds.git;a=commitdiff_plain;h=b56a27630c7afd24cd2bbaf0592116c96d2862d2 Moved stack unit test to gtest framework Removed Android build --- diff --git a/CMakeLists.txt b/CMakeLists.txt index b445413b..c8d253ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,8 +39,14 @@ set(CDS_STATIC_LIBRARY ${PROJECT_NAME}-s) set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) set(CMAKE_INCLUDE_CURRENT_DIR ON) -set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) -set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) +if(CDS_BIN_ROOT) + set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/${CDS_BIN_ROOT}) + set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/${CDS_BIN_ROOT}) +else() + set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) + set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) +endif() +message(STATUS "Binary output path: ${EXECUTABLE_OUTPUT_PATH}") if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Debug CACHE STRING "Default build type to Debug" FORCE) @@ -75,9 +81,10 @@ set(SOURCES src/hp_gc.cpp src/dllmain.cpp) add_library(${CDS_SHARED_LIBRARY} SHARED ${SOURCES}) +set_target_properties( ${CDS_SHARED_LIBRARY} PROPERTIES VERSION ${PROJECT_VERSION}) add_library(${CDS_STATIC_LIBRARY} STATIC ${SOURCES}) -target_link_libraries(${CDS_SHARED_LIBRARY} PRIVATE ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) -target_link_libraries(${CDS_STATIC_LIBRARY} PRIVATE ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) +target_link_libraries(${CDS_SHARED_LIBRARY} PRIVATE ${CMAKE_THREAD_LIBS_INIT}) +target_link_libraries(${CDS_STATIC_LIBRARY} PRIVATE ${CMAKE_THREAD_LIBS_INIT}) install(TARGETS ${CDS_SHARED_LIBRARY} DESTINATION lib COMPONENT ${LIBRARIES_COMPONENT}) install(TARGETS ${CDS_STATIC_LIBRARY} DESTINATION lib COMPONENT ${LIBRARIES_COMPONENT}) @@ -85,6 +92,7 @@ install(DIRECTORY ${CMAKE_SOURCE_DIR}/cds DESTINATION include COMPONENT ${HEADER if(WITH_TESTS) enable_testing() + add_subdirectory(${CMAKE_SOURCE_DIR}/test) add_subdirectory(${CMAKE_SOURCE_DIR}/tests) message(STATUS "Build tests: activated") endif(WITH_TESTS) diff --git a/cds/intrusive/treiber_stack.h b/cds/intrusive/treiber_stack.h index ab164016..aa4147e0 100644 --- a/cds/intrusive/treiber_stack.h +++ b/cds/intrusive/treiber_stack.h @@ -658,6 +658,9 @@ namespace cds { namespace intrusive { typedef typename traits::stat stat; ///< Internal statistics typedef typename traits::back_off back_off; ///< back-off strategy + /// How many Hazard pointers is required for Treiber's stack implementation + static CDS_CONSTEXPR size_t const c_nHazardPtrCount = 1; + public: // related to elimination back-off /// Elimination back-off is enabled or not @@ -707,7 +710,7 @@ namespace cds { namespace intrusive { /// Constructs empty stack and initializes elimination back-off data /** This form should be used if you use elimination back-off with dynamically allocated collision array, i.e - \p Options... contains cds::opt::buffer< cds::opt::v::dynamic_buffer >. + \p Traits contains typedef cds::opt::v::dynamic_buffer buffer. \p nCollisionCapacity parameter specifies the capacity of collision array. */ TreiberStack( size_t nCollisionCapacity ) diff --git a/projects/Win/vc14/cds.sln b/projects/Win/vc14/cds.sln index 86833450..1299dddc 100644 --- a/projects/Win/vc14/cds.sln +++ b/projects/Win/vc14/cds.sln @@ -153,12 +153,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hdr-test-set", "hdr-test-se {408FE9BC-44F0-4E6A-89FA-D6F952584239} = {408FE9BC-44F0-4E6A-89FA-D6F952584239} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hdr-test-stack", "hdr-test-stack.vcxproj", "{E3F2927A-6ED6-4B18-BDE6-B3B760E1AF18}" - ProjectSection(ProjectDependencies) = postProject - {61179F2F-07E1-490D-B64D-D85A90B6EF81} = {61179F2F-07E1-490D-B64D-D85A90B6EF81} - {408FE9BC-44F0-4E6A-89FA-D6F952584239} = {408FE9BC-44F0-4E6A-89FA-D6F952584239} - EndProjectSection -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hdr-test-striped-set", "hdr-test-striped-set.vcxproj", "{A38E5597-6916-4480-A343-C9846EF544E4}" ProjectSection(ProjectDependencies) = postProject {61179F2F-07E1-490D-B64D-D85A90B6EF81} = {61179F2F-07E1-490D-B64D-D85A90B6EF81} @@ -413,18 +407,6 @@ Global {E5E9DB4A-7816-45D4-A116-6BBBA0EE8EE7}.Release|Win32.Build.0 = Release|Win32 {E5E9DB4A-7816-45D4-A116-6BBBA0EE8EE7}.Release|x64.ActiveCfg = Release|x64 {E5E9DB4A-7816-45D4-A116-6BBBA0EE8EE7}.Release|x64.Build.0 = Release|x64 - {E3F2927A-6ED6-4B18-BDE6-B3B760E1AF18}.Debug|Win32.ActiveCfg = Debug|Win32 - {E3F2927A-6ED6-4B18-BDE6-B3B760E1AF18}.Debug|Win32.Build.0 = Debug|Win32 - {E3F2927A-6ED6-4B18-BDE6-B3B760E1AF18}.Debug|x64.ActiveCfg = Debug|x64 - {E3F2927A-6ED6-4B18-BDE6-B3B760E1AF18}.Debug|x64.Build.0 = Debug|x64 - {E3F2927A-6ED6-4B18-BDE6-B3B760E1AF18}.DebugVLD|Win32.ActiveCfg = DebugVLD|Win32 - {E3F2927A-6ED6-4B18-BDE6-B3B760E1AF18}.DebugVLD|Win32.Build.0 = DebugVLD|Win32 - {E3F2927A-6ED6-4B18-BDE6-B3B760E1AF18}.DebugVLD|x64.ActiveCfg = DebugVLD|x64 - {E3F2927A-6ED6-4B18-BDE6-B3B760E1AF18}.DebugVLD|x64.Build.0 = DebugVLD|x64 - {E3F2927A-6ED6-4B18-BDE6-B3B760E1AF18}.Release|Win32.ActiveCfg = Release|Win32 - {E3F2927A-6ED6-4B18-BDE6-B3B760E1AF18}.Release|Win32.Build.0 = Release|Win32 - {E3F2927A-6ED6-4B18-BDE6-B3B760E1AF18}.Release|x64.ActiveCfg = Release|x64 - {E3F2927A-6ED6-4B18-BDE6-B3B760E1AF18}.Release|x64.Build.0 = Release|x64 {A38E5597-6916-4480-A343-C9846EF544E4}.Debug|Win32.ActiveCfg = Debug|Win32 {A38E5597-6916-4480-A343-C9846EF544E4}.Debug|Win32.Build.0 = Debug|Win32 {A38E5597-6916-4480-A343-C9846EF544E4}.Debug|x64.ActiveCfg = Debug|x64 @@ -532,7 +514,6 @@ Global {90192F7D-5850-41DD-AE89-62D26B387162} = {B8C24D26-A3BF-4DA6-B64C-142CBA4BFE75} {33664E63-8D24-4FF4-A744-9782EB711509} = {B8C24D26-A3BF-4DA6-B64C-142CBA4BFE75} {E5E9DB4A-7816-45D4-A116-6BBBA0EE8EE7} = {B8C24D26-A3BF-4DA6-B64C-142CBA4BFE75} - {E3F2927A-6ED6-4B18-BDE6-B3B760E1AF18} = {B8C24D26-A3BF-4DA6-B64C-142CBA4BFE75} {A38E5597-6916-4480-A343-C9846EF544E4} = {B8C24D26-A3BF-4DA6-B64C-142CBA4BFE75} {6F834EAD-7B94-4979-A0F1-A662E3D30145} = {B8C24D26-A3BF-4DA6-B64C-142CBA4BFE75} {20B6C380-E96A-4CFF-BC17-D88AAE581919} = {B30CA283-1796-4763-92C3-2E4848D443F7} diff --git a/projects/Win/vc14/gtest-stack.vcxproj b/projects/Win/vc14/gtest-stack.vcxproj index 0080e6d6..acbcad6d 100644 --- a/projects/Win/vc14/gtest-stack.vcxproj +++ b/projects/Win/vc14/gtest-stack.vcxproj @@ -28,7 +28,16 @@ + + + + + + + + + {5407E9D2-67D9-4266-976E-7A90BDE2541D} diff --git a/projects/Win/vc14/gtest-stack.vcxproj.filters b/projects/Win/vc14/gtest-stack.vcxproj.filters index 6b4da025..621b653c 100644 --- a/projects/Win/vc14/gtest-stack.vcxproj.filters +++ b/projects/Win/vc14/gtest-stack.vcxproj.filters @@ -21,5 +21,28 @@ Source Files + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + \ No newline at end of file diff --git a/projects/Win/vc14/hdr-test-stack.vcxproj b/projects/Win/vc14/hdr-test-stack.vcxproj deleted file mode 100644 index b8134ecf..00000000 --- a/projects/Win/vc14/hdr-test-stack.vcxproj +++ /dev/null @@ -1,351 +0,0 @@ - - - - - DebugVLD - Win32 - - - DebugVLD - x64 - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {E3F2927A-6ED6-4B18-BDE6-B3B760E1AF18} - hdrteststack - Win32Proj - 8.1 - - - - Application - MultiByte - v140 - - - Application - MultiByte - true - v140 - - - Application - MultiByte - v140 - - - Application - MultiByte - v140 - - - Application - MultiByte - true - v140 - - - Application - MultiByte - v140 - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.40219.1 - $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)\ - $(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\ - false - $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)\ - $(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\ - false - $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)-release\ - $(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\ - false - $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)-release\ - $(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\ - false - $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)\ - $(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\ - false - $(SolutionDir)..\..\..\bin\vc.$(PlatformToolset)\$(Platform)\ - $(SolutionDir)..\..\..\obj\vc.$(PlatformToolset)\$(Platform)\$(ProjectName)\$(Configuration)\ - false - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - $(ProjectName)_d - $(ProjectName)_d - $(ProjectName)_d - $(ProjectName)_d - - - - /bigobj /Zc:inline %(AdditionalOptions) - Disabled - $(SolutionDir)..\..\..;$(SolutionDir)..\..\..\tests\test-hdr;$(SolutionDir)..\..\..\tests;$(BOOST_PATH);%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;_SCL_SECURE=0;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - EditAndContinue - Cdecl - 4520 - - - unit-prerequisites_d.lib;%(AdditionalDependencies) - $(TargetPath) - $(BOOST_PATH)/stage32/lib;$(BOOST_PATH)/stage/lib;$(BOOST_PATH)/bin;$(OutDir);%(AdditionalLibraryDirectories) - true - Console - false - - - MachineX86 - MultiplyDefinedSymbolOnly - - - - - X64 - - - /bigobj /Zc:inline %(AdditionalOptions) - Disabled - $(SolutionDir)..\..\..;$(SolutionDir)..\..\..\tests\test-hdr;$(SolutionDir)..\..\..\tests;$(BOOST_PATH);%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;_SCL_SECURE=0;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - ProgramDatabase - Cdecl - 4520 - - - unit-prerequisites_d.lib;%(AdditionalDependencies) - $(TargetPath) - $(BOOST_PATH)/stage64/lib;$(BOOST_PATH)/bin;$(OutDir);%(AdditionalLibraryDirectories) - true - Console - false - - - MachineX64 - MultiplyDefinedSymbolOnly - - - - - /bigobj /Zc:inline %(AdditionalOptions) - Full - AnySuitable - true - Speed - false - $(SolutionDir)..\..\..;$(SolutionDir)..\..\..\tests\test-hdr;$(SolutionDir)..\..\..\tests;$(BOOST_PATH);%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;_WIN32_WINNT=0x0500;_SCL_SECURE=0;%(PreprocessorDefinitions) - true - MultiThreadedDLL - StreamingSIMDExtensions2 - - - Level3 - ProgramDatabase - Cdecl - false - 4520 - - - unit-prerequisites.lib;%(AdditionalDependencies) - $(TargetPath) - $(BOOST_PATH)/stage32/lib;$(BOOST_PATH)/stage/lib;$(BOOST_PATH)/bin;$(OutDir);%(AdditionalLibraryDirectories) - true - Console - true - true - false - - - MachineX86 - true - MultiplyDefinedSymbolOnly - - - - - X64 - - - /bigobj /Zc:inline %(AdditionalOptions) - Full - AnySuitable - true - Speed - false - $(SolutionDir)..\..\..;$(SolutionDir)..\..\..\tests\test-hdr;$(SolutionDir)..\..\..\tests;$(BOOST_PATH);%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;_WIN32_WINNT=0x0501;_SCL_SECURE=0;%(PreprocessorDefinitions) - true - MultiThreadedDLL - - - Level3 - ProgramDatabase - Cdecl - false - 4520 - - - unit-prerequisites.lib;%(AdditionalDependencies) - $(TargetPath) - $(BOOST_PATH)/stage64/lib;$(BOOST_PATH)/bin;$(OutDir);%(AdditionalLibraryDirectories) - true - Console - true - true - UseLinkTimeCodeGeneration - false - - - MachineX64 - true - MultiplyDefinedSymbolOnly - - - - - /bigobj /Zc:inline %(AdditionalOptions) - Disabled - $(SolutionDir)..\..\..;$(SolutionDir)..\..\..\tests\test-hdr;$(SolutionDir)..\..\..\tests;$(BOOST_PATH);%(AdditionalIncludeDirectories) - CDS_USE_VLD;WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;_SCL_SECURE=0;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - EditAndContinue - Cdecl - 4520 - - - unit-prerequisites_d.lib;%(AdditionalDependencies) - $(TargetPath) - $(BOOST_PATH)/stage32/lib;$(BOOST_PATH)/stage/lib;$(BOOST_PATH)/bin;$(OutDir);%(AdditionalLibraryDirectories) - true - Console - false - - - MachineX86 - MultiplyDefinedSymbolOnly - - - - - X64 - - - /bigobj /Zc:inline %(AdditionalOptions) - Disabled - $(SolutionDir)..\..\..;$(SolutionDir)..\..\..\tests\test-hdr;$(SolutionDir)..\..\..\tests;$(BOOST_PATH);%(AdditionalIncludeDirectories) - CDS_USE_VLD;WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;_SCL_SECURE=0;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - ProgramDatabase - Cdecl - 4520 - - - unit-prerequisites_d.lib;%(AdditionalDependencies) - $(TargetPath) - $(BOOST_PATH)/stage64/lib;$(BOOST_PATH)/bin;$(OutDir);%(AdditionalLibraryDirectories) - true - Console - false - - - MachineX64 - MultiplyDefinedSymbolOnly - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/projects/android/jni/Android.mk b/projects/android/jni/Android.mk deleted file mode 100644 index 4505c042..00000000 --- a/projects/android/jni/Android.mk +++ /dev/null @@ -1,185 +0,0 @@ - - CDS_LIBRARY_VERSION := 2.2.0 - LOCAL_PATH := $(call my-dir) - CDS_ROOT_DIR = $(LOCAL_PATH)/../../.. - - BOOST_LIBS := -lboost_thread -lboost_system - BOOST_LIB_PATH := $(BOOST_ROOT)/stage32-android/lib - - CDS_TESTHDR_INCLUDE := $(LOCAL_PATH)/../../.. \ - $(LOCAL_PATH)/../../../tests \ - $(LOCAL_PATH)/../../../tests/test-hdr \ - $(BOOST_ROOT) -# libcds - include $(CLEAR_VARS) - - LOCAL_MODULE := cds - LOCAL_MODULE_FILENAME = libcds-$(CDS_LIBRARY_VERSION) - include $(CDS_ROOT_DIR)/projects/source.libcds.mk - LOCAL_SRC_FILES := $(CDS_SOURCES:%.cpp=$(CDS_ROOT_DIR)/%.cpp) - LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../.. $(BOOST_ROOT) - LOCAL_CPP_FEATURES := exceptions - - include $(BUILD_SHARED_LIBRARY) - -#test-hdr-map - include $(CLEAR_VARS) - - LOCAL_MODULE := test-hdr-map - include $(CDS_ROOT_DIR)/projects/source.test-common.mk - include $(CDS_ROOT_DIR)/projects/source.test-hdr.mk - include $(CDS_ROOT_DIR)/projects/source.test-hdr.offsetof.mk - LOCAL_SRC_FILES := $(CDS_TESTCOMMON_SOURCES:%.cpp=$(CDS_ROOT_DIR)/%.cpp) - LOCAL_SRC_FILES += $(CDS_TESTHDR_MAP:%.cpp=$(CDS_ROOT_DIR)/%.cpp) - LOCAL_SRC_FILES += $(CDS_TESTHDR_OFFSETOF_MAP:%.cpp=$(CDS_ROOT_DIR)/%.cpp) - LOCAL_C_INCLUDES := $(CDS_TESTHDR_INCLUDE) - LOCAL_SHARED_LIBRARIES := cds - LOCAL_CPP_FEATURES := exceptions - LOCAL_CPPFLAGS := -Wno-invalid-offsetof -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS - LOCAL_LDLIBS := $(BOOST_LIBS) - LOCAL_LDFLAGS := -L$(BOOST_LIB_PATH) - include $(BUILD_EXECUTABLE) - -#test-hdr-deque - include $(CLEAR_VARS) - - LOCAL_MODULE := test-hdr-deque - include $(CDS_ROOT_DIR)/projects/source.test-common.mk - include $(CDS_ROOT_DIR)/projects/source.test-hdr.mk - include $(CDS_ROOT_DIR)/projects/source.test-hdr.offsetof.mk - LOCAL_SRC_FILES := $(CDS_TESTCOMMON_SOURCES:%.cpp=$(CDS_ROOT_DIR)/%.cpp) - LOCAL_SRC_FILES += $(CDS_TESTHDR_DEQUE:%.cpp=$(CDS_ROOT_DIR)/%.cpp) - LOCAL_SRC_FILES += $(CDS_TESTHDR_OFFSETOF_DEQUE:%.cpp=$(CDS_ROOT_DIR)/%.cpp) - LOCAL_C_INCLUDES := $(CDS_TESTHDR_INCLUDE) - LOCAL_SHARED_LIBRARIES := cds - LOCAL_CPP_FEATURES := exceptions - LOCAL_CPPFLAGS := -Wno-invalid-offsetof -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS - LOCAL_LDLIBS := $(BOOST_LIBS) - LOCAL_LDFLAGS := -L$(BOOST_LIB_PATH) - include $(BUILD_EXECUTABLE) - -#test-hdr-ordlist - include $(CLEAR_VARS) - - LOCAL_MODULE := test-hdr-ordlist - include $(CDS_ROOT_DIR)/projects/source.test-common.mk - include $(CDS_ROOT_DIR)/projects/source.test-hdr.mk - include $(CDS_ROOT_DIR)/projects/source.test-hdr.offsetof.mk - LOCAL_SRC_FILES := $(CDS_TESTCOMMON_SOURCES:%.cpp=$(CDS_ROOT_DIR)/%.cpp) - LOCAL_SRC_FILES += $(CDS_TESTHDR_ORDLIST:%.cpp=$(CDS_ROOT_DIR)/%.cpp) - LOCAL_SRC_FILES += $(CDS_TESTHDR_OFFSETOF_ORDLIST:%.cpp=$(CDS_ROOT_DIR)/%.cpp) - LOCAL_C_INCLUDES := $(CDS_TESTHDR_INCLUDE) - LOCAL_SHARED_LIBRARIES := cds - LOCAL_CPP_FEATURES := exceptions - LOCAL_CPPFLAGS := -Wno-invalid-offsetof -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS - LOCAL_LDLIBS := $(BOOST_LIBS) - LOCAL_LDFLAGS := -L$(BOOST_LIB_PATH) - include $(BUILD_EXECUTABLE) - -#test-hdr-pqueue - include $(CLEAR_VARS) - - LOCAL_MODULE := test-hdr-pqueue - include $(CDS_ROOT_DIR)/projects/source.test-common.mk - include $(CDS_ROOT_DIR)/projects/source.test-hdr.mk - include $(CDS_ROOT_DIR)/projects/source.test-hdr.offsetof.mk - LOCAL_SRC_FILES := $(CDS_TESTCOMMON_SOURCES:%.cpp=$(CDS_ROOT_DIR)/%.cpp) - LOCAL_SRC_FILES += $(CDS_TESTHDR_PQUEUE:%.cpp=$(CDS_ROOT_DIR)/%.cpp) -# LOCAL_SRC_FILES += $(CDS_TESTHDR_OFFSETOF_PQUEUE:%.cpp=$(CDS_ROOT_DIR)/%.cpp) - LOCAL_C_INCLUDES := $(CDS_TESTHDR_INCLUDE) - LOCAL_SHARED_LIBRARIES := cds - LOCAL_CPP_FEATURES := exceptions - LOCAL_CPPFLAGS := -Wno-invalid-offsetof -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS - LOCAL_LDLIBS := $(BOOST_LIBS) - LOCAL_LDFLAGS := -L$(BOOST_LIB_PATH) - include $(BUILD_EXECUTABLE) - -#test-hdr-queue - include $(CLEAR_VARS) - - LOCAL_MODULE := test-hdr-queue - include $(CDS_ROOT_DIR)/projects/source.test-common.mk - include $(CDS_ROOT_DIR)/projects/source.test-hdr.mk - include $(CDS_ROOT_DIR)/projects/source.test-hdr.offsetof.mk - LOCAL_SRC_FILES := $(CDS_TESTCOMMON_SOURCES:%.cpp=$(CDS_ROOT_DIR)/%.cpp) - LOCAL_SRC_FILES += $(CDS_TESTHDR_QUEUE:%.cpp=$(CDS_ROOT_DIR)/%.cpp) - LOCAL_SRC_FILES += $(CDS_TESTHDR_OFFSETOF_QUEUE:%.cpp=$(CDS_ROOT_DIR)/%.cpp) - LOCAL_C_INCLUDES := $(CDS_TESTHDR_INCLUDE) - LOCAL_SHARED_LIBRARIES := cds - LOCAL_CPP_FEATURES := exceptions - LOCAL_CPPFLAGS := -Wno-invalid-offsetof -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS - LOCAL_LDLIBS := $(BOOST_LIBS) - LOCAL_LDFLAGS := -L$(BOOST_LIB_PATH) - include $(BUILD_EXECUTABLE) - -#test-hdr-set - include $(CLEAR_VARS) - - LOCAL_MODULE := test-hdr-set - include $(CDS_ROOT_DIR)/projects/source.test-common.mk - include $(CDS_ROOT_DIR)/projects/source.test-hdr.mk - include $(CDS_ROOT_DIR)/projects/source.test-hdr.offsetof.mk - LOCAL_SRC_FILES := $(CDS_TESTCOMMON_SOURCES:%.cpp=$(CDS_ROOT_DIR)/%.cpp) - LOCAL_SRC_FILES += $(CDS_TESTHDR_SET:%.cpp=$(CDS_ROOT_DIR)/%.cpp) - LOCAL_SRC_FILES += $(CDS_TESTHDR_OFFSETOF_SET:%.cpp=$(CDS_ROOT_DIR)/%.cpp) - LOCAL_C_INCLUDES := $(CDS_TESTHDR_INCLUDE) - LOCAL_SHARED_LIBRARIES := cds - LOCAL_CPP_FEATURES := exceptions - LOCAL_CPPFLAGS := -Wno-invalid-offsetof -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS - LOCAL_LDLIBS := $(BOOST_LIBS) - LOCAL_LDFLAGS := -L$(BOOST_LIB_PATH) - include $(BUILD_EXECUTABLE) - -#test-hdr-stack - include $(CLEAR_VARS) - - LOCAL_MODULE := test-hdr-stack - include $(CDS_ROOT_DIR)/projects/source.test-common.mk - include $(CDS_ROOT_DIR)/projects/source.test-hdr.mk - include $(CDS_ROOT_DIR)/projects/source.test-hdr.offsetof.mk - LOCAL_SRC_FILES := $(CDS_TESTCOMMON_SOURCES:%.cpp=$(CDS_ROOT_DIR)/%.cpp) - LOCAL_SRC_FILES += $(CDS_TESTHDR_STACK:%.cpp=$(CDS_ROOT_DIR)/%.cpp) - LOCAL_SRC_FILES += $(CDS_TESTHDR_OFFSETOF_STACK:%.cpp=$(CDS_ROOT_DIR)/%.cpp) - LOCAL_C_INCLUDES := $(CDS_TESTHDR_INCLUDE) - LOCAL_SHARED_LIBRARIES := cds - LOCAL_CPP_FEATURES := exceptions - LOCAL_CPPFLAGS := -Wno-invalid-offsetof -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS - LOCAL_LDLIBS := $(BOOST_LIBS) - LOCAL_LDFLAGS := -L$(BOOST_LIB_PATH) - include $(BUILD_EXECUTABLE) - -#test-hdr-tree - include $(CLEAR_VARS) - - LOCAL_MODULE := test-hdr-tree - include $(CDS_ROOT_DIR)/projects/source.test-common.mk - include $(CDS_ROOT_DIR)/projects/source.test-hdr.mk - include $(CDS_ROOT_DIR)/projects/source.test-hdr.offsetof.mk - LOCAL_SRC_FILES := $(CDS_TESTCOMMON_SOURCES:%.cpp=$(CDS_ROOT_DIR)/%.cpp) - LOCAL_SRC_FILES += $(CDS_TESTHDR_TREE:%.cpp=$(CDS_ROOT_DIR)/%.cpp) - LOCAL_SRC_FILES += $(CDS_TESTHDR_OFFSETOF_TREE:%.cpp=$(CDS_ROOT_DIR)/%.cpp) - LOCAL_C_INCLUDES := $(CDS_TESTHDR_INCLUDE) - LOCAL_SHARED_LIBRARIES := cds - LOCAL_CPP_FEATURES := exceptions - LOCAL_CPPFLAGS := -Wno-invalid-offsetof -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS - LOCAL_LDLIBS := $(BOOST_LIBS) - LOCAL_LDFLAGS := -L$(BOOST_LIB_PATH) - include $(BUILD_EXECUTABLE) - -#test-hdr-misc - include $(CLEAR_VARS) - - LOCAL_MODULE := test-hdr-misc - include $(CDS_ROOT_DIR)/projects/source.test-common.mk - include $(CDS_ROOT_DIR)/projects/source.test-hdr.mk - include $(CDS_ROOT_DIR)/projects/source.test-hdr.offsetof.mk - LOCAL_SRC_FILES := $(CDS_TESTCOMMON_SOURCES:%.cpp=$(CDS_ROOT_DIR)/%.cpp) - LOCAL_SRC_FILES += $(CDS_TESTHDR_MISC:%.cpp=$(CDS_ROOT_DIR)/%.cpp) -# LOCAL_SRC_FILES += $(CDS_TESTHDR_OFFSETOF_MISC:%.cpp=$(CDS_ROOT_DIR)/%.cpp) - LOCAL_C_INCLUDES := $(CDS_TESTHDR_INCLUDE) - LOCAL_SHARED_LIBRARIES := cds - LOCAL_CPP_FEATURES := exceptions - LOCAL_CPPFLAGS := -Wno-invalid-offsetof -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS - LOCAL_LDLIBS := $(BOOST_LIBS) - LOCAL_LDFLAGS := -L$(BOOST_LIB_PATH) - include $(BUILD_EXECUTABLE) diff --git a/projects/android/jni/Application.mk b/projects/android/jni/Application.mk deleted file mode 100644 index ad5a1e21..00000000 --- a/projects/android/jni/Application.mk +++ /dev/null @@ -1,10 +0,0 @@ - -APP_MODULES := cds test-hdr-map test-hdr-deque test-hdr-ordlist test_hdr_pqueue -APP_MODULES += test-hdr-queue test-hdr-set test-hdr-stack test-hdr-tree test-hdr-misc -APP_ABI := armeabi-v7a -APP_OPTIM := debug -APP_STL := gnustl_shared -APP_CPPFLAGS := -std=c++0x -frtti -pedantic -Wall -Wno-unused-local-typedefs -#APP_LDFLAGS := -APP_GNUSTL_FORCE_CPP_FEATURES := exceptions -NDK_TOOLCHAIN_VERSION := 4.8 diff --git a/projects/android/jni/build.sh b/projects/android/jni/build.sh deleted file mode 100644 index dfb8f67b..00000000 --- a/projects/android/jni/build.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -BOOST_ROOT=~/works/libs/boost_1_53_0 $NDK/ndk-build -j 1 2>&1 |tee arm-build.log diff --git a/projects/source.test-hdr.mk b/projects/source.test-hdr.mk index 7ae0cf05..3bfc132e 100644 --- a/projects/source.test-hdr.mk +++ b/projects/source.test-hdr.mk @@ -238,14 +238,6 @@ CDS_TESTHDR_SET := \ tests/test-hdr/set/hdr_striped_hashset_slist.cpp \ tests/test-hdr/set/hdr_striped_hashset_vector.cpp -CDS_TESTHDR_STACK := \ - tests/test-hdr/stack/hdr_intrusive_fcstack.cpp \ - tests/test-hdr/stack/hdr_treiber_stack_hp.cpp \ - tests/test-hdr/stack/hdr_treiber_stack_dhp.cpp \ - tests/test-hdr/stack/hdr_elimination_stack_hp.cpp \ - tests/test-hdr/stack/hdr_elimination_stack_dhp.cpp \ - tests/test-hdr/stack/hdr_fcstack.cpp - CDS_TESTHDR_TREE := \ tests/test-hdr/tree/hdr_tree_reg.cpp \ tests/test-hdr/tree/hdr_intrusive_ellen_bintree_hp.cpp \ @@ -296,7 +288,6 @@ CDS_TESTHDR_MISC := \ CDS_TESTHDR_SOURCES := \ $(CDS_TESTHDR_QUEUE) \ $(CDS_TESTHDR_PQUEUE) \ - $(CDS_TESTHDR_STACK) \ $(CDS_TESTHDR_MAP) \ $(CDS_TESTHDR_DEQUE) \ $(CDS_TESTHDR_LIST) \ diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 00000000..4ba62c57 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,9 @@ + +find_package(GTest REQUIRED) + +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${GTEST_INCLUDE_DIRS} +) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/unit) diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt new file mode 100644 index 00000000..3f733605 --- /dev/null +++ b/test/unit/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/stack) diff --git a/test/unit/stack/CMakeLists.txt b/test/unit/stack/CMakeLists.txt new file mode 100644 index 00000000..0d02cf94 --- /dev/null +++ b/test/unit/stack/CMakeLists.txt @@ -0,0 +1,26 @@ +set(PACKAGE_NAME unit-stack) + +set(CDSGTEST_STACK_SOURCES + fcstack.cpp + intrusive_fcstack.cpp + intrusive_treiber_stack_dhp.cpp + intrusive_treiber_stack_hp.cpp + main.cpp + treiber_stack_dhp.cpp + treiber_stack_hp.cpp +) + +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} +) + +add_executable(${PACKAGE_NAME} ${CDSGTEST_STACK_SOURCES}) +target_link_libraries(${PACKAGE_NAME} + ${CDS_SHARED_LIBRARY} + ${GTEST_LIBRARY} + ${Boost_THREAD_LIBRARY} + ${Boost_SYSTEM_LIBRARY} + ${CMAKE_THREAD_LIBS_INIT} +) + +add_test(NAME ${PACKAGE_NAME} COMMAND ${PACKAGE_NAME} WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) \ No newline at end of file diff --git a/test/unit/stack/intrusive_fcstack.cpp b/test/unit/stack/intrusive_fcstack.cpp new file mode 100644 index 00000000..d4cce2b2 --- /dev/null +++ b/test/unit/stack/intrusive_fcstack.cpp @@ -0,0 +1,332 @@ +/* + This file is a part of libcds - Concurrent Data Structures library + + (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 + + Source code repo: http://github.com/khizmax/libcds/ + Download: http://sourceforge.net/projects/libcds/files/ + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include +#include + +#include + +namespace { + class IntrusiveFCStack : public ::testing::Test + { + protected: + template + struct base_hook_item : public Hook + { + int nVal; + int nDisposeCount; + + base_hook_item() + : nDisposeCount( 0 ) + {} + }; + + template + struct member_hook_item + { + int nVal; + int nDisposeCount; + Hook hMember; + + member_hook_item() + : nDisposeCount( 0 ) + {} + }; + + struct mock_disposer + { + template + void operator ()( T * p ) + { + ++p->nDisposeCount; + } + }; + + template + void test() + { + typedef typename Stack::value_type value_type; + Stack stack; + + ASSERT_TRUE( stack.empty() ); + + value_type v1, v2, v3; + v1.nVal = 1; + v2.nVal = 2; + v3.nVal = 3; + ASSERT_TRUE( stack.push( v1 ) ); + ASSERT_TRUE( !stack.empty() ); + ASSERT_TRUE( stack.push( v2 ) ); + ASSERT_TRUE( !stack.empty() ); + ASSERT_TRUE( stack.push( v3 ) ); + ASSERT_TRUE( !stack.empty() ); + + value_type * pv; + pv = stack.pop(); + ASSERT_TRUE( pv != nullptr ); + ASSERT_EQ( pv->nVal, 3 ); + ASSERT_TRUE( !stack.empty() ); + pv = stack.pop(); + ASSERT_TRUE( pv != nullptr ); + ASSERT_EQ( pv->nVal, 2 ); + ASSERT_TRUE( !stack.empty() ); + pv = stack.pop(); + ASSERT_TRUE( pv != nullptr ); + ASSERT_EQ( pv->nVal, 1 ); + ASSERT_TRUE( stack.empty() ); + pv = stack.pop(); + ASSERT_TRUE( pv == nullptr ); + ASSERT_TRUE( stack.empty() ); + + if ( !std::is_same::value ) { + int v1disp = v1.nDisposeCount; + int v2disp = v2.nDisposeCount; + int v3disp = v3.nDisposeCount; + + ASSERT_TRUE( stack.push( v1 )); + ASSERT_TRUE( stack.push( v2 )); + ASSERT_TRUE( stack.push( v3 )); + + stack.clear(); + ASSERT_TRUE( stack.empty() ); + + EXPECT_EQ( v1.nDisposeCount, v1disp); + EXPECT_EQ( v2.nDisposeCount, v2disp); + EXPECT_EQ( v3.nDisposeCount, v3disp); + + ASSERT_TRUE( stack.push( v1 ) ); + ASSERT_TRUE( stack.push( v2 ) ); + ASSERT_TRUE( stack.push( v3 ) ); + ASSERT_TRUE( !stack.empty() ); + + stack.clear( true ); + ASSERT_TRUE( stack.empty() ); + + EXPECT_EQ( v1.nDisposeCount, v1disp + 1 ); + EXPECT_EQ( v2.nDisposeCount, v2disp + 1 ); + EXPECT_EQ( v3.nDisposeCount, v3disp + 1 ); + } + } + }; + + TEST_F( IntrusiveFCStack, slist ) + { + typedef base_hook_item< boost::intrusive::slist_base_hook<> > value_type; + typedef cds::intrusive::FCStack< value_type, boost::intrusive::slist< value_type > > stack_type; + test(); + } + + TEST_F( IntrusiveFCStack, slist_disposer ) + { + typedef base_hook_item< boost::intrusive::slist_base_hook<> > value_type; + struct stack_traits : public cds::intrusive::fcstack::traits + { + typedef mock_disposer disposer; + }; + typedef cds::intrusive::FCStack< value_type, boost::intrusive::slist< value_type >, stack_traits > stack_type; + test(); + } + + TEST_F( IntrusiveFCStack, slist_mutex ) + { + typedef base_hook_item< boost::intrusive::slist_base_hook<> > value_type; + struct stack_traits : public cds::intrusive::fcstack::traits + { + typedef std::mutex lock_type; + }; + typedef cds::intrusive::FCStack< value_type, boost::intrusive::slist< value_type >, stack_traits > stack_type; + test(); + } + + TEST_F( IntrusiveFCStack, slist_elimination ) + { + typedef base_hook_item< boost::intrusive::slist_base_hook<> > value_type; + struct stack_traits : public + cds::intrusive::fcstack::make_traits < + cds::opt::enable_elimination < true > + > ::type + {}; + typedef cds::intrusive::FCStack< value_type, boost::intrusive::slist< value_type >, stack_traits > stack_type; + test(); + } + + TEST_F( IntrusiveFCStack, slist_elimination_disposer ) + { + typedef base_hook_item< boost::intrusive::slist_base_hook<> > value_type; + struct stack_traits : public + cds::intrusive::fcstack::make_traits < + cds::opt::enable_elimination < true >, + cds::intrusive::opt::disposer< mock_disposer > + > ::type + {}; + typedef cds::intrusive::FCStack< value_type, boost::intrusive::slist< value_type >, stack_traits > stack_type; + test(); + } + + TEST_F( IntrusiveFCStack, slist_elimination_stat ) + { + typedef base_hook_item< boost::intrusive::slist_base_hook<> > value_type; + typedef cds::intrusive::FCStack< value_type, boost::intrusive::slist< value_type >, + cds::intrusive::fcstack::make_traits< + cds::opt::enable_elimination< true > + , cds::opt::stat< cds::intrusive::fcstack::stat<> > + >::type + > stack_type; + test(); + } + + TEST_F( IntrusiveFCStack, slist_member ) + { + typedef member_hook_item< boost::intrusive::slist_member_hook<> > value_type; + typedef boost::intrusive::member_hook, &value_type::hMember> member_option; + + typedef cds::intrusive::FCStack< value_type, boost::intrusive::slist< value_type, member_option > > stack_type; + test(); + } + + TEST_F( IntrusiveFCStack, slist_member_disposer ) + { + typedef member_hook_item< boost::intrusive::slist_member_hook<> > value_type; + typedef boost::intrusive::member_hook, &value_type::hMember> member_option; + struct stack_traits : public cds::intrusive::fcstack::traits + { + typedef mock_disposer disposer; + }; + + typedef cds::intrusive::FCStack< value_type, boost::intrusive::slist< value_type, member_option >, stack_traits > stack_type; + test(); + } + + TEST_F( IntrusiveFCStack, slist_member_elimination ) + { + typedef member_hook_item< boost::intrusive::slist_member_hook<> > value_type; + typedef boost::intrusive::member_hook, &value_type::hMember> member_option; + + typedef cds::intrusive::FCStack< value_type, boost::intrusive::slist< value_type, member_option >, + cds::intrusive::fcstack::make_traits< + cds::opt::enable_elimination< true > + >::type + > stack_type; + test(); + } + + TEST_F( IntrusiveFCStack, slist_member_elimination_stat ) + { + typedef member_hook_item< boost::intrusive::slist_member_hook<> > value_type; + typedef boost::intrusive::member_hook, &value_type::hMember> member_option; + + typedef cds::intrusive::FCStack< value_type, boost::intrusive::slist< value_type, member_option >, + cds::intrusive::fcstack::make_traits< + cds::opt::enable_elimination< true > + , cds::opt::stat< cds::intrusive::fcstack::stat<> > + >::type + > stack_type; + test(); + } + + TEST_F( IntrusiveFCStack, list ) + { + typedef base_hook_item< boost::intrusive::list_base_hook<> > value_type; + typedef cds::intrusive::FCStack< value_type, boost::intrusive::list< value_type > > stack_type; + test(); + } + + TEST_F( IntrusiveFCStack, list_mutex ) + { + typedef base_hook_item< boost::intrusive::list_base_hook<> > value_type; + typedef cds::intrusive::FCStack< value_type, boost::intrusive::list< value_type >, + cds::intrusive::fcstack::make_traits< + cds::opt::lock_type< std::mutex > + >::type + > stack_type; + test(); + } + + + TEST_F( IntrusiveFCStack, list_elimination ) + { + typedef base_hook_item< boost::intrusive::list_base_hook<> > value_type; + typedef cds::intrusive::FCStack< value_type, boost::intrusive::list< value_type >, + cds::intrusive::fcstack::make_traits< + cds::opt::enable_elimination< true > + >::type + > stack_type; + test(); + } + + TEST_F( IntrusiveFCStack, list_elimination_stat ) + { + typedef base_hook_item< boost::intrusive::list_base_hook<> > value_type; + typedef cds::intrusive::FCStack< value_type, boost::intrusive::list< value_type >, + cds::intrusive::fcstack::make_traits< + cds::opt::enable_elimination< true > + , cds::opt::stat< cds::intrusive::fcstack::stat<> > + >::type + > stack_type; + test(); + } + + TEST_F( IntrusiveFCStack, list_member ) + { + typedef member_hook_item< boost::intrusive::list_member_hook<> > value_type; + typedef boost::intrusive::member_hook, &value_type::hMember> member_option; + + typedef cds::intrusive::FCStack< value_type, boost::intrusive::list< value_type, member_option > > stack_type; + test(); + } + + TEST_F( IntrusiveFCStack, list_member_elimination ) + { + typedef member_hook_item< boost::intrusive::list_member_hook<> > value_type; + typedef boost::intrusive::member_hook, &value_type::hMember> member_option; + + typedef cds::intrusive::FCStack< value_type, boost::intrusive::list< value_type, member_option >, + cds::intrusive::fcstack::make_traits< + cds::opt::enable_elimination< true > + >::type + > stack_type; + test(); + } + + TEST_F( IntrusiveFCStack, list_member_elimination_stat ) + { + typedef member_hook_item< boost::intrusive::list_member_hook<> > value_type; + typedef boost::intrusive::member_hook, &value_type::hMember> member_option; + + typedef cds::intrusive::FCStack< value_type, boost::intrusive::list< value_type, member_option >, + cds::intrusive::fcstack::make_traits< + cds::opt::enable_elimination< true > + , cds::opt::stat< cds::intrusive::fcstack::stat<> > + >::type + > stack_type; + test(); + } + +} // namespace diff --git a/test/unit/stack/intrusive_treiber_stack_dhp.cpp b/test/unit/stack/intrusive_treiber_stack_dhp.cpp new file mode 100644 index 00000000..c92ecf9d --- /dev/null +++ b/test/unit/stack/intrusive_treiber_stack_dhp.cpp @@ -0,0 +1,288 @@ +/* + This file is a part of libcds - Concurrent Data Structures library + + (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 + + Source code repo: http://github.com/khizmax/libcds/ + Download: http://sourceforge.net/projects/libcds/files/ + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "test_intrusive_treiber_stack.h" + +#include +#include + +namespace { + + namespace ci = cds::intrusive; + + class IntrusiveTreiberStack_DHP : public cds_gtest::IntrusiveTreiberStack + { + typedef cds_gtest::IntrusiveTreiberStack base_class; + protected: + typedef cds::gc::DHP gc_type; + + void SetUp() + { + typedef cds::intrusive::TreiberStack< gc_type, + base_hook_item + , typename ci::treiber_stack::make_traits< + ci::opt::hook< + ci::treiber_stack::base_hook< + ci::opt::gc + > + > + >::type + > stack_type; + + cds::gc::dhp::GarbageCollector::Construct( 16, stack_type::c_nHazardPtrCount ); + cds::threading::Manager::attachThread(); + } + + void TearDown() + { + cds::threading::Manager::detachThread(); + cds::gc::dhp::GarbageCollector::Destruct(); + } + + template + void test() + { + Stack stack; + base_class::test( stack ); + } + + template + void test_dyn( size_t elimination_size ) + { + Stack stack( elimination_size ); + base_class::test( stack ); + } + }; + + TEST_F( IntrusiveTreiberStack_DHP, base ) + { + typedef cds::intrusive::TreiberStack< gc_type, + base_hook_item + , typename ci::treiber_stack::make_traits< + ci::opt::hook< + ci::treiber_stack::base_hook< + ci::opt::gc + > + > + >::type + > stack_type; + + test(); + } + + TEST_F( IntrusiveTreiberStack_DHP, base_disposer ) + { + struct traits: + ci::treiber_stack::make_traits < + ci::opt::hook< + ci::treiber_stack::base_hook< ci::opt::gc> + > + ,ci::opt::disposer< mock_disposer > + >::type + {}; + typedef cds::intrusive::TreiberStack< + gc_type, + base_hook_item, + traits + > stack_type; + + test(); + } + + TEST_F( IntrusiveTreiberStack_DHP, member ) + { + struct traits + : ci::treiber_stack::make_traits < + ci::opt::hook< + ci::treiber_stack::member_hook< + offsetof( member_hook_item, hMember), + ci::opt::gc + > + > + > ::type + {}; + typedef cds::intrusive::TreiberStack< + gc_type, + member_hook_item, + traits + > stack_type; + + test(); + } + + TEST_F( IntrusiveTreiberStack_DHP, member_disposer ) + { + struct traits + : ci::treiber_stack::make_traits < + ci::opt::hook< + ci::treiber_stack::member_hook< + offsetof( member_hook_item, hMember), + ci::opt::gc + > + > + ,ci::opt::disposer< mock_disposer > + >::type + {}; + typedef cds::intrusive::TreiberStack< + gc_type, + member_hook_item, + traits + > stack_type; + + test(); + } + + TEST_F( IntrusiveTreiberStack_DHP, relaxed ) + { + typedef cds::intrusive::TreiberStack< gc_type, + base_hook_item + , typename ci::treiber_stack::make_traits< + ci::opt::memory_model< ci::opt::v::relaxed_ordering > + ,ci::opt::hook< + ci::treiber_stack::base_hook< + ci::opt::gc + > + > + >::type + > stack_type; + + test(); + } + + TEST_F( IntrusiveTreiberStack_DHP, elimination_base ) + { + typedef cds::intrusive::TreiberStack< gc_type, + base_hook_item + , typename ci::treiber_stack::make_traits< + cds::opt::enable_elimination + ,ci::opt::hook< + ci::treiber_stack::base_hook< + ci::opt::gc + > + > + >::type + > stack_type; + + test(); + } + + TEST_F( IntrusiveTreiberStack_DHP, elimination_base_dynamic ) + { + typedef cds::intrusive::TreiberStack< gc_type, + base_hook_item + , typename ci::treiber_stack::make_traits< + cds::opt::enable_elimination + ,ci::opt::hook< + ci::treiber_stack::base_hook< + ci::opt::gc + > + > + ,ci::opt::buffer< ci::opt::v::dynamic_buffer > + >::type + > stack_type; + + test_dyn( 2 ); + } + + TEST_F( IntrusiveTreiberStack_DHP, elimination_base_disposer ) + { + typedef cds::intrusive::TreiberStack< gc_type, + base_hook_item + , typename ci::treiber_stack::make_traits< + cds::opt::enable_elimination + ,ci::opt::hook< + ci::treiber_stack::base_hook< ci::opt::gc > + > + ,ci::opt::disposer< mock_disposer > + >::type + > stack_type; + + test(); + } + + TEST_F( IntrusiveTreiberStack_DHP, elimination_member ) + { + typedef cds::intrusive::TreiberStack< gc_type, + member_hook_item + , typename ci::treiber_stack::make_traits< + cds::opt::enable_elimination + ,ci::opt::hook< + ci::treiber_stack::member_hook< + offsetof( member_hook_item, hMember), + ci::opt::gc + > + > + >::type + > stack_type; + + test(); + } + + TEST_F( IntrusiveTreiberStack_DHP, elimination_member_dynamic ) + { + typedef cds::intrusive::TreiberStack< gc_type, + member_hook_item + , typename ci::treiber_stack::make_traits< + cds::opt::enable_elimination + ,ci::opt::hook< + ci::treiber_stack::member_hook< + offsetof( member_hook_item, hMember), + ci::opt::gc + > + > + ,ci::opt::buffer< ci::opt::v::dynamic_buffer > + >::type + > stack_type; + + test_dyn( 2 ); + } + + TEST_F( IntrusiveTreiberStack_DHP, elimination_member_disposer ) + { + typedef cds::intrusive::TreiberStack< gc_type, + member_hook_item + , typename ci::treiber_stack::make_traits< + cds::opt::enable_elimination + ,ci::opt::hook< + ci::treiber_stack::member_hook< + offsetof( member_hook_item, hMember), + ci::opt::gc + > + > + ,ci::opt::buffer< ci::opt::v::dynamic_buffer > + , ci::opt::disposer< mock_disposer > + >::type + > stack_type; + + test_dyn( 2 ); + } + +} // namespace + diff --git a/test/unit/stack/intrusive_treiber_stack_hp.cpp b/test/unit/stack/intrusive_treiber_stack_hp.cpp new file mode 100644 index 00000000..a6d5bc6f --- /dev/null +++ b/test/unit/stack/intrusive_treiber_stack_hp.cpp @@ -0,0 +1,295 @@ +/* + This file is a part of libcds - Concurrent Data Structures library + + (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 + + Source code repo: http://github.com/khizmax/libcds/ + Download: http://sourceforge.net/projects/libcds/files/ + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "test_intrusive_treiber_stack.h" + +#include +#include + +namespace { + + namespace ci = cds::intrusive; + typedef cds::gc::HP gc_type; + + class IntrusiveTreiberStack_HP : public cds_gtest::IntrusiveTreiberStack + { + typedef cds_gtest::IntrusiveTreiberStack base_class; + + protected: + void SetUp() + { + typedef cds::intrusive::TreiberStack< gc_type, base_hook_item> stack_type; + + cds::gc::hp::GarbageCollector::Construct( stack_type::c_nHazardPtrCount, 1, 16 ); + cds::threading::Manager::attachThread(); + } + + void TearDown() + { + cds::threading::Manager::detachThread(); + cds::gc::hp::GarbageCollector::Destruct( true ); + } + + template + void test() + { + Stack stack; + base_class::test( stack ); + } + + template + void test_dyn( size_t elimination_size ) + { + Stack stack( elimination_size ); + base_class::test( stack ); + } + }; + + TEST_F( IntrusiveTreiberStack_HP, defaulted ) + { + typedef cds::intrusive::TreiberStack< gc_type, + base_hook_item + > stack_type; + + test(); + } + + TEST_F( IntrusiveTreiberStack_HP, base ) + { + typedef cds::intrusive::TreiberStack< gc_type, + base_hook_item + , typename ci::treiber_stack::make_traits< + ci::opt::hook< + ci::treiber_stack::base_hook< + ci::opt::gc + > + > + >::type + > stack_type; + + test(); + } + + TEST_F( IntrusiveTreiberStack_HP, base_disposer ) + { + struct traits: + ci::treiber_stack::make_traits < + ci::opt::hook< + ci::treiber_stack::base_hook< ci::opt::gc > + > + ,ci::opt::disposer< mock_disposer > + >::type + {}; + typedef cds::intrusive::TreiberStack< + gc_type, + base_hook_item, + traits + > stack_type; + + test(); + } + + TEST_F( IntrusiveTreiberStack_HP, member ) + { + struct traits + : ci::treiber_stack::make_traits < + ci::opt::hook< + ci::treiber_stack::member_hook< + offsetof( member_hook_item, hMember), + ci::opt::gc + > + > + > ::type + {}; + typedef cds::intrusive::TreiberStack< + gc_type, + member_hook_item, + traits + > stack_type; + + test(); + } + + TEST_F( IntrusiveTreiberStack_HP, member_disposer ) + { + struct traits + : ci::treiber_stack::make_traits < + ci::opt::hook< + ci::treiber_stack::member_hook< + offsetof( member_hook_item, hMember), + ci::opt::gc + > + > + ,ci::opt::disposer< mock_disposer > + >::type + {}; + typedef cds::intrusive::TreiberStack< + gc_type, + member_hook_item, + traits + > stack_type; + + test(); + } + + TEST_F( IntrusiveTreiberStack_HP, relaxed ) + { + typedef cds::intrusive::TreiberStack< gc_type, + base_hook_item + , typename ci::treiber_stack::make_traits< + ci::opt::memory_model< ci::opt::v::relaxed_ordering > + >::type + > stack_type; + + test(); + } + + TEST_F( IntrusiveTreiberStack_HP, elimination ) + { + typedef cds::intrusive::TreiberStack< gc_type, + base_hook_item + , typename ci::treiber_stack::make_traits< + cds::opt::enable_elimination + >::type + > stack_type; + + test(); + } + + TEST_F( IntrusiveTreiberStack_HP, elimination_base ) + { + typedef cds::intrusive::TreiberStack< gc_type, + base_hook_item + , typename ci::treiber_stack::make_traits< + cds::opt::enable_elimination + ,ci::opt::hook< + ci::treiber_stack::base_hook< + ci::opt::gc + > + > + >::type + > stack_type; + + test(); + } + + TEST_F( IntrusiveTreiberStack_HP, elimination_base_dynamic ) + { + typedef cds::intrusive::TreiberStack< gc_type, + base_hook_item + , typename ci::treiber_stack::make_traits< + cds::opt::enable_elimination + ,ci::opt::hook< + ci::treiber_stack::base_hook< + ci::opt::gc + > + > + ,ci::opt::buffer< ci::opt::v::dynamic_buffer > + >::type + > stack_type; + + test_dyn( 2 ); + } + + TEST_F( IntrusiveTreiberStack_HP, elimination_base_disposer ) + { + typedef cds::intrusive::TreiberStack< gc_type, + base_hook_item + , typename ci::treiber_stack::make_traits< + cds::opt::enable_elimination + ,ci::opt::hook< + ci::treiber_stack::base_hook< ci::opt::gc > + > + ,ci::opt::disposer< mock_disposer > + >::type + > stack_type; + + test(); + } + + TEST_F( IntrusiveTreiberStack_HP, elimination_member ) + { + typedef cds::intrusive::TreiberStack< gc_type, + member_hook_item + , typename ci::treiber_stack::make_traits< + cds::opt::enable_elimination + ,ci::opt::hook< + ci::treiber_stack::member_hook< + offsetof( member_hook_item, hMember), + ci::opt::gc + > + > + >::type + > stack_type; + + test(); + } + + TEST_F( IntrusiveTreiberStack_HP, elimination_member_dynamic ) + { + typedef cds::intrusive::TreiberStack< gc_type, + member_hook_item + , typename ci::treiber_stack::make_traits< + cds::opt::enable_elimination + ,ci::opt::hook< + ci::treiber_stack::member_hook< + offsetof( member_hook_item, hMember), + ci::opt::gc + > + > + ,ci::opt::buffer< ci::opt::v::dynamic_buffer > + >::type + > stack_type; + + test_dyn( 2 ); + } + + TEST_F( IntrusiveTreiberStack_HP, elimination_member_disposer ) + { + typedef cds::intrusive::TreiberStack< gc_type, + member_hook_item + , typename ci::treiber_stack::make_traits< + cds::opt::enable_elimination + ,ci::opt::hook< + ci::treiber_stack::member_hook< + offsetof( member_hook_item, hMember), + ci::opt::gc + > + > + ,ci::opt::buffer< ci::opt::v::dynamic_buffer > + , ci::opt::disposer< mock_disposer > + >::type + > stack_type; + + test_dyn( 2 ); + } + +} // namespace + diff --git a/test/unit/stack/test_intrusive_treiber_stack.h b/test/unit/stack/test_intrusive_treiber_stack.h new file mode 100644 index 00000000..b6a72afe --- /dev/null +++ b/test/unit/stack/test_intrusive_treiber_stack.h @@ -0,0 +1,134 @@ +/* + This file is a part of libcds - Concurrent Data Structures library + + (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 + + Source code repo: http://github.com/khizmax/libcds/ + Download: http://sourceforge.net/projects/libcds/files/ + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef CDSUNIT_STACK_INTRUSIVE_TREIBER_STACK_H +#define CDSUNIT_STACK_INTRUSIVE_TREIBER_STACK_H + +#include +#include + +namespace cds_gtest { + + class IntrusiveTreiberStack : public ::testing::Test + { + protected: + template + struct base_hook_item : public cds::intrusive::single_link::node< GC > + { + int nVal; + int nDisposeCount; + + base_hook_item() + : nDisposeCount( 0 ) + {} + }; + + template + struct member_hook_item + { + int nVal; + int nDisposeCount; + cds::intrusive::single_link::node< GC > hMember; + + member_hook_item() + : nDisposeCount( 0 ) + {} + }; + + struct mock_disposer + { + template + void operator ()( T * p ) + { + ++p->nDisposeCount; + } + }; + + template + void test( Stack& stack ) + { + typedef typename Stack::value_type value_type; + + ASSERT_TRUE( stack.empty() ); + + value_type v1, v2, v3; + v1.nVal = 1; + v2.nVal = 2; + v3.nVal = 3; + ASSERT_TRUE( stack.push( v1 ) ); + ASSERT_TRUE( !stack.empty() ); + ASSERT_TRUE( stack.push( v2 ) ); + ASSERT_TRUE( !stack.empty() ); + ASSERT_TRUE( stack.push( v3 ) ); + ASSERT_TRUE( !stack.empty() ); + + value_type * pv; + pv = stack.pop(); + ASSERT_NE( pv, nullptr ); + ASSERT_EQ( pv, &v3 ); + ASSERT_EQ( pv->nVal, 3 ); + ASSERT_TRUE( !stack.empty() ); + pv = stack.pop(); + ASSERT_NE( pv, nullptr ); + ASSERT_EQ( pv, &v2 ); + ASSERT_EQ( pv->nVal, 2 ); + ASSERT_TRUE( !stack.empty() ); + pv = stack.pop(); + ASSERT_NE( pv, nullptr ); + ASSERT_EQ( pv, &v1 ); + ASSERT_EQ( pv->nVal, 1 ); + ASSERT_TRUE( stack.empty() ); + pv = stack.pop(); + ASSERT_EQ( pv, nullptr ); + ASSERT_TRUE( stack.empty() ); + + ASSERT_EQ( v1.nDisposeCount, 0 ); + ASSERT_EQ( v2.nDisposeCount, 0 ); + ASSERT_EQ( v3.nDisposeCount, 0 ); + + stack.push( v1 ); + stack.push( v2 ); + stack.push( v3 ); + + stack.clear(); + ASSERT_TRUE( stack.empty() ); + + Stack::gc::scan(); + if ( !std::is_same::value ) { + ASSERT_EQ( v1.nDisposeCount, 1 ); + ASSERT_EQ( v2.nDisposeCount, 1 ); + ASSERT_EQ( v3.nDisposeCount, 1 ); + } + } + }; + +} // namespace cds_gtest + +#endif // CDSUNIT_STACK_INTRUSIVE_TREIBER_STACK_H diff --git a/test/unit/stack/test_treiber_stack.h b/test/unit/stack/test_treiber_stack.h new file mode 100644 index 00000000..d8227347 --- /dev/null +++ b/test/unit/stack/test_treiber_stack.h @@ -0,0 +1,87 @@ +/* + This file is a part of libcds - Concurrent Data Structures library + + (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 + + Source code repo: http://github.com/khizmax/libcds/ + Download: http://sourceforge.net/projects/libcds/files/ + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef CDSUNIT_STACK_TREIBER_STACK_H +#define CDSUNIT_STACK_TREIBER_STACK_H + +#include + +namespace cds_gtest { + + class TreiberStack : public ::testing::Test + { + protected: + template + void test( Stack& stack ) + { + typedef typename Stack::value_type value_type; + value_type v; + + ASSERT_TRUE( stack.empty() ); + + ASSERT_TRUE( stack.push( 1 ) ); + ASSERT_TRUE( !stack.empty() ); + ASSERT_TRUE( stack.push( 2 ) ); + ASSERT_TRUE( !stack.empty() ); + ASSERT_TRUE( stack.push( 3 ) ); + ASSERT_TRUE( !stack.empty() ); + + ASSERT_TRUE( stack.pop( v ) ); + ASSERT_EQ( v, 3 ); + ASSERT_TRUE( !stack.empty() ); + ASSERT_TRUE( stack.pop_with( [&v]( value_type& src ) { v = src; } ) ); + ASSERT_EQ( v, 2 ); + ASSERT_TRUE( !stack.empty() ); + ASSERT_TRUE( stack.pop( v ) ); + ASSERT_EQ( v, 1 ); + ASSERT_TRUE( stack.empty() ); + v = 1000; + ASSERT_TRUE( !stack.pop( v ) ); + ASSERT_EQ( v, 1000 ); + ASSERT_TRUE( stack.empty() ); + + ASSERT_TRUE( stack.push( 10 ) ); + ASSERT_TRUE( stack.push( 20 ) ); + ASSERT_TRUE( stack.push( 30 ) ); + ASSERT_TRUE( !stack.empty() ); + + ASSERT_TRUE( stack.emplace( 100 ) ); + ASSERT_TRUE( stack.pop( v ) ); + ASSERT_EQ( v, 100 ); + + stack.clear(); + ASSERT_TRUE( stack.empty() ); + + Stack::gc::scan(); + } + }; +} // namespace cds_gtest + +#endif // CDSUNIT_STACK_TREIBER_STACK_H diff --git a/test/unit/stack/treiber_stack_dhp.cpp b/test/unit/stack/treiber_stack_dhp.cpp new file mode 100644 index 00000000..3eef2fb7 --- /dev/null +++ b/test/unit/stack/treiber_stack_dhp.cpp @@ -0,0 +1,179 @@ +/* + This file is a part of libcds - Concurrent Data Structures library + + (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 + + Source code repo: http://github.com/khizmax/libcds/ + Download: http://sourceforge.net/projects/libcds/files/ + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "test_treiber_stack.h" + +#include +#include + +namespace { + + namespace cc = cds::container; + typedef cds::gc::DHP gc_type; + + class TreiberStack_DHP : public cds_gtest::TreiberStack + { + typedef cds_gtest::TreiberStack base_class; + + protected: + void SetUp() + { + typedef cc::TreiberStack< gc_type, int > stack_type; + + cds::gc::dhp::GarbageCollector::Construct( 16, stack_type::c_nHazardPtrCount ); + cds::threading::Manager::attachThread(); + } + + void TearDown() + { + cds::threading::Manager::detachThread(); + cds::gc::dhp::GarbageCollector::Destruct(); + } + + template + void test() + { + Stack stack; + base_class::test( stack ); + } + + template + void test_dyn( size_t elimination_size ) + { + Stack stack( elimination_size ); + base_class::test( stack ); + } + }; + + TEST_F( TreiberStack_DHP, defaulted ) + { + typedef cc::TreiberStack< gc_type, int > stack_type; + + test(); + } + + TEST_F( TreiberStack_DHP, backoff ) + { + typedef cc::TreiberStack< gc_type, int + , typename cc::treiber_stack::make_traits< + cds::opt::back_off< cds::backoff::yield> + >::type + > stack_type; + + test(); + } + + TEST_F( TreiberStack_DHP, alloc ) + { + // allocator must be rebinded for real value type + struct foo + { + size_t arr[ 1024 * 1024 ]; + size_t a2[1024 * 1024]; + size_t a3[1024 * 1024]; + size_t a4[1024 * 1024]; + }; + + typedef cc::TreiberStack< gc_type, int + , typename cc::treiber_stack::make_traits< + cds::opt::back_off< cds::backoff::pause> + ,cds::opt::memory_model + ,cds::opt::allocator< std::allocator< foo >> + >::type + > stack_type; + + test(); + } + + TEST_F( TreiberStack_DHP, elimination ) + { + typedef cc::TreiberStack< gc_type, int + , typename cc::treiber_stack::make_traits< + cds::opt::enable_elimination + >::type + > stack_type; + + test(); + } + + TEST_F( TreiberStack_DHP, elimination_backoff ) + { + struct traits : public cc::treiber_stack::traits + { + enum { + enable_elimination = true + }; + typedef cds::backoff::pause back_off; + }; + typedef cc::TreiberStack< gc_type, int, traits > stack_type; + + test(); + } + + TEST_F( TreiberStack_DHP, elimination_dynamic ) + { + typedef cc::TreiberStack< gc_type, int + , typename cc::treiber_stack::make_traits< + cds::opt::enable_elimination + , cds::opt::buffer< cds::opt::v::dynamic_buffer > + >::type + > stack_type; + + test_dyn( 4 ); + } + + TEST_F( TreiberStack_DHP, elimination_stat ) + { + typedef cc::TreiberStack< gc_type, int + , typename cc::treiber_stack::make_traits< + cds::opt::enable_elimination + , cds::opt::stat< cc::treiber_stack::stat<> > + >::type + > stack_type; + + test(); + } + + TEST_F( TreiberStack_DHP, elimination_dynamic_backoff ) + { + struct traits : public cc::treiber_stack::traits + { + enum { + enable_elimination = true + }; + typedef cds::opt::v::dynamic_buffer buffer; + typedef cds::backoff::yield back_off; + }; + typedef cc::TreiberStack< gc_type, int, traits > stack_type; + + test_dyn( 2 ); + } + +} // namespace diff --git a/test/unit/stack/treiber_stack_hp.cpp b/test/unit/stack/treiber_stack_hp.cpp new file mode 100644 index 00000000..ca617ebd --- /dev/null +++ b/test/unit/stack/treiber_stack_hp.cpp @@ -0,0 +1,173 @@ +/* + This file is a part of libcds - Concurrent Data Structures library + + (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 + + Source code repo: http://github.com/khizmax/libcds/ + Download: http://sourceforge.net/projects/libcds/files/ + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "test_treiber_stack.h" + +#include +#include + +namespace { + + namespace cc = cds::container; + typedef cds::gc::HP gc_type; + + class TreiberStack_HP : public cds_gtest::TreiberStack + { + typedef cds_gtest::TreiberStack base_class; + + protected: + void SetUp() + { + typedef cc::TreiberStack< gc_type, int > stack_type; + + cds::gc::hp::GarbageCollector::Construct( stack_type::c_nHazardPtrCount, 1, 16 ); + cds::threading::Manager::attachThread(); + } + + void TearDown() + { + cds::threading::Manager::detachThread(); + cds::gc::hp::GarbageCollector::Destruct( true ); + } + + template + void test() + { + Stack stack; + base_class::test( stack ); + } + + template + void test_dyn( size_t elimination_size ) + { + Stack stack( elimination_size ); + base_class::test( stack ); + } + }; + + TEST_F( TreiberStack_HP, defaulted ) + { + typedef cc::TreiberStack< gc_type, int > stack_type; + + test(); + } + + TEST_F( TreiberStack_HP, backoff ) + { + typedef cc::TreiberStack< gc_type, int + , typename cc::treiber_stack::make_traits< + cds::opt::back_off< cds::backoff::yield> + >::type + > stack_type; + + test(); + } + + TEST_F( TreiberStack_HP, alloc ) + { + // allocator must be rebinded for real value type + struct foo; + + typedef cc::TreiberStack< gc_type, int + , typename cc::treiber_stack::make_traits< + cds::opt::back_off< cds::backoff::pause> + ,cds::opt::memory_model + ,cds::opt::allocator< std::allocator< foo >> + >::type + > stack_type; + + test(); + } + + TEST_F( TreiberStack_HP, elimination ) + { + typedef cc::TreiberStack< gc_type, int + , typename cc::treiber_stack::make_traits< + cds::opt::enable_elimination + >::type + > stack_type; + + test(); + } + + TEST_F( TreiberStack_HP, elimination_backoff ) + { + struct traits : public cc::treiber_stack::traits + { + enum { + enable_elimination = true + }; + typedef cds::backoff::pause back_off; + }; + typedef cc::TreiberStack< gc_type, int, traits > stack_type; + + test(); + } + + TEST_F( TreiberStack_HP, elimination_dynamic ) + { + typedef cc::TreiberStack< gc_type, int + , typename cc::treiber_stack::make_traits< + cds::opt::enable_elimination + , cds::opt::buffer< cds::opt::v::dynamic_buffer > + >::type + > stack_type; + + test_dyn( 4 ); + } + + TEST_F( TreiberStack_HP, elimination_stat ) + { + typedef cc::TreiberStack< gc_type, int + , typename cc::treiber_stack::make_traits< + cds::opt::enable_elimination + , cds::opt::stat< cc::treiber_stack::stat<> > + >::type + > stack_type; + + test(); + } + + TEST_F( TreiberStack_HP, elimination_dynamic_backoff ) + { + struct traits : public cc::treiber_stack::traits + { + enum { + enable_elimination = true + }; + typedef cds::opt::v::dynamic_buffer buffer; + typedef cds::backoff::yield back_off; + }; + typedef cc::TreiberStack< gc_type, int, traits > stack_type; + + test_dyn( 2 ); + } + +} // namespace diff --git a/tests/test-hdr/CMakeLists.txt b/tests/test-hdr/CMakeLists.txt index 7e41be48..40988a05 100644 --- a/tests/test-hdr/CMakeLists.txt +++ b/tests/test-hdr/CMakeLists.txt @@ -240,14 +240,6 @@ set(CDS_TESTHDR_SET set/hdr_striped_hashset_slist.cpp set/hdr_striped_hashset_vector.cpp) -set(CDS_TESTHDR_STACK - stack/hdr_intrusive_fcstack.cpp - stack/hdr_treiber_stack_hp.cpp - stack/hdr_treiber_stack_dhp.cpp - stack/hdr_elimination_stack_hp.cpp - stack/hdr_elimination_stack_dhp.cpp - stack/hdr_fcstack.cpp) - set(CDS_TESTHDR_TREE tree/hdr_tree_reg.cpp tree/hdr_intrusive_ellen_bintree_hp.cpp @@ -404,7 +396,6 @@ endif(CMAKE_COMPILER_IS_GNUCC) set(CDS_TESTHDR_SOURCES ${CDS_TESTHDR_QUEUE} ${CDS_TESTHDR_PQUEUE} - ${CDS_TESTHDR_STACK} ${CDS_TESTHDR_MAP} ${CDS_TESTHDR_DEQUE} ${CDS_TESTHDR_LIST} diff --git a/tests/test-hdr/stack/hdr_elimination_stack_dhp.cpp b/tests/test-hdr/stack/hdr_elimination_stack_dhp.cpp deleted file mode 100644 index 0df497f2..00000000 --- a/tests/test-hdr/stack/hdr_elimination_stack_dhp.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/* - This file is a part of libcds - Concurrent Data Structures library - - (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 - - Source code repo: http://github.com/khizmax/libcds/ - Download: http://sourceforge.net/projects/libcds/files/ - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "hdr_treiber_stack.h" -#include -#include - -namespace stack { -#define TEST(X) void TestStack::X() { test(); } -#define TEST_DYN(X) void TestStack::X() { test_elimination(); } - namespace cs = cds::container; - - namespace defs { namespace { - - typedef cs::TreiberStack< cds::gc::DHP, int - ,typename cs::treiber_stack::make_traits< - cds::opt::enable_elimination - >::type - > Elimination_DHP; - - - typedef cs::TreiberStack< cds::gc::DHP, int - ,typename cs::treiber_stack::make_traits< - cds::opt::enable_elimination - ,cds::opt::buffer< cds::opt::v::dynamic_buffer > - >::type - > Elimination_DHP_dyn; - - typedef cs::TreiberStack< cds::gc::DHP, int - , typename cs::treiber_stack::make_traits< - cds::opt::buffer< cds::opt::v::dynamic_buffer > - ,cds::opt::stat< cs::treiber_stack::stat<> > - ,cds::opt::enable_elimination - >::type - > Elimination_DHP_stat; - - typedef cs::TreiberStack< cds::gc::DHP, int - , typename cs::treiber_stack::make_traits< - cds::opt::memory_model - ,cds::opt::enable_elimination - >::type - > Elimination_DHP_relaxed; - - typedef cs::TreiberStack< cds::gc::DHP, int - , typename cs::treiber_stack::make_traits< - cds::opt::back_off< cds::backoff::yield> - ,cds::opt::enable_elimination - >::type - > Elimination_DHP_yield; - - typedef cs::TreiberStack< cds::gc::DHP, int - , typename cs::treiber_stack::make_traits< - cds::opt::back_off< cds::backoff::yield> - ,cds::opt::memory_model - ,cds::opt::enable_elimination - >::type - > Elimination_DHP_yield_relaxed; - - typedef cs::TreiberStack< cds::gc::DHP, int - , typename cs::treiber_stack::make_traits< - cds::opt::back_off< cds::backoff::pause > - ,cds::opt::allocator< std::allocator< bool * > > - ,cds::opt::enable_elimination - >::type - > Elimination_DHP_pause_alloc; - - typedef cs::TreiberStack< cds::gc::DHP, int - , typename cs::treiber_stack::make_traits< - cds::opt::memory_model - ,cds::opt::back_off< cds::backoff::pause> - ,cds::opt::allocator< std::allocator< bool * > > - ,cds::opt::enable_elimination - >::type - > Elimination_DHP_pause_alloc_relaxed; - }} - - TEST(Elimination_DHP) - TEST_DYN(Elimination_DHP_dyn) - TEST_DYN(Elimination_DHP_stat) - TEST(Elimination_DHP_yield) - TEST(Elimination_DHP_pause_alloc) - - TEST(Elimination_DHP_relaxed) - TEST(Elimination_DHP_yield_relaxed) - TEST(Elimination_DHP_pause_alloc_relaxed) - -} diff --git a/tests/test-hdr/stack/hdr_elimination_stack_hp.cpp b/tests/test-hdr/stack/hdr_elimination_stack_hp.cpp deleted file mode 100644 index 5b03cfd2..00000000 --- a/tests/test-hdr/stack/hdr_elimination_stack_hp.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/* - This file is a part of libcds - Concurrent Data Structures library - - (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 - - Source code repo: http://github.com/khizmax/libcds/ - Download: http://sourceforge.net/projects/libcds/files/ - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "hdr_treiber_stack.h" -#include -#include - -namespace stack { -#define TEST(X) void TestStack::X() { test(); } -#define TEST_DYN(X) void TestStack::X() { test_elimination(); } - - namespace cs = cds::container; - - namespace defs { namespace { - - typedef cs::TreiberStack< cds::gc::HP, int - , typename cs::treiber_stack::make_traits< - cds::opt::enable_elimination - >::type - > Elimination_HP; - - typedef cs::TreiberStack< cds::gc::HP, int - , typename cs::treiber_stack::make_traits< - cds::opt::enable_elimination - , cds::opt::buffer< cds::opt::v::dynamic_buffer > - >::type - > Elimination_HP_dyn; - - typedef cs::TreiberStack< cds::gc::HP, int - , typename cs::treiber_stack::make_traits< - cds::opt::enable_elimination - , cds::opt::buffer< cds::opt::v::dynamic_buffer > - , cds::opt::stat< cs::treiber_stack::stat<> > - >::type - > Elimination_HP_stat; - - typedef cs::TreiberStack< cds::gc::HP, int - , typename cs::treiber_stack::make_traits< - cds::opt::enable_elimination - , cds::opt::memory_model - >::type - > Elimination_HP_relaxed; - - typedef cs::TreiberStack< cds::gc::HP, int - , typename cs::treiber_stack::make_traits< - cds::opt::enable_elimination - ,cds::opt::back_off< cds::backoff::yield> - >::type - > Elimination_HP_yield; - - typedef cs::TreiberStack< cds::gc::HP, int - , typename cs::treiber_stack::make_traits< - cds::opt::back_off< cds::backoff::yield> - ,cds::opt::enable_elimination - , cds::opt::memory_model - >::type - > Elimination_HP_yield_relaxed; - - typedef cs::TreiberStack< cds::gc::HP, int - , typename cs::treiber_stack::make_traits< - cds::opt::back_off< cds::backoff::pause> - ,cds::opt::allocator< std::allocator< bool * > > - ,cds::opt::enable_elimination - >::type - > Elimination_HP_pause_alloc; - - typedef cs::TreiberStack< cds::gc::HP, int - , typename cs::treiber_stack::make_traits< - cds::opt::back_off< cds::backoff::pause> - ,cds::opt::memory_model - ,cds::opt::allocator< std::allocator< bool * > > - ,cds::opt::enable_elimination - >::type - > Elimination_HP_pause_alloc_relaxed; - - }} - - TEST(Elimination_HP) - TEST_DYN(Elimination_HP_dyn) - TEST_DYN(Elimination_HP_stat) - TEST(Elimination_HP_yield) - TEST(Elimination_HP_pause_alloc) - - TEST(Elimination_HP_relaxed) - TEST(Elimination_HP_yield_relaxed) - TEST(Elimination_HP_pause_alloc_relaxed) -} diff --git a/tests/test-hdr/stack/hdr_fcstack.cpp b/tests/test-hdr/stack/hdr_fcstack.cpp deleted file mode 100644 index b85a0d5d..00000000 --- a/tests/test-hdr/stack/hdr_fcstack.cpp +++ /dev/null @@ -1,173 +0,0 @@ -/* - This file is a part of libcds - Concurrent Data Structures library - - (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 - - Source code repo: http://github.com/khizmax/libcds/ - Download: http://sourceforge.net/projects/libcds/files/ - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "cppunit/cppunit_proxy.h" -#include - -#include -#include - -namespace stack { - - class TestFCStack: public CppUnitMini::TestCase - { - template - void test() - { - Stack s; - test_with( s ); - } - - template - void test_with( Stack& stack) - { - typedef typename Stack::value_type value_type; - value_type v; - - CPPUNIT_ASSERT( stack.empty() ); - CPPUNIT_ASSERT( stack.size() == 0 ); - - CPPUNIT_ASSERT( stack.push(1)); - CPPUNIT_ASSERT( !stack.empty() ); - CPPUNIT_ASSERT( stack.size() == 1 ); - CPPUNIT_ASSERT( stack.push(2)); - CPPUNIT_ASSERT( !stack.empty() ); - CPPUNIT_ASSERT( stack.size() == 2 ); - CPPUNIT_ASSERT( stack.push(3)); - CPPUNIT_ASSERT( !stack.empty() ); - CPPUNIT_ASSERT( stack.size() == 3 ); - - CPPUNIT_ASSERT( stack.pop(v) ); - CPPUNIT_ASSERT( v == 3 ); - CPPUNIT_ASSERT( !stack.empty() ); - CPPUNIT_ASSERT( stack.size() == 2 ); - CPPUNIT_ASSERT( stack.pop(v) ); - CPPUNIT_ASSERT( v == 2 ); - CPPUNIT_ASSERT( !stack.empty() ); - CPPUNIT_ASSERT( stack.size() == 1 ); - CPPUNIT_ASSERT( stack.pop(v) ); - CPPUNIT_ASSERT( v == 1 ); - CPPUNIT_ASSERT( stack.empty() ); - CPPUNIT_ASSERT( stack.size() == 0 ); - v = 1000; - CPPUNIT_ASSERT( !stack.pop(v) ); - CPPUNIT_ASSERT( v == 1000 ); - CPPUNIT_ASSERT( stack.empty() ); - CPPUNIT_ASSERT( stack.size() == 0 ); - - CPPUNIT_ASSERT( stack.push(10)); - CPPUNIT_ASSERT( stack.push(20)); - CPPUNIT_ASSERT( stack.push(30)); - CPPUNIT_ASSERT( !stack.empty()); - CPPUNIT_ASSERT( stack.size() == 3 ); - - while ( stack.pop(v) ); - - CPPUNIT_ASSERT( stack.empty() ); - CPPUNIT_ASSERT( stack.size() == 0 ); - } - - void FCStack_default(); - void FCStack_deque(); - void FCStack_deque_elimination(); - void FCStack_vector(); - void FCStack_vector_elimination(); - void FCStack_list(); - void FCStack_list_elimination(); - - CPPUNIT_TEST_SUITE(TestFCStack); - CPPUNIT_TEST( FCStack_default ) - CPPUNIT_TEST( FCStack_deque ) - CPPUNIT_TEST( FCStack_deque_elimination ) - CPPUNIT_TEST( FCStack_vector ) - CPPUNIT_TEST( FCStack_vector_elimination ) - CPPUNIT_TEST( FCStack_list ) - CPPUNIT_TEST( FCStack_list_elimination ) - CPPUNIT_TEST_SUITE_END(); - }; - - void TestFCStack::FCStack_default() - { - typedef cds::container::FCStack< unsigned int > stack_type; - test(); - } - - void TestFCStack::FCStack_deque() - { - typedef cds::container::FCStack< unsigned int, std::stack > > stack_type; - test(); - } - - void TestFCStack::FCStack_deque_elimination() - { - struct stack_traits : public - cds::container::fcstack::make_traits < - cds::opt::enable_elimination < true > - > ::type - {}; - typedef cds::container::FCStack< unsigned int, std::stack >, stack_traits > stack_type; - test(); - } - - void TestFCStack::FCStack_vector() - { - typedef cds::container::FCStack< unsigned int, std::stack > > stack_type; - test(); - } - - void TestFCStack::FCStack_vector_elimination() - { - typedef cds::container::FCStack< unsigned int, std::stack >, - cds::container::fcstack::make_traits< - cds::opt::enable_elimination< true > - >::type - > stack_type; - test(); - } - - void TestFCStack::FCStack_list() - { - typedef cds::container::FCStack< unsigned int, std::stack > > stack_type; - test(); - } - - void TestFCStack::FCStack_list_elimination() - { - typedef cds::container::FCStack< unsigned int, std::stack >, - cds::container::fcstack::make_traits< - cds::opt::enable_elimination< true > - >::type - > stack_type; - test(); - } - - CPPUNIT_TEST_SUITE_REGISTRATION(stack::TestFCStack); -} // namespace stack - diff --git a/tests/test-hdr/stack/hdr_intrusive_elimination_stack_dhp.cpp b/tests/test-hdr/stack/hdr_intrusive_elimination_stack_dhp.cpp deleted file mode 100644 index 427bc6d4..00000000 --- a/tests/test-hdr/stack/hdr_intrusive_elimination_stack_dhp.cpp +++ /dev/null @@ -1,184 +0,0 @@ -/* - This file is a part of libcds - Concurrent Data Structures library - - (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 - - Source code repo: http://github.com/khizmax/libcds/ - Download: http://sourceforge.net/projects/libcds/files/ - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "hdr_intrusive_treiber_stack.h" -#include -#include - -namespace stack { - -#define TEST(X) void TestIntrusiveStack::X() { test(); } -#define TEST_DYN(X) void TestIntrusiveStack::X() { test_elimination(); } - - namespace defs { - // DHP GC + base hook - typedef cds::intrusive::TreiberStack< cds::gc::DHP, - TestIntrusiveStack::base_hook_item - , typename ci::treiber_stack::make_traits< - cds::opt::enable_elimination - ,ci::opt::hook< - ci::treiber_stack::base_hook< ci::opt::gc > - > - >::type - > Elimination_DHP_base; - - typedef cds::intrusive::TreiberStack< cds::gc::DHP, - TestIntrusiveStack::base_hook_item - , typename ci::treiber_stack::make_traits< - ci::opt::hook< - ci::treiber_stack::base_hook< ci::opt::gc > - > - ,cds::opt::enable_elimination - ,ci::opt::buffer< ci::opt::v::dynamic_buffer > - >::type - > Elimination_DHP_base_dyn; - - typedef cds::intrusive::TreiberStack< cds::gc::DHP, - TestIntrusiveStack::base_hook_item - , typename ci::treiber_stack::make_traits< - ci::opt::hook< - ci::treiber_stack::base_hook< ci::opt::gc > - > - ,cds::opt::enable_elimination - ,ci::opt::memory_model< ci::opt::v::relaxed_ordering > - >::type - > Elimination_DHP_base_relaxed; - - // DHP GC + base hook + disposer - typedef cds::intrusive::TreiberStack< cds::gc::DHP, - TestIntrusiveStack::base_hook_item - , typename ci::treiber_stack::make_traits< - ci::opt::hook< - ci::treiber_stack::base_hook< ci::opt::gc > - > - ,cds::opt::enable_elimination - ,ci::opt::disposer< TestIntrusiveStack::faked_disposer > - >::type - > Elimination_DHP_base_disposer; - - typedef cds::intrusive::TreiberStack< cds::gc::DHP, - TestIntrusiveStack::base_hook_item - , typename ci::treiber_stack::make_traits< - ci::opt::hook< - ci::treiber_stack::base_hook< ci::opt::gc > - > - ,cds::opt::enable_elimination - ,ci::opt::disposer< TestIntrusiveStack::faked_disposer > - ,ci::opt::memory_model< ci::opt::v::relaxed_ordering > - >::type - > Elimination_DHP_base_disposer_relaxed; - - // DHP GC + member hook - typedef cds::intrusive::TreiberStack< cds::gc::DHP, - TestIntrusiveStack::member_hook_item - , typename ci::treiber_stack::make_traits< - ci::opt::hook< - ci::treiber_stack::member_hook< - offsetof(TestIntrusiveStack::member_hook_item, hMember), - ci::opt::gc - > - > - ,cds::opt::enable_elimination - >::type - > Elimination_DHP_member; - - typedef cds::intrusive::TreiberStack< cds::gc::DHP, - TestIntrusiveStack::member_hook_item - , typename ci::treiber_stack::make_traits< - ci::opt::hook< - ci::treiber_stack::member_hook< - offsetof(TestIntrusiveStack::member_hook_item, hMember), - ci::opt::gc - > - > - ,cds::opt::enable_elimination - ,ci::opt::buffer< ci::opt::v::dynamic_buffer > - >::type - > Elimination_DHP_member_dyn; - - typedef cds::intrusive::TreiberStack< cds::gc::DHP, - TestIntrusiveStack::member_hook_item - , typename ci::treiber_stack::make_traits< - ci::opt::hook< - ci::treiber_stack::member_hook< - offsetof(TestIntrusiveStack::member_hook_item, hMember), - ci::opt::gc - > - > - ,cds::opt::enable_elimination - ,ci::opt::memory_model< ci::opt::v::relaxed_ordering > - >::type - > Elimination_DHP_member_relaxed; - - // DHP GC + member hook + disposer - typedef cds::intrusive::TreiberStack< cds::gc::DHP, - TestIntrusiveStack::member_hook_item - , typename ci::treiber_stack::make_traits< - ci::opt::hook< - ci::treiber_stack::member_hook< - offsetof(TestIntrusiveStack::member_hook_item, hMember), - ci::opt::gc - > - > - ,cds::opt::enable_elimination - ,ci::opt::disposer< TestIntrusiveStack::faked_disposer > - >::type - > Elimination_DHP_member_disposer; - - typedef cds::intrusive::TreiberStack< cds::gc::DHP, - TestIntrusiveStack::member_hook_item - , typename ci::treiber_stack::make_traits< - ci::opt::hook< - ci::treiber_stack::member_hook< - offsetof(TestIntrusiveStack::member_hook_item, hMember), - ci::opt::gc - > - > - ,cds::opt::enable_elimination - ,ci::opt::disposer< TestIntrusiveStack::faked_disposer > - ,ci::opt::memory_model< ci::opt::v::relaxed_ordering > - >::type - > Elimination_DHP_member_disposer_relaxed; - } - - TEST(Elimination_DHP_base) - TEST_DYN(Elimination_DHP_base_dyn) - TEST(Elimination_DHP_base_disposer) - TEST(Elimination_DHP_member) - TEST_DYN(Elimination_DHP_member_dyn) - TEST(Elimination_DHP_member_disposer) - - TEST(Elimination_DHP_base_relaxed) - TEST(Elimination_DHP_base_disposer_relaxed) - TEST(Elimination_DHP_member_relaxed) - TEST(Elimination_DHP_member_disposer_relaxed) - -} // namespace stack - diff --git a/tests/test-hdr/stack/hdr_intrusive_elimination_stack_hp.cpp b/tests/test-hdr/stack/hdr_intrusive_elimination_stack_hp.cpp deleted file mode 100644 index fc09ecac..00000000 --- a/tests/test-hdr/stack/hdr_intrusive_elimination_stack_hp.cpp +++ /dev/null @@ -1,206 +0,0 @@ -/* - This file is a part of libcds - Concurrent Data Structures library - - (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 - - Source code repo: http://github.com/khizmax/libcds/ - Download: http://sourceforge.net/projects/libcds/files/ - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "hdr_intrusive_treiber_stack.h" -#include -#include - -namespace stack { - -#define TEST(X) void TestIntrusiveStack::X() { test(); } -#define TEST_DYN(X) void TestIntrusiveStack::X() { test_elimination(); } - - namespace defs { - typedef cds::intrusive::TreiberStack< cds::gc::HP, - TestIntrusiveStack::base_hook_item - , typename ci::treiber_stack::make_traits< - cds::opt::enable_elimination - >::type - > Elimination_HP_default; - - typedef cds::intrusive::TreiberStack< cds::gc::HP, - TestIntrusiveStack::base_hook_item - , typename ci::treiber_stack::make_traits< - cds::opt::enable_elimination - ,ci::opt::memory_model< ci::opt::v::relaxed_ordering > - >::type - > Elimination_HP_default_relaxed; - - // HZP GC + base hook - typedef cds::intrusive::TreiberStack< cds::gc::HP, - TestIntrusiveStack::base_hook_item - , typename ci::treiber_stack::make_traits< - cds::opt::enable_elimination - ,ci::opt::hook< - ci::treiber_stack::base_hook< - ci::opt::gc - > - > - >::type - > Elimination_HP_base; - - typedef cds::intrusive::TreiberStack< cds::gc::HP, - TestIntrusiveStack::base_hook_item - , typename ci::treiber_stack::make_traits< - cds::opt::enable_elimination - ,ci::opt::hook< - ci::treiber_stack::base_hook< - ci::opt::gc - > - > - ,ci::opt::buffer< ci::opt::v::dynamic_buffer > - >::type - > Elimination_HP_base_dyn; - - typedef cds::intrusive::TreiberStack< cds::gc::HP, - TestIntrusiveStack::base_hook_item - , typename ci::treiber_stack::make_traits< - cds::opt::enable_elimination - ,ci::opt::hook< - ci::treiber_stack::base_hook< - ci::opt::gc - > - > - ,ci::opt::memory_model< ci::opt::v::relaxed_ordering > - >::type - > Elimination_HP_base_relaxed; - - // HZP GC + base hook + disposer - typedef cds::intrusive::TreiberStack< cds::gc::HP, - TestIntrusiveStack::base_hook_item - , typename ci::treiber_stack::make_traits< - cds::opt::enable_elimination - ,ci::opt::hook< - ci::treiber_stack::base_hook< ci::opt::gc > - > - ,ci::opt::disposer< TestIntrusiveStack::faked_disposer > - >::type - > Elimination_HP_base_disposer; - - typedef cds::intrusive::TreiberStack< cds::gc::HP, - TestIntrusiveStack::base_hook_item - , typename ci::treiber_stack::make_traits< - cds::opt::enable_elimination - ,ci::opt::hook< - ci::treiber_stack::base_hook< ci::opt::gc > - > - ,ci::opt::disposer< TestIntrusiveStack::faked_disposer > - ,ci::opt::memory_model< ci::opt::v::relaxed_ordering > - >::type - > Elimination_HP_base_disposer_relaxed; - - // HZP GC + member hook - typedef cds::intrusive::TreiberStack< cds::gc::HP, - TestIntrusiveStack::member_hook_item - , typename ci::treiber_stack::make_traits< - cds::opt::enable_elimination - ,ci::opt::hook< - ci::treiber_stack::member_hook< - offsetof(TestIntrusiveStack::member_hook_item, hMember), - ci::opt::gc - > - > - >::type - > Elimination_HP_member; - - typedef cds::intrusive::TreiberStack< cds::gc::HP, - TestIntrusiveStack::member_hook_item - , typename ci::treiber_stack::make_traits< - cds::opt::enable_elimination - ,ci::opt::hook< - ci::treiber_stack::member_hook< - offsetof(TestIntrusiveStack::member_hook_item, hMember), - ci::opt::gc - > - > - ,ci::opt::buffer< ci::opt::v::dynamic_buffer > - >::type - > Elimination_HP_member_dyn; - - typedef cds::intrusive::TreiberStack< cds::gc::HP, - TestIntrusiveStack::member_hook_item - , typename ci::treiber_stack::make_traits< - cds::opt::enable_elimination - ,ci::opt::hook< - ci::treiber_stack::member_hook< - offsetof(TestIntrusiveStack::member_hook_item, hMember), - ci::opt::gc - > - > - ,ci::opt::memory_model< ci::opt::v::relaxed_ordering > - >::type - > Elimination_HP_member_relaxed; - - // HZP GC + member hook + disposer - typedef cds::intrusive::TreiberStack< cds::gc::HP, - TestIntrusiveStack::member_hook_item - , typename ci::treiber_stack::make_traits< - cds::opt::enable_elimination - ,ci::opt::hook< - ci::treiber_stack::member_hook< - offsetof(TestIntrusiveStack::member_hook_item, hMember), - ci::opt::gc - > - > - ,ci::opt::disposer< TestIntrusiveStack::faked_disposer > - >::type - > Elimination_HP_member_disposer; - - typedef cds::intrusive::TreiberStack< cds::gc::HP, - TestIntrusiveStack::member_hook_item - , typename ci::treiber_stack::make_traits< - cds::opt::enable_elimination - ,ci::opt::hook< - ci::treiber_stack::member_hook< - offsetof(TestIntrusiveStack::member_hook_item, hMember), - ci::opt::gc - > - > - ,ci::opt::disposer< TestIntrusiveStack::faked_disposer > - ,ci::opt::memory_model< ci::opt::v::relaxed_ordering > - >::type - > Elimination_HP_member_disposer_relaxed; - } - - TEST(Elimination_HP_default) - TEST(Elimination_HP_base) - TEST_DYN(Elimination_HP_base_dyn) - TEST(Elimination_HP_base_disposer) - TEST(Elimination_HP_member) - TEST_DYN(Elimination_HP_member_dyn) - TEST(Elimination_HP_member_disposer) - - TEST(Elimination_HP_default_relaxed) - TEST(Elimination_HP_base_relaxed) - TEST(Elimination_HP_base_disposer_relaxed) - TEST(Elimination_HP_member_relaxed) - TEST(Elimination_HP_member_disposer_relaxed) - -} // namespace stack diff --git a/tests/test-hdr/stack/hdr_intrusive_fcstack.cpp b/tests/test-hdr/stack/hdr_intrusive_fcstack.cpp deleted file mode 100644 index 985ae3b9..00000000 --- a/tests/test-hdr/stack/hdr_intrusive_fcstack.cpp +++ /dev/null @@ -1,323 +0,0 @@ -/* - This file is a part of libcds - Concurrent Data Structures library - - (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 - - Source code repo: http://github.com/khizmax/libcds/ - Download: http://sourceforge.net/projects/libcds/files/ - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "cppunit/cppunit_proxy.h" -#include - -#include - -namespace stack { - - class TestIntrusiveFCStack: public CppUnitMini::TestCase - { - public: - template - struct base_hook_item: public Hook - { - int nVal; - int nDisposeCount; - - base_hook_item() - : nDisposeCount(0) - {} - }; - - template - struct member_hook_item - { - int nVal; - int nDisposeCount; - Hook hMember; - - member_hook_item() - : nDisposeCount(0) - {} - }; - - struct faked_disposer - { - template - void operator ()( T * p ) - { - ++p->nDisposeCount; - } - }; - - template - void test() - { - Stack stack; - test_with(stack); - } - - template - void test_with( Stack& stack ) - { - typedef typename Stack::value_type value_type; - - CPPUNIT_ASSERT( stack.empty() ); - - value_type v1, v2, v3; - v1.nVal = 1; - v2.nVal = 2; - v3.nVal = 3; - CPPUNIT_ASSERT( stack.push(v1)); - CPPUNIT_ASSERT( !stack.empty() ); - CPPUNIT_ASSERT( stack.push(v2)); - CPPUNIT_ASSERT( !stack.empty() ); - CPPUNIT_ASSERT( stack.push(v3)); - CPPUNIT_ASSERT( !stack.empty() ); - - value_type * pv; - pv = stack.pop(); - CPPUNIT_ASSERT( pv != nullptr ); - CPPUNIT_ASSERT( pv->nVal == 3 ); - CPPUNIT_ASSERT( !stack.empty() ); - pv = stack.pop(); - CPPUNIT_ASSERT( pv != nullptr ); - CPPUNIT_ASSERT( pv->nVal == 2 ); - CPPUNIT_ASSERT( !stack.empty() ); - pv = stack.pop(); - CPPUNIT_ASSERT( pv != nullptr ); - CPPUNIT_ASSERT( pv->nVal == 1 ); - CPPUNIT_ASSERT( stack.empty() ); - pv = stack.pop(); - CPPUNIT_ASSERT( pv == nullptr ); - - CPPUNIT_ASSERT( v1.nDisposeCount == 0 ); - CPPUNIT_ASSERT( v2.nDisposeCount == 0 ); - CPPUNIT_ASSERT( v3.nDisposeCount == 0 ); - - stack.push(v1); - stack.push(v2); - stack.push(v3); - - stack.clear(); - CPPUNIT_ASSERT( stack.empty() ); - - if ( !std::is_same::value ) { - CPPUNIT_ASSERT( v1.nDisposeCount == 1 ); - CPPUNIT_ASSERT( v2.nDisposeCount == 1 ); - CPPUNIT_ASSERT( v3.nDisposeCount == 1 ); - } - } - - void FCStack_slist(); - void FCStack_slist_mutex(); - void FCStack_slist_elimination(); - void FCStack_slist_elimination_stat(); - void FCStack_slist_member(); - void FCStack_slist_member_elimination(); - void FCStack_slist_member_elimination_stat(); - void FCStack_list(); - void FCStack_list_mutex(); - void FCStack_list_elimination(); - void FCStack_list_elimination_stat(); - void FCStack_list_member(); - void FCStack_list_member_elimination(); - void FCStack_list_member_elimination_stat(); - - CPPUNIT_TEST_SUITE(TestIntrusiveFCStack) - CPPUNIT_TEST(FCStack_slist) - CPPUNIT_TEST(FCStack_slist_mutex) - CPPUNIT_TEST(FCStack_slist_elimination) - CPPUNIT_TEST(FCStack_slist_elimination_stat) - CPPUNIT_TEST(FCStack_slist_member) - CPPUNIT_TEST(FCStack_slist_member_elimination) - CPPUNIT_TEST(FCStack_slist_member_elimination_stat) - CPPUNIT_TEST(FCStack_list) - CPPUNIT_TEST(FCStack_list_mutex) - CPPUNIT_TEST(FCStack_list_elimination) - CPPUNIT_TEST(FCStack_list_elimination_stat) - CPPUNIT_TEST(FCStack_list_member) - CPPUNIT_TEST(FCStack_list_member_elimination) - CPPUNIT_TEST(FCStack_list_member_elimination_stat) - CPPUNIT_TEST_SUITE_END() - }; - - void TestIntrusiveFCStack::FCStack_slist() - { - typedef base_hook_item< boost::intrusive::slist_base_hook<> > value_type; - typedef cds::intrusive::FCStack< value_type, boost::intrusive::slist< value_type > > stack_type; - test(); - } - - void TestIntrusiveFCStack::FCStack_slist_mutex() - { - typedef base_hook_item< boost::intrusive::slist_base_hook<> > value_type; - struct stack_traits : public cds::intrusive::fcstack::traits - { - typedef std::mutex lock_type; - }; - typedef cds::intrusive::FCStack< value_type, boost::intrusive::slist< value_type >, stack_traits > stack_type; - test(); - } - - void TestIntrusiveFCStack::FCStack_slist_elimination() - { - typedef base_hook_item< boost::intrusive::slist_base_hook<> > value_type; - struct stack_traits : public - cds::intrusive::fcstack::make_traits < - cds::opt::enable_elimination < true > - > ::type - {}; - typedef cds::intrusive::FCStack< value_type, boost::intrusive::slist< value_type >, stack_traits > stack_type; - test(); - } - - void TestIntrusiveFCStack::FCStack_slist_elimination_stat() - { - typedef base_hook_item< boost::intrusive::slist_base_hook<> > value_type; - typedef cds::intrusive::FCStack< value_type, boost::intrusive::slist< value_type >, - cds::intrusive::fcstack::make_traits< - cds::opt::enable_elimination< true > - ,cds::opt::stat< cds::intrusive::fcstack::stat<> > - >::type - > stack_type; - test(); - } - - void TestIntrusiveFCStack::FCStack_slist_member() - { - typedef member_hook_item< boost::intrusive::slist_member_hook<> > value_type; - typedef boost::intrusive::member_hook, &value_type::hMember> member_option; - - typedef cds::intrusive::FCStack< value_type, boost::intrusive::slist< value_type, member_option > > stack_type; - test(); - } - - void TestIntrusiveFCStack::FCStack_slist_member_elimination() - { - typedef member_hook_item< boost::intrusive::slist_member_hook<> > value_type; - typedef boost::intrusive::member_hook, &value_type::hMember> member_option; - - typedef cds::intrusive::FCStack< value_type, boost::intrusive::slist< value_type, member_option >, - cds::intrusive::fcstack::make_traits< - cds::opt::enable_elimination< true > - >::type - > stack_type; - test(); - } - - void TestIntrusiveFCStack::FCStack_slist_member_elimination_stat() - { - typedef member_hook_item< boost::intrusive::slist_member_hook<> > value_type; - typedef boost::intrusive::member_hook, &value_type::hMember> member_option; - - typedef cds::intrusive::FCStack< value_type, boost::intrusive::slist< value_type, member_option >, - cds::intrusive::fcstack::make_traits< - cds::opt::enable_elimination< true > - ,cds::opt::stat< cds::intrusive::fcstack::stat<> > - >::type - > stack_type; - test(); - } - - void TestIntrusiveFCStack::FCStack_list() - { - typedef base_hook_item< boost::intrusive::list_base_hook<> > value_type; - typedef cds::intrusive::FCStack< value_type, boost::intrusive::list< value_type > > stack_type; - test(); - } - - void TestIntrusiveFCStack::FCStack_list_mutex() - { - typedef base_hook_item< boost::intrusive::list_base_hook<> > value_type; - typedef cds::intrusive::FCStack< value_type, boost::intrusive::list< value_type >, - cds::intrusive::fcstack::make_traits< - cds::opt::lock_type< std::mutex > - >::type - > stack_type; - test(); - } - - - void TestIntrusiveFCStack::FCStack_list_elimination() - { - typedef base_hook_item< boost::intrusive::list_base_hook<> > value_type; - typedef cds::intrusive::FCStack< value_type, boost::intrusive::list< value_type >, - cds::intrusive::fcstack::make_traits< - cds::opt::enable_elimination< true > - >::type - > stack_type; - test(); - } - - void TestIntrusiveFCStack::FCStack_list_elimination_stat() - { - typedef base_hook_item< boost::intrusive::list_base_hook<> > value_type; - typedef cds::intrusive::FCStack< value_type, boost::intrusive::list< value_type >, - cds::intrusive::fcstack::make_traits< - cds::opt::enable_elimination< true > - ,cds::opt::stat< cds::intrusive::fcstack::stat<> > - >::type - > stack_type; - test(); - } - - void TestIntrusiveFCStack::FCStack_list_member() - { - typedef member_hook_item< boost::intrusive::list_member_hook<> > value_type; - typedef boost::intrusive::member_hook, &value_type::hMember> member_option; - - typedef cds::intrusive::FCStack< value_type, boost::intrusive::list< value_type, member_option > > stack_type; - test(); - } - - void TestIntrusiveFCStack::FCStack_list_member_elimination() - { - typedef member_hook_item< boost::intrusive::list_member_hook<> > value_type; - typedef boost::intrusive::member_hook, &value_type::hMember> member_option; - - typedef cds::intrusive::FCStack< value_type, boost::intrusive::list< value_type, member_option >, - cds::intrusive::fcstack::make_traits< - cds::opt::enable_elimination< true > - >::type - > stack_type; - test(); - } - - void TestIntrusiveFCStack::FCStack_list_member_elimination_stat() - { - typedef member_hook_item< boost::intrusive::list_member_hook<> > value_type; - typedef boost::intrusive::member_hook, &value_type::hMember> member_option; - - typedef cds::intrusive::FCStack< value_type, boost::intrusive::list< value_type, member_option >, - cds::intrusive::fcstack::make_traits< - cds::opt::enable_elimination< true > - ,cds::opt::stat< cds::intrusive::fcstack::stat<> > - >::type - > stack_type; - test(); - } - - CPPUNIT_TEST_SUITE_REGISTRATION(stack::TestIntrusiveFCStack); -} // namespace stack - diff --git a/tests/test-hdr/stack/hdr_intrusive_treiber_stack.h b/tests/test-hdr/stack/hdr_intrusive_treiber_stack.h deleted file mode 100644 index 4be31836..00000000 --- a/tests/test-hdr/stack/hdr_intrusive_treiber_stack.h +++ /dev/null @@ -1,235 +0,0 @@ -/* - This file is a part of libcds - Concurrent Data Structures library - - (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 - - Source code repo: http://github.com/khizmax/libcds/ - Download: http://sourceforge.net/projects/libcds/files/ - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef CDSTEST_HDR_INTRUSIVE_TREIBER_STACK_H -#define CDSTEST_HDR_INTRUSIVE_TREIBER_STACK_H - -#include "cppunit/cppunit_proxy.h" -#include - -namespace stack { - - namespace ci = cds::intrusive; - - class TestIntrusiveStack: public CppUnitMini::TestCase - { - public: - template - struct base_hook_item: public ci::single_link::node< GC > - { - int nVal; - int nDisposeCount; - - base_hook_item() - : nDisposeCount(0) - {} - }; - - template - struct member_hook_item - { - int nVal; - int nDisposeCount; - ci::single_link::node< GC > hMember; - - member_hook_item() - : nDisposeCount(0) - {} - }; - - struct faked_disposer - { - template - void operator ()( T * p ) - { - ++p->nDisposeCount; - } - }; - - template - void test_elimination() - { - Stack stack( 2 ); - test_with( stack ); - } - - template - void test() - { - Stack stack; - test_with(stack); - } - - - template - void test_with( Stack& stack ) - { - typedef typename Stack::value_type value_type; - - CPPUNIT_ASSERT( stack.empty() ); - - value_type v1, v2, v3; - v1.nVal = 1; - v2.nVal = 2; - v3.nVal = 3; - CPPUNIT_ASSERT( stack.push(v1)); - CPPUNIT_ASSERT( !stack.empty() ); - CPPUNIT_ASSERT( stack.push(v2)); - CPPUNIT_ASSERT( !stack.empty() ); - CPPUNIT_ASSERT( stack.push(v3)); - CPPUNIT_ASSERT( !stack.empty() ); - - value_type * pv; - pv = stack.pop(); - CPPUNIT_ASSERT( pv != nullptr ); - CPPUNIT_ASSERT( pv->nVal == 3 ); - CPPUNIT_ASSERT( !stack.empty() ); - pv = stack.pop(); - CPPUNIT_ASSERT( pv != nullptr ); - CPPUNIT_ASSERT( pv->nVal == 2 ); - CPPUNIT_ASSERT( !stack.empty() ); - pv = stack.pop(); - CPPUNIT_ASSERT( pv != nullptr ); - CPPUNIT_ASSERT( pv->nVal == 1 ); - CPPUNIT_ASSERT( stack.empty() ); - pv = stack.pop(); - CPPUNIT_ASSERT( pv == nullptr ); - - CPPUNIT_ASSERT( v1.nDisposeCount == 0 ); - CPPUNIT_ASSERT( v2.nDisposeCount == 0 ); - CPPUNIT_ASSERT( v3.nDisposeCount == 0 ); - - stack.push(v1); - stack.push(v2); - stack.push(v3); - - stack.clear(); - CPPUNIT_ASSERT( stack.empty() ); - - Stack::gc::scan(); - if ( !std::is_same::value ) { - CPPUNIT_ASSERT( v1.nDisposeCount == 1 ); - CPPUNIT_ASSERT( v2.nDisposeCount == 1 ); - CPPUNIT_ASSERT( v3.nDisposeCount == 1 ); - } - } - - void Treiber_HP_default(); - void Treiber_HP_base(); - void Treiber_HP_base_disposer(); - void Treiber_HP_member(); - void Treiber_HP_member_disposer(); - void Treiber_DHP_base(); - void Treiber_DHP_base_disposer(); - void Treiber_DHP_member(); - void Treiber_DHP_member_disposer(); - - void Treiber_HP_default_relaxed(); - void Treiber_HP_base_relaxed(); - void Treiber_HP_base_disposer_relaxed(); - void Treiber_HP_member_relaxed(); - void Treiber_HP_member_disposer_relaxed(); - void Treiber_DHP_base_relaxed(); - void Treiber_DHP_base_disposer_relaxed(); - void Treiber_DHP_member_relaxed(); - void Treiber_DHP_member_disposer_relaxed(); - - void Elimination_HP_default(); - void Elimination_HP_base(); - void Elimination_HP_base_dyn(); - void Elimination_HP_base_disposer(); - void Elimination_HP_member(); - void Elimination_HP_member_dyn(); - void Elimination_HP_member_disposer(); - void Elimination_DHP_base(); - void Elimination_DHP_base_dyn(); - void Elimination_DHP_base_disposer(); - void Elimination_DHP_member(); - void Elimination_DHP_member_dyn(); - void Elimination_DHP_member_disposer(); - - void Elimination_HP_default_relaxed(); - void Elimination_HP_base_relaxed(); - void Elimination_HP_base_disposer_relaxed(); - void Elimination_HP_member_relaxed(); - void Elimination_HP_member_disposer_relaxed(); - void Elimination_DHP_base_relaxed(); - void Elimination_DHP_base_disposer_relaxed(); - void Elimination_DHP_member_relaxed(); - void Elimination_DHP_member_disposer_relaxed(); - - CPPUNIT_TEST_SUITE(TestIntrusiveStack) - CPPUNIT_TEST(Treiber_HP_default) - CPPUNIT_TEST(Treiber_HP_default_relaxed) - CPPUNIT_TEST(Treiber_HP_base) - CPPUNIT_TEST(Treiber_HP_base_relaxed) - CPPUNIT_TEST(Treiber_HP_base_disposer) - CPPUNIT_TEST(Treiber_HP_base_disposer_relaxed) - CPPUNIT_TEST(Treiber_HP_member) - CPPUNIT_TEST(Treiber_HP_member_relaxed) - CPPUNIT_TEST(Treiber_HP_member_disposer) - CPPUNIT_TEST(Treiber_HP_member_disposer_relaxed) - CPPUNIT_TEST(Treiber_DHP_base) - CPPUNIT_TEST(Treiber_DHP_base_relaxed) - CPPUNIT_TEST(Treiber_DHP_base_disposer) - CPPUNIT_TEST(Treiber_DHP_base_disposer_relaxed) - CPPUNIT_TEST(Treiber_DHP_member) - CPPUNIT_TEST(Treiber_DHP_member_relaxed) - CPPUNIT_TEST(Treiber_DHP_member_disposer) - CPPUNIT_TEST(Treiber_DHP_member_disposer_relaxed) - - CPPUNIT_TEST(Elimination_HP_default) - CPPUNIT_TEST(Elimination_HP_default_relaxed) - CPPUNIT_TEST(Elimination_HP_base) - CPPUNIT_TEST(Elimination_HP_base_dyn) - CPPUNIT_TEST(Elimination_HP_base_relaxed) - CPPUNIT_TEST(Elimination_HP_base_disposer) - CPPUNIT_TEST(Elimination_HP_base_disposer_relaxed) - CPPUNIT_TEST(Elimination_HP_member) - CPPUNIT_TEST(Elimination_HP_member_dyn) - CPPUNIT_TEST(Elimination_HP_member_relaxed) - CPPUNIT_TEST(Elimination_HP_member_disposer) - CPPUNIT_TEST(Elimination_HP_member_disposer_relaxed) - CPPUNIT_TEST(Elimination_DHP_base) - CPPUNIT_TEST(Elimination_DHP_base_dyn) - CPPUNIT_TEST(Elimination_DHP_base_relaxed) - CPPUNIT_TEST(Elimination_DHP_base_disposer) - CPPUNIT_TEST(Elimination_DHP_base_disposer_relaxed) - CPPUNIT_TEST(Elimination_DHP_member) - CPPUNIT_TEST(Elimination_DHP_member_dyn) - CPPUNIT_TEST(Elimination_DHP_member_relaxed) - CPPUNIT_TEST(Elimination_DHP_member_disposer) - CPPUNIT_TEST(Elimination_DHP_member_disposer_relaxed) - CPPUNIT_TEST_SUITE_END() - }; - -} // namespace stack - -#endif // #ifndef CDSTEST_HDR_INTRUSIVE_TREIBER_STACK_H diff --git a/tests/test-hdr/stack/hdr_intrusive_treiber_stack_dhp.cpp b/tests/test-hdr/stack/hdr_intrusive_treiber_stack_dhp.cpp deleted file mode 100644 index 8b26202b..00000000 --- a/tests/test-hdr/stack/hdr_intrusive_treiber_stack_dhp.cpp +++ /dev/null @@ -1,148 +0,0 @@ -/* - This file is a part of libcds - Concurrent Data Structures library - - (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 - - Source code repo: http://github.com/khizmax/libcds/ - Download: http://sourceforge.net/projects/libcds/files/ - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "hdr_intrusive_treiber_stack.h" -#include -#include - -namespace stack { - -#define TEST(X) void TestIntrusiveStack::X() { test(); } - - namespace defs { - // DHP GC + base hook - typedef cds::intrusive::TreiberStack< cds::gc::DHP, - TestIntrusiveStack::base_hook_item - ,typename ci::treiber_stack::make_traits< - ci::opt::hook< - ci::treiber_stack::base_hook< ci::opt::gc > - > - >::type - > Treiber_DHP_base; - - typedef cds::intrusive::TreiberStack< cds::gc::DHP, - TestIntrusiveStack::base_hook_item - ,typename ci::treiber_stack::make_traits< - ci::opt::hook< - ci::treiber_stack::base_hook< ci::opt::gc > - > - ,ci::opt::memory_model< ci::opt::v::relaxed_ordering > - >::type - > Treiber_DHP_base_relaxed; - - // DHP GC + base hook + disposer - typedef cds::intrusive::TreiberStack< cds::gc::DHP, - TestIntrusiveStack::base_hook_item - ,typename ci::treiber_stack::make_traits< - ci::opt::hook< - ci::treiber_stack::base_hook< ci::opt::gc > - > - ,ci::opt::disposer< TestIntrusiveStack::faked_disposer > - >::type - > Treiber_DHP_base_disposer; - - typedef cds::intrusive::TreiberStack< cds::gc::DHP, - TestIntrusiveStack::base_hook_item - ,typename ci::treiber_stack::make_traits< - ci::opt::hook< - ci::treiber_stack::base_hook< ci::opt::gc > - > - ,ci::opt::disposer< TestIntrusiveStack::faked_disposer > - ,ci::opt::memory_model< ci::opt::v::relaxed_ordering > - >::type - > Treiber_DHP_base_disposer_relaxed; - - // DHP GC + member hook - typedef cds::intrusive::TreiberStack< cds::gc::DHP, - TestIntrusiveStack::member_hook_item - ,typename ci::treiber_stack::make_traits< - ci::opt::hook< - ci::treiber_stack::member_hook< - offsetof(TestIntrusiveStack::member_hook_item, hMember), - ci::opt::gc - > - > - >::type - > Treiber_DHP_member; - - typedef cds::intrusive::TreiberStack< cds::gc::DHP, - TestIntrusiveStack::member_hook_item - ,typename ci::treiber_stack::make_traits< - ci::opt::hook< - ci::treiber_stack::member_hook< - offsetof(TestIntrusiveStack::member_hook_item, hMember), - ci::opt::gc - > - > - ,ci::opt::memory_model< ci::opt::v::relaxed_ordering > - >::type - > Treiber_DHP_member_relaxed; - - // DHP GC + member hook + disposer - typedef cds::intrusive::TreiberStack< cds::gc::DHP, - TestIntrusiveStack::member_hook_item - , typename ci::treiber_stack::make_traits< - ci::opt::hook< - ci::treiber_stack::member_hook< - offsetof(TestIntrusiveStack::member_hook_item, hMember), - ci::opt::gc - > - > - ,ci::opt::disposer< TestIntrusiveStack::faked_disposer > - >::type - > Treiber_DHP_member_disposer; - - typedef cds::intrusive::TreiberStack< cds::gc::DHP, - TestIntrusiveStack::member_hook_item - , typename ci::treiber_stack::make_traits< - ci::opt::hook< - ci::treiber_stack::member_hook< - offsetof(TestIntrusiveStack::member_hook_item, hMember), - ci::opt::gc - > - > - ,ci::opt::disposer< TestIntrusiveStack::faked_disposer > - ,ci::opt::memory_model< ci::opt::v::relaxed_ordering > - >::type - > Treiber_DHP_member_disposer_relaxed; - } - - TEST(Treiber_DHP_base) - TEST(Treiber_DHP_base_disposer) - TEST(Treiber_DHP_member) - TEST(Treiber_DHP_member_disposer) - - TEST(Treiber_DHP_base_relaxed) - TEST(Treiber_DHP_base_disposer_relaxed) - TEST(Treiber_DHP_member_relaxed) - TEST(Treiber_DHP_member_disposer_relaxed) - -} // namespace stack - diff --git a/tests/test-hdr/stack/hdr_intrusive_treiber_stack_hp.cpp b/tests/test-hdr/stack/hdr_intrusive_treiber_stack_hp.cpp deleted file mode 100644 index 5c7d3f92..00000000 --- a/tests/test-hdr/stack/hdr_intrusive_treiber_stack_hp.cpp +++ /dev/null @@ -1,184 +0,0 @@ -/* - This file is a part of libcds - Concurrent Data Structures library - - (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 - - Source code repo: http://github.com/khizmax/libcds/ - Download: http://sourceforge.net/projects/libcds/files/ - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "hdr_intrusive_treiber_stack.h" -#include -#include - -namespace stack { - -#define TEST(X) void TestIntrusiveStack::X() { test(); } - - namespace defs { namespace { - typedef cds::intrusive::TreiberStack< cds::gc::HP, - TestIntrusiveStack::base_hook_item - > Treiber_HP_default; - - typedef cds::intrusive::TreiberStack< cds::gc::HP, - TestIntrusiveStack::base_hook_item - , typename ci::treiber_stack::make_traits< - ci::opt::memory_model< ci::opt::v::relaxed_ordering > - >::type - > Treiber_HP_default_relaxed; - - // HZP GC + base hook - typedef cds::intrusive::TreiberStack< cds::gc::HP, - TestIntrusiveStack::base_hook_item - , typename ci::treiber_stack::make_traits< - ci::opt::hook< - ci::treiber_stack::base_hook< - ci::opt::gc - > - > - >::type - > Treiber_HP_base; - - struct traits_Treiber_HP_base_relaxed - : ci::treiber_stack::make_traits < - ci::opt::hook< - ci::treiber_stack::base_hook< - ci::opt::gc - > - > - ,ci::opt::memory_model< ci::opt::v::relaxed_ordering > - > ::type - {}; - typedef cds::intrusive::TreiberStack< cds::gc::HP, - TestIntrusiveStack::base_hook_item, - traits_Treiber_HP_base_relaxed - > Treiber_HP_base_relaxed; - - // HZP GC + base hook + disposer - struct traits_Treiber_HP_base_disposer - : ci::treiber_stack::make_traits < - ci::opt::hook< - ci::treiber_stack::base_hook< ci::opt::gc > - > - ,ci::opt::disposer< TestIntrusiveStack::faked_disposer > - >::type - {}; - typedef cds::intrusive::TreiberStack< cds::gc::HP, - TestIntrusiveStack::base_hook_item, - traits_Treiber_HP_base_disposer - > Treiber_HP_base_disposer; - - typedef cds::intrusive::TreiberStack< cds::gc::HP, - TestIntrusiveStack::base_hook_item - ,typename ci::treiber_stack::make_traits < - ci::opt::hook< - ci::treiber_stack::base_hook< ci::opt::gc > - > - ,ci::opt::disposer< TestIntrusiveStack::faked_disposer > - ,ci::opt::memory_model< ci::opt::v::relaxed_ordering > - >::type - > Treiber_HP_base_disposer_relaxed; - - // HZP GC + member hook - struct traits_Treiber_HP_member - : ci::treiber_stack::make_traits < - ci::opt::hook< - ci::treiber_stack::member_hook< - offsetof(TestIntrusiveStack::member_hook_item, hMember), - ci::opt::gc - > - > - > ::type - {}; - typedef cds::intrusive::TreiberStack< cds::gc::HP, - TestIntrusiveStack::member_hook_item, - traits_Treiber_HP_member - > Treiber_HP_member; - - struct traits_Treiber_HP_member_relaxed - : ci::treiber_stack::make_traits < - ci::opt::hook< - ci::treiber_stack::member_hook< - offsetof(TestIntrusiveStack::member_hook_item, hMember), - ci::opt::gc - > - > - ,ci::opt::memory_model< ci::opt::v::relaxed_ordering > - >::type - {}; - typedef cds::intrusive::TreiberStack< cds::gc::HP, - TestIntrusiveStack::member_hook_item, - traits_Treiber_HP_member_relaxed - > Treiber_HP_member_relaxed; - - // HZP GC + member hook + disposer - struct traits_Treiber_HP_member_disposer - : ci::treiber_stack::make_traits < - ci::opt::hook< - ci::treiber_stack::member_hook< - offsetof(TestIntrusiveStack::member_hook_item, hMember), - ci::opt::gc - > - > - ,ci::opt::disposer< TestIntrusiveStack::faked_disposer > - >::type - {}; - typedef cds::intrusive::TreiberStack< cds::gc::HP, - TestIntrusiveStack::member_hook_item, - traits_Treiber_HP_member_disposer - > Treiber_HP_member_disposer; - - struct traits_Treiber_HP_member_disposer_relaxed - : ci::treiber_stack::make_traits < - ci::opt::hook< - ci::treiber_stack::member_hook< - offsetof(TestIntrusiveStack::member_hook_item, hMember), - ci::opt::gc - > - > - ,ci::opt::disposer< TestIntrusiveStack::faked_disposer > - ,ci::opt::memory_model< ci::opt::v::relaxed_ordering > - >::type - {}; - typedef cds::intrusive::TreiberStack< cds::gc::HP, - TestIntrusiveStack::member_hook_item, - traits_Treiber_HP_member_disposer_relaxed - > Treiber_HP_member_disposer_relaxed; - }} - - TEST(Treiber_HP_default) - TEST(Treiber_HP_base) - TEST(Treiber_HP_base_disposer) - TEST(Treiber_HP_member) - TEST(Treiber_HP_member_disposer) - - TEST(Treiber_HP_default_relaxed) - TEST(Treiber_HP_base_relaxed) - TEST(Treiber_HP_base_disposer_relaxed) - TEST(Treiber_HP_member_relaxed) - TEST(Treiber_HP_member_disposer_relaxed) - -} // namespace stack - -CPPUNIT_TEST_SUITE_REGISTRATION(stack::TestIntrusiveStack); diff --git a/tests/test-hdr/stack/hdr_treiber_stack.h b/tests/test-hdr/stack/hdr_treiber_stack.h deleted file mode 100644 index 0fe4709d..00000000 --- a/tests/test-hdr/stack/hdr_treiber_stack.h +++ /dev/null @@ -1,164 +0,0 @@ -/* - This file is a part of libcds - Concurrent Data Structures library - - (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 - - Source code repo: http://github.com/khizmax/libcds/ - Download: http://sourceforge.net/projects/libcds/files/ - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef CDSTEST_HDR_TREIBER_STACK_H -#define CDSTEST_HDR_TREIBER_STACK_H - -#include "cppunit/cppunit_proxy.h" - -namespace stack { - - class TestStack: public CppUnitMini::TestCase - { - template - void test() - { - Stack s; - test_with( s ); - } - - template - void test_elimination() - { - Stack s(2); - test_with( s ); - } - - template - void test_with( Stack& stack) - { - typedef typename Stack::value_type value_type; - value_type v; - - CPPUNIT_ASSERT( stack.empty() ); - - CPPUNIT_ASSERT( stack.push(1)); - CPPUNIT_ASSERT( !stack.empty() ); - CPPUNIT_ASSERT( stack.push(2)); - CPPUNIT_ASSERT( !stack.empty() ); - CPPUNIT_ASSERT( stack.push(3)); - CPPUNIT_ASSERT( !stack.empty() ); - - CPPUNIT_ASSERT( stack.pop(v) ); - CPPUNIT_ASSERT( v == 3 ); - CPPUNIT_ASSERT( !stack.empty() ); - CPPUNIT_ASSERT( stack.pop_with( [&v]( value_type& src ) { v = src; } )); - CPPUNIT_ASSERT( v == 2 ); - CPPUNIT_ASSERT( !stack.empty() ); - CPPUNIT_ASSERT( stack.pop(v) ); - CPPUNIT_ASSERT( v == 1 ); - CPPUNIT_ASSERT( stack.empty() ); - v = 1000; - CPPUNIT_ASSERT( !stack.pop(v) ); - CPPUNIT_ASSERT( v == 1000 ); - CPPUNIT_ASSERT( stack.empty() ); - - CPPUNIT_ASSERT( stack.push(10)); - CPPUNIT_ASSERT( stack.push(20)); - CPPUNIT_ASSERT( stack.push(30)); - CPPUNIT_ASSERT( !stack.empty()); - - CPPUNIT_ASSERT( stack.emplace(100)); - CPPUNIT_ASSERT( stack.pop(v)); - CPPUNIT_ASSERT( v == 100 ); - - stack.clear(); - CPPUNIT_ASSERT( stack.empty() ); - - Stack::gc::scan(); - } - - void Treiber_HP(); - void Treiber_DHP(); - void Treiber_HP_yield(); - void Treiber_DHP_yield(); - void Treiber_HP_pause_alloc(); - void Treiber_DHP_pause_alloc(); - - void Treiber_HP_relaxed(); - void Treiber_DHP_relaxed(); - void Treiber_HP_yield_relaxed(); - void Treiber_DHP_yield_relaxed(); - void Treiber_HP_pause_alloc_relaxed(); - void Treiber_DHP_pause_alloc_relaxed(); - - void Elimination_HP(); - void Elimination_HP_dyn(); - void Elimination_HP_stat(); - void Elimination_DHP(); - void Elimination_DHP_dyn(); - void Elimination_DHP_stat(); - void Elimination_HP_yield(); - void Elimination_DHP_yield(); - void Elimination_HP_pause_alloc(); - void Elimination_DHP_pause_alloc(); - - void Elimination_HP_relaxed(); - void Elimination_DHP_relaxed(); - void Elimination_HP_yield_relaxed(); - void Elimination_DHP_yield_relaxed(); - void Elimination_HP_pause_alloc_relaxed(); - void Elimination_DHP_pause_alloc_relaxed(); - - CPPUNIT_TEST_SUITE(TestStack); - CPPUNIT_TEST(Treiber_HP) - CPPUNIT_TEST(Treiber_HP_relaxed) - CPPUNIT_TEST(Treiber_DHP) - CPPUNIT_TEST(Treiber_DHP_relaxed) - CPPUNIT_TEST(Treiber_HP_yield) - CPPUNIT_TEST(Treiber_HP_yield_relaxed) - CPPUNIT_TEST(Treiber_DHP_yield) - CPPUNIT_TEST(Treiber_DHP_yield_relaxed) - CPPUNIT_TEST(Treiber_HP_pause_alloc) - CPPUNIT_TEST(Treiber_HP_pause_alloc_relaxed) - CPPUNIT_TEST(Treiber_DHP_pause_alloc) - CPPUNIT_TEST(Treiber_DHP_pause_alloc_relaxed) - - CPPUNIT_TEST(Elimination_HP) - CPPUNIT_TEST(Elimination_HP_dyn) - CPPUNIT_TEST(Elimination_HP_stat) - CPPUNIT_TEST(Elimination_HP_relaxed) - CPPUNIT_TEST(Elimination_DHP) - CPPUNIT_TEST(Elimination_DHP_dyn) - CPPUNIT_TEST(Elimination_DHP_stat) - CPPUNIT_TEST(Elimination_DHP_relaxed) - CPPUNIT_TEST(Elimination_HP_yield) - CPPUNIT_TEST(Elimination_HP_yield_relaxed) - CPPUNIT_TEST(Elimination_DHP_yield) - CPPUNIT_TEST(Elimination_DHP_yield_relaxed) - CPPUNIT_TEST(Elimination_HP_pause_alloc) - CPPUNIT_TEST(Elimination_HP_pause_alloc_relaxed) - CPPUNIT_TEST(Elimination_DHP_pause_alloc) - CPPUNIT_TEST(Elimination_DHP_pause_alloc_relaxed) - CPPUNIT_TEST_SUITE_END(); - }; -} // namespace stack - -#endif // #ifndef CDSTEST_HDR_TREIBER_STACK_H diff --git a/tests/test-hdr/stack/hdr_treiber_stack_dhp.cpp b/tests/test-hdr/stack/hdr_treiber_stack_dhp.cpp deleted file mode 100644 index 63c4364c..00000000 --- a/tests/test-hdr/stack/hdr_treiber_stack_dhp.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* - This file is a part of libcds - Concurrent Data Structures library - - (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 - - Source code repo: http://github.com/khizmax/libcds/ - Download: http://sourceforge.net/projects/libcds/files/ - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "hdr_treiber_stack.h" -#include -#include - -namespace stack { -#define TEST(X) void TestStack::X() { test(); } - namespace cs = cds::container; - - namespace defs { namespace { - - typedef cs::TreiberStack< cds::gc::DHP, int > Treiber_DHP; - typedef cs::TreiberStack< cds::gc::DHP, int - , typename cs::treiber_stack::make_traits< - cds::opt::memory_model - >::type - > Treiber_DHP_relaxed; - - typedef cs::TreiberStack< cds::gc::DHP, int - , typename cs::treiber_stack::make_traits< - cds::opt::back_off< cds::backoff::yield> - >::type - > Treiber_DHP_yield; - - typedef cs::TreiberStack< cds::gc::DHP, int - , typename cs::treiber_stack::make_traits< - cds::opt::back_off< cds::backoff::yield> - ,cds::opt::memory_model - >::type - > Treiber_DHP_yield_relaxed; - - typedef cs::TreiberStack< cds::gc::DHP, int - , typename cs::treiber_stack::make_traits< - cds::opt::back_off< cds::backoff::pause> - ,cds::opt::allocator< std::allocator< bool * > > - >::type - > Treiber_DHP_pause_alloc; - - typedef cs::TreiberStack< cds::gc::DHP, int - , typename cs::treiber_stack::make_traits< - cds::opt::memory_model - ,cds::opt::back_off< cds::backoff::pause> - ,cds::opt::allocator< std::allocator< bool * > > - >::type - > Treiber_DHP_pause_alloc_relaxed; - }} - - TEST(Treiber_DHP) - TEST(Treiber_DHP_yield) - TEST(Treiber_DHP_pause_alloc) - - TEST(Treiber_DHP_relaxed) - TEST(Treiber_DHP_yield_relaxed) - TEST(Treiber_DHP_pause_alloc_relaxed) - -} diff --git a/tests/test-hdr/stack/hdr_treiber_stack_hp.cpp b/tests/test-hdr/stack/hdr_treiber_stack_hp.cpp deleted file mode 100644 index 2a5963e5..00000000 --- a/tests/test-hdr/stack/hdr_treiber_stack_hp.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* - This file is a part of libcds - Concurrent Data Structures library - - (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016 - - Source code repo: http://github.com/khizmax/libcds/ - Download: http://sourceforge.net/projects/libcds/files/ - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "hdr_treiber_stack.h" -#include -#include - - -namespace stack { -#define TEST(X) void TestStack::X() { test(); } - namespace cs = cds::container; - - namespace defs { namespace { - - typedef cs::TreiberStack< cds::gc::HP, int > Treiber_HP; - typedef cs::TreiberStack< cds::gc::HP, int - , typename cs::treiber_stack::make_traits< - cds::opt::memory_model - >::type - > Treiber_HP_relaxed; - - typedef cs::TreiberStack< cds::gc::HP, int - , typename cs::treiber_stack::make_traits< - cds::opt::back_off< cds::backoff::yield> - >::type - > Treiber_HP_yield; - - typedef cs::TreiberStack< cds::gc::HP, int - , typename cs::treiber_stack::make_traits< - cds::opt::back_off< cds::backoff::yield> - , cds::opt::memory_model - >::type - > Treiber_HP_yield_relaxed; - - typedef cs::TreiberStack< cds::gc::HP, int - , typename cs::treiber_stack::make_traits< - cds::opt::back_off< cds::backoff::pause> - ,cds::opt::allocator< std::allocator< bool * > > - >::type - > Treiber_HP_pause_alloc; - - typedef cs::TreiberStack< cds::gc::HP, int - , typename cs::treiber_stack::make_traits< - cds::opt::back_off< cds::backoff::pause> - ,cds::opt::memory_model - ,cds::opt::allocator< std::allocator< unsigned long > > - >::type - > Treiber_HP_pause_alloc_relaxed; - }} - - TEST(Treiber_HP) - TEST(Treiber_HP_yield) - TEST(Treiber_HP_pause_alloc) - - TEST(Treiber_HP_relaxed) - TEST(Treiber_HP_yield_relaxed) - TEST(Treiber_HP_pause_alloc_relaxed) -} -CPPUNIT_TEST_SUITE_REGISTRATION(stack::TestStack);