tools/tinytest-codegen.py: Externalise tests list.
Remove port-specific test directories and excluded tests from tinytest-codegen, and let it read said information from an external file. This way tinytest-codegen is not limited to always generate tests for the `qemu-arm` target. This allows having port-specific test directory and excluded tests for more than one QEMU bare-metal target. The `qemu-arm` port Makefile was modified to work with the generator changes and a tests profile file was added to said port. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit is contained in:
parent
c35cc63366
commit
bea6ff82fa
|
@ -13,10 +13,12 @@ CFLAGS += -DTEST
|
||||||
|
|
||||||
.PHONY: $(BUILD)/genhdr/tests.h
|
.PHONY: $(BUILD)/genhdr/tests.h
|
||||||
|
|
||||||
|
TESTS_PROFILE = $(dir $(abspath $(firstword $(MAKEFILE_LIST))))/tests_profile.txt
|
||||||
|
|
||||||
$(BUILD)/test_main.o: $(BUILD)/genhdr/tests.h
|
$(BUILD)/test_main.o: $(BUILD)/genhdr/tests.h
|
||||||
$(BUILD)/genhdr/tests.h:
|
$(BUILD)/genhdr/tests.h:
|
||||||
(cd $(TOP)/tests; ./run-tests.py --target=qemu-arm --write-exp)
|
(cd $(TOP)/tests; ./run-tests.py --target=qemu-arm --write-exp)
|
||||||
$(Q)echo "Generating $@";(cd $(TOP)/tests; ../tools/tinytest-codegen.py $(addprefix --exclude ,$(TESTS_EXCLUDE))) > $@
|
$(Q)echo "Generating $@";(cd $(TOP)/tests; ../tools/tinytest-codegen.py --profile $(TESTS_PROFILE) $(addprefix --exclude ,$(TESTS_EXCLUDE))) > $@
|
||||||
|
|
||||||
$(BUILD)/lib/tinytest/tinytest.o: CFLAGS += -DNO_FORKING
|
$(BUILD)/lib/tinytest/tinytest.o: CFLAGS += -DNO_FORKING
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
# Port-specific test directories.
|
||||||
|
|
||||||
|
test_dirs.add(("inlineasm", "qemu-arm"))
|
||||||
|
|
||||||
|
# Port-specific tests exclusion list.
|
||||||
|
|
||||||
|
exclude_tests.add(
|
||||||
|
(
|
||||||
|
# inline asm FP tests (require Cortex-M4)
|
||||||
|
"inlineasm/asmfpaddsub.py",
|
||||||
|
"inlineasm/asmfpcmp.py",
|
||||||
|
"inlineasm/asmfpldrstr.py",
|
||||||
|
"inlineasm/asmfpmuldiv.py",
|
||||||
|
"inlineasm/asmfpsqrt.py",
|
||||||
|
)
|
||||||
|
)
|
|
@ -32,6 +32,12 @@ def script_to_map(test_file):
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
|
||||||
|
def load_profile(profile_file, test_dirs, exclude_tests):
|
||||||
|
profile_globals = {"test_dirs": test_dirs, "exclude_tests": exclude_tests}
|
||||||
|
exec(profile_file.read(), profile_globals)
|
||||||
|
return profile_globals["test_dirs"], profile_globals["exclude_tests"]
|
||||||
|
|
||||||
|
|
||||||
test_function = (
|
test_function = (
|
||||||
"void {name}(void* data) {{\n"
|
"void {name}(void* data) {{\n"
|
||||||
" static const char pystr[] = {script};\n"
|
" static const char pystr[] = {script};\n"
|
||||||
|
@ -50,58 +56,55 @@ testgroup_struct = "struct testgroup_t groups[] = {{\n{body}\n END_OF_GROUPS\n}
|
||||||
testgroup_member = ' {{ "{name}", {name}_tests }},'
|
testgroup_member = ' {{ "{name}", {name}_tests }},'
|
||||||
|
|
||||||
## XXX: may be we could have `--without <groups>` argument...
|
## XXX: may be we could have `--without <groups>` argument...
|
||||||
# currently these tests are selected because they pass on qemu-arm
|
|
||||||
test_dirs = (
|
test_dirs = set(
|
||||||
"basics",
|
(
|
||||||
"micropython",
|
"basics",
|
||||||
"misc",
|
"extmod",
|
||||||
"extmod",
|
"float",
|
||||||
"float",
|
"micropython",
|
||||||
"inlineasm",
|
"misc",
|
||||||
"qemu-arm",
|
)
|
||||||
) # 'import', 'io',)
|
)
|
||||||
exclude_tests = (
|
|
||||||
# pattern matching in .exp
|
exclude_tests = set(
|
||||||
"basics/bytes_compare3.py",
|
(
|
||||||
"extmod/ticks_diff.py",
|
# pattern matching in .exp
|
||||||
"extmod/time_ms_us.py",
|
"basics/bytes_compare3.py",
|
||||||
# unicode char issue
|
"extmod/ticks_diff.py",
|
||||||
"extmod/json_loads.py",
|
"extmod/time_ms_us.py",
|
||||||
# doesn't output to python stdout
|
# unicode char issue
|
||||||
"extmod/re_debug.py",
|
"extmod/json_loads.py",
|
||||||
"extmod/vfs_basic.py",
|
# doesn't output to python stdout
|
||||||
"extmod/vfs_fat_ramdisk.py",
|
"extmod/re_debug.py",
|
||||||
"extmod/vfs_fat_fileio.py",
|
"extmod/vfs_basic.py",
|
||||||
"extmod/vfs_fat_fsusermount.py",
|
"extmod/vfs_fat_ramdisk.py",
|
||||||
"extmod/vfs_fat_oldproto.py",
|
"extmod/vfs_fat_fileio.py",
|
||||||
# rounding issues
|
"extmod/vfs_fat_fsusermount.py",
|
||||||
"float/float_divmod.py",
|
"extmod/vfs_fat_oldproto.py",
|
||||||
# requires double precision floating point to work
|
# rounding issues
|
||||||
"float/float2int_doubleprec_intbig.py",
|
"float/float_divmod.py",
|
||||||
"float/float_format_ints_doubleprec.py",
|
# requires double precision floating point to work
|
||||||
"float/float_parse_doubleprec.py",
|
"float/float2int_doubleprec_intbig.py",
|
||||||
# inline asm FP tests (require Cortex-M4)
|
"float/float_format_ints_doubleprec.py",
|
||||||
"inlineasm/asmfpaddsub.py",
|
"float/float_parse_doubleprec.py",
|
||||||
"inlineasm/asmfpcmp.py",
|
# different filename in output
|
||||||
"inlineasm/asmfpldrstr.py",
|
"micropython/emg_exc.py",
|
||||||
"inlineasm/asmfpmuldiv.py",
|
"micropython/heapalloc_traceback.py",
|
||||||
"inlineasm/asmfpsqrt.py",
|
# don't have emergency exception buffer
|
||||||
# different filename in output
|
"micropython/heapalloc_exc_compressed_emg_exc.py",
|
||||||
"micropython/emg_exc.py",
|
# pattern matching in .exp
|
||||||
"micropython/heapalloc_traceback.py",
|
"micropython/meminfo.py",
|
||||||
# don't have emergency exception buffer
|
# needs sys stdfiles
|
||||||
"micropython/heapalloc_exc_compressed_emg_exc.py",
|
"misc/print_exception.py",
|
||||||
# pattern matching in .exp
|
# settrace .exp files are too large
|
||||||
"micropython/meminfo.py",
|
"misc/sys_settrace_loop.py",
|
||||||
# needs sys stdfiles
|
"misc/sys_settrace_generator.py",
|
||||||
"misc/print_exception.py",
|
"misc/sys_settrace_features.py",
|
||||||
# settrace .exp files are too large
|
# don't have f-string
|
||||||
"misc/sys_settrace_loop.py",
|
"basics/string_fstring.py",
|
||||||
"misc/sys_settrace_generator.py",
|
"basics/string_fstring_debug.py",
|
||||||
"misc/sys_settrace_features.py",
|
)
|
||||||
# don't have f-string
|
|
||||||
"basics/string_fstring.py",
|
|
||||||
"basics/string_fstring_debug.py",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
output = []
|
output = []
|
||||||
|
@ -112,11 +115,18 @@ argparser = argparse.ArgumentParser(
|
||||||
)
|
)
|
||||||
argparser.add_argument("--stdin", action="store_true", help="read list of tests from stdin")
|
argparser.add_argument("--stdin", action="store_true", help="read list of tests from stdin")
|
||||||
argparser.add_argument("--exclude", action="append", help="exclude test by name")
|
argparser.add_argument("--exclude", action="append", help="exclude test by name")
|
||||||
|
argparser.add_argument(
|
||||||
|
"--profile",
|
||||||
|
type=argparse.FileType("rt", encoding="utf-8"),
|
||||||
|
help="optional profile file providing test directories and exclusion list",
|
||||||
|
)
|
||||||
args = argparser.parse_args()
|
args = argparser.parse_args()
|
||||||
|
|
||||||
if not args.stdin:
|
if not args.stdin:
|
||||||
|
if args.profile:
|
||||||
|
test_dirs, exclude_tests = load_profile(args.profile, test_dirs, exclude_tests)
|
||||||
if args.exclude:
|
if args.exclude:
|
||||||
exclude_tests += tuple(args.exclude)
|
exclude_tests = exclude_tests.union(args.exclude)
|
||||||
for group in test_dirs:
|
for group in test_dirs:
|
||||||
tests += [test for test in glob("{}/*.py".format(group)) if test not in exclude_tests]
|
tests += [test for test in glob("{}/*.py".format(group)) if test not in exclude_tests]
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue