-
Notifications
You must be signed in to change notification settings - Fork 243
Adds native unit test support, initial test coverage of Utils and Identity #1065
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
aqua
wants to merge
22
commits into
meshcore-dev:dev
Choose a base branch
from
aqua:testing
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+473
−17
Conversation
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
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
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.)