Files
Balsam_167/tests/ump_logger/run_test.py
Andrey 52683164af Перенести улучшения прошивки в ветку 166
Добавить CAN heartbeat и передачу по изменению с повтором через 1,3 с,
компактный логгер v4, паспорт прошивки и блочное чтение EEPROM.
Подключить автоматическую версию и проверяемую сборку BIN.
Сохранить локальные исправления стробов и защиты Timer1.
Обновить тесты, документацию, UTF-8 и исключения временных файлов.

Проверки: CAN, R3, EEPROM, паспорт, TESTLAMP, логгер, START/STOP;
9 сценариев сборки, включая реальную конверсию TI.
Все 17 внутренних модулей скомпилированы TI C2000 без ошибок.
2026-10-19 13:46:29 +03:00

42 lines
3.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""Host test of the 166 recorder. Requires Clang/lld or MSVC (Windows).
Example: py -3 tests/ump_logger/run_test.py --compiler "C:/path/to/cl.exe"
All build products are written to a temporary directory.
"""
import argparse
import os
from pathlib import Path
import shutil
import subprocess
import tempfile
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--compiler', default=shutil.which('clang') or shutil.which('cl') or shutil.which('gcc') or ('C:/msys64/mingw64/bin/gcc.exe' if Path('C:/msys64/mingw64/bin/gcc.exe').is_file() else None)) # Поддерживает имеющийся GCC для проверки нового include-пути без обязательной установки другого host-компилятора.
args = parser.parse_args()
if not args.compiler:
parser.error('Provide --compiler pointing to clang.exe, cl.exe or gcc.exe') # Явно перечисляет поддерживаемые инструменты проверки, не меняя компилятор самой прошивки.
root = Path(__file__).resolve().parents[2]
with tempfile.TemporaryDirectory(prefix='ump-recorder-') as directory:
output = Path(directory)
library = output / 'recorder_test.dll'
includes = [root / 'tests/ump_logger/stubs', root / 'Source/Internal/Include', root.parent / 'newProject/templates/c/firmware-info/include'] # Адаптер CAN теперь использует общий статический интерфейс паспорта, как production-сборка 166.
source = root / 'tests/ump_logger/recorder_test.c'
if Path(args.compiler).stem.lower() == 'cl':
command = [args.compiler, '/nologo', '/LD', '/GS-', '/wd4068', '/wd4312',
*['/I' + str(p) for p in includes], str(source),
'/Fo' + str(output / 'recorder.obj'), '/link', '/NOENTRY',
'/NODEFAULTLIB', '/OUT:' + str(library)]
elif Path(args.compiler).stem.lower() in ('gcc', 'cc'): # MinGW использует обычную DLL с CRT и не принимает специальные параметры компоновщика Clang/lld.
command = [args.compiler, '-shared', '-O3', '-Wno-unknown-pragmas', '-Wno-int-to-pointer-cast', *['-I' + str(p) for p in includes], str(source), '-o', str(library)] # Компилирует тот же существующий recorder_test.c и production-логгер без копирования его алгоритма.
os.environ['PATH'] = str(Path(args.compiler).resolve().parent) + os.pathsep + os.environ.get('PATH', '') # Даёт дочернему Python доступ к runtime DLL выбранного MinGW только в этом тестовом процессе.
else:
command = [args.compiler, '-shared', '-nostdlib', '-fuse-ld=lld',
'-Wl,/noentry,/nodefaultlib', '-Wno-unknown-pragmas',
'-Wno-int-to-pointer-cast', *['-I' + str(p) for p in includes],
str(source), '-o', str(library)]
subprocess.run(command, cwd=output, check=True)
subprocess.run([os.sys.executable, '-c',
'import ctypes,sys; r=ctypes.CDLL(sys.argv[1]).run_tests(); '
'print("PASS" if r==0 else f"FAIL: C line {r}"); sys.exit(bool(r))',
str(library)], check=True)