| 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/mac/service_management.h" | 15 #include "util/mac/service_management.h" |
| 16 | 16 |
| 17 #import <Foundation/Foundation.h> | 17 #import <Foundation/Foundation.h> |
| 18 #include <launch.h> | 18 #include <launch.h> |
| 19 #include <time.h> | 19 #include <time.h> |
| 20 | 20 |
| 21 #include <string> | 21 #include <string> |
| 22 #include <vector> | 22 #include <vector> |
| 23 | 23 |
| 24 #include "base/mac/foundation_util.h" | 24 #include "base/mac/foundation_util.h" |
| 25 #include "base/mac/scoped_cftyperef.h" | 25 #include "base/mac/scoped_cftyperef.h" |
| 26 #include "base/strings/stringprintf.h" | 26 #include "base/strings/stringprintf.h" |
| 27 #include "base/strings/sys_string_conversions.h" | 27 #include "base/strings/sys_string_conversions.h" |
| 28 #include "base/rand_util.h" | 28 #include "base/rand_util.h" |
| 29 #include "gtest/gtest.h" | 29 #include "gtest/gtest.h" |
| 30 #include "util/mac/mac_util.h" |
| 30 #include "util/posix/process_util.h" | 31 #include "util/posix/process_util.h" |
| 31 #include "util/stdlib/objc.h" | 32 #include "util/stdlib/objc.h" |
| 32 | 33 |
| 33 namespace { | 34 namespace { |
| 34 | 35 |
| 35 using namespace crashpad; | 36 using namespace crashpad; |
| 36 | 37 |
| 37 // Ensures that the process with the specified PID is running, identifying it by | 38 // Ensures that the process with the specified PID is running, identifying it by |
| 38 // requiring that its argv[argc - 1] compare equal to last_arg. | 39 // requiring that its argv[argc - 1] compare equal to last_arg. |
| 39 void ExpectProcessIsRunning(pid_t pid, std::string& last_arg) { | 40 void ExpectProcessIsRunning(pid_t pid, std::string& last_arg) { |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 ASSERT_GT(job_pid, 0); | 151 ASSERT_GT(job_pid, 0); |
| 151 | 152 |
| 152 ExpectProcessIsRunning(job_pid, shell_script); | 153 ExpectProcessIsRunning(job_pid, shell_script); |
| 153 | 154 |
| 154 // Remove the job. | 155 // Remove the job. |
| 155 ASSERT_TRUE(ServiceManagementRemoveJob(kJobLabel, true)); | 156 ASSERT_TRUE(ServiceManagementRemoveJob(kJobLabel, true)); |
| 156 EXPECT_FALSE(ServiceManagementIsJobLoaded(kJobLabel)); | 157 EXPECT_FALSE(ServiceManagementIsJobLoaded(kJobLabel)); |
| 157 EXPECT_EQ(0, ServiceManagementIsJobRunning(kJobLabel)); | 158 EXPECT_EQ(0, ServiceManagementIsJobRunning(kJobLabel)); |
| 158 | 159 |
| 159 // Now that the job is unloaded, a subsequent attempt to unload it should be | 160 // Now that the job is unloaded, a subsequent attempt to unload it should be |
| 160 // an error. | 161 // an error. However, ServiceManagementRemoveJob does not properly report |
| 161 EXPECT_FALSE(ServiceManagementRemoveJob(kJobLabel, false)); | 162 // this error case on Mac OS X 10.10. |
| 163 if (MacOSXMinorVersion() >= 10) { |
| 164 // If this check starts failing because radar 18268941 is fixed, remove |
| 165 // the OS version check here and revise the interface documentation for |
| 166 // ServiceManagementRemoveJob(). |
| 167 EXPECT_TRUE(ServiceManagementRemoveJob(kJobLabel, false)); |
| 168 } else { |
| 169 EXPECT_FALSE(ServiceManagementRemoveJob(kJobLabel, false)); |
| 170 } |
| 162 | 171 |
| 163 ExpectProcessIsNotRunning(job_pid, shell_script); | 172 ExpectProcessIsNotRunning(job_pid, shell_script); |
| 164 } | 173 } |
| 165 } | 174 } |
| 166 | 175 |
| 167 } // namespace | 176 } // namespace |
| OLD | NEW |