Skip to content

Commit bea6ff8

Browse files
agattidpgeorge
authored andcommitted
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>
1 parent c35cc63 commit bea6ff8

File tree

3 files changed

+82
-54
lines changed

3 files changed

+82
-54
lines changed

ports/qemu-arm/Makefile.test

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ CFLAGS += -DTEST
1313

1414
.PHONY: $(BUILD)/genhdr/tests.h
1515

16+
TESTS_PROFILE = $(dir $(abspath $(firstword $(MAKEFILE_LIST))))/tests_profile.txt
17+
1618
$(BUILD)/test_main.o: $(BUILD)/genhdr/tests.h
1719
$(BUILD)/genhdr/tests.h:
1820
(cd $(TOP)/tests; ./run-tests.py --target=qemu-arm --write-exp)
19-
$(Q)echo "Generating $@";(cd $(TOP)/tests; ../tools/tinytest-codegen.py $(addprefix --exclude ,$(TESTS_EXCLUDE))) > $@
21+
$(Q)echo "Generating $@";(cd $(TOP)/tests; ../tools/tinytest-codegen.py --profile $(TESTS_PROFILE) $(addprefix --exclude ,$(TESTS_EXCLUDE))) > $@
2022

2123
$(BUILD)/lib/tinytest/tinytest.o: CFLAGS += -DNO_FORKING
2224

ports/qemu-arm/tests_profile.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Port-specific test directories.
2+
3+
test_dirs.add(("inlineasm", "qemu-arm"))
4+
5+
# Port-specific tests exclusion list.
6+
7+
exclude_tests.add(
8+
(
9+
# inline asm FP tests (require Cortex-M4)
10+
"inlineasm/asmfpaddsub.py",
11+
"inlineasm/asmfpcmp.py",
12+
"inlineasm/asmfpldrstr.py",
13+
"inlineasm/asmfpmuldiv.py",
14+
"inlineasm/asmfpsqrt.py",
15+
)
16+
)

tools/tinytest-codegen.py

Lines changed: 63 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ def script_to_map(test_file):
3232
return r
3333

3434

