1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

dist: add testrunner shared pexpect code

This commit is contained in:
test 2016-03-05 15:59:35 +01:00 committed by Kaspar Schleiser
parent ee05aca342
commit 819dfacccc

35
dist/tools/testrunner/testrunner.py vendored Executable file
View File

@ -0,0 +1,35 @@
#!/usr/bin/env python3
# Copyright (C) 2016 Kaspar Schleiser <kaspar@schleiser.de>
# 2014 Martine Lenders <mlenders@inf.fu-berlin.de>
#
# This file is subject to the terms and conditions of the GNU Lesser
# General Public License v2.1. See the file LICENSE in the top level
# directory for more details.
import os, signal, sys, subprocess
from pexpect import spawnu, TIMEOUT, EOF
def run(testfunc, timeout=5, echo=True):
env = os.environ.copy()
child = spawnu("make term", env=env, timeout=timeout)
if echo:
child.logfile = sys.stdout
try:
subprocess.check_output(('make', 'reset'), env=env,
stderr=subprocess.PIPE)
except subprocess.CalledProcessError:
# make reset yields error on some boards even if successful
pass
try:
testfunc(child)
except TIMEOUT:
print("Timeout in expect script")
return 1
finally:
print("")
child.kill(signal.SIGKILL)
child.close()
return 0