test: Add support for testing klippy with multi-mcu configs
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
5922a1ea1b
commit
cc6b416660
|
@ -7,6 +7,7 @@ import sys, os, optparse, logging, subprocess
|
|||
|
||||
TEMP_GCODE_FILE = "_test_.gcode"
|
||||
TEMP_LOG_FILE = "_test_.log"
|
||||
TEMP_OUTPUT_FILE = "_test_output"
|
||||
|
||||
|
||||
######################################################################
|
||||
|
@ -32,7 +33,7 @@ class TestCase:
|
|||
return os.path.join(reldir, fname)
|
||||
def parse_test(self):
|
||||
# Parse file into test cases
|
||||
config_fname = gcode_fname = dict_fname = None
|
||||
config_fname = gcode_fname = dict_fnames = None
|
||||
should_fail = multi_tests = False
|
||||
gcode = []
|
||||
f = open(self.fname, 'rb')
|
||||
|
@ -48,14 +49,18 @@ class TestCase:
|
|||
# Multiple tests in same file
|
||||
if not multi_tests:
|
||||
multi_tests = True
|
||||
self.launch_test(config_fname, dict_fname,
|
||||
self.launch_test(config_fname, dict_fnames,
|
||||
gcode_fname, gcode, should_fail)
|
||||
config_fname = self.relpath(parts[1])
|
||||
if multi_tests:
|
||||
self.launch_test(config_fname, dict_fname,
|
||||
self.launch_test(config_fname, dict_fnames,
|
||||
gcode_fname, gcode, should_fail)
|
||||
elif parts[0] == "DICTIONARY":
|
||||
dict_fname = self.relpath(parts[1], 'dict')
|
||||
dict_fnames = [self.relpath(parts[1], 'dict')]
|
||||
for mcu_dict in parts[2:]:
|
||||
mcu, fname = mcu_dict.split('=', 1)
|
||||
dict_fnames.append('%s=%s' % (
|
||||
mcu.strip(), self.relpath(fname.strip(), 'dict')))
|
||||
elif parts[0] == "GCODE":
|
||||
gcode_fname = self.relpath(parts[1])
|
||||
elif parts[0] == "SHOULD_FAIL":
|
||||
|
@ -64,9 +69,9 @@ class TestCase:
|
|||
gcode.append(line.strip())
|
||||
f.close()
|
||||
if not multi_tests:
|
||||
self.launch_test(config_fname, dict_fname,
|
||||
self.launch_test(config_fname, dict_fnames,
|
||||
gcode_fname, gcode, should_fail)
|
||||
def launch_test(self, config_fname, dict_fname, gcode_fname, gcode,
|
||||
def launch_test(self, config_fname, dict_fnames, gcode_fname, gcode,
|
||||
should_fail):
|
||||
gcode_is_temp = False
|
||||
if gcode_fname is None:
|
||||
|
@ -79,15 +84,15 @@ class TestCase:
|
|||
raise error("Can't specify both a gcode file and gcode commands")
|
||||
if config_fname is None:
|
||||
raise error("config file not specified")
|
||||
if dict_fname is None:
|
||||
if dict_fnames is None:
|
||||
raise error("data dictionary file not specified")
|
||||
# Call klippy
|
||||
sys.stderr.write(" Starting %s (%s)\n" % (
|
||||
self.fname, os.path.basename(config_fname)))
|
||||
args = [sys.executable, './klippy/klippy.py', config_fname,
|
||||
'-i', gcode_fname, '-o', '/dev/null', '-v',
|
||||
'-d', dict_fname
|
||||
]
|
||||
args = [ sys.executable, './klippy/klippy.py', config_fname,
|
||||
'-i', gcode_fname, '-o', TEMP_OUTPUT_FILE, '-v' ]
|
||||
for df in dict_fnames:
|
||||
args += ['-d', df]
|
||||
if not self.verbose:
|
||||
args += ['-l', TEMP_LOG_FILE]
|
||||
res = subprocess.call(args)
|
||||
|
@ -99,6 +104,9 @@ class TestCase:
|
|||
raise error("Test failed to raise an error")
|
||||
raise error("Error during test")
|
||||
# Do cleanup
|
||||
for fname in os.listdir(self.tempdir):
|
||||
if fname.startswith(TEMP_OUTPUT_FILE):
|
||||
os.unlink(fname)
|
||||
if not self.verbose:
|
||||
os.unlink(TEMP_LOG_FILE)
|
||||
else:
|
||||
|
|
|
@ -46,3 +46,14 @@ CONFIG ../../config/generic-radds.cfg
|
|||
DICTIONARY lpc176x.dict
|
||||
CONFIG ../../config/generic-re-arm.cfg
|
||||
CONFIG ../../config/generic-smoothieboard.cfg
|
||||
|
||||
# Printers using the PRU
|
||||
DICTIONARY pru.dict host=linuxprocess.dict
|
||||
CONFIG ../../config/generic-cramps.cfg
|
||||
CONFIG ../../config/generic-replicape.cfg
|
||||
|
||||
# Tests with multiple mcus
|
||||
DICTIONARY atmega2560-16mhz.dict zboard=atmega2560-16mhz.dict auxboard=atmega2560-16mhz.dict
|
||||
CONFIG ../../config/example-multi-mcu.cfg
|
||||
DICTIONARY atmega2560-16mhz.dict z=atmega2560-16mhz.dict
|
||||
CONFIG ../../config/kit-voron2-2018.cfg
|
||||
|
|
Loading…
Reference in New Issue