Skip to content

Commit edadfd5

Browse files
committed
tools/tinytest-codegen, qemu-arm: 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 06a7bf9 commit edadfd5

File tree

3 files changed

+75
-24
lines changed

3 files changed

+75
-24
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: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Test profile for `qemu-arm`
2+
3+
[test_directories]
4+
5+
inlineasm
6+
micropython
7+
qemu-arm
8+
9+
[excluded_tests]
10+
11+
# inline asm FP tests (require Cortex-M4)
12+
inlineasm/asmfpaddsub.py
13+
inlineasm/asmfpcmp.py
14+
inlineasm/asmfpldrstr.py
15+
inlineasm/asmfpmuldiv.py
16+
inlineasm/asmfpsqrt.py
17+
18+
# different filename in output
19+
micropython/emg_exc.py
20+
micropython/heapalloc_traceback.py
21+
22+
# don't have emergency exception buffer
23+
micropython/heapalloc_exc_compressed_emg_exc.py
24+
25+
# pattern matching in .exp
26+
micropython/meminfo.py

tools/tinytest-codegen.py

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

3434

35+
def load_profile(profile_file):
36+
in_test_dirs = False
37+
in_exclusion_list = False
38+
39+
test_dirs = set()
40+
exclusion_list = set()
41+
42+
for line in profile_file:
43+
# Allow quoted comment markers if that's absolutely needed.
44+
if line := sub(r"\s*(?<!\\)#.*$", "", line.strip()):
45+
if line == "[test_directories]":
46+
in_test_dirs = True
47+
in_exclusion_list = False
48+
continue
49+
if line == "[excluded_tests]":
50+
in_test_dirs = False
51+
in_exclusion_list = True
52+
continue
53+
54+
if in_test_dirs:
55+
test_dirs.add(line)
56+
elif in_exclusion_list:
57+
exclusion_list.add(line)
58+
else:
59+
pass
60+
61+
return test_dirs, exclusion_list
62+
63+
3564
test_function = (
3665
"void {name}(void* data) {{\n"
3766
" static const char pystr[] = {script};\n"
@@ -50,17 +79,15 @@ def script_to_map(test_file):
5079
testgroup_member = ' {{ "{name}", {name}_tests }},'
5180

5281
## XXX: may be we could have `--without <groups>` argument...
53-
# currently these tests are selected because they pass on qemu-arm
54-
test_dirs = (
82+
83+
test_dirs = set((
5584
"basics",
56-
"micropython",
57-
"misc",
5885
"extmod",
5986
"float",
60-
"inlineasm",
61-
"qemu-arm",
62-
) # 'import', 'io',)
63-
exclude_tests = (
87+
"misc",
88+
))
89+
90+
exclude_tests = set((
6491
# pattern matching in .exp
6592
"basics/bytes_compare3.py",
6693
"extmod/ticks_diff.py",
@@ -80,19 +107,6 @@ def script_to_map(test_file):
80107
"float/float2int_doubleprec_intbig.py",
81108
"float/float_format_ints_doubleprec.py",
82109
"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",
96110
# needs sys stdfiles
97111
"misc/print_exception.py",
98112
# settrace .exp files are too large
@@ -102,7 +116,7 @@ def script_to_map(test_file):
102116
# don't have f-string
103117
"basics/string_fstring.py",
104118
"basics/string_fstring_debug.py",
105-
)
119+
))
106120

107121
output = []
108122
tests = []
@@ -112,11 +126,20 @@ def script_to_map(test_file):
112126
)
113127
argparser.add_argument("--stdin", action="store_true", help="read list of tests from stdin")
114128
argparser.add_argument("--exclude", action="append", help="exclude test by name")
129+
argparser.add_argument(
130+
"--profile",
131+
type=argparse.FileType('rt', encoding='utf-8'),
132+
help="optional profile file providing test directories and exclusion list"
133+
)
115134
args = argparser.parse_args()
116135

117136
if not args.stdin:
137+
if args.profile:
138+
directories, excluded = load_profile(args.profile)
139+
test_dirs = test_dirs.union(directories)
140+
exclude_tests = exclude_tests.union(excluded)
118141
if args.exclude:
119-
exclude_tests += tuple(args.exclude)
142+
exclude_tests = exclude_tests.union(args.exclude)
120143
for group in test_dirs:
121144
tests += [test for test in glob("{}/*.py".format(group)) if test not in exclude_tests]
122145
else:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy