OLD | NEW |
1 # Copyright (C) 2010 Google Inc. All rights reserved. | 1 # Copyright (C) 2010 Google Inc. All rights reserved. |
2 # Copyright (C) 2009 Daniel Bates (dbates@intudata.com). All rights reserved. | 2 # Copyright (C) 2009 Daniel Bates (dbates@intudata.com). All rights reserved. |
3 # | 3 # |
4 # Redistribution and use in source and binary forms, with or without | 4 # Redistribution and use in source and binary forms, with or without |
5 # modification, are permitted provided that the following conditions are | 5 # modification, are permitted provided that the following conditions are |
6 # met: | 6 # met: |
7 # | 7 # |
8 # * Redistributions of source code must retain the above copyright | 8 # * Redistributions of source code must retain the above copyright |
9 # notice, this list of conditions and the following disclaimer. | 9 # notice, this list of conditions and the following disclaimer. |
10 # * Redistributions in binary form must reproduce the above | 10 # * Redistributions in binary form must reproduce the above |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 output = executive.run_command(command_line('echo', unicode_tor_input)) | 151 output = executive.run_command(command_line('echo', unicode_tor_input)) |
152 self.assertEqual(output, unicode_tor_output) | 152 self.assertEqual(output, unicode_tor_output) |
153 | 153 |
154 output = executive.run_command(command_line('echo', unicode_tor_input),
decode_output=False) | 154 output = executive.run_command(command_line('echo', unicode_tor_input),
decode_output=False) |
155 self.assertEqual(output, encoded_tor) | 155 self.assertEqual(output, encoded_tor) |
156 | 156 |
157 # Make sure that str() input also works. | 157 # Make sure that str() input also works. |
158 output = executive.run_command(command_line('cat'), input=encoded_tor, d
ecode_output=False) | 158 output = executive.run_command(command_line('cat'), input=encoded_tor, d
ecode_output=False) |
159 self.assertEqual(output, encoded_tor) | 159 self.assertEqual(output, encoded_tor) |
160 | 160 |
161 # FIXME: We should only have one run* method to test | |
162 output = executive.run_and_throw_if_fail(command_line('echo', unicode_to
r_input), quiet=True) | |
163 self.assertEqual(output, unicode_tor_output) | |
164 | |
165 output = executive.run_and_throw_if_fail(command_line('echo', unicode_to
r_input), quiet=True, decode_output=False) | |
166 self.assertEqual(output, encoded_tor) | |
167 | |
168 def test_kill_process(self): | 161 def test_kill_process(self): |
169 executive = Executive() | 162 executive = Executive() |
170 process = subprocess.Popen(never_ending_command(), stdout=subprocess.PIP
E) | 163 process = subprocess.Popen(never_ending_command(), stdout=subprocess.PIP
E) |
171 self.assertEqual(process.poll(), None) # Process is running | 164 self.assertEqual(process.poll(), None) # Process is running |
172 executive.kill_process(process.pid) | 165 executive.kill_process(process.pid) |
173 | 166 |
174 # Killing again should fail silently. | 167 # Killing again should fail silently. |
175 executive.kill_process(process.pid) | 168 executive.kill_process(process.pid) |
176 | 169 |
177 def _assert_windows_image_name(self, name, expected_windows_name): | 170 def _assert_windows_image_name(self, name, expected_windows_name): |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 import msvcrt | 204 import msvcrt |
212 msvcrt.setmode(stdout.fileno(), os.O_BINARY) | 205 msvcrt.setmode(stdout.fileno(), os.O_BINARY) |
213 if cmd == '--cat': | 206 if cmd == '--cat': |
214 stdout.write(stdin.read()) | 207 stdout.write(stdin.read()) |
215 elif cmd == '--echo': | 208 elif cmd == '--echo': |
216 stdout.write(' '.join(args)) | 209 stdout.write(' '.join(args)) |
217 return 0 | 210 return 0 |
218 | 211 |
219 if __name__ == '__main__' and len(sys.argv) > 1 and sys.argv[1] in ('--cat', '--
echo'): | 212 if __name__ == '__main__' and len(sys.argv) > 1 and sys.argv[1] in ('--cat', '--
echo'): |
220 sys.exit(main(sys.platform, sys.stdin, sys.stdout, sys.argv[1], sys.argv[2:]
)) | 213 sys.exit(main(sys.platform, sys.stdin, sys.stdout, sys.argv[1], sys.argv[2:]
)) |
OLD | NEW |