1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2026-01-01 01:41:18 +01:00

tests/warn_conflict: cleanup python test script and move to tests folder

This commit is contained in:
Alexandre Abadie 2017-12-04 09:34:42 +01:00
parent 2320c269c1
commit 404a32f346
3 changed files with 52 additions and 23 deletions

View File

@ -11,3 +11,6 @@ BOARD_WHITELIST := stm32f4discovery
FEATURES_REQUIRED = periph_dac periph_spi
include $(RIOTBASE)/Makefile.include
test:
tests/01-make.py

View File

@ -1,23 +0,0 @@
#!/usr/bin/env python3
import subprocess
import os
cross_gcc = "arm-none-eabi-gcc"
try:
devnull = open(os.devnull)
subprocess.Popen([cross_gcc], stdout=devnull, stderr=devnull).communicate()
output = subprocess.Popen(["make", "BOARD=stm32f4discovery"], stderr=subprocess.PIPE, stdout=subprocess.PIPE )
out,err = output.communicate()
compare = b'\x1b[1;33mThe following features may conflict:\x1b[0m \x1b[1;32mperiph_dac periph_spi\x1b[0m\n\x1b[1;33mRationale: \x1b[0mOn stm32f4discovery boards there are the same pins for the DAC and/or SPI_DEV(0).\n\n\x1b[1;33mEXPECT undesired behaviour!\x1b[0m\n'
if err == compare:
print("Test SUCCEEDED! Compile time output is as expected!\n")
else:
print("Test FAILED! Compile time output is NOT as expected!\n")
print("Expected:\n" + compare.decode("ascii") )
print("Received:\n" + err.decode("ascii") )
except OSError as e:
if e.errno == os.errno.ENOENT:
print("ABORTING TEST:"+ cross_gcc +" seems to be missing.\n")

View File

@ -0,0 +1,49 @@
#!/usr/bin/env python3
import os
import sys
import subprocess
from traceback import print_tb
import pexpect
BOARD = os.getenv('BOARD', 'stm32f4discovery')
def testfunc():
cross_gcc = "arm-none-eabi-gcc"
try:
devnull = open(os.devnull)
subprocess.Popen([cross_gcc],
stdout=devnull, stderr=devnull).communicate()
except OSError as exc:
if exc.errno == os.errno.ENOENT:
print("ABORTING TEST: {} seems to be missing.\n".format(cross_gcc))
else:
child = pexpect.spawnu(['make'], env=os.environ)
child.logfile = sys.stdout
try:
if BOARD == 'stm32f4discovery':
child.expect_exact('\x1b[1;33mThe following features may conflict:'
'\x1b[0m \x1b[1;32mperiph_dac periph_spi\x1b[0m')
child.expect_exact('\x1b[1;33mRationale: '
'\x1b[0mOn stm32f4discovery boards there are '
'the same pins for the DAC and/or SPI_0.')
child.expect_exact('\x1b[1;33mEXPECT undesired behaviour!\x1b[0m')
else:
child.expect_exact('\x1b[1;31mThe selected BOARD={} is not whitelisted:\x1b[0m stm32f4discovery'
.format(BOARD))
except pexpect.TIMEOUT:
print("\x1b[1;31mTimeout in expect script\x1b[0m")
print_tb(sys.exc_info()[2])
sys.exit(1)
except pexpect.EOF:
print("\x1b[1;31mUnexpected end of file in expect script\x1b[0m")
print_tb(sys.exc_info()[2])
sys.exit(1)
finally:
child.close()
if __name__ == '__main__':
testfunc()