Skip to content

Commit f872859

Browse files
authored
Use EXPECT_FALSE instead of EXPECT_EQ(false, X) (cpp-netlib#752)
This fixes the failures we're finding from the CI builds. We also take the opportunity to improve the build system, to use ccache if it's available, and also to simplify the travis config. Now that we can just test with Boost 1.55 in the meantime, let's set the appropriate flags that will make the clang build/support work.
1 parent 9e76e5f commit f872859

File tree

6 files changed

+91
-68
lines changed

6 files changed

+91
-68
lines changed

.travis.yml

+41-30
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,49 @@ compiler:
44
- g++
55
- clang
66
env:
7-
- BOOST_VER=1.59.0 BUILD_SHARED_LIBS="ON" CMAKE_BUILD_TYPE="Release" ENABLE_HTTPS="ON" Uri_BUILD_TESTS=OFF Uri_DISABLE_LIBCXX=YES
8-
- BOOST_VER=1.59.0 BUILD_SHARED_LIBS="ON" CMAKE_BUILD_TYPE="Release" ENABLE_HTTPS="OFF" Uri_BUILD_TESTS=OFF Uri_DISABLE_LIBCXX=YES
9-
- BOOST_VER=1.59.0 BUILD_SHARED_LIBS="ON" CMAKE_BUILD_TYPE="Debug" ENABLE_HTTPS="ON" Uri_BUILD_TESTS=OFF Uri_DISABLE_LIBCXX=YES
10-
- BOOST_VER=1.59.0 BUILD_SHARED_LIBS="ON" CMAKE_BUILD_TYPE="Debug" ENABLE_HTTPS="OFF" Uri_BUILD_TESTS=OFF Uri_DISABLE_LIBCXX=YES
11-
- BOOST_VER=1.59.0 BUILD_SHARED_LIBS="OFF" CMAKE_BUILD_TYPE="Release" ENABLE_HTTPS="ON" Uri_BUILD_TESTS=OFF Uri_DISABLE_LIBCXX=YES
12-
- BOOST_VER=1.59.0 BUILD_SHARED_LIBS="OFF" CMAKE_BUILD_TYPE="Release" ENABLE_HTTPS="OFF" Uri_BUILD_TESTS=OFF Uri_DISABLE_LIBCXX=YES
13-
- BOOST_VER=1.59.0 BUILD_SHARED_LIBS="OFF" CMAKE_BUILD_TYPE="Debug" ENABLE_HTTPS="ON" Uri_BUILD_TESTS=OFF Uri_DISABLE_LIBCXX=YES
14-
- BOOST_VER=1.59.0 BUILD_SHARED_LIBS="OFF" CMAKE_BUILD_TYPE="Debug" ENABLE_HTTPS="OFF" Uri_BUILD_TESTS=OFF Uri_DISABLE_LIBCXX=YES
7+
- BUILD_SHARED_LIBS="ON" CMAKE_BUILD_TYPE="Release" ENABLE_HTTPS="ON" Uri_BUILD_TESTS=OFF Uri_DISABLE_LIBCXX=YES
8+
- BUILD_SHARED_LIBS="ON" CMAKE_BUILD_TYPE="Release" ENABLE_HTTPS="OFF" Uri_BUILD_TESTS=OFF Uri_DISABLE_LIBCXX=YES
9+
- BUILD_SHARED_LIBS="ON" CMAKE_BUILD_TYPE="Debug" ENABLE_HTTPS="ON" Uri_BUILD_TESTS=OFF Uri_DISABLE_LIBCXX=YES
10+
- BUILD_SHARED_LIBS="ON" CMAKE_BUILD_TYPE="Debug" ENABLE_HTTPS="OFF" Uri_BUILD_TESTS=OFF Uri_DISABLE_LIBCXX=YES
11+
- BUILD_SHARED_LIBS="OFF" CMAKE_BUILD_TYPE="Release" ENABLE_HTTPS="ON" Uri_BUILD_TESTS=OFF Uri_DISABLE_LIBCXX=YES
12+
- BUILD_SHARED_LIBS="OFF" CMAKE_BUILD_TYPE="Release" ENABLE_HTTPS="OFF" Uri_BUILD_TESTS=OFF Uri_DISABLE_LIBCXX=YES
13+
- BUILD_SHARED_LIBS="OFF" CMAKE_BUILD_TYPE="Debug" ENABLE_HTTPS="ON" Uri_BUILD_TESTS=OFF Uri_DISABLE_LIBCXX=YES
14+
- BUILD_SHARED_LIBS="OFF" CMAKE_BUILD_TYPE="Debug" ENABLE_HTTPS="OFF" Uri_BUILD_TESTS=OFF Uri_DISABLE_LIBCXX=YES
1515
# Support the sanitizers in clang only
16-
# - BOOST_VER=1.59.0 BUILD_SHARED_LIBS="OFF" CMAKE_BUILD_TYPE="Debug" ENABLE_HTTPS="ON" CMAKE_CXX_FLAGS="-fsanitize=thread"
17-
# - BOOST_VER=1.59.0 BUILD_SHARED_LIBS="OFF" CMAKE_BUILD_TYPE="Debug" ENABLE_HTTPS="ON" CMAKE_CXX_FLAGS="-fsanitize=address"
16+
- BUILD_SHARED_LIBS="OFF" CMAKE_BUILD_TYPE="Debug" ENABLE_HTTPS="ON" CMAKE_CXX_FLAGS="-fsanitize=thread" Uri_BUILD_TEST=OFF Uri_DISABLE_LIBCXX=YES
17+
- BUILD_SHARED_LIBS="OFF" CMAKE_BUILD_TYPE="Debug" ENABLE_HTTPS="ON" CMAKE_CXX_FLAGS="-fsanitize=address" Uri_BUILD_TEST=OFF Uri_DISABLE_LIBCXX=YES
1818
# TODO(deanberris): It seems Boost is not msan-clean yet; report bugs and maybe fix?
1919
#- BOOST_VER=1.59.0 BUILD_SHARED_LIBS="OFF" CMAKE_BUILD_TYPE="Debug" ENABLE_HTTPS="ON" CMAKE_CXX_FLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2"
20-
# matrix:
21-
# exclude:
22-
# - compiler: g++
23-
# env: BOOST_VER=1.59.0 BUILD_SHARED_LIBS="OFF" CMAKE_BUILD_TYPE="Debug" ENABLE_HTTPS="ON" CMAKE_CXX_FLAGS="-fsanitize=thread"
24-
# - compiler: g++
25-
# env: BOOST_VER=1.59.0 BUILD_SHARED_LIBS="OFF" CMAKE_BUILD_TYPE="Debug" ENABLE_HTTPS="ON" CMAKE_CXX_FLAGS="-fsanitize=address"
20+
cache:
21+
- apt
22+
- ccache
23+
matrix:
24+
exclude:
25+
- compiler: g++
26+
env: BUILD_SHARED_LIBS="OFF" CMAKE_BUILD_TYPE="Debug" ENABLE_HTTPS="ON" CMAKE_CXX_FLAGS="-fsanitize=thread" Uri_BUILD_TEST=OFF Uri_DISABLE_LIBCXX=YES
27+
- compiler: g++
28+
env: BOOST_VER=1.59.0 BUILD_SHARED_LIBS="OFF" CMAKE_BUILD_TYPE="Debug" ENABLE_HTTPS="ON" CMAKE_CXX_FLAGS="-fsanitize=address" Uri_BUILD_TEST=OFF Uri_DISABLE_LIBCXX=YES
2629
# TODO(deanberris): It seems Boost is not msan-clean yet; report bugs and maybe fix?
2730
# - compiler: g++
2831
# env: BOOST_VER=1.59.0 BUILD_SHARED_LIBS="OFF" CMAKE_BUILD_TYPE="Debug" ENABLE_HTTPS="ON" CMAKE_CXX_FLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2"
2932
install:
30-
- mkdir -p ${HOME}/bin
31-
- if [ "${CC}" = "gcc" ]; then export TOOLSET="gcc"; ln -s `which g++-4.8` ${HOME}/bin/g++;
32-
ln -s `which gcc-4.8` ${HOME}/bin/gcc; fi
33-
- if [ "${CC}" = "clang" ]; then export TOOLSET="clang"; ln -s `which clang-3.6` ${HOME}/bin/clang;
34-
ln -s `which clang++-3.6` ${HOME}/bin/clang++; fi
35-
- export BOOST_VERSION=${BOOST_VER//./_}
36-
- export PATH=${HOME}/bin:${PATH}
33+
- pwd
34+
- export CUR_DIR=`pwd`
35+
- mkdir -p ${CUR_DIR}/bin
36+
- if [ "${CC}" = "gcc" ]; then
37+
export CXX=g++-4.9;
38+
export CC=gcc-4.9;
39+
fi
40+
- if [ "${CC}" = "clang" ]; then
41+
export CXX=clang++-3.8;
42+
export CC=clang-3.8;
43+
export CCACHE_CPP2=yes;
44+
fi
45+
before_script:
46+
- echo ${CXX}
3747
- "${CXX} --version"
38-
cache:
39-
directories:
40-
- "${HOME}/${CC}-boost_${BOOST_VER//./_}"
48+
- echo ${CC}
49+
- "${CC} --version"
4150
script:
4251
- pwd
4352
- sh -x build.sh
@@ -47,15 +56,17 @@ addons:
4756
apt:
4857
sources:
4958
- ubuntu-toolchain-r-test
50-
- llvm-toolchain-precise-3.6
59+
- llvm-toolchain-precise-3.8
5160
- kalakris-cmake
5261
- boost-latest
62+
- george-edison55-precise-backports
5363
packages:
5464
- libboost1.55-all-dev
55-
- gcc-4.8
56-
- g++-4.8
57-
- clang-3.6
65+
- gcc-4.9
66+
- g++-4.9
67+
- clang-3.8
5868
- cmake
69+
- cmake-data
5970
notifications:
6071
slack:
6172
secure: Y7lLjqZ83+b/jaJ5+EKwvgCDeERi4bVbDn9tLp8sieTdu+ENsPI+JmLYSXZXPpe7JrItrXW6uJJXN2wG1h7au4mpVVTghd31HBzuzrqVxDphWPhp16NYzvbAgQQRBXvFVvfSdW/Kb/n2fX6xDApY0t6vNREb/GKg0GyzESb4ZjU=

CMakeLists.txt

+13-1
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,16 @@ if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
9797
elseif (${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
9898
# We want to link in C++11 mode in Clang too, but also set a high enough
9999
# template depth for the template metaprogramming.
100-
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -ftemplate-depth=256 -std=c++11")
100+
set (CMAKE_CXX_FLAGS
101+
"${CMAKE_CXX_FLAGS} -Wall -ftemplate-depth=256 -std=c++11 -DBOOST_ASIO_HAS_STD_CHRONO -DBOOST_ASIO_HAS_STD_ARRAY -DBOOST_ASIO_HAS_STD_SHARED_PTR -DBOOST_ASIO_HAS_STD_ATOMIC -DBOOST_ASIO_HAS_VARIADIC_TEMPLATES -DBOOST_ASIO_HAS_MOVE -DBOOST_THREAD_VERSION=3")
101102
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
102103
# Use libc++ only in OS X.
103104
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
104105
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lc++")
106+
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
107+
# Use libstdc++ for Linux.
108+
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++")
109+
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lstdc++")
105110
endif()
106111
endif()
107112

@@ -140,6 +145,13 @@ if (MSVC)
140145
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
141146
endif()
142147

148+
# See whether we can find the ccache program -- if we can, then use it for the build.
149+
find_program(CCACHE_FOUND ccache)
150+
if(CCACHE_FOUND)
151+
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
152+
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
153+
endif(CCACHE_FOUND)
154+
143155
enable_testing()
144156

145157
install(DIRECTORY boost DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

boost/network/protocol/http/client/connection/async_normal.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ struct http_async_connection
147147
connection_delegate_ptr;
148148

149149
http_async_connection(resolver_type& resolver, resolve_function resolve,
150-
bool follow_redirect, int timeout,
150+
bool follow_redirect, int64_t timeout,
151151
bool remove_chunk_markers,
152152
connection_delegate_ptr delegate)
153153
: timeout_(timeout),
@@ -578,7 +578,7 @@ struct http_async_connection
578578
}
579579
}
580580

581-
int timeout_;
581+
int64_t timeout_;
582582
bool remove_chunk_markers_;
583583
boost::asio::steady_timer timer_;
584584
bool is_timedout_;

build.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ cmake -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE \
1313
-DUri_DISABLE_LIBCXX=$Uri_DISABLE_LIBCXX \
1414
-DCMAKE_CXX_FLAGS="-std=c++11 ${CMAKE_CXX_FLAGS}" \
1515
..
16-
make -j8
16+
make
1717
make test
1818
cd ..

libs/network/test/http/request_incremental_parser_test.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ TEST(IncrementalRequestParserTest, ParseMethod) {
5252
p.reset();
5353
std::tie(parsed_ok, result_range) =
5454
p.parse_until(request_parser_type::method_done, invalid_http_method);
55-
EXPECT_EQ(false, parsed_ok);
55+
EXPECT_FALSE(parsed_ok);
5656
parsed.assign(std::begin(result_range), std::end(result_range));
5757
std::cout << "PARSED: " << parsed << " [state:" << p.state() << "] "
5858
<< std::endl;
@@ -68,7 +68,7 @@ TEST(IncrementalRequestParserTest, ParseURI) {
6868
std::string valid_http_request = "GET / HTTP/1.1\r\n";
6969
std::tie(parsed_ok, result_range) =
7070
p.parse_until(request_parser_type::uri_done, valid_http_request);
71-
EXPECT_EQ(true, parsed_ok);
71+
EXPECT_TRUE(parsed_ok);
7272
EXPECT_FALSE(boost::empty(result_range));
7373
std::string parsed(std::begin(result_range), std::end(result_range));
7474
std::cout << "PARSED: " << parsed << " [state:" << p.state() << "] "
@@ -78,7 +78,7 @@ TEST(IncrementalRequestParserTest, ParseURI) {
7878
p.reset();
7979
std::tie(parsed_ok, result_range) =
8080
p.parse_until(request_parser_type::uri_done, invalid_http_request);
81-
EXPECT_EQ(false, parsed_ok);
81+
EXPECT_FALSE(parsed_ok);
8282
parsed.assign(std::begin(result_range), std::end(result_range));
8383
std::cout << "PARSED: " << parsed << " [state:" << p.state() << "] "
8484
<< std::endl;
@@ -104,7 +104,7 @@ TEST(IncrementalRequestParserTest, ParseHTTPVersion) {
104104
p.reset();
105105
std::tie(parsed_ok, result_range) =
106106
p.parse_until(request_parser_type::version_done, invalid_http_request);
107-
EXPECT_EQ(false, parsed_ok);
107+
EXPECT_FALSE(parsed_ok);
108108
parsed.assign(std::begin(result_range), std::end(result_range));
109109
std::cout << "PARSED: " << parsed << " [state:" << p.state() << "] "
110110
<< std::endl;
@@ -121,7 +121,7 @@ TEST(IncrementalRequestParserTest, ParseHTTPHeaders) {
121121
"GET / HTTP/1.1\r\nHost: cpp-netlib.org\r\n\r\n";
122122
std::tie(parsed_ok, result_range) =
123123
p.parse_until(request_parser_type::headers_done, valid_http_request);
124-
EXPECT_EQ(true, parsed_ok);
124+
EXPECT_TRUE(parsed_ok);
125125
EXPECT_FALSE(boost::empty(result_range));
126126
std::string parsed(std::begin(result_range), std::end(result_range));
127127
std::cout << "PARSED: " << parsed << " [state:" << p.state() << "] "

0 commit comments

Comments
 (0)