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_GCODE_FILE = "_test_.gcode"
|
||||||
TEMP_LOG_FILE = "_test_.log"
|
TEMP_LOG_FILE = "_test_.log"
|
||||||
|
TEMP_OUTPUT_FILE = "_test_output"
|
||||||
|
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
|
@ -32,7 +33,7 @@ class TestCase:
|
||||||
return os.path.join(reldir, fname)
|
return os.path.join(reldir, fname)
|
||||||
def parse_test(self):
|
def parse_test(self):
|
||||||
# Parse file into test cases
|
# Parse file into test cases
|
||||||
config_fname = gcode_fname = dict_fname = None
|
config_fname = gcode_fname = dict_fnames = None
|
||||||
should_fail = multi_tests = False
|
should_fail = multi_tests = False
|
||||||
gcode = []
|
gcode = []
|
||||||
f = open(self.fname, 'rb')
|
f = open(self.fname, 'rb')
|
||||||
|
@ -48,14 +49,18 @@ class TestCase:
|
||||||
# Multiple tests in same file
|
# Multiple tests in same file
|
||||||
if not multi_tests:
|
if not multi_tests:
|
||||||
multi_tests = True
|
multi_tests = True
|
||||||
self.launch_test(config_fname, dict_fname,
|
self.launch_test(config_fname, dict_fnames,
|
||||||
gcode_fname, gcode, should_fail)
|
gcode_fname, gcode, should_fail)
|
||||||
config_fname = self.relpath(parts[1])
|
config_fname = self.relpath(parts[1])
|
||||||
if multi_tests:
|
if multi_tests:
|
||||||
self.launch_test(config_fname, dict_fname,
|
self.launch_test(config_fname, dict_fnames,
|
||||||
gcode_fname, gcode, should_fail)
|
gcode_fname, gcode, should_fail)
|
||||||
elif parts[0] == "DICTIONARY":
|
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":
|
elif parts[0] == "GCODE":
|
||||||
gcode_fname = self.relpath(parts[1])
|
gcode_fname = self.relpath(parts[1])
|
||||||
elif parts[0] == "SHOULD_FAIL":
|
elif parts[0] == "SHOULD_FAIL":
|
||||||
|
@ -64,9 +69,9 @@ class TestCase:
|
||||||
gcode.append(line.strip())
|
gcode.append(line.strip())
|
||||||
f.close()
|
f.close()
|
||||||
if not multi_tests:
|
if not multi_tests:
|
||||||
self.launch_test(config_fname, dict_fname,
|
self.launch_test(config_fname, dict_fnames,
|
||||||
gcode_fname, gcode, should_fail)
|
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):
|
should_fail):
|
||||||
gcode_is_temp = False
|
gcode_is_temp = False
|
||||||
if gcode_fname is None:
|
if gcode_fname is None:
|
||||||
|
@ -79,15 +84,15 @@ class TestCase:
|
||||||
raise error("Can't specify both a gcode file and gcode commands")
|
raise error("Can't specify both a gcode file and gcode commands")
|
||||||
if config_fname is None:
|
if config_fname is None:
|
||||||
raise error("config file not specified")
|
raise error("config file not specified")
|
||||||
if dict_fname is None:
|
if dict_fnames is None:
|
||||||
raise error("data dictionary file not specified")
|
raise error("data dictionary file not specified")
|
||||||
# Call klippy
|
# Call klippy
|
||||||
sys.stderr.write(" Starting %s (%s)\n" % (
|
sys.stderr.write(" Starting %s (%s)\n" % (
|
||||||
self.fname, os.path.basename(config_fname)))
|
self.fname, os.path.basename(config_fname)))
|
||||||
args = [sys.executable, './klippy/klippy.py', config_fname,
|
args = [ sys.executable, './klippy/klippy.py', config_fname,
|
||||||
'-i', gcode_fname, '-o', '/dev/null', '-v',
|
'-i', gcode_fname, '-o', TEMP_OUTPUT_FILE, '-v' ]
|
||||||
'-d', dict_fname
|
for df in dict_fnames:
|
||||||
]
|
args += ['-d', df]
|
||||||
if not self.verbose:
|
if not self.verbose:
|
||||||
args += ['-l', TEMP_LOG_FILE]
|
args += ['-l', TEMP_LOG_FILE]
|
||||||
res = subprocess.call(args)
|
res = subprocess.call(args)
|
||||||
|
@ -99,6 +104,9 @@ class TestCase:
|
||||||
raise error("Test failed to raise an error")
|
raise error("Test failed to raise an error")
|
||||||
raise error("Error during test")
|
raise error("Error during test")
|
||||||
# Do cleanup
|
# Do cleanup
|
||||||
|
for fname in os.listdir(self.tempdir):
|
||||||
|
if fname.startswith(TEMP_OUTPUT_FILE):
|
||||||
|
os.unlink(fname)
|
||||||
if not self.verbose:
|
if not self.verbose:
|
||||||
os.unlink(TEMP_LOG_FILE)
|
os.unlink(TEMP_LOG_FILE)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -46,3 +46,14 @@ CONFIG ../../config/generic-radds.cfg
|
||||||
DICTIONARY lpc176x.dict
|
DICTIONARY lpc176x.dict
|
||||||
CONFIG ../../config/generic-re-arm.cfg
|
CONFIG ../../config/generic-re-arm.cfg
|
||||||
CONFIG ../../config/generic-smoothieboard.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