| OLD | NEW |
| 1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 74 |
| 75 EXPECT_EQ(kExceptionMask, crash_handler[0].mask); | 75 EXPECT_EQ(kExceptionMask, crash_handler[0].mask); |
| 76 EXPECT_EQ(expect_port, crash_handler[0].port); | 76 EXPECT_EQ(expect_port, crash_handler[0].port); |
| 77 EXPECT_EQ(expect_behavior, crash_handler[0].behavior); | 77 EXPECT_EQ(expect_behavior, crash_handler[0].behavior); |
| 78 EXPECT_EQ(expect_flavor, crash_handler[0].flavor); | 78 EXPECT_EQ(expect_flavor, crash_handler[0].flavor); |
| 79 } else { | 79 } else { |
| 80 EXPECT_TRUE(crash_handler.empty()); | 80 EXPECT_TRUE(crash_handler.empty()); |
| 81 } | 81 } |
| 82 | 82 |
| 83 std::vector<ExceptionPorts::ExceptionHandler> handlers; | 83 std::vector<ExceptionPorts::ExceptionHandler> handlers; |
| 84 ASSERT_TRUE(exception_ports.GetExceptionPorts( | 84 ASSERT_TRUE(exception_ports.GetExceptionPorts(ExcMaskValid(), &handlers)); |
| 85 ExcMaskAll() | EXC_MASK_CRASH, &handlers)); | |
| 86 | 85 |
| 87 EXPECT_GE(handlers.size(), crash_handler.size()); | 86 EXPECT_GE(handlers.size(), crash_handler.size()); |
| 88 bool found = false; | 87 bool found = false; |
| 89 for (const ExceptionPorts::ExceptionHandler& handler : handlers) { | 88 for (const ExceptionPorts::ExceptionHandler& handler : handlers) { |
| 90 if ((handler.mask & kExceptionMask) != 0) { | 89 if ((handler.mask & kExceptionMask) != 0) { |
| 91 base::mac::ScopedMachSendRight port_owner(handler.port); | 90 base::mac::ScopedMachSendRight port_owner(handler.port); |
| 92 | 91 |
| 93 EXPECT_FALSE(found); | 92 EXPECT_FALSE(found); |
| 94 found = true; | 93 found = true; |
| 95 EXPECT_EQ(expect_port, handler.port); | 94 EXPECT_EQ(expect_port, handler.port); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 ExcCrashRecoverOriginalException(code[0], nullptr, &signal); | 192 ExcCrashRecoverOriginalException(code[0], nullptr, &signal); |
| 194 | 193 |
| 195 // The child crashed with __builtin_trap(), which shows up as SIGILL. | 194 // The child crashed with __builtin_trap(), which shows up as SIGILL. |
| 196 EXPECT_EQ(SIGILL, signal); | 195 EXPECT_EQ(SIGILL, signal); |
| 197 | 196 |
| 198 SetExpectedChildTermination(kTerminationSignal, signal); | 197 SetExpectedChildTermination(kTerminationSignal, signal); |
| 199 } | 198 } |
| 200 | 199 |
| 201 EXPECT_EQ(0, AuditPIDFromMachMessageTrailer(trailer)); | 200 EXPECT_EQ(0, AuditPIDFromMachMessageTrailer(trailer)); |
| 202 | 201 |
| 203 return ExcServerSuccessfulReturnValue(behavior, false); | 202 ExcServerCopyState( |
| 203 behavior, old_state, old_state_count, new_state, new_state_count); |
| 204 return ExcServerSuccessfulReturnValue(exception, behavior, false); |
| 204 } | 205 } |
| 205 | 206 |
| 206 private: | 207 private: |
| 207 class Child { | 208 class Child { |
| 208 public: | 209 public: |
| 209 explicit Child(TestExceptionPorts* test_exception_ports) | 210 explicit Child(TestExceptionPorts* test_exception_ports) |
| 210 : test_exception_ports_(test_exception_ports), | 211 : test_exception_ports_(test_exception_ports), |
| 211 thread_(), | 212 thread_(), |
| 212 init_semaphore_(0), | 213 init_semaphore_(0), |
| 213 crash_semaphore_(0) {} | 214 crash_semaphore_(0) {} |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 // looking for a KERN_INVALID_ARGUMENT return value. Or, on the off chance | 584 // looking for a KERN_INVALID_ARGUMENT return value. Or, on the off chance |
| 584 // that the test is being run as root, just look for KERN_SUCCESS. | 585 // that the test is being run as root, just look for KERN_SUCCESS. |
| 585 // host_set_exception_ports() is not tested, because if the test were running | 586 // host_set_exception_ports() is not tested, because if the test were running |
| 586 // as root and the call succeeded, it would have global effects. | 587 // as root and the call succeeded, it would have global effects. |
| 587 | 588 |
| 588 base::mac::ScopedMachSendRight host(mach_host_self()); | 589 base::mac::ScopedMachSendRight host(mach_host_self()); |
| 589 ExceptionPorts explicit_host_ports(ExceptionPorts::kTargetTypeHost, host); | 590 ExceptionPorts explicit_host_ports(ExceptionPorts::kTargetTypeHost, host); |
| 590 EXPECT_STREQ("host", explicit_host_ports.TargetTypeName()); | 591 EXPECT_STREQ("host", explicit_host_ports.TargetTypeName()); |
| 591 | 592 |
| 592 std::vector<ExceptionPorts::ExceptionHandler> handlers; | 593 std::vector<ExceptionPorts::ExceptionHandler> handlers; |
| 593 bool rv = explicit_host_ports.GetExceptionPorts( | 594 bool rv = explicit_host_ports.GetExceptionPorts(ExcMaskValid(), &handlers); |
| 594 ExcMaskAll() | EXC_MASK_CRASH, &handlers); | |
| 595 if (geteuid() == 0) { | 595 if (geteuid() == 0) { |
| 596 EXPECT_TRUE(rv); | 596 EXPECT_TRUE(rv); |
| 597 } else { | 597 } else { |
| 598 EXPECT_FALSE(rv); | 598 EXPECT_FALSE(rv); |
| 599 } | 599 } |
| 600 | 600 |
| 601 ExceptionPorts implicit_host_ports(ExceptionPorts::kTargetTypeHost, | 601 ExceptionPorts implicit_host_ports(ExceptionPorts::kTargetTypeHost, |
| 602 HOST_NULL); | 602 HOST_NULL); |
| 603 EXPECT_STREQ("host", implicit_host_ports.TargetTypeName()); | 603 EXPECT_STREQ("host", implicit_host_ports.TargetTypeName()); |
| 604 | 604 |
| 605 rv = implicit_host_ports.GetExceptionPorts( | 605 rv = implicit_host_ports.GetExceptionPorts(ExcMaskValid(), &handlers); |
| 606 ExcMaskAll() | EXC_MASK_CRASH, &handlers); | |
| 607 if (geteuid() == 0) { | 606 if (geteuid() == 0) { |
| 608 EXPECT_TRUE(rv); | 607 EXPECT_TRUE(rv); |
| 609 } else { | 608 } else { |
| 610 EXPECT_FALSE(rv); | 609 EXPECT_FALSE(rv); |
| 611 } | 610 } |
| 612 } | 611 } |
| 613 | 612 |
| 614 } // namespace | 613 } // namespace |
| 615 } // namespace test | 614 } // namespace test |
| 616 } // namespace crashpad | 615 } // namespace crashpad |
| OLD | NEW |