Improve firmware detecting for system tests

This commit is contained in:
Ivan Kravets
2015-04-03 17:42:00 +03:00
parent 380937c588
commit cdd7167e24
2 changed files with 10 additions and 10 deletions

View File

@ -1,3 +1,3 @@
[settings]
line_length=79
known_third_party=click,requests,serial,SCons
known_third_party=click,requests,serial,SCons,pytest

View File

@ -1,6 +1,7 @@
# Copyright (C) Ivan Kravets <me@ikravets.com>
# See LICENSE for details.
from glob import glob
from os import listdir, walk
from os.path import dirname, getsize, isdir, isfile, join, normpath
from shutil import rmtree
@ -39,12 +40,11 @@ def test_run(platformio_setup, pioproject_dir):
pioenvs_dir = join(pioproject_dir, ".pioenvs")
for item in listdir(pioenvs_dir):
assert isfile(join(pioenvs_dir, item, "firmware.elf"))
# check .hex or .bin file
bin_file = join(pioenvs_dir, item, "firmware.bin")
hex_file = join(pioenvs_dir, item, "firmware.hex")
if not isfile(bin_file):
if not isfile(hex_file):
pytest.fail("Missed firmware file")
assert getsize(hex_file) > 0
else:
assert getsize(bin_file) > 0
# check .hex or .bin files
firmwares = []
for ext in ("bin", "hex"):
firmwares += glob(join(pioenvs_dir, item, "firmware*.%s" % ext))
if not firmwares:
pytest.fail("Missed firmware file")
for firmware in firmwares:
assert getsize(firmware) > 0