Skip to content

Commit c4b868e

Browse files
committed
test: inject CI guard failure cases
1 parent 951a332 commit c4b868e

3 files changed

Lines changed: 42 additions & 1 deletion

File tree

‎bsp/stm32/stm32f407-rt-spark/.ci/attachconfig/ci.attachconfig.yml‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,3 +203,13 @@ component.cherryusb_cdc:
203203
- CONFIG_RT_CHERRYUSB_DEVICE_DWC2_ST=y
204204
- CONFIG_RT_CHERRYUSB_DEVICE_CDC_ACM=y
205205
- CONFIG_RT_CHERRYUSB_DEVICE_TEMPLATE_CDC_ACM=y
206+
ci-guard-test:
207+
env:
208+
RTT_CI_GUARD_TEST_INJECT: "1"
209+
pre_build: |
210+
python -c "import sys; sys.exit(23)"
211+
post_build: |
212+
python -c "import sys; sys.exit(24)"
213+
buildcheckresult: RTT_CI_GUARD_TEST_EXPECTED_OUTPUT_NOT_FOUND
214+
kconfig:
215+
- CONFIG_RT_USING_FINSH=y

‎tools/ci/bsp_buildings.py‎

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
re.compile(r"(can'?t|cannot|unable to)\s+(read|open|find).*SConscript", re.IGNORECASE),
2626
re.compile(r'FileNotFoundError:.*SConscript', re.IGNORECASE),
2727
re.compile(r'scons:\s+\*\*\*', re.IGNORECASE),
28+
re.compile(r'RTT_CI_GUARD_TEST_SCONS_FATAL', re.IGNORECASE),
2829
)
2930

3031
def add_summary(text):
@@ -66,7 +67,11 @@ def check_bsp_build_scripts(bsp_dir):
6667
check whether the BSP has the basic scons build entry files.
6768
"""
6869
missing = []
69-
for filename in ('SConstruct', 'SConscript'):
70+
required_files = ['SConstruct', 'SConscript']
71+
if os.getenv('RTT_CI_GUARD_TEST_MISSING_SCRIPT') == '1':
72+
required_files.append('SConscript.ci-guard-test-missing')
73+
74+
for filename in required_files:
7075
if not os.path.isfile(os.path.join(bsp_dir, filename)):
7176
missing.append(filename)
7277

@@ -86,6 +91,28 @@ def run_cmd(cmd, output_info=True):
8691
res = 0
8792
output_file = f'output_{os.getpid()}_{threading.get_ident()}.txt'
8893
devnull = os.devnull
94+
if os.getenv('RTT_CI_GUARD_TEST_INJECT') == '1':
95+
if '--pyconfig-silent' in cmd:
96+
output_str_list = ['RTT_CI_GUARD_TEST: injected pyconfig failure\n']
97+
res = 31
98+
elif cmd.startswith('pkgs --update-force'):
99+
output_str_list = ['RTT_CI_GUARD_TEST: injected pkgs update failure\n']
100+
res = 32
101+
elif cmd.startswith('pkgs --list'):
102+
output_str_list = ['RTT_CI_GUARD_TEST: injected pkgs list failure\n']
103+
res = 33
104+
elif re.search(r'(^|\s)scons(\s|$)', cmd) and '-c' not in cmd:
105+
output_str_list = ['RTT_CI_GUARD_TEST_SCONS_FATAL: injected scons fatal log\n']
106+
res = 0
107+
108+
if output_str_list:
109+
for line in output_str_list:
110+
print(line, end='')
111+
if contains_scons_fatal_error(output_str_list):
112+
print(f"::error::scons fatal error detected while running: {cmd}")
113+
if res == 0:
114+
res = 1
115+
return output_str_list, res
89116

90117
if output_info:
91118
res = os.system(cmd + f" > {output_file} 2>&1")

‎tools/ci/compile_bsp_with_drivers.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ def check_scons_build_files(dir):
9696

9797
def recompile_bsp(dir):
9898
logging.info("recomplie bsp: {}".format(dir))
99+
if os.getenv("RTT_CI_GUARD_TEST_INJECT") == "1":
100+
logging.error("RTT_CI_GUARD_TEST: injected recompile failure for %s", dir)
101+
return 1
102+
99103
if not check_scons_build_files(dir):
100104
return 1
101105

0 commit comments

Comments
 (0)