mirror of
https://github.com/ruvnet/RuView
synced 2026-07-26 18:01:48 +00:00
ffeaa46bc6
Implement full QEMU emulation framework for firmware testing without physical hardware: Mock CSI Generator (mock_csi.c): - 10 test scenarios: empty room, static/walking person, fall, multi-person, channel sweep, MAC filter, ring overflow, boundary RSSI, zero-length - Physics-based signal model with breathing modulation and Doppler - LFSR pseudo-random noise, CONFIG_CSI_MOCK_ENABLED Kconfig guard - Scenario 255 runs all sequentially QEMU Runner & CI: - qemu-esp32s3-test.sh: build, merge flash image, run QEMU, validate - validate_qemu_output.py: 14 automated checks (boot, NVS, edge, vitals, crash detection) with colored output and severity-based exit codes - generate_nvs_matrix.py: 14 NVS provisioning configs for matrix testing - firmware-qemu.yml: GitHub Actions CI with 4-scenario matrix Fuzz Testing: - 3 libFuzzer targets: CSI serialize, NVS config validation, ring buffer - Host-compilable ESP-IDF stubs (no ESP-IDF dependency for fuzzing) - 6 seed corpus files for guided fuzzing - Makefile with ASAN + UBSAN sanitizers Documentation: - firmware/esp32-csi-node/README.md: comprehensive QEMU testing guide - Root README.md: collapsed QEMU testing section Build verified: normal firmware build (RC=0) with mock_csi excluded. Closes #259 Co-Authored-By: claude-flow <ruv@ruv.net>
66 lines
1.9 KiB
C
66 lines
1.9 KiB
C
/**
|
|
* @file esp_stubs.c
|
|
* @brief Implementation of ESP-IDF stubs for host-based fuzz testing.
|
|
*
|
|
* Must be compiled with: -Istubs -I../main
|
|
* so that ESP-IDF headers resolve to stubs/ and firmware headers
|
|
* resolve to ../main/.
|
|
*/
|
|
|
|
#include "esp_stubs.h"
|
|
#include "edge_processing.h"
|
|
#include "wasm_runtime.h"
|
|
#include <stdint.h>
|
|
|
|
/** Monotonically increasing microsecond counter for esp_timer_get_time(). */
|
|
static int64_t s_fake_time_us = 0;
|
|
|
|
int64_t esp_timer_get_time(void)
|
|
{
|
|
/* Advance by 50ms each call (~20 Hz CSI rate simulation). */
|
|
s_fake_time_us += 50000;
|
|
return s_fake_time_us;
|
|
}
|
|
|
|
/* ---- stream_sender stubs ---- */
|
|
|
|
int stream_sender_send(const uint8_t *data, size_t len)
|
|
{
|
|
(void)data;
|
|
return (int)len;
|
|
}
|
|
|
|
int stream_sender_init(void)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
int stream_sender_init_with(const char *ip, uint16_t port)
|
|
{
|
|
(void)ip; (void)port;
|
|
return 0;
|
|
}
|
|
|
|
void stream_sender_deinit(void)
|
|
{
|
|
}
|
|
|
|
/* ---- wasm_runtime stubs ---- */
|
|
|
|
void wasm_runtime_on_frame(const float *phases, const float *amplitudes,
|
|
const float *variances, uint16_t n_sc,
|
|
const edge_vitals_pkt_t *vitals)
|
|
{
|
|
(void)phases; (void)amplitudes; (void)variances;
|
|
(void)n_sc; (void)vitals;
|
|
}
|
|
|
|
esp_err_t wasm_runtime_init(void) { return ESP_OK; }
|
|
esp_err_t wasm_runtime_load(const uint8_t *d, uint32_t l, uint8_t *id) { (void)d; (void)l; (void)id; return ESP_OK; }
|
|
esp_err_t wasm_runtime_start(uint8_t id) { (void)id; return ESP_OK; }
|
|
esp_err_t wasm_runtime_stop(uint8_t id) { (void)id; return ESP_OK; }
|
|
esp_err_t wasm_runtime_unload(uint8_t id) { (void)id; return ESP_OK; }
|
|
void wasm_runtime_on_timer(void) {}
|
|
void wasm_runtime_get_info(wasm_module_info_t *info, uint8_t *count) { (void)info; if(count) *count = 0; }
|
|
esp_err_t wasm_runtime_set_manifest(uint8_t id, const char *n, uint32_t c, uint32_t m) { (void)id; (void)n; (void)c; (void)m; return ESP_OK; }
|