summaryrefslogtreecommitdiff
path: root/util/run_host_test
blob: bf8d8efd970210ca0bee99c69d87b7e79b0cefab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env python

# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import pexpect
import sys

TIMEOUT=10

test_name = sys.argv[1]
child = pexpect.spawn('build/host/{0}/{0}.exe'.format(test_name),
                      timeout=TIMEOUT)
child.logfile = sys.stdout
result_id = child.expect([pexpect.TIMEOUT, 'Pass!', 'Fail!'])
if result_id == 0:
  sys.stderr.write('Test %s timed out after %d seconds!\n' %
                   (test_name, TIMEOUT))
  sys.exit(1)
elif result_id == 1:
  sys.stderr.write('Test %s passed!\n' % test_name)
  sys.exit(0)
elif result_id == 2:
  sys.stderr.write('Test %s failed!\n' % test_name)
  sys.exit(1)