OLD | NEW |
1 // Copyright 2015 The Crashpad Authors. All rights reserved. | 1 // Copyright 2015 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 | 95 |
96 TEST(ExceptionTypes, IsExceptionNonfatalResource) { | 96 TEST(ExceptionTypes, IsExceptionNonfatalResource) { |
97 const pid_t pid = getpid(); | 97 const pid_t pid = getpid(); |
98 | 98 |
99 mach_exception_code_t code = 0; | 99 mach_exception_code_t code = 0; |
100 EXC_RESOURCE_ENCODE_TYPE(code, RESOURCE_TYPE_CPU); | 100 EXC_RESOURCE_ENCODE_TYPE(code, RESOURCE_TYPE_CPU); |
101 EXC_RESOURCE_ENCODE_FLAVOR(code, FLAVOR_CPU_MONITOR); | 101 EXC_RESOURCE_ENCODE_FLAVOR(code, FLAVOR_CPU_MONITOR); |
102 EXPECT_TRUE(IsExceptionNonfatalResource(EXC_RESOURCE, code, pid)); | 102 EXPECT_TRUE(IsExceptionNonfatalResource(EXC_RESOURCE, code, pid)); |
103 | 103 |
104 if (MacOSXMinorVersion() >= 10) { | 104 if (MacOSXMinorVersion() >= 10) { |
105 // FLAVOR_CPU_MONITOR_FATAL was introduced in Mac OS X 10.10. | 105 // FLAVOR_CPU_MONITOR_FATAL was introduced in OS X 10.10. |
106 code = 0; | 106 code = 0; |
107 EXC_RESOURCE_ENCODE_TYPE(code, RESOURCE_TYPE_CPU); | 107 EXC_RESOURCE_ENCODE_TYPE(code, RESOURCE_TYPE_CPU); |
108 EXC_RESOURCE_ENCODE_FLAVOR(code, FLAVOR_CPU_MONITOR_FATAL); | 108 EXC_RESOURCE_ENCODE_FLAVOR(code, FLAVOR_CPU_MONITOR_FATAL); |
109 EXPECT_FALSE(IsExceptionNonfatalResource(EXC_RESOURCE, code, pid)); | 109 EXPECT_FALSE(IsExceptionNonfatalResource(EXC_RESOURCE, code, pid)); |
110 } | 110 } |
111 | 111 |
112 // This assumes that WAKEMON_MAKE_FATAL is not set for this process. The | 112 // This assumes that WAKEMON_MAKE_FATAL is not set for this process. The |
113 // default is for WAKEMON_MAKE_FATAL to not be set, there’s no public API to | 113 // default is for WAKEMON_MAKE_FATAL to not be set, there’s no public API to |
114 // enable it, and nothing in this process should have enabled it. | 114 // enable it, and nothing in this process should have enabled it. |
115 code = 0; | 115 code = 0; |
(...skipping 16 matching lines...) Expand all Loading... |
132 EXPECT_FALSE(IsExceptionNonfatalResource(EXC_BAD_INSTRUCTION, 1, pid)); | 132 EXPECT_FALSE(IsExceptionNonfatalResource(EXC_BAD_INSTRUCTION, 1, pid)); |
133 EXPECT_FALSE(IsExceptionNonfatalResource(EXC_ARITHMETIC, 1, pid)); | 133 EXPECT_FALSE(IsExceptionNonfatalResource(EXC_ARITHMETIC, 1, pid)); |
134 EXPECT_FALSE(IsExceptionNonfatalResource(EXC_BREAKPOINT, 2, pid)); | 134 EXPECT_FALSE(IsExceptionNonfatalResource(EXC_BREAKPOINT, 2, pid)); |
135 EXPECT_FALSE(IsExceptionNonfatalResource(0, 0, pid)); | 135 EXPECT_FALSE(IsExceptionNonfatalResource(0, 0, pid)); |
136 EXPECT_FALSE(IsExceptionNonfatalResource(kMachExceptionSimulated, 0, pid)); | 136 EXPECT_FALSE(IsExceptionNonfatalResource(kMachExceptionSimulated, 0, pid)); |
137 } | 137 } |
138 | 138 |
139 } // namespace | 139 } // namespace |
140 } // namespace test | 140 } // namespace test |
141 } // namespace crashpad | 141 } // namespace crashpad |
OLD | NEW |