Skip to content

Conversation

@aqua
Copy link

@aqua aqua commented Nov 5, 2025

This is an expanded form of PR #925 to address issue #1059 . They overlap but are easily reconciled -- either could be merged and the other updated to adjust for it. This fixes native compilation of almost the entire MC firmware, adds address sanitization, and adds slightly more test coverage. #925 has a couple extra tests I didn't think of, a couple more mocks we might want to merge in for convenient use, and adds a github workflow to run the tests (which is a good idea if maintainers are willing to accept that into the merge workflow -- I'd have done it but held off for feedback.)

Devin Carraway added 22 commits November 3, 2025 00:30
Libraries vary on whether they accept a no-argument println(),
but they all accept a single string value.
There aren't any standard mocks for these and our code
invokes the adafruit LittleFS library and RTC library
calls which assume they exist.
Doesn't really add any value over `pio test -e native` but stays
consistent with the current build procedure and any -D defines that
may become mandatory later.
Uses the native platform, which compiles with the host system's
compilers.  This was tested on MacOS' GNU c++.

Use the skaygin/ArduinoNative libdep for the Arduino platform
library dependencies; it's the most complete native mock
currently available in PlatformIO and covers almost everything
we use.

Reuses the preexisting stm32 clone of Adafruit's LittleFS for our
filesystem dependency, which seemed to be the easiest path
(though it's also the most demanding of the SPI interface.) Uses
private mocks of SPI and Wire.

The initial two sets of unit tests are fairly trivial, covering
our SHA256 library and mesh::Utils::toHex(), just to show that
everything's working.
Found the first bug, in fromHex() :)
- printHex (demonstrates a mock/spy stream)
- 2-part sha256
It's fast enough (and the current set of tests is small enough) to turn
on for the main native env, but not all local compilers will support it
so I made it a separate target.

Usage: pio test -e native-asan

Current tests all pass asan checks.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant