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
41 # include <cds/urcu/signal_threaded.h>
\r
44 #ifdef CDS_ENABLE_HPSTAT
\r
45 # include <cds_test/stat_hp_out.h>
\r
46 # include <cds_test/stat_dhp_out.h>
\r
47 # include <iostream>
\r
50 int main( int argc, char **argv )
\r
55 // Read test config file
\r
56 cds_test::init_config( argc, argv );
\r
58 std::cout << "Hardware concurrency: " << std::thread::hardware_concurrency() << "\n";
\r
61 ::testing::InitGoogleTest( &argc, argv );
\r
63 cds_test::config const& general_cfg = cds_test::stress_fixture::get_config( "General" );
\r
67 general_cfg.get_size_t( "hazard_pointer_count", 16 ),
\r
68 general_cfg.get_size_t( "hp_max_thread_count", 0 ),
\r
69 general_cfg.get_size_t( "hp_retired_ptr_count", 0 ),
\r
70 general_cfg.get( "hp_scan_strategy", "inplace" ) == "inplace" ? cds::gc::HP::scan_type::inplace : cds::gc::HP::scan_type::classic
\r
74 general_cfg.get_size_t( "dhp_init_guard_count", 16 )
\r
77 #ifdef CDSUNIT_USE_URCU
\r
78 size_t rcu_buffer_size = general_cfg.get_size_t( "rcu_buffer_size", 256 );
\r
81 typedef cds::urcu::gc< cds::urcu::general_instant<> > rcu_gpi;
\r
84 typedef cds::urcu::gc< cds::urcu::general_buffered<> > rcu_gpb;
\r
85 rcu_gpb gpbRCU( rcu_buffer_size );
\r
87 typedef cds::urcu::gc< cds::urcu::general_threaded<> > rcu_gpt;
\r
88 rcu_gpt gptRCU( rcu_buffer_size );
\r
90 # ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
\r
91 typedef cds::urcu::gc< cds::urcu::signal_buffered<> > rcu_shb;
\r
92 rcu_shb shbRCU( rcu_buffer_size, SIGUSR1 );
\r
94 typedef cds::urcu::gc< cds::urcu::signal_threaded<> > rcu_sht;
\r
95 rcu_sht shtRCU( rcu_buffer_size, SIGUSR2 );
\r
97 #endif // CDSUNIT_USE_URCU
\r
99 cds::threading::Manager::attachThread();
\r
101 result = RUN_ALL_TESTS();
\r
103 cds::threading::Manager::detachThread();
\r
106 #ifdef CDS_ENABLE_HPSTAT
\r
108 cds::gc::HP::stat const& st = cds::gc::HP::postmortem_statistics();
\r
109 EXPECT_EQ( st.guard_allocated, st.guard_freed );
\r
110 EXPECT_EQ( st.retired_count, st.free_count );
\r
114 cds::gc::DHP::stat const& st = cds::gc::DHP::postmortem_statistics();
\r
115 EXPECT_EQ( st.guard_allocated, st.guard_freed );
\r
116 EXPECT_EQ( st.retired_count, st.free_count );
\r