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 12 matching lines...) Expand all Loading... |
23 #include "base/mac/foundation_util.h" | 23 #include "base/mac/foundation_util.h" |
24 #include "base/mac/scoped_cftyperef.h" | 24 #include "base/mac/scoped_cftyperef.h" |
25 #include "base/strings/stringprintf.h" | 25 #include "base/strings/stringprintf.h" |
26 #include "base/strings/sys_string_conversions.h" | 26 #include "base/strings/sys_string_conversions.h" |
27 #include "base/rand_util.h" | 27 #include "base/rand_util.h" |
28 #include "gtest/gtest.h" | 28 #include "gtest/gtest.h" |
29 #include "util/misc/clock.h" | 29 #include "util/misc/clock.h" |
30 #include "util/posix/process_util.h" | 30 #include "util/posix/process_util.h" |
31 #include "util/stdlib/objc.h" | 31 #include "util/stdlib/objc.h" |
32 | 32 |
| 33 namespace crashpad { |
| 34 namespace test { |
33 namespace { | 35 namespace { |
34 | 36 |
35 using namespace crashpad; | |
36 | |
37 // Ensures that the process with the specified PID is running, identifying it by | 37 // 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. | 38 // requiring that its argv[argc - 1] compare equal to last_arg. |
39 void ExpectProcessIsRunning(pid_t pid, std::string& last_arg) { | 39 void ExpectProcessIsRunning(pid_t pid, std::string& last_arg) { |
40 // The process may not have called exec yet, so loop with a small delay while | 40 // The process may not have called exec yet, so loop with a small delay while |
41 // looking for the cookie. | 41 // looking for the cookie. |
42 int outer_tries = 10; | 42 int outer_tries = 10; |
43 std::vector<std::string> job_argv; | 43 std::vector<std::string> job_argv; |
44 while (outer_tries--) { | 44 while (outer_tries--) { |
45 // If the process is in the middle of calling exec, ProcessArgumentsForPID | 45 // If the process is in the middle of calling exec, ProcessArgumentsForPID |
46 // may fail. Loop with a small retry delay while waiting for the expected | 46 // may fail. Loop with a small retry delay while waiting for the expected |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 | 149 |
150 // Now that the job is unloaded, a subsequent attempt to unload it should be | 150 // Now that the job is unloaded, a subsequent attempt to unload it should be |
151 // an error. | 151 // an error. |
152 EXPECT_FALSE(ServiceManagementRemoveJob(kJobLabel, false)); | 152 EXPECT_FALSE(ServiceManagementRemoveJob(kJobLabel, false)); |
153 | 153 |
154 ExpectProcessIsNotRunning(job_pid, shell_script); | 154 ExpectProcessIsNotRunning(job_pid, shell_script); |
155 } | 155 } |
156 } | 156 } |
157 | 157 |
158 } // namespace | 158 } // namespace |
| 159 } // namespace test |
| 160 } // namespace crashpad |
OLD | NEW |