2014-12-04 16:45:02 -05:00
|
|
|
|
// Copyright 2014 The Crashpad Authors. All rights reserved.
|
|
|
|
|
//
|
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
|
//
|
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
//
|
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
|
|
#include "util/mach/composite_mach_message_server.h"
|
|
|
|
|
|
2016-01-06 12:22:50 -05:00
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
2014-12-04 16:45:02 -05:00
|
|
|
|
#include "base/strings/stringprintf.h"
|
|
|
|
|
#include "gtest/gtest.h"
|
mac: Tests that crash intentionally shouldn’t go to ReportCrash
Crashpad has many tests that crash intentionally. Some of these are
gtest death tests, and others arrange for intentional crashes to test
Crashpad’s own crash-catching logic. On macOS, all of the gtest death
tests and some of the other intentional crashes were being logged by
ReportCrash, the system’s crash reporter. Since these reports
corresponded to intentional crashes, they were never useful, and served
only to clutter ~/Library/Logs/DiagnosticReports.
Since Crashpad is adept at handling exceptions on its own, this
introduces the “exception swallowing server”,
crashpad_exception_swallower, which is a Mach exception server that
implements a no-op exception handler routine for all exceptions
received. The exception swallowing server is established as the task
handler for EXC_CRASH and EXC_CORPSE_NOTIFY exceptions during gtest
death tests invoked by {ASSERT,EXPECT}_DEATH_{CHECK,CRASH}, and for all
child processes invoked by the Multiprocess test infrastructure. The
exception swallowing server is not in effect at other times, so
unexpected crashes in test code can still be handled by ReportCrash or
another crash reporter.
With this change in place, no new reports are generated in the
user-level ~/Library/Logs/DiagnosticReports or the system’s
/Library/Logs/DiagnosticReports during a run of Crashpad’s full test
suite on macOS.
Bug: crashpad:33
Change-Id: I13891853a7e25accc30da21fa7ea8bd7d1f3bd2f
Reviewed-on: https://chromium-review.googlesource.com/777859
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2017-11-20 13:32:26 -05:00
|
|
|
|
#include "test/gtest_death.h"
|
2014-12-04 16:45:02 -05:00
|
|
|
|
#include "util/mach/mach_message.h"
|
|
|
|
|
|
|
|
|
|
namespace crashpad {
|
|
|
|
|
namespace test {
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
TEST(CompositeMachMessageServer, Empty) {
|
|
|
|
|
CompositeMachMessageServer server;
|
|
|
|
|
|
|
|
|
|
EXPECT_TRUE(server.MachMessageServerRequestIDs().empty());
|
|
|
|
|
|
|
|
|
|
mach_msg_empty_rcv_t request = {};
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
|
EXPECT_EQ(server.MachMessageServerRequestSize(), sizeof(request.header));
|
2014-12-04 16:45:02 -05:00
|
|
|
|
|
|
|
|
|
mig_reply_error_t reply = {};
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
|
EXPECT_EQ(server.MachMessageServerReplySize(), sizeof(reply));
|
2014-12-04 16:45:02 -05:00
|
|
|
|
|
|
|
|
|
bool destroy_complex_request = false;
|
|
|
|
|
EXPECT_FALSE(server.MachMessageServerFunction(
|
|
|
|
|
&request.header, &reply.Head, &destroy_complex_request));
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
|
EXPECT_EQ(reply.RetCode, MIG_BAD_ID);
|
2014-12-04 16:45:02 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class TestMachMessageHandler : public MachMessageServer::Interface {
|
|
|
|
|
public:
|
|
|
|
|
TestMachMessageHandler()
|
|
|
|
|
: MachMessageServer::Interface(),
|
|
|
|
|
request_ids_(),
|
|
|
|
|
request_size_(0),
|
|
|
|
|
reply_size_(0),
|
|
|
|
|
return_code_(KERN_FAILURE),
|
|
|
|
|
return_value_(false),
|
|
|
|
|
destroy_complex_request_(false) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
~TestMachMessageHandler() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SetReturnCodes(bool return_value,
|
|
|
|
|
kern_return_t return_code,
|
|
|
|
|
bool destroy_complex_request) {
|
|
|
|
|
return_value_ = return_value;
|
|
|
|
|
return_code_ = return_code;
|
|
|
|
|
destroy_complex_request_ = destroy_complex_request;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AddRequestID(mach_msg_id_t request_id) {
|
|
|
|
|
request_ids_.insert(request_id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SetRequestSize(mach_msg_size_t request_size) {
|
|
|
|
|
request_size_ = request_size;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SetReplySize(mach_msg_size_t reply_size) {
|
|
|
|
|
reply_size_ = reply_size;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// MachMessageServer::Interface:
|
|
|
|
|
|
|
|
|
|
bool MachMessageServerFunction(const mach_msg_header_t* in,
|
|
|
|
|
mach_msg_header_t* out,
|
|
|
|
|
bool* destroy_complex_request) override {
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
|
EXPECT_NE(request_ids_.find(in->msgh_id), request_ids_.end());
|
2014-12-04 16:45:02 -05:00
|
|
|
|
|
|
|
|
|
*destroy_complex_request = destroy_complex_request_;
|
|
|
|
|
PrepareMIGReplyFromRequest(in, out);
|
|
|
|
|
SetMIGReplyError(out, return_code_);
|
|
|
|
|
return return_value_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::set<mach_msg_id_t> MachMessageServerRequestIDs() override {
|
|
|
|
|
return request_ids_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mach_msg_size_t MachMessageServerRequestSize() override {
|
|
|
|
|
return request_size_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mach_msg_size_t MachMessageServerReplySize() override {
|
|
|
|
|
return reply_size_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
std::set<mach_msg_id_t> request_ids_;
|
|
|
|
|
mach_msg_size_t request_size_;
|
|
|
|
|
mach_msg_size_t reply_size_;
|
|
|
|
|
kern_return_t return_code_;
|
|
|
|
|
bool return_value_;
|
|
|
|
|
bool destroy_complex_request_;
|
|
|
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(TestMachMessageHandler);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
TEST(CompositeMachMessageServer, HandlerDoesNotHandle) {
|
|
|
|
|
TestMachMessageHandler handler;
|
|
|
|
|
|
|
|
|
|
CompositeMachMessageServer server;
|
|
|
|
|
server.AddHandler(&handler);
|
|
|
|
|
|
|
|
|
|
EXPECT_TRUE(server.MachMessageServerRequestIDs().empty());
|
|
|
|
|
|
|
|
|
|
mach_msg_empty_rcv_t request = {};
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
|
EXPECT_EQ(server.MachMessageServerRequestSize(), sizeof(request.header));
|
2014-12-04 16:45:02 -05:00
|
|
|
|
|
|
|
|
|
mig_reply_error_t reply = {};
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
|
EXPECT_EQ(server.MachMessageServerReplySize(), sizeof(reply));
|
2014-12-04 16:45:02 -05:00
|
|
|
|
|
|
|
|
|
bool destroy_complex_request = false;
|
|
|
|
|
EXPECT_FALSE(server.MachMessageServerFunction(
|
|
|
|
|
&request.header, &reply.Head, &destroy_complex_request));
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
|
EXPECT_EQ(reply.RetCode, MIG_BAD_ID);
|
2014-12-04 16:45:02 -05:00
|
|
|
|
EXPECT_FALSE(destroy_complex_request);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(CompositeMachMessageServer, OneHandler) {
|
2017-07-25 19:15:48 -04:00
|
|
|
|
constexpr mach_msg_id_t kRequestID = 100;
|
|
|
|
|
constexpr mach_msg_size_t kRequestSize = 256;
|
|
|
|
|
constexpr mach_msg_size_t kReplySize = 128;
|
|
|
|
|
constexpr kern_return_t kReturnCode = KERN_SUCCESS;
|
2014-12-04 16:45:02 -05:00
|
|
|
|
|
|
|
|
|
TestMachMessageHandler handler;
|
|
|
|
|
handler.AddRequestID(kRequestID);
|
|
|
|
|
handler.SetRequestSize(kRequestSize);
|
|
|
|
|
handler.SetReplySize(kReplySize);
|
|
|
|
|
handler.SetReturnCodes(true, kReturnCode, true);
|
|
|
|
|
|
|
|
|
|
CompositeMachMessageServer server;
|
|
|
|
|
|
|
|
|
|
// The chosen request and reply sizes must be larger than the defaults for
|
|
|
|
|
// that portion fo the test to be valid.
|
|
|
|
|
EXPECT_GT(kRequestSize, server.MachMessageServerRequestSize());
|
|
|
|
|
EXPECT_GT(kReplySize, server.MachMessageServerReplySize());
|
|
|
|
|
|
|
|
|
|
server.AddHandler(&handler);
|
|
|
|
|
|
|
|
|
|
std::set<mach_msg_id_t> expect_request_ids;
|
|
|
|
|
expect_request_ids.insert(kRequestID);
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
|
EXPECT_EQ(server.MachMessageServerRequestIDs(), expect_request_ids);
|
2014-12-04 16:45:02 -05:00
|
|
|
|
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
|
EXPECT_EQ(server.MachMessageServerRequestSize(), kRequestSize);
|
|
|
|
|
EXPECT_EQ(server.MachMessageServerReplySize(), kReplySize);
|
2014-12-04 16:45:02 -05:00
|
|
|
|
|
|
|
|
|
mach_msg_empty_rcv_t request = {};
|
|
|
|
|
mig_reply_error_t reply = {};
|
|
|
|
|
|
|
|
|
|
// Send a message with an unknown request ID.
|
|
|
|
|
request.header.msgh_id = 0;
|
|
|
|
|
bool destroy_complex_request = false;
|
|
|
|
|
EXPECT_FALSE(server.MachMessageServerFunction(
|
|
|
|
|
&request.header, &reply.Head, &destroy_complex_request));
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
|
EXPECT_EQ(reply.RetCode, MIG_BAD_ID);
|
2014-12-04 16:45:02 -05:00
|
|
|
|
EXPECT_FALSE(destroy_complex_request);
|
|
|
|
|
|
|
|
|
|
// Send a message with a known request ID.
|
|
|
|
|
request.header.msgh_id = kRequestID;
|
|
|
|
|
EXPECT_TRUE(server.MachMessageServerFunction(
|
|
|
|
|
&request.header, &reply.Head, &destroy_complex_request));
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
|
EXPECT_EQ(reply.RetCode, kReturnCode);
|
2014-12-04 16:45:02 -05:00
|
|
|
|
EXPECT_TRUE(destroy_complex_request);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(CompositeMachMessageServer, ThreeHandlers) {
|
2017-07-25 13:34:04 -04:00
|
|
|
|
static constexpr mach_msg_id_t kRequestIDs0[] = {5};
|
2017-07-25 19:15:48 -04:00
|
|
|
|
constexpr kern_return_t kReturnCode0 = KERN_SUCCESS;
|
2014-12-04 16:45:02 -05:00
|
|
|
|
|
2017-07-25 13:34:04 -04:00
|
|
|
|
static constexpr mach_msg_id_t kRequestIDs1[] = {4, 7};
|
2017-07-25 19:15:48 -04:00
|
|
|
|
constexpr kern_return_t kReturnCode1 = KERN_PROTECTION_FAILURE;
|
2014-12-04 16:45:02 -05:00
|
|
|
|
|
2017-07-25 13:34:04 -04:00
|
|
|
|
static constexpr mach_msg_id_t kRequestIDs2[] = {10, 0, 20};
|
2017-07-25 19:15:48 -04:00
|
|
|
|
constexpr mach_msg_size_t kRequestSize2 = 6144;
|
|
|
|
|
constexpr mach_msg_size_t kReplySize2 = 16384;
|
|
|
|
|
constexpr kern_return_t kReturnCode2 = KERN_NOT_RECEIVER;
|
2014-12-04 16:45:02 -05:00
|
|
|
|
|
|
|
|
|
TestMachMessageHandler handlers[3];
|
|
|
|
|
std::set<mach_msg_id_t> expect_request_ids;
|
|
|
|
|
|
|
|
|
|
for (size_t index = 0; index < arraysize(kRequestIDs0); ++index) {
|
|
|
|
|
const mach_msg_id_t request_id = kRequestIDs0[index];
|
|
|
|
|
handlers[0].AddRequestID(request_id);
|
|
|
|
|
expect_request_ids.insert(request_id);
|
|
|
|
|
}
|
|
|
|
|
handlers[0].SetRequestSize(sizeof(mach_msg_header_t));
|
|
|
|
|
handlers[0].SetReplySize(sizeof(mig_reply_error_t));
|
|
|
|
|
handlers[0].SetReturnCodes(true, kReturnCode0, false);
|
|
|
|
|
|
|
|
|
|
for (size_t index = 0; index < arraysize(kRequestIDs1); ++index) {
|
|
|
|
|
const mach_msg_id_t request_id = kRequestIDs1[index];
|
|
|
|
|
handlers[1].AddRequestID(request_id);
|
|
|
|
|
expect_request_ids.insert(request_id);
|
|
|
|
|
}
|
|
|
|
|
handlers[1].SetRequestSize(100);
|
|
|
|
|
handlers[1].SetReplySize(200);
|
|
|
|
|
handlers[1].SetReturnCodes(false, kReturnCode1, true);
|
|
|
|
|
|
|
|
|
|
for (size_t index = 0; index < arraysize(kRequestIDs2); ++index) {
|
|
|
|
|
const mach_msg_id_t request_id = kRequestIDs2[index];
|
|
|
|
|
handlers[2].AddRequestID(request_id);
|
|
|
|
|
expect_request_ids.insert(request_id);
|
|
|
|
|
}
|
|
|
|
|
handlers[2].SetRequestSize(kRequestSize2);
|
|
|
|
|
handlers[2].SetReplySize(kReplySize2);
|
|
|
|
|
handlers[2].SetReturnCodes(true, kReturnCode2, true);
|
|
|
|
|
|
|
|
|
|
CompositeMachMessageServer server;
|
|
|
|
|
|
|
|
|
|
// The chosen request and reply sizes must be larger than the defaults for
|
|
|
|
|
// that portion fo the test to be valid.
|
|
|
|
|
EXPECT_GT(kRequestSize2, server.MachMessageServerRequestSize());
|
|
|
|
|
EXPECT_GT(kReplySize2, server.MachMessageServerReplySize());
|
|
|
|
|
|
|
|
|
|
server.AddHandler(&handlers[0]);
|
|
|
|
|
server.AddHandler(&handlers[1]);
|
|
|
|
|
server.AddHandler(&handlers[2]);
|
|
|
|
|
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
|
EXPECT_EQ(server.MachMessageServerRequestIDs(), expect_request_ids);
|
2014-12-04 16:45:02 -05:00
|
|
|
|
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
|
EXPECT_EQ(server.MachMessageServerRequestSize(), kRequestSize2);
|
|
|
|
|
EXPECT_EQ(server.MachMessageServerReplySize(), kReplySize2);
|
2014-12-04 16:45:02 -05:00
|
|
|
|
|
|
|
|
|
mach_msg_empty_rcv_t request = {};
|
|
|
|
|
mig_reply_error_t reply = {};
|
|
|
|
|
|
|
|
|
|
// Send a message with an unknown request ID.
|
|
|
|
|
request.header.msgh_id = 100;
|
|
|
|
|
bool destroy_complex_request = false;
|
|
|
|
|
EXPECT_FALSE(server.MachMessageServerFunction(
|
|
|
|
|
&request.header, &reply.Head, &destroy_complex_request));
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
|
EXPECT_EQ(reply.RetCode, MIG_BAD_ID);
|
2014-12-04 16:45:02 -05:00
|
|
|
|
EXPECT_FALSE(destroy_complex_request);
|
|
|
|
|
|
|
|
|
|
// Send messages with known request IDs.
|
|
|
|
|
|
|
|
|
|
for (size_t index = 0; index < arraysize(kRequestIDs0); ++index) {
|
|
|
|
|
request.header.msgh_id = kRequestIDs0[index];
|
|
|
|
|
SCOPED_TRACE(base::StringPrintf(
|
|
|
|
|
"handler 0, index %zu, id %d", index, request.header.msgh_id));
|
|
|
|
|
|
|
|
|
|
EXPECT_TRUE(server.MachMessageServerFunction(
|
|
|
|
|
&request.header, &reply.Head, &destroy_complex_request));
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
|
EXPECT_EQ(reply.RetCode, kReturnCode0);
|
2014-12-04 16:45:02 -05:00
|
|
|
|
EXPECT_FALSE(destroy_complex_request);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (size_t index = 0; index < arraysize(kRequestIDs1); ++index) {
|
|
|
|
|
request.header.msgh_id = kRequestIDs1[index];
|
|
|
|
|
SCOPED_TRACE(base::StringPrintf(
|
|
|
|
|
"handler 1, index %zu, id %d", index, request.header.msgh_id));
|
|
|
|
|
|
|
|
|
|
EXPECT_FALSE(server.MachMessageServerFunction(
|
|
|
|
|
&request.header, &reply.Head, &destroy_complex_request));
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
|
EXPECT_EQ(reply.RetCode, kReturnCode1);
|
2014-12-04 16:45:02 -05:00
|
|
|
|
EXPECT_TRUE(destroy_complex_request);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (size_t index = 0; index < arraysize(kRequestIDs2); ++index) {
|
|
|
|
|
request.header.msgh_id = kRequestIDs2[index];
|
|
|
|
|
SCOPED_TRACE(base::StringPrintf(
|
|
|
|
|
"handler 2, index %zu, id %d", index, request.header.msgh_id));
|
|
|
|
|
|
|
|
|
|
EXPECT_TRUE(server.MachMessageServerFunction(
|
|
|
|
|
&request.header, &reply.Head, &destroy_complex_request));
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
|
EXPECT_EQ(reply.RetCode, kReturnCode2);
|
2014-12-04 16:45:02 -05:00
|
|
|
|
EXPECT_TRUE(destroy_complex_request);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// CompositeMachMessageServer can’t deal with two handlers that want to handle
|
|
|
|
|
// the same request ID.
|
|
|
|
|
TEST(CompositeMachMessageServerDeathTest, DuplicateRequestID) {
|
2017-07-25 19:15:48 -04:00
|
|
|
|
constexpr mach_msg_id_t kRequestID = 400;
|
2014-12-04 16:45:02 -05:00
|
|
|
|
|
|
|
|
|
TestMachMessageHandler handlers[2];
|
|
|
|
|
handlers[0].AddRequestID(kRequestID);
|
|
|
|
|
handlers[1].AddRequestID(kRequestID);
|
|
|
|
|
|
|
|
|
|
CompositeMachMessageServer server;
|
|
|
|
|
|
|
|
|
|
server.AddHandler(&handlers[0]);
|
2015-03-09 18:02:14 -04:00
|
|
|
|
EXPECT_DEATH_CHECK(server.AddHandler(&handlers[1]), "duplicate request ID");
|
2014-12-04 16:45:02 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
} // namespace test
|
|
|
|
|
} // namespace crashpad
|