| Index: third_party/crashpad/crashpad/util/mach/exc_server_variants_test.cc
|
| diff --git a/third_party/crashpad/crashpad/util/mach/exc_server_variants_test.cc b/third_party/crashpad/crashpad/util/mach/exc_server_variants_test.cc
|
| index 1a24e698b488868da569bbc37320c0078190dc16..482edac35573f4aad7551773b43ed799bb97e1a0 100644
|
| --- a/third_party/crashpad/crashpad/util/mach/exc_server_variants_test.cc
|
| +++ b/third_party/crashpad/crashpad/util/mach/exc_server_variants_test.cc
|
| @@ -123,26 +123,26 @@ struct __attribute__((packed, aligned(4))) ExceptionRaiseReply {
|
| // MachExceptionRaiseReply. Knowing which behavior is expected allows the
|
| // message ID to be checked.
|
| void Verify(exception_behavior_t behavior) {
|
| - EXPECT_EQ(implicit_cast<mach_msg_bits_t>(
|
| - MACH_MSGH_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE, 0)),
|
| - Head.msgh_bits);
|
| - EXPECT_EQ(sizeof(*this), Head.msgh_size);
|
| - EXPECT_EQ(kClientRemotePort, Head.msgh_remote_port);
|
| - EXPECT_EQ(kMachPortNull, Head.msgh_local_port);
|
| + EXPECT_EQ(Head.msgh_bits,
|
| + implicit_cast<mach_msg_bits_t>(
|
| + MACH_MSGH_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE, 0)));
|
| + EXPECT_EQ(Head.msgh_size, sizeof(*this));
|
| + EXPECT_EQ(Head.msgh_remote_port, kClientRemotePort);
|
| + EXPECT_EQ(Head.msgh_local_port, kMachPortNull);
|
| switch (behavior) {
|
| case EXCEPTION_DEFAULT:
|
| - EXPECT_EQ(2501, Head.msgh_id);
|
| + EXPECT_EQ(Head.msgh_id, 2501);
|
| break;
|
| case EXCEPTION_DEFAULT | kMachExceptionCodes:
|
| - EXPECT_EQ(2505, Head.msgh_id);
|
| + EXPECT_EQ(Head.msgh_id, 2505);
|
| break;
|
| default:
|
| ADD_FAILURE() << "behavior " << behavior << ", Head.msgh_id "
|
| << Head.msgh_id;
|
| break;
|
| }
|
| - EXPECT_EQ(0, memcmp(&NDR, &NDR_record, sizeof(NDR)));
|
| - EXPECT_EQ(KERN_SUCCESS, RetCode);
|
| + EXPECT_EQ(memcmp(&NDR, &NDR_record, sizeof(NDR)), 0);
|
| + EXPECT_EQ(RetCode, KERN_SUCCESS);
|
| }
|
|
|
| mach_msg_header_t Head;
|
| @@ -201,34 +201,34 @@ struct __attribute__((packed, aligned(4))) ExceptionRaiseStateReply {
|
| // MachExceptionRaiseStateIdentityReply. Knowing which behavior is expected
|
| // allows the message ID to be checked.
|
| void Verify(exception_behavior_t behavior) {
|
| - EXPECT_EQ(implicit_cast<mach_msg_bits_t>(
|
| - MACH_MSGH_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE, 0)),
|
| - Head.msgh_bits);
|
| - EXPECT_EQ(sizeof(*this), Head.msgh_size);
|
| - EXPECT_EQ(kClientRemotePort, Head.msgh_remote_port);
|
| - EXPECT_EQ(kMachPortNull, Head.msgh_local_port);
|
| + EXPECT_EQ(Head.msgh_bits,
|
| + implicit_cast<mach_msg_bits_t>(
|
| + MACH_MSGH_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE, 0)));
|
| + EXPECT_EQ(Head.msgh_size, sizeof(*this));
|
| + EXPECT_EQ(Head.msgh_remote_port, kClientRemotePort);
|
| + EXPECT_EQ(Head.msgh_local_port, kMachPortNull);
|
| switch (behavior) {
|
| case EXCEPTION_STATE:
|
| - EXPECT_EQ(2502, Head.msgh_id);
|
| + EXPECT_EQ(Head.msgh_id, 2502);
|
| break;
|
| case EXCEPTION_STATE_IDENTITY:
|
| - EXPECT_EQ(2503, Head.msgh_id);
|
| + EXPECT_EQ(Head.msgh_id, 2503);
|
| break;
|
| case EXCEPTION_STATE | kMachExceptionCodes:
|
| - EXPECT_EQ(2506, Head.msgh_id);
|
| + EXPECT_EQ(Head.msgh_id, 2506);
|
| break;
|
| case EXCEPTION_STATE_IDENTITY | kMachExceptionCodes:
|
| - EXPECT_EQ(2507, Head.msgh_id);
|
| + EXPECT_EQ(Head.msgh_id, 2507);
|
| break;
|
| default:
|
| ADD_FAILURE() << "behavior " << behavior << ", Head.msgh_id "
|
| << Head.msgh_id;
|
| break;
|
| }
|
| - EXPECT_EQ(0, memcmp(&NDR, &NDR_record, sizeof(NDR)));
|
| - EXPECT_EQ(KERN_SUCCESS, RetCode);
|
| - EXPECT_EQ(kThreadStateFlavor, flavor);
|
| - EXPECT_EQ(arraysize(new_state), new_stateCnt);
|
| + EXPECT_EQ(memcmp(&NDR, &NDR_record, sizeof(NDR)), 0);
|
| + EXPECT_EQ(RetCode, KERN_SUCCESS);
|
| + EXPECT_EQ(flavor, kThreadStateFlavor);
|
| + EXPECT_EQ(new_stateCnt, arraysize(new_state));
|
| }
|
|
|
| mach_msg_header_t Head;
|
| @@ -441,15 +441,15 @@ struct BadIDErrorReply : public mig_reply_error_t {
|
| }
|
|
|
| void Verify(mach_msg_id_t id) {
|
| - EXPECT_EQ(implicit_cast<mach_msg_bits_t>(
|
| - MACH_MSGH_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE, 0)),
|
| - Head.msgh_bits);
|
| - EXPECT_EQ(sizeof(*this), Head.msgh_size);
|
| - EXPECT_EQ(kClientRemotePort, Head.msgh_remote_port);
|
| - EXPECT_EQ(kMachPortNull, Head.msgh_local_port);
|
| - EXPECT_EQ(id + 100, Head.msgh_id);
|
| - EXPECT_EQ(0, memcmp(&NDR, &NDR_record, sizeof(NDR)));
|
| - EXPECT_EQ(MIG_BAD_ID, RetCode);
|
| + EXPECT_EQ(Head.msgh_bits,
|
| + implicit_cast<mach_msg_bits_t>(
|
| + MACH_MSGH_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE, 0)));
|
| + EXPECT_EQ(Head.msgh_size, sizeof(*this));
|
| + EXPECT_EQ(Head.msgh_remote_port, kClientRemotePort);
|
| + EXPECT_EQ(Head.msgh_local_port, kMachPortNull);
|
| + EXPECT_EQ(Head.msgh_id, id + 100);
|
| + EXPECT_EQ(memcmp(&NDR, &NDR_record, sizeof(NDR)), 0);
|
| + EXPECT_EQ(RetCode, MIG_BAD_ID);
|
| }
|
| };
|
|
|
| @@ -591,7 +591,7 @@ TEST(ExcServerVariants, MockExceptionRaise) {
|
|
|
| std::set<mach_msg_id_t> ids =
|
| universal_mach_exc_server.MachMessageServerRequestIDs();
|
| - EXPECT_NE(ids.end(), ids.find(2401)); // There is no constant for this.
|
| + EXPECT_NE(ids.find(2401), ids.end()); // There is no constant for this.
|
|
|
| ExceptionRaiseRequest request;
|
| EXPECT_LE(request.Head.msgh_size,
|
| @@ -636,7 +636,7 @@ TEST(ExcServerVariants, MockExceptionRaiseState) {
|
|
|
| std::set<mach_msg_id_t> ids =
|
| universal_mach_exc_server.MachMessageServerRequestIDs();
|
| - EXPECT_NE(ids.end(), ids.find(2402)); // There is no constant for this.
|
| + EXPECT_NE(ids.find(2402), ids.end()); // There is no constant for this.
|
|
|
| ExceptionRaiseStateRequest request;
|
| EXPECT_LE(request.Head.msgh_size,
|
| @@ -685,7 +685,7 @@ TEST(ExcServerVariants, MockExceptionRaiseStateIdentity) {
|
|
|
| std::set<mach_msg_id_t> ids =
|
| universal_mach_exc_server.MachMessageServerRequestIDs();
|
| - EXPECT_NE(ids.end(), ids.find(2403)); // There is no constant for this.
|
| + EXPECT_NE(ids.find(2403), ids.end()); // There is no constant for this.
|
|
|
| ExceptionRaiseStateIdentityRequest request;
|
| EXPECT_LE(request.Head.msgh_size,
|
| @@ -731,7 +731,7 @@ TEST(ExcServerVariants, MockMachExceptionRaise) {
|
|
|
| std::set<mach_msg_id_t> ids =
|
| universal_mach_exc_server.MachMessageServerRequestIDs();
|
| - EXPECT_NE(ids.end(), ids.find(2405)); // There is no constant for this.
|
| + EXPECT_NE(ids.find(2405), ids.end()); // There is no constant for this.
|
|
|
| MachExceptionRaiseRequest request;
|
| EXPECT_LE(request.Head.msgh_size,
|
| @@ -778,7 +778,7 @@ TEST(ExcServerVariants, MockMachExceptionRaiseState) {
|
|
|
| std::set<mach_msg_id_t> ids =
|
| universal_mach_exc_server.MachMessageServerRequestIDs();
|
| - EXPECT_NE(ids.end(), ids.find(2406)); // There is no constant for this.
|
| + EXPECT_NE(ids.find(2406), ids.end()); // There is no constant for this.
|
|
|
| MachExceptionRaiseStateRequest request;
|
| EXPECT_LE(request.Head.msgh_size,
|
| @@ -828,7 +828,7 @@ TEST(ExcServerVariants, MockMachExceptionRaiseStateIdentity) {
|
|
|
| std::set<mach_msg_id_t> ids =
|
| universal_mach_exc_server.MachMessageServerRequestIDs();
|
| - EXPECT_NE(ids.end(), ids.find(2407)); // There is no constant for this.
|
| + EXPECT_NE(ids.find(2407), ids.end()); // There is no constant for this.
|
|
|
| MachExceptionRaiseStateIdentityRequest request;
|
| EXPECT_LE(request.Head.msgh_size,
|
| @@ -913,7 +913,7 @@ TEST(ExcServerVariants, MockUnknownID) {
|
|
|
| std::set<mach_msg_id_t> ids =
|
| universal_mach_exc_server.MachMessageServerRequestIDs();
|
| - EXPECT_EQ(ids.end(), ids.find(id));
|
| + EXPECT_EQ(ids.find(id), ids.end());
|
|
|
| InvalidRequest request(id);
|
| EXPECT_LE(sizeof(request),
|
| @@ -953,8 +953,8 @@ TEST(ExcServerVariants, MachMessageServerRequestIDs) {
|
| MockUniversalMachExcServer server;
|
| UniversalMachExcServer universal_mach_exc_server(&server);
|
|
|
| - EXPECT_EQ(expect_request_ids,
|
| - universal_mach_exc_server.MachMessageServerRequestIDs());
|
| + EXPECT_EQ(universal_mach_exc_server.MachMessageServerRequestIDs(),
|
| + expect_request_ids);
|
| }
|
|
|
| class TestExcServerVariants : public MachMultiprocess,
|
| @@ -992,20 +992,20 @@ class TestExcServerVariants : public MachMultiprocess,
|
| EXPECT_FALSE(handled_);
|
| handled_ = true;
|
|
|
| - EXPECT_EQ(behavior_, behavior);
|
| + EXPECT_EQ(behavior, behavior_);
|
|
|
| - EXPECT_EQ(LocalPort(), exception_port);
|
| + EXPECT_EQ(exception_port, LocalPort());
|
|
|
| if (ExceptionBehaviorHasIdentity(behavior)) {
|
| - EXPECT_NE(THREAD_NULL, thread);
|
| - EXPECT_EQ(ChildTask(), task);
|
| + EXPECT_NE(thread, THREAD_NULL);
|
| + EXPECT_EQ(task, ChildTask());
|
| } else {
|
| - EXPECT_EQ(THREAD_NULL, thread);
|
| - EXPECT_EQ(TASK_NULL, task);
|
| + EXPECT_EQ(thread, THREAD_NULL);
|
| + EXPECT_EQ(task, TASK_NULL);
|
| }
|
|
|
| - EXPECT_EQ(EXC_CRASH, exception);
|
| - EXPECT_EQ(2u, code_count);
|
| + EXPECT_EQ(exception, EXC_CRASH);
|
| + EXPECT_EQ(code_count, 2u);
|
|
|
| // The exception and code_count checks above would ideally use ASSERT_EQ so
|
| // that the next conditional would not be necessary, but ASSERT_* requires a
|
| @@ -1018,24 +1018,25 @@ class TestExcServerVariants : public MachMultiprocess,
|
|
|
| const bool has_state = ExceptionBehaviorHasState(behavior);
|
| if (has_state) {
|
| - EXPECT_EQ(flavor_, *flavor);
|
| - EXPECT_EQ(state_count_, old_state_count);
|
| - EXPECT_NE(nullptr, old_state);
|
| - EXPECT_EQ(implicit_cast<mach_msg_type_number_t>(THREAD_STATE_MAX),
|
| - *new_state_count);
|
| - EXPECT_NE(nullptr, new_state);
|
| + EXPECT_EQ(*flavor, flavor_);
|
| + EXPECT_EQ(old_state_count, state_count_);
|
| + EXPECT_NE(old_state, nullptr);
|
| + EXPECT_EQ(*new_state_count,
|
| + implicit_cast<mach_msg_type_number_t>(THREAD_STATE_MAX));
|
| + EXPECT_NE(new_state, nullptr);
|
| } else {
|
| - EXPECT_EQ(THREAD_STATE_NONE, *flavor);
|
| - EXPECT_EQ(0u, old_state_count);
|
| - EXPECT_EQ(nullptr, old_state);
|
| - EXPECT_EQ(0u, *new_state_count);
|
| - EXPECT_EQ(nullptr, new_state);
|
| + EXPECT_EQ(*flavor, THREAD_STATE_NONE);
|
| + EXPECT_EQ(old_state_count, 0u);
|
| + EXPECT_EQ(old_state, nullptr);
|
| + EXPECT_EQ(*new_state_count, 0u);
|
| + EXPECT_EQ(new_state, nullptr);
|
| }
|
|
|
| - EXPECT_EQ(implicit_cast<mach_msg_trailer_type_t>(MACH_MSG_TRAILER_FORMAT_0),
|
| - trailer->msgh_trailer_type);
|
| - EXPECT_EQ(REQUESTED_TRAILER_SIZE(kMachMessageOptions),
|
| - trailer->msgh_trailer_size);
|
| + EXPECT_EQ(
|
| + trailer->msgh_trailer_type,
|
| + implicit_cast<mach_msg_trailer_type_t>(MACH_MSG_TRAILER_FORMAT_0));
|
| + EXPECT_EQ(trailer->msgh_trailer_size,
|
| + REQUESTED_TRAILER_SIZE(kMachMessageOptions));
|
|
|
| ExcServerCopyState(
|
| behavior, old_state, old_state_count, new_state, new_state_count);
|
| @@ -1056,7 +1057,7 @@ class TestExcServerVariants : public MachMultiprocess,
|
| MachMessageServer::kOneShot,
|
| MachMessageServer::kReceiveLargeError,
|
| kMachMessageTimeoutWaitIndefinitely);
|
| - EXPECT_EQ(KERN_SUCCESS, kr)
|
| + EXPECT_EQ(kr, KERN_SUCCESS)
|
| << MachErrorMessage(kr, "MachMessageServer::Run");
|
|
|
| EXPECT_TRUE(handled_);
|
| @@ -1066,7 +1067,7 @@ class TestExcServerVariants : public MachMultiprocess,
|
| // Set the parent as the exception handler for EXC_CRASH.
|
| kern_return_t kr = task_set_exception_ports(
|
| mach_task_self(), EXC_MASK_CRASH, RemotePort(), behavior_, flavor_);
|
| - ASSERT_EQ(KERN_SUCCESS, kr)
|
| + ASSERT_EQ(kr, KERN_SUCCESS)
|
| << MachErrorMessage(kr, "task_set_exception_ports");
|
|
|
| // Now crash.
|
| @@ -1259,10 +1260,10 @@ TEST(ExcServerVariants, ExcServerSuccessfulReturnValue) {
|
| test_data.behavior,
|
| test_data.set_thread_state ? "true" : "false"));
|
|
|
| - EXPECT_EQ(test_data.kr,
|
| - ExcServerSuccessfulReturnValue(test_data.exception,
|
| + EXPECT_EQ(ExcServerSuccessfulReturnValue(test_data.exception,
|
| test_data.behavior,
|
| - test_data.set_thread_state));
|
| + test_data.set_thread_state),
|
| + test_data.kr);
|
| }
|
| }
|
|
|
| @@ -1280,9 +1281,9 @@ TEST(ExcServerVariants, ExcServerCopyState) {
|
| old_state_count,
|
| new_state,
|
| &new_state_count);
|
| - EXPECT_EQ(arraysize(new_state), new_state_count);
|
| + EXPECT_EQ(new_state_count, arraysize(new_state));
|
| for (size_t i = 0; i < arraysize(new_state); ++i) {
|
| - EXPECT_EQ(0u, new_state[i]) << "i " << i;
|
| + EXPECT_EQ(new_state[i], 0u) << "i " << i;
|
| }
|
|
|
| ExcServerCopyState(MACH_EXCEPTION_CODES | EXCEPTION_DEFAULT,
|
| @@ -1290,21 +1291,21 @@ TEST(ExcServerVariants, ExcServerCopyState) {
|
| old_state_count,
|
| new_state,
|
| &new_state_count);
|
| - EXPECT_EQ(arraysize(new_state), new_state_count);
|
| + EXPECT_EQ(new_state_count, arraysize(new_state));
|
| for (size_t i = 0; i < arraysize(new_state); ++i) {
|
| - EXPECT_EQ(0u, new_state[i]) << "i " << i;
|
| + EXPECT_EQ(new_state[i], 0u) << "i " << i;
|
| }
|
|
|
| // This is a state-carrying exception where old_state_count is small.
|
| mach_msg_type_number_t copy_limit = 2;
|
| ExcServerCopyState(
|
| EXCEPTION_STATE, old_state, copy_limit, new_state, &new_state_count);
|
| - EXPECT_EQ(copy_limit, new_state_count);
|
| + EXPECT_EQ(new_state_count, copy_limit);
|
| for (size_t i = 0; i < copy_limit; ++i) {
|
| - EXPECT_EQ(old_state[i], new_state[i]) << "i " << i;
|
| + EXPECT_EQ(new_state[i], old_state[i]) << "i " << i;
|
| }
|
| for (size_t i = copy_limit; i < arraysize(new_state); ++i) {
|
| - EXPECT_EQ(0u, new_state[i]) << "i " << i;
|
| + EXPECT_EQ(new_state[i], 0u) << "i " << i;
|
| }
|
|
|
| // This is a state-carrying exception where new_state_count is small.
|
| @@ -1315,12 +1316,12 @@ TEST(ExcServerVariants, ExcServerCopyState) {
|
| old_state_count,
|
| new_state,
|
| &new_state_count);
|
| - EXPECT_EQ(copy_limit, new_state_count);
|
| + EXPECT_EQ(new_state_count, copy_limit);
|
| for (size_t i = 0; i < copy_limit; ++i) {
|
| - EXPECT_EQ(old_state[i], new_state[i]) << "i " << i;
|
| + EXPECT_EQ(new_state[i], old_state[i]) << "i " << i;
|
| }
|
| for (size_t i = copy_limit; i < arraysize(new_state); ++i) {
|
| - EXPECT_EQ(0u, new_state[i]) << "i " << i;
|
| + EXPECT_EQ(new_state[i], 0u) << "i " << i;
|
| }
|
|
|
| // This is a state-carrying exception where all of old_state is copied to
|
| @@ -1331,12 +1332,12 @@ TEST(ExcServerVariants, ExcServerCopyState) {
|
| old_state_count,
|
| new_state,
|
| &new_state_count);
|
| - EXPECT_EQ(old_state_count, new_state_count);
|
| + EXPECT_EQ(new_state_count, old_state_count);
|
| for (size_t i = 0; i < arraysize(old_state); ++i) {
|
| - EXPECT_EQ(old_state[i], new_state[i]) << "i " << i;
|
| + EXPECT_EQ(new_state[i], old_state[i]) << "i " << i;
|
| }
|
| for (size_t i = arraysize(old_state); i < arraysize(new_state); ++i) {
|
| - EXPECT_EQ(0u, new_state[i]) << "i " << i;
|
| + EXPECT_EQ(new_state[i], 0u) << "i " << i;
|
| }
|
| }
|
|
|
|
|