2 This file is a part of libcds - Concurrent Data Structures library
\r
4 (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2017
\r
6 Source code repo: http://github.com/khizmax/libcds/
\r
7 Download: http://sourceforge.net/projects/libcds/files/
\r
9 Redistribution and use in source and binary forms, with or without
\r
10 modification, are permitted provided that the following conditions are met:
\r
12 * Redistributions of source code must retain the above copyright notice, this
\r
13 list of conditions and the following disclaimer.
\r
15 * Redistributions in binary form must reproduce the above copyright notice,
\r
16 this list of conditions and the following disclaimer in the documentation
\r
17 and/or other materials provided with the distribution.
\r
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
\r
20 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
\r
21 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
\r
22 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
\r
23 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
\r
24 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
\r
25 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
\r
26 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
\r
27 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
\r
28 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\r
31 #include <cds_test/stress_test.h>
\r
33 #include <cds/init.h>
\r
34 #include <cds/gc/hp.h>
\r
35 #include <cds/gc/dhp.h>
\r
36 #ifdef CDSUNIT_USE_URCU
\r
37 # include <cds/urcu/general_instant.h>
\r
38 # include <cds/urcu/general_buffered.h>
\r
39 # include <cds/urcu/general_threaded.h>
\r
40 # include <cds/urcu/signal_buffered.h>
\r
43 #ifdef CDS_ENABLE_HPSTAT
\r
44 # include <cds_test/stat_hp_out.h>
\r
45 # include <cds_test/stat_dhp_out.h>
\r
46 # include <iostream>
\r
49 int main( int argc, char **argv )
\r
54 // Read test config file
\r
55 cds_test::init_config( argc, argv );
\r
57 std::cout << "Hardware concurrency: " << std::thread::hardware_concurrency() << "\n";
\r
60 ::testing::InitGoogleTest( &argc, argv );
\r
62 cds_test::config const& general_cfg = cds_test::stress_fixture::get_config( "General" );
\r
66 general_cfg.get_size_t( "hazard_pointer_count", 16 ),
\r
67 general_cfg.get_size_t( "hp_max_thread_count", 0 ),
\r
68 general_cfg.get_size_t( "hp_retired_ptr_count", 0 ),
\r
69 general_cfg.get( "hp_scan_strategy", "inplace" ) == "inplace" ? cds::gc::HP::scan_type::inplace : cds::gc::HP::scan_type::classic
\r
73 general_cfg.get_size_t( "dhp_init_guard_count", 16 )
\r
76 #ifdef CDSUNIT_USE_URCU
\r
77 size_t rcu_buffer_size = general_cfg.get_size_t( "rcu_buffer_size", 256 );
\r
80 typedef cds::urcu::gc< cds::urcu::general_instant<> > rcu_gpi;
\r
83 typedef cds::urcu::gc< cds::urcu::general_buffered<> > rcu_gpb;
\r
84 rcu_gpb gpbRCU( rcu_buffer_size );
\r
86 typedef cds::urcu::gc< cds::urcu::general_threaded<> > rcu_gpt;
\r
87 rcu_gpt gptRCU( rcu_buffer_size );
\r
89 # ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
\r
90 typedef cds::urcu::gc< cds::urcu::signal_buffered<> > rcu_shb;
\r
91 rcu_shb shbRCU( rcu_buffer_size, SIGUSR1 );
\r
93 #endif // CDSUNIT_USE_URCU
\r
95 cds::threading::Manager::attachThread();
\r
97 result = RUN_ALL_TESTS();
\r
99 cds::threading::Manager::detachThread();
\r
102 #ifdef CDS_ENABLE_HPSTAT
\r
104 cds::gc::HP::stat const& st = cds::gc::HP::postmortem_statistics();
\r
105 EXPECT_EQ( st.guard_allocated, st.guard_freed );
\r
106 EXPECT_EQ( st.retired_count, st.free_count );
\r
110 cds::gc::DHP::stat const& st = cds::gc::DHP::postmortem_statistics();
\r
111 EXPECT_EQ( st.guard_allocated, st.guard_freed );
\r
112 EXPECT_EQ( st.retired_count, st.free_count );
\r