summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorhathach <[email protected]>2024-10-04 15:01:03 +0700
committerhathach <[email protected]>2024-10-04 15:01:03 +0700
commit1b295de9adbe8eb42f1590ce6b478af5c23e5f8b (patch)
treefc38ac78ad84c90d841332febb8640247c3096f8 /test
parenteda3cceab207bce390b995462e313ed124fa7732 (diff)
add hil_ci_set_matrix.py, starting to support hil with additional build flags
Diffstat (limited to 'test')
-rw-r--r--test/hil/hil_ci_set_matrix.py42
-rw-r--r--test/hil/hil_test.py60
2 files changed, 76 insertions, 26 deletions
diff --git a/test/hil/hil_ci_set_matrix.py b/test/hil/hil_ci_set_matrix.py
new file mode 100644
index 000000000..56952eab3
--- /dev/null
+++ b/test/hil/hil_ci_set_matrix.py
@@ -0,0 +1,42 @@
+import argparse
+import json
+import os
+
+def main():
+ parser = argparse.ArgumentParser()
+ parser.add_argument('config_file', help='Configuration JSON file')
+ args = parser.parse_args()
+
+ config_file = args.config_file
+
+ # if config file is not found, try to find it in the same directory as this script
+ if not os.path.exists(config_file):
+ config_file = os.path.join(os.path.dirname(__file__), config_file)
+ with open(config_file) as f:
+ config = json.load(f)
+
+ matrix = {
+ 'arm-gcc': [],
+ 'esp-idf': []
+ }
+ for board in config['boards']:
+ name = board['name']
+ if board['flasher'] == 'esptool':
+ toolchain = 'esp-idf'
+ else:
+ toolchain = 'arm-gcc'
+
+ if 'build_flags_on' in board:
+ for f in board['build_flags_on']:
+ if f == '':
+ matrix[toolchain].append(f'-b {name}')
+ else:
+ matrix[toolchain].append(f'-b {name}-{f.replace(" ", "_")}')
+ else:
+ matrix[toolchain].append(f'-b {name}')
+
+ print(json.dumps(matrix))
+
+
+if __name__ == '__main__':
+ main()
diff --git a/test/hil/hil_test.py b/test/hil/hil_test.py
index cb885aeb5..eaa9dd3bd 100644
--- a/test/hil/hil_test.py
+++ b/test/hil/hil_test.py
@@ -424,37 +424,45 @@ def test_board(board):
test_list.append('device/board_test')
err_count = 0
- for test in test_list:
- fw_dir = f'cmake-build/cmake-build-{name}/{test}'
- if not os.path.exists(fw_dir):
- fw_dir = f'examples/cmake-build-{name}/{test}'
- fw_name = f'{fw_dir}/{os.path.basename(test)}'
- print(f'{name:25} {test:30} ... ', end='')
+ flags_opt_list = [""]
+ if 'build_flags_on' in board:
+ flags_opt_list = board['build_flags_on']
- if not os.path.exists(fw_dir):
- print('Skip (no binary)')
- continue
+ for flags_opt in flags_opt_list:
+ flags_opt_str = ""
+ if flags_opt != "":
+ flags_opt_str = '-' + flags_opt.replace(' ', '-')
+ for test in test_list:
+ fw_dir = f'cmake-build/cmake-build-{name}{flags_opt_str}/{test}'
+ if not os.path.exists(fw_dir):
+ fw_dir = f'examples/cmake-build-{name}{flags_opt_str}/{test}'
+ fw_name = f'{fw_dir}/{os.path.basename(test)}'
+ print(f'{name+flags_opt_str:40} {test:30} ... ', end='')
+
+ if not os.path.exists(fw_dir):
+ print('Skip (no binary)')
+ continue
+
+ # flash firmware. It may fail randomly, retry a few times
+ for i in range(3):
+ ret = globals()[f'flash_{flasher}'](board, fw_name)
+ if ret.returncode == 0:
+ break
+ else:
+ print(f'Flashing failed, retry {i+1}')
+ time.sleep(1)
- # flash firmware. It may fail randomly, retry a few times
- for i in range(3):
- ret = globals()[f'flash_{flasher}'](board, fw_name)
if ret.returncode == 0:
- break
+ try:
+ ret = globals()[f'test_{test.replace("/", "_")}'](board)
+ print('OK')
+ except Exception as e:
+ err_count += 1
+ print(STATUS_FAILED)
+ print(f' {e}')
else:
- print(f'Flashing failed, retry {i+1}')
- time.sleep(1)
-
- if ret.returncode == 0:
- try:
- ret = globals()[f'test_{test.replace("/", "_")}'](board)
- print('OK')
- except Exception as e:
err_count += 1
- print(STATUS_FAILED)
- print(f' {e}')
- else:
- err_count += 1
- print(f'Flash {STATUS_FAILED}')
+ print(f'Flash {STATUS_FAILED}')
return err_count