Include build rules for clang with address sanitizer
Usage: GYP_DEFINES='clang=1' BUILD_CONFIG=Debug examples/build.sh
The expectations on the mocked call using itself were wrong and depend
on the order of evaluation and leads to weird bugs, specifically clang
evaluates the parts of EXPECT_CALL in different order leading to wrong
behavior.
Change-Id: I0b2cf1e986268cd4dfecbd37d1ab3b4b1b725a5c
Reviewed-on: https://weave-review.googlesource.com/1990
Reviewed-by: Vitaly Buka <vitalybuka@google.com>
diff --git a/examples/provider/event_http_server.cc b/examples/provider/event_http_server.cc
index ae8bbec..ae9833e 100644
--- a/examples/provider/event_http_server.cc
+++ b/examples/provider/event_http_server.cc
@@ -34,8 +34,7 @@
class HttpServerImpl::RequestImpl : public Request {
public:
- RequestImpl(evhttp_request* req, provider::TaskRunner* task_runner)
- : task_runner_{task_runner} {
+ RequestImpl(evhttp_request* req) {
req_.reset(req);
uri_ = evhttp_request_get_evhttp_uri(req_.get());
@@ -70,7 +69,6 @@
private:
std::unique_ptr<evhttp_request, decltype(&evhttp_cancel_request)> req_{
nullptr, &evhttp_cancel_request};
- provider::TaskRunner* task_runner_{nullptr};
std::string data_;
const evhttp_uri* uri_{nullptr};
};
@@ -147,7 +145,7 @@
}
void HttpServerImpl::ProcessRequest(evhttp_request* req) {
- std::unique_ptr<RequestImpl> request{new RequestImpl{req, task_runner_}};
+ std::unique_ptr<RequestImpl> request{new RequestImpl{req}};
std::string path = request->GetPath();
auto it = handlers_.find(path);
if (it != handlers_.end()) {
diff --git a/libweave_common.gypi b/libweave_common.gypi
index e4251d8..e7b45ce 100644
--- a/libweave_common.gypi
+++ b/libweave_common.gypi
@@ -2,6 +2,9 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
{
+ 'variables': {
+ 'clang%': 0,
+ },
'target_defaults': {
'configurations': {
'Release': {
@@ -58,6 +61,27 @@
# 'library_dirs' does not work as expected with make files
'-Lthird_party/lib',
],
- 'library_dirs': ['third_party/lib']
+ 'library_dirs': ['third_party/lib'],
},
+ 'conditions': [
+ ['clang==1', {
+ 'target_defaults': {
+ 'cflags!': ['-Wl,--exclude-libs,ALL'],
+ 'cflags': [
+ '-fsanitize=address',
+ '-fno-omit-frame-pointer',
+ '-Wno-deprecated-register',
+ '-Wno-inconsistent-missing-override',
+ ],
+ 'ldflags': [
+ '-fsanitize=address',
+ ],
+ },
+ 'make_global_settings': [
+ ['CC','/usr/bin/clang-3.6'],
+ ['CXX','/usr/bin/clang++-3.6'],
+ ['LINK','/usr/bin/clang++-3.6'],
+ ],
+ }],
+ ]
}
diff --git a/src/privet/auth_manager_unittest.cc b/src/privet/auth_manager_unittest.cc
index 66ed8da..a571d4f 100644
--- a/src/privet/auth_manager_unittest.cc
+++ b/src/privet/auth_manager_unittest.cc
@@ -70,8 +70,8 @@
EXPECT_EQ(
"s3GnCThkQXIzGQoPDlJoiehQiJ5yy4SYUVQzMN2kY0o0OjQ1NjoxNDEwMDAwMDAw",
Base64Encode(auth_.CreateAccessToken(UserInfo{AuthScope::kOwner, 456})));
- EXPECT_CALL(clock_, Now())
- .WillRepeatedly(Return(clock_.Now() + base::TimeDelta::FromDays(11)));
+ auto new_time = clock_.Now() + base::TimeDelta::FromDays(11);
+ EXPECT_CALL(clock_, Now()).WillRepeatedly(Return(new_time));
EXPECT_EQ(
"qAmlJykiPTnFljfOKSf3BUII9YZG8/ttzD76q+fII1YyOjM0NToxNDEwOTUwNDAw",
Base64Encode(auth_.CreateAccessToken(UserInfo{AuthScope::kUser, 345})));
@@ -126,8 +126,8 @@
}
TEST_F(AuthManagerTest, GetRootClientAuthTokenDifferentTime) {
- EXPECT_CALL(clock_, Now())
- .WillRepeatedly(Return(clock_.Now() + base::TimeDelta::FromDays(15)));
+ auto new_time = clock_.Now() + base::TimeDelta::FromDays(15);
+ EXPECT_CALL(clock_, Now()).WillRepeatedly(Return(new_time));
EXPECT_EQ("UGKqwMYGQNOd8jeYFDOsM02CQgECRgMaVB6rAA==",
Base64Encode(auth_.GetRootClientAuthToken()));
}