28 lines
1.5 KiB
Python
28 lines
1.5 KiB
Python
#!/usr/bin/env python3
|
|
"""Compile the real Influx worker against a deterministic FreeRTOS/HTTP simulator."""
|
|
from pathlib import Path
|
|
import subprocess
|
|
import tempfile
|
|
|
|
firmware = Path(__file__).resolve().parents[2]
|
|
tests = Path(__file__).resolve().parent
|
|
source = firmware / 'components/net_influx'
|
|
with tempfile.TemporaryDirectory(prefix='nanopsx-influx-test-') as directory:
|
|
build = Path(directory)
|
|
for header in ['esp_err.h', 'esp_log.h', 'esp_timer.h', 'esp_http_client.h',
|
|
'storage.h', 'sys_status.h', 'freertos/FreeRTOS.h',
|
|
'freertos/task.h', 'freertos/queue.h', 'freertos/semphr.h']:
|
|
path = build / header
|
|
path.parent.mkdir(parents=True, exist_ok=True)
|
|
path.write_text('#include "fake_sdk.h"\n')
|
|
program = build / 'test_runtime'
|
|
subprocess.run(['cc', '-std=c11', '-D_POSIX_C_SOURCE=200809L', '-Wall', '-Wextra',
|
|
'-Wno-sign-compare', '-g', '-fsanitize=address,undefined',
|
|
'-fno-omit-frame-pointer', '-fno-pie', '-no-pie',
|
|
'-I', str(build), '-I', str(tests), '-I', str(source / 'include'),
|
|
'-I', str(source / 'src'), str(tests / 'test_runtime.c'),
|
|
str(source / 'src/influx_batch.c'), '-lm', '-o', str(program)], check=True)
|
|
for scenario in ['format', 'clock', 'normal', 'retry', 'overflow', 'no-date',
|
|
'no-date-failure', 'partial', 'max-body', 'reject']:
|
|
subprocess.run([str(program), scenario], check=True)
|