35+
def load_profile(profile_file, test_dirs, exclude_tests):
36+
profile_globals = {"test_dirs": test_dirs, "exclude_tests": exclude_tests}
37+
exec(profile_file.read(), profile_globals)
38+
return profile_globals["test_dirs"], profile_globals["exclude_tests"]
39+
40+
3541
test_function = (
3642
"void {name}(void* data) {{\n"
3743
" static const char pystr[] = {script};\n"
@@ -50,58 +56,55 @@ def script_to_map(test_file):
5056
testgroup_member = ' {{ "{name}", {name}_tests }},'
5157

5258
## XXX: may be we could have `--without <groups>` argument...
53-
# currently these tests are selected because they pass on qemu-arm
54-
test_dirs = (
55-
"basics",
56-
"micropython",
57-
"misc",
58-
"extmod",
59-
"float",
60-
"inlineasm",
61-
"qemu-arm",
62-
) # 'import', 'io',)
63-
exclude_tests = (
64-
# pattern matching in .exp
65-
"basics/bytes_compare3.py",
66-
"extmod/ticks_diff.py",
67-
"extmod/time_ms_us.py",
68-
# unicode char issue
69-
"extmod/json_loads.py",
70-
# doesn't output to python stdout
71-
"extmod/re_debug.py",
72-
"extmod/vfs_basic.py",
73-
"extmod/vfs_fat_ramdisk.py",
74-
"extmod/vfs_fat_fileio.py",
75-
"extmod/vfs_fat_fsusermount.py",
76-
"extmod/vfs_fat_oldproto.py",
77-
# rounding issues
78-
"float/float_divmod.py",
79-
# requires double precision floating point to work
80-
"float/float2int_doubleprec_intbig.py",
81-
"float/float_format_ints_doubleprec.py",
82-
"float/float_parse_doubleprec.py",
83-
# inline asm FP tests (require Cortex-M4)
84-
"inlineasm/asmfpaddsub.py",
85-
"inlineasm/asmfpcmp.py",
86-
"inlineasm/asmfpldrstr.py",
87-
"inlineasm/asmfpmuldiv.py",
88-
"inlineasm/asmfpsqrt.py",
89-
# different filename in output
90-
"micropython/emg_exc.py",
91-
"micropython/heapalloc_traceback.py",
92-
# don't have emergency exception buffer
93-
"micropython/heapalloc_exc_compressed_emg_exc.py",
94-
# pattern matching in .exp
95-
"micropython/meminfo.py",
96-
# needs sys stdfiles
97-
"misc/print_exception.py",
98-
# settrace .exp files are too large
99-
"misc/sys_settrace_loop.py",
100-
"misc/sys_settrace_generator.py",
101-
"misc/sys_settrace_features.py",
102-
# don't have f-string
103-
"basics/string_fstring.py",
104-
"basics/string_fstring_debug.py",
59+
60+
test_dirs = set(
61+
(
62+
"basics",
63+
"extmod",
64+
"float",
65+
"micropython",
66+
"misc",
67+
)
68+
)
69+
70+
exclude_tests = set(
71+
(
72+
# pattern matching in .exp
73+
"basics/bytes_compare3.py",
74+
"extmod/ticks_diff.py",
75+
"extmod/time_ms_us.py",
76+
# unicode char issue
77+
"extmod/json_loads.py",
78+
# doesn't output to python stdout
79+
"extmod/re_debug.py",
80+
"extmod/vfs_basic.py",
81+
"extmod/vfs_fat_ramdisk.py",
82+
"extmod/vfs_fat_fileio.py",
83+
"extmod/vfs_fat_fsusermount.py",
84+
"extmod/vfs_fat_oldproto.py",
85+
# rounding issues
86+
"float/float_divmod.py",
87+
# requires double precision floating point to work
88+
"float/float2int_doubleprec_intbig.py",
89+
"float/float_format_ints_doubleprec.py",
90+
"float/float_parse_doubleprec.py",
91+
# different filename in output
92+
"micropython/emg_exc.py",
93+
"micropython/heapalloc_traceback.py",
94+
# don't have emergency exception buffer
95+
"micropython/heapalloc_exc_compressed_emg_exc.py",
96+
# pattern matching in .exp
97+
"micropython/meminfo.py",
98+
# needs sys stdfiles
99+
"misc/print_exception.py",
100+
# settrace .exp files are too large
101+
"misc/sys_settrace_loop.py",
102+
"misc/sys_settrace_generator.py",
103+
"misc/sys_settrace_features.py",
104+
# don't have f-string
105+
"basics/string_fstring.py",
106+
"basics/string_fstring_debug.py",
107+
)
105108
)
106109

107110
output = []
@@ -112,11 +115,18 @@ def script_to_map(test_file):
112115
)
113116
argparser.add_argument("--stdin", action="store_true", help="read list of tests from stdin")
114117
argparser.add_argument("--exclude", action="append", help="exclude test by name")
118+
argparser.add_argument(
119+
"--profile",
120+
type=argparse.FileType("rt", encoding="utf-8"),
121+
help="optional profile file providing test directories and exclusion list",
122+
)
115123
args = argparser.parse_args()
116124

117125
if not args.stdin:
126+
if args.profile:
127+
test_dirs, exclude_tests = load_profile(args.profile, test_dirs, exclude_tests)
118128
if args.exclude:
119-
exclude_tests += tuple(args.exclude)
129+
exclude_tests = exclude_tests.union(args.exclude)
120130
for group in test_dirs:
121131
tests += [test for test in glob("{}/*.py".format(group)) if test not in exclude_tests]
122132
else:

0 commit comments

Comments
 (0)