Adds native unit test support, initial test coverage of Utils and Identity#1065
Open
aqua wants to merge 23 commits intomeshcore-dev:devfrom
Open
Adds native unit test support, initial test coverage of Utils and Identity#1065aqua wants to merge 23 commits intomeshcore-dev:devfrom
aqua wants to merge 23 commits intomeshcore-dev:devfrom
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.)