"""Host regression suite. CC may point to clang/gcc; this does not replace a TI build.""" import os from pathlib import Path import shutil import subprocess import tempfile root = Path(__file__).resolve().parents[1] cc = os.environ.get('CC') or shutil.which('clang') or shutil.which('gcc') if not cc: raise SystemExit('Set CC to a C99 host compiler') store = 'ports/tms320f28335/f28335_boot_store.c' cases = [ ('core', [], ['src/pcan_boot.c', 'tests/test_pcan_boot.c']), ('store_native', [], [store, 'tests/test_f28335_boot_store.c']), ('store_wide', ['-DPCAN_BOOT_WIDE_BYTES'], [store, 'tests/test_f28335_boot_store.c']), ('loader', ['-DPCAN_BOOT_WIDE_BYTES'], [store, 'src/pcan_boot.c', 'tests/test_f28335_can_boot.c']), ('application', ['-DPCAN_BOOT_WIDE_BYTES', '-DF28335_BOOT_LOADER=0'], [store, 'src/pcan_boot.c', 'tests/test_f28335_can_boot.c']), ] with tempfile.TemporaryDirectory(prefix='f28335-ab-') as tmp: for name, defines, sources in cases: exe = Path(tmp) / (name + '.exe') subprocess.run([cc, '-std=c99', '-Wall', '-Wextra', '-Werror', '-Iinclude', '-Itests/f28335_stubs', *defines, *sources, '-o', str(exe)], cwd=root, check=True) sample = os.environ.get('F28335_SAMPLE_IMAGE') if name == 'store_wide' else None subprocess.run([str(exe), *([sample] if sample else [])], check=True, timeout=30)