

8 changed files with 67 additions and 102 deletions
@ -1,33 +1,19 @@
|
||||
#!/usr/bin/env python |
||||
#!/usr/bin/env python3 |
||||
|
||||
# Copyright (C) 2014 Martine Lenders <mlenders@inf.fu-berlin.de> |
||||
# Copyright (C) 2016 Kaspar Schleiser <kaspar@schleiser.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 |
||||
from pexpect import spawn, TIMEOUT, EOF |
||||
import os |
||||
import sys |
||||
|
||||
sys.path.append(os.path.join(os.environ['RIOTBASE'], 'dist/tools/testrunner')) |
||||
import testrunner |
||||
|
||||
DEFAULT_TIMEOUT = 5 |
||||
|
||||
def main(): |
||||
p = None |
||||
|
||||
try: |
||||
p = spawn("make term", timeout=DEFAULT_TIMEOUT) |
||||
p.logfile = sys.stdout |
||||
|
||||
p.expect("Test successful.") |
||||
except TIMEOUT as exc: |
||||
print(exc) |
||||
return 1 |
||||
finally: |
||||
if p and not p.terminate(): |
||||
os.killpg(p.pid, signal.SIGKILL) |
||||
|
||||
return 0 |
||||
def testfunc(child): |
||||
child.expect(u"Test successful.") |
||||
|
||||
if __name__ == "__main__": |
||||
sys.exit(main()) |
||||
sys.exit(testrunner.run(testfunc)) |
||||
|
@ -1,8 +1,20 @@
|
||||
#!/usr/bin/python |
||||
#!/usr/bin/env python3 |
||||
|
||||
import pexpect |
||||
# Copyright (C) 2016 Kaspar Schleiser <kaspar@schleiser.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. |
||||
|
||||
term = pexpect.spawn("make term") |
||||
import os |
||||
import sys |
||||
|
||||
term.expect('first thread\r\n') |
||||
term.expect('second thread\r\n') |
||||
sys.path.append(os.path.join(os.environ['RIOTBASE'], 'dist/tools/testrunner')) |
||||
import testrunner |
||||
|
||||
def testfunc(child): |
||||
child.expect('first thread\r\n') |
||||
child.expect('second thread\r\n') |
||||
|
||||
if __name__ == "__main__": |
||||
sys.exit(testrunner.run(testfunc)) |
||||
|
@ -1,38 +1,19 @@
|
||||
#!/usr/bin/env python |
||||
#!/usr/bin/env python3 |
||||
|
||||
# Copyright (C) 2014 Martine Lenders <mlenders@inf.fu-berlin.de> |
||||
# Copyright (C) 2016 Kaspar Schleiser <kaspar@schleiser.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 spawn, TIMEOUT, EOF |
||||
import os |
||||
import sys |
||||
|
||||
DEFAULT_TIMEOUT = 5 |
||||
sys.path.append(os.path.join(os.environ['RIOTBASE'], 'dist/tools/testrunner')) |
||||
import testrunner |
||||
|
||||
def main(): |
||||
env = os.environ.copy() |
||||
child = spawn("make term", env=env, timeout=DEFAULT_TIMEOUT, |
||||
encoding="utf-8") |
||||
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: |
||||
child.expect(u"OK \\([0-9]+ tests\\)") |
||||
except TIMEOUT: |
||||
print("There where errors in the unittests") |
||||
return 1 |
||||
finally: |
||||
print("") |
||||
child.close() |
||||
|
||||
return 0 |
||||
def testfunc(child): |
||||
child.expect(u"OK \\([0-9]+ tests\\)") |
||||
|
||||
if __name__ == "__main__": |
||||
sys.exit(main()) |
||||
sys.exit(testrunner.run(testfunc)) |
||||
|
@ -1,39 +1,21 @@
|
||||
#!/usr/bin/env python |
||||
#!/usr/bin/env python3 |
||||
|
||||
# Copyright (C) 2015 INRIA |
||||
# Copyright (C) 2016 Kaspar Schleiser <kaspar@schleiser.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 |
||||
from pexpect import TIMEOUT, EOF |
||||
if sys.version_info[0] == 2: |
||||
from pexpect import spawn |
||||
else: |
||||
from pexpect import spawnu as spawn |
||||
import os |
||||
import sys |
||||
|
||||
DEFAULT_TIMEOUT = 2 |
||||
sys.path.append(os.path.join(os.environ['RIOTBASE'], 'dist/tools/testrunner')) |
||||
import testrunner |
||||
|
||||
def main(): |
||||
p = None |
||||
|
||||
try: |
||||
p = spawn("make term", timeout=DEFAULT_TIMEOUT) |
||||
p.logfile = sys.stdout |
||||
|
||||
for i in range(10): |
||||
p.expect("Message received: 44") |
||||
p.expect("Timeout") |
||||
except TIMEOUT as exc: |
||||
print(exc) |
||||
return 1 |
||||
finally: |
||||
if p and not p.terminate(): |
||||
print("SUCCESS") |
||||
os.killpg(p.pid, signal.SIGKILL) |
||||
|
||||
return 0 |
||||
def testfunc(child): |
||||
for i in range(5): |
||||
child.expect("Message received: 44") |
||||
child.expect("Timeout!") |
||||
|
||||
if __name__ == "__main__": |
||||
sys.exit(main()) |
||||
sys.exit(testrunner.run(testfunc)) |
||||
|
Loading…
Reference in new issue