2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
6 """Mock chrome process used by test code for http server."""
14 sys
.stdout
.write(s
+ '\n')
18 parser
= argparse
.ArgumentParser(description
=__doc__
)
19 parser
.add_argument('--post', help='POST to URL.', dest
='post',
21 parser
.add_argument('--get', help='GET to URL.', dest
='get',
23 parser
.add_argument('--sleep',
24 help='Number of seconds to sleep after reading URL',
25 dest
='sleep', default
=0)
26 parser
.add_argument('--expect-to-be-killed', help='If set, the script will'
27 ' warn if it isn\'t killed before it finishes sleeping.',
28 dest
='expect_to_be_killed', action
='store_true')
29 parser
.add_argument('url')
31 options
= parser
.parse_args(args
)
33 PrintAndFlush('Starting %s.' % sys
.argv
[0])
36 urllib2
.urlopen(options
.url
, data
='').read()
38 urllib2
.urlopen(options
.url
).read()
40 # Do nothing but wait to be killed.
43 time
.sleep(float(options
.sleep
))
45 if options
.expect_to_be_killed
:
46 PrintAndFlush('Done sleeping. Expected to be killed.')
49 if __name__
== '__main__':
50 sys
.exit(main(sys
.argv
[1:]))