-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Allow test framework to use cores/esp8266/Arduino.h directly #7377
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
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
84d8866
Allow test framework to use cores/esp8266/Arduino.h directly
mcspr c89d0f6
fix wps debugging
mcspr 0e0849d
some more missing debug.h
mcspr 65fab13
Merge remote-tracking branch 'origin/master' into tests/sync-arduino-h
mcspr 555c272
Hunt down debug.h and roll-back
mcspr 6b36f6e
Move abs+round checks to test/device/test_sw
mcspr ffc3744
Restore macros for C code
mcspr 6db24f8
fixup! Move abs+round checks to test/device/test_sw
mcspr e59f926
Fix bad c/p, actually try round with ints
mcspr 0c8c7ab
Merge branch 'master' into tests/sync-arduino-h
d-a-v 1f14878
tweak c macros per review
mcspr 9e1b019
Merge remote-tracking branch 'origin/master' into tests/sync-arduino-h
mcspr 247c6c3
fix gcc-10 missing cerrno include
mcspr 685c25f
amend 555c272, again
mcspr 60de322
fixup! Merge remote-tracking branch 'origin/master' into tests/sync-a…
mcspr 1a2fd27
fixup! amend 555c272, again
mcspr 8c89d90
switch to the current -std=... opts
mcspr f48cd49
Revert "switch to the current -std=... opts"
mcspr 481b351
trying to fix CI, clean-up configTime decl + def
mcspr b496509
Merge branch 'master' into tests/sync-arduino-h
mcspr 8e7a003
Merge remote-tracking branch 'origin/master' into tests/sync-arduino-h
mcspr 1fa62d4
Merge branch 'master' into tests/sync-arduino-h
mcspr 3d7379f
Merge branch 'master' into tests/sync-arduino-h
d-a-v File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
#define ESP_H | ||
|
||
#include <Arduino.h> | ||
#include "core_esp8266_features.h" | ||
#include "spi_vendors.h" | ||
|
||
/** | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,6 @@ | |
|
||
#include <stdlib.h> | ||
#include <assert.h> | ||
#include <debug.h> | ||
#include <Arduino.h> | ||
#include <cxxabi.h> | ||
|
||
|
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
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
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
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
86 changes: 86 additions & 0 deletions
86
tests/device/test_sw_arduino_math_overrides/test_sw_arduino_math_overrides.ino
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* | ||
Small math example, checking whether we properly integrate with c++ math | ||
|
||
ref: | ||
- https://github.com/esp8266/Arduino/issues/5530 | ||
- https://github.com/espressif/arduino-esp32/pull/2738 | ||
|
||
Released to public domain | ||
*/ | ||
|
||
#include <BSTest.h> | ||
#include <type_traits> | ||
|
||
BS_ENV_DECLARE(); | ||
|
||
void setup() | ||
{ | ||
Serial.begin(115200); | ||
BS_RUN(Serial); | ||
} | ||
|
||
bool pretest() | ||
{ | ||
return true; | ||
} | ||
|
||
#define TEST_MATH_IS_SAME(OP1, OP2) \ | ||
std::is_same<decltype(OP1), decltype(OP2)>::value | ||
|
||
TEST_CASE("std::abs and abs result is the same", "[arduino-math]") | ||
{ | ||
CHECK(TEST_MATH_IS_SAME(abs(-5), std::abs(-5))); | ||
CHECK(TEST_MATH_IS_SAME(abs(-25.0), std::abs(-25.0))); | ||
CHECK(TEST_MATH_IS_SAME(abs(10.0), std::abs(10.0))); | ||
CHECK(! TEST_MATH_IS_SAME(abs(10.0), std::abs(10))); | ||
CHECK(! TEST_MATH_IS_SAME(abs(-5), std::abs(10.0))); | ||
} | ||
|
||
TEST_CASE("abs works with ints", "[arduino-math]") | ||
{ | ||
int a = -3; | ||
int b = 3; | ||
CHECK(TEST_MATH_IS_SAME(abs(a), a)); | ||
CHECK(TEST_MATH_IS_SAME(abs(b), b)); | ||
CHECK(abs(a) == b); | ||
CHECK(abs(b) == b); | ||
} | ||
|
||
template <typename T> | ||
bool compare_floats(T a, T b) { | ||
static_assert(std::is_floating_point<T>::value, ""); | ||
return std::fabs(a - b) < std::numeric_limits<float>::epsilon(); | ||
} | ||
|
||
TEST_CASE("abs works with floats", "[arduino-math]") | ||
{ | ||
float a = -3.5; | ||
float b = 3.5; | ||
CHECK(TEST_MATH_IS_SAME(abs(a), a)); | ||
CHECK(TEST_MATH_IS_SAME(abs(b), b)); | ||
CHECK(compare_floats(abs(a), b)); | ||
CHECK(compare_floats(abs(b), b)); | ||
} | ||
|
||
TEST_CASE("round works with ints", "[arduino-math]") | ||
{ | ||
int a = 5; | ||
int b = 10; | ||
CHECK(TEST_MATH_IS_SAME(round(a), std::round(a))); | ||
CHECK(TEST_MATH_IS_SAME(round(b), std::round(b))); | ||
CHECK(compare_floats(round(a), std::round(a))); | ||
CHECK(compare_floats(round(b), std::round(b))); | ||
} | ||
|
||
TEST_CASE("round works with floats", "[arduino-math]") | ||
{ | ||
float a = 2.9; | ||
float b = 3.0; | ||
CHECK(TEST_MATH_IS_SAME(round(a), a)); | ||
CHECK(TEST_MATH_IS_SAME(round(b), b)); | ||
CHECK(compare_floats(round(a), b)); | ||
CHECK(compare_floats(round(b), b)); | ||
} | ||
|
||
void loop(){} | ||
|
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.