Перенесены онлайн-запись, архив отключения и доступ по RS/CAN из 167. Учтены готовность READY, фиксированный разгон ЦАП и каналы АЦП проекта 166. Добавлены документация и тесты, обновлены файлы прошивки.
39 lines
1.8 KiB
Python
39 lines
1.8 KiB
Python
"""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'))
|
|
args = parser.parse_args()
|
|
if not args.compiler:
|
|
parser.error('Provide --compiler pointing to clang.exe or cl.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']
|
|
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)]
|
|
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)
|