Skip to content

Commit fa9cd3f

Browse files
committed
Protect some test & examples with acceptable boost version
1 parent 35813c8 commit fa9cd3f

File tree

4 files changed

+23
-17
lines changed

4 files changed

+23
-17
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ os:
88
- linux
99

1010
before_script:
11-
- wget -q -O - https://sourceforge.net/projects/boost/files/boost/1.69.0/boost_1_69_0.tar.gz | tar -xz
12-
- cd boost_1_69_0 && ./bootstrap.sh --with-libraries=coroutine,context,chrono,system,thread,regex,filesystem,program_options
11+
- wget -q -O - https://sourceforge.net/projects/boost/files/boost/1.70.0/boost_1_70_0.tar.gz | tar -xz
12+
- cd boost_1_70_0 && ./bootstrap.sh --with-libraries=coroutine,context,chrono,system,thread,regex,filesystem,program_options
1313
- ./b2 --ignore-site-config && cd ..
1414
- mkdir build
1515
- cd build
16-
- cmake -DBOOST_ROOT=`pwd`/../boost_1_69_0 ..
16+
- cmake -DBOOST_ROOT=`pwd`/../boost_1_70_0 ..
1717

1818
addons:
1919
apt:

CMakeLists.txt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ else()
7878
set(LINK_DEPENDENCIES pthread ${Boost_LIBRARIES} catch_lib) # asan ubsan
7979
endif()
8080

81+
set(BOOST_VERSION_OK, (Boost_MAJOR_VERSION GREATER_EQUAL 1) AND (Boost_MINOR_VERSION GREATER_EQUAL 70))
82+
8183
add_subdirectory(examples)
8284

8385
add_executable(t-05-protocol t/05-protocol.cpp)
@@ -138,9 +140,11 @@ add_executable(t-19-transaction t/19-transaction.cpp)
138140
target_link_libraries(t-19-transaction ${LINK_DEPENDENCIES})
139141
add_test("t-19-transaction" t-19-transaction)
140142

141-
add_executable(t-20-promise t/20-promise.cpp)
142-
target_link_libraries(t-20-promise ${LINK_DEPENDENCIES})
143-
add_test("t-20-promise" t-20-promise)
143+
if(BOOST_VERSION_OK)
144+
add_executable(t-20-promise t/20-promise.cpp)
145+
target_link_libraries(t-20-promise ${LINK_DEPENDENCIES})
146+
add_test("t-20-promise" t-20-promise)
147+
endif()
144148

145149
add_executable(t-21-coroutine t/21-coroutine.cpp)
146150
target_link_libraries(t-21-coroutine ${LINK_DEPENDENCIES})
@@ -154,7 +158,7 @@ add_executable(t-23-stream t/23-stream.cpp)
154158
target_link_libraries(t-23-stream ${LINK_DEPENDENCIES})
155159
add_test("t-23-stream" t-23-stream)
156160

157-
if((Boost_MAJOR_VERSION GREATER_EQUAL 1) AND (Boost_MINOR_VERSION GREATER_EQUAL 70))
161+
if(BOOST_VERSION_OK)
158162
add_executable(t-24-dynbuff t/24-dynbuff.cpp)
159163
target_link_libraries(t-24-dynbuff ${LINK_DEPENDENCIES})
160164
add_test("t-24-dynbuff" t-24-dynbuff)

examples/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ target_link_libraries(stream-parse ${LINK_DEPENDENCIES})
88
add_executable(synch-subscription synch-subscription.cpp)
99
target_link_libraries(synch-subscription ${LINK_DEPENDENCIES})
1010

11-
add_executable(speed_test_async_multi speed_test_async_multi.cpp)
12-
target_link_libraries(speed_test_async_multi ${LINK_DEPENDENCIES})
11+
if(BOOST_VERSION_OK)
12+
add_executable(speed_test_async_multi speed_test_async_multi.cpp)
13+
target_link_libraries(speed_test_async_multi ${LINK_DEPENDENCIES})
14+
endif()
1315

1416
add_executable(multi-threads-1 multi-threads-1.cpp)
1517
target_link_libraries(multi-threads-1 ${LINK_DEPENDENCIES})

examples/speed_test_async_multi.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,15 @@ int main(int argc, char **argv) {
5353
// common setup
5454
using socket_t = asio::ip::tcp::socket;
5555
using next_layer_t = socket_t;
56-
using Buffer = boost::asio::streambuf;
57-
/*
56+
//using Buffer = boost::asio::streambuf;
5857
using Buffer = boost::asio::dynamic_string_buffer<
5958
std::string::value_type,
6059
std::string::traits_type,
6160
std::string::allocator_type
6261
>;
63-
*/
6462
using Iterator = typename r::to_iterator<Buffer>::iterator_t;
65-
//using policy_t = r::parsing_policy::drop_result;
66-
using policy_t = r::parsing_policy::keep_result;
63+
using policy_t = r::parsing_policy::drop_result;
64+
//using policy_t = r::parsing_policy::keep_result;
6765

6866
if (argc < 2) {
6967
std::cout << "Usage : " << argv[0] << " ip:port \n";
@@ -103,9 +101,11 @@ int main(int argc, char **argv) {
103101
// wrap it into bredis connection
104102
r::Connection<next_layer_t> c(std::move(socket));
105103

106-
//std::string tx_backend, rx_backend;
107-
//Buffer tx_buff(tx_backend), rx_buff(rx_backend);
108-
Buffer tx_buff, rx_buff;
104+
std::string tx_backend, rx_backend;
105+
//tx_backend.reserve(cmds_count * 4);
106+
//rx_backend.reserve(cmds_count * 4);
107+
Buffer tx_buff(tx_backend), rx_buff(rx_backend);
108+
//Buffer tx_buff, rx_buff;
109109
std::promise<void> completion_promise;
110110
auto completion_future = completion_promise.get_future();
111111

0 commit comments

Comments
 (0)