aboutsummaryrefslogtreecommitdiff
path: root/tests/stm32/gen_test.py
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2023-04-17 21:49:34 +0200
committerDario Nieuwenhuis <[email protected]>2023-04-17 21:49:34 +0200
commite63a34ba2167cd7637601ff2e7770dca00b1e3e1 (patch)
tree953f1c773896beb30d9403dd6ab72c2560bddcda /tests/stm32/gen_test.py
parent82dd7a5f8c08fe9b03b9d885ad992fcab1a9b00f (diff)
stm32/sdmmc: add hil test for f4.
Diffstat (limited to 'tests/stm32/gen_test.py')
-rw-r--r--tests/stm32/gen_test.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/stm32/gen_test.py b/tests/stm32/gen_test.py
new file mode 100644
index 000000000..8ff156c0e
--- /dev/null
+++ b/tests/stm32/gen_test.py
@@ -0,0 +1,44 @@
1import os
2import toml
3from glob import glob
4
5abspath = os.path.abspath(__file__)
6dname = os.path.dirname(abspath)
7os.chdir(dname)
8
9# ======= load test list
10tests = {}
11for f in sorted(glob('./src/bin/*.rs')):
12 name = os.path.splitext(os.path.basename(f))[0]
13 features = []
14 with open(f, 'r') as f:
15 for line in f:
16 if line.startswith('// required-features:'):
17 features = line.split(':', 2)[1].strip().split(',')
18
19 tests[name] = features
20
21# ========= Update Cargo.toml
22
23things = {
24 'bin': [
25 {
26 'name': f'{name}',
27 'path': f'src/bin/{name}.rs',
28 'required-features': features,
29 }
30 for name, features in tests.items()
31 ]
32}
33
34SEPARATOR_START = '# BEGIN TESTS\n'
35SEPARATOR_END = '# END TESTS\n'
36HELP = '# Generated by gen_test.py. DO NOT EDIT.\n'
37with open('Cargo.toml', 'r') as f:
38 data = f.read()
39before, data = data.split(SEPARATOR_START, maxsplit=1)
40_, after = data.split(SEPARATOR_END, maxsplit=1)
41data = before + SEPARATOR_START + HELP + \
42 toml.dumps(things) + SEPARATOR_END + after
43with open('Cargo.toml', 'w') as f:
44 f.write(data)