| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/test/launcher/test_launcher.h" | 5 #include "base/test/launcher/test_launcher.h" |
| 6 | 6 |
| 7 #if defined(OS_POSIX) | 7 #if defined(OS_POSIX) |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 fflush(stdout); | 135 fflush(stdout); |
| 136 } | 136 } |
| 137 | 137 |
| 138 // I/O watcher for the reading end of the self-pipe above. | 138 // I/O watcher for the reading end of the self-pipe above. |
| 139 // Terminates any launched child processes and exits the process. | 139 // Terminates any launched child processes and exits the process. |
| 140 class SignalFDWatcher : public MessageLoopForIO::Watcher { | 140 class SignalFDWatcher : public MessageLoopForIO::Watcher { |
| 141 public: | 141 public: |
| 142 SignalFDWatcher() { | 142 SignalFDWatcher() { |
| 143 } | 143 } |
| 144 | 144 |
| 145 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE { | 145 void OnFileCanReadWithoutBlocking(int fd) override { |
| 146 fprintf(stdout, "\nCaught signal. Killing spawned test processes...\n"); | 146 fprintf(stdout, "\nCaught signal. Killing spawned test processes...\n"); |
| 147 fflush(stdout); | 147 fflush(stdout); |
| 148 | 148 |
| 149 KillSpawnedTestProcesses(); | 149 KillSpawnedTestProcesses(); |
| 150 | 150 |
| 151 // The signal would normally kill the process, so exit now. | 151 // The signal would normally kill the process, so exit now. |
| 152 exit(1); | 152 exit(1); |
| 153 } | 153 } |
| 154 | 154 |
| 155 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE { | 155 void OnFileCanWriteWithoutBlocking(int fd) override { NOTREACHED(); } |
| 156 NOTREACHED(); | |
| 157 } | |
| 158 | 156 |
| 159 private: | 157 private: |
| 160 DISALLOW_COPY_AND_ASSIGN(SignalFDWatcher); | 158 DISALLOW_COPY_AND_ASSIGN(SignalFDWatcher); |
| 161 }; | 159 }; |
| 162 #endif // defined(OS_POSIX) | 160 #endif // defined(OS_POSIX) |
| 163 | 161 |
| 164 // Parses the environment variable var as an Int32. If it is unset, returns | 162 // Parses the environment variable var as an Int32. If it is unset, returns |
| 165 // true. If it is set, unsets it then converts it to Int32 before | 163 // true. If it is set, unsets it then converts it to Int32 before |
| 166 // returning it in |result|. Returns true on success. | 164 // returning it in |result|. Returns true on success. |
| 167 bool TakeInt32FromEnvironment(const char* const var, int32* result) { | 165 bool TakeInt32FromEnvironment(const char* const var, int32* result) { |
| (...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1090 } | 1088 } |
| 1091 | 1089 |
| 1092 std::string snippet(full_output.substr(run_pos)); | 1090 std::string snippet(full_output.substr(run_pos)); |
| 1093 if (end_pos != std::string::npos) | 1091 if (end_pos != std::string::npos) |
| 1094 snippet = full_output.substr(run_pos, end_pos - run_pos); | 1092 snippet = full_output.substr(run_pos, end_pos - run_pos); |
| 1095 | 1093 |
| 1096 return snippet; | 1094 return snippet; |
| 1097 } | 1095 } |
| 1098 | 1096 |
| 1099 } // namespace base | 1097 } // namespace base |
| OLD | NEW |