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, |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 // See the License for the specific language governing permissions and | 12 // See the License for the specific language governing permissions and |
13 // limitations under the License. | 13 // limitations under the License. |
14 | 14 |
15 #include "util/mach/mach_extensions.h" | 15 #include "util/mach/mach_extensions.h" |
16 | 16 |
17 #include "base/mac/scoped_mach_port.h" | 17 #include "base/mac/scoped_mach_port.h" |
18 #include "base/rand_util.h" | |
19 #include "gtest/gtest.h" | 18 #include "gtest/gtest.h" |
20 #include "test/mac/mach_errors.h" | 19 #include "test/mac/mach_errors.h" |
21 #include "util/mac/mac_util.h" | 20 #include "util/mac/mac_util.h" |
| 21 #include "util/misc/random_string.h" |
22 | 22 |
23 namespace crashpad { | 23 namespace crashpad { |
24 namespace test { | 24 namespace test { |
25 namespace { | 25 namespace { |
26 | 26 |
27 TEST(MachExtensions, MachThreadSelf) { | 27 TEST(MachExtensions, MachThreadSelf) { |
28 base::mac::ScopedMachSendRight thread_self(mach_thread_self()); | 28 base::mac::ScopedMachSendRight thread_self(mach_thread_self()); |
29 EXPECT_EQ(thread_self, MachThreadSelf()); | 29 EXPECT_EQ(thread_self, MachThreadSelf()); |
30 } | 30 } |
31 | 31 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 EXPECT_TRUE(ExcMaskValid() & ~ExcMaskAll()); | 132 EXPECT_TRUE(ExcMaskValid() & ~ExcMaskAll()); |
133 } | 133 } |
134 | 134 |
135 TEST(MachExtensions, BootstrapCheckInAndLookUp) { | 135 TEST(MachExtensions, BootstrapCheckInAndLookUp) { |
136 // This should always exist. | 136 // This should always exist. |
137 base::mac::ScopedMachSendRight | 137 base::mac::ScopedMachSendRight |
138 report_crash(BootstrapLookUp("com.apple.ReportCrash")); | 138 report_crash(BootstrapLookUp("com.apple.ReportCrash")); |
139 EXPECT_NE(report_crash, kMachPortNull); | 139 EXPECT_NE(report_crash, kMachPortNull); |
140 | 140 |
141 std::string service_name = "org.chromium.crashpad.test.bootstrap_check_in."; | 141 std::string service_name = "org.chromium.crashpad.test.bootstrap_check_in."; |
142 for (int index = 0; index < 16; ++index) { | 142 service_name.append(RandomString()); |
143 service_name.append(1, base::RandInt('A', 'Z')); | |
144 } | |
145 | 143 |
146 { | 144 { |
147 // The new service hasn’t checked in yet, so this should fail. | 145 // The new service hasn’t checked in yet, so this should fail. |
148 base::mac::ScopedMachSendRight send(BootstrapLookUp(service_name)); | 146 base::mac::ScopedMachSendRight send(BootstrapLookUp(service_name)); |
149 EXPECT_EQ(kMachPortNull, send); | 147 EXPECT_EQ(kMachPortNull, send); |
150 | 148 |
151 // Check it in. | 149 // Check it in. |
152 base::mac::ScopedMachReceiveRight receive(BootstrapCheckIn(service_name)); | 150 base::mac::ScopedMachReceiveRight receive(BootstrapCheckIn(service_name)); |
153 EXPECT_NE(receive, kMachPortNull); | 151 EXPECT_NE(receive, kMachPortNull); |
154 | 152 |
(...skipping 17 matching lines...) Expand all Loading... |
172 | 170 |
173 TEST(MachExtensions, SystemCrashReporterHandler) { | 171 TEST(MachExtensions, SystemCrashReporterHandler) { |
174 base::mac::ScopedMachSendRight | 172 base::mac::ScopedMachSendRight |
175 system_crash_reporter_handler(SystemCrashReporterHandler()); | 173 system_crash_reporter_handler(SystemCrashReporterHandler()); |
176 EXPECT_TRUE(system_crash_reporter_handler.is_valid()); | 174 EXPECT_TRUE(system_crash_reporter_handler.is_valid()); |
177 } | 175 } |
178 | 176 |
179 } // namespace | 177 } // namespace |
180 } // namespace test | 178 } // namespace test |
181 } // namespace crashpad | 179 } // namespace crashpad |
OLD | NEW |