forked from espressif/arduino-esp32
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Enhance tests TODO #1
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
Draft
JakubAndrysek
wants to merge
3
commits into
master
Choose a base branch
from
enhance-tests
base: master
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.
Draft
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
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
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 | ||||
---|---|---|---|---|---|---|
|
@@ -2,30 +2,58 @@ | |||||
#include <unity.h> | ||||||
|
||||||
#define BTN 0 | ||||||
#define LED 4 | ||||||
|
||||||
void test_button() { | ||||||
Serial.println("Button test"); | ||||||
static int count = 0; | ||||||
static int lastState = HIGH; | ||||||
while (count < 3) { | ||||||
int state = digitalRead(BTN); | ||||||
if (state != lastState) { | ||||||
if (state == LOW) { | ||||||
count++; | ||||||
Serial.print("Button pressed "); | ||||||
Serial.print(count); | ||||||
Serial.println(" times"); | ||||||
} | ||||||
lastState = state; | ||||||
} | ||||||
delay(10); | ||||||
} | ||||||
void setUp(void) {} | ||||||
|
||||||
void tearDown(void) {} | ||||||
|
||||||
void test_read_basic(void) { | ||||||
Serial.println("GPIO read - basic START"); | ||||||
|
||||||
pinMode(BTN, INPUT_PULLUP); | ||||||
assert(digitalRead(BTN) == 1); | ||||||
TEST_ASSERT_EQUAL(HIGH, digitalRead(BTN)); | ||||||
Serial.println("BTN read as HIGH after pinMode INPUT_PULLUP"); | ||||||
|
||||||
delay(1000); | ||||||
TEST_ASSERT_EQUAL(LOW, digitalRead(BTN)); | ||||||
Serial.println("BTN read as LOW"); | ||||||
|
||||||
delay(1000); | ||||||
TEST_ASSERT_EQUAL(HIGH, digitalRead(BTN)); | ||||||
Serial.println("BTN read as HIGH"); | ||||||
} | ||||||
|
||||||
void test_write_basic(void) { | ||||||
Serial.println("GPIO write - basic test"); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This print message doesn’t match scenario.yaml, which expects "GPIO write - basic START". Update it to match the scenario.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||
pinMode(LED, OUTPUT); | ||||||
delay(1000); | ||||||
Serial.println("GPIO LED set to OUTPUT"); | ||||||
delay(2000); | ||||||
|
||||||
digitalWrite(LED, HIGH); | ||||||
delay(1000); | ||||||
Serial.println("LED set to HIGH"); | ||||||
|
||||||
delay(3000); | ||||||
digitalWrite(LED, LOW); | ||||||
Serial.println("LED set to LOW"); | ||||||
} | ||||||
|
||||||
|
||||||
void setup() { | ||||||
Serial.begin(115200); | ||||||
pinMode(BTN, INPUT_PULLUP); | ||||||
test_button(); | ||||||
while (!Serial) { | ||||||
; | ||||||
} | ||||||
|
||||||
UNITY_BEGIN(); | ||||||
RUN_TEST(test_read_basic); | ||||||
RUN_TEST(test_write_basic); | ||||||
UNITY_END(); | ||||||
|
||||||
Serial.println("GPIO test END"); | ||||||
} | ||||||
|
||||||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,48 @@ | ||
name: Pushbutton counter test | ||
version: 1 | ||
author: Jan Prochazka ([email protected]) | ||
author: Jan Prochazka ([email protected]) + Jakub Andrysek ([email protected]) | ||
|
||
steps: | ||
- wait-serial: "Button test" | ||
#### GPIO read - basic test | ||
- wait-serial: "GPIO read - basic START" | ||
- wait-serial: "BTN read as HIGH after pinMode INPUT_PULLUP" | ||
|
||
# Need for 1s delay for scenario to run properly | ||
- delay: 5000ms | ||
|
||
# Press once | ||
# Set the button to HIGH | ||
- set-control: | ||
part-id: btn1 | ||
control: pressed | ||
value: 1 | ||
- delay: 2000ms | ||
|
||
- wait-serial: "BTN read as LOW" | ||
|
||
# Set the button to LOW | ||
- set-control: | ||
part-id: btn1 | ||
control: pressed | ||
value: 0 | ||
- delay: 3000ms | ||
- wait-serial: "BTN read as HIGH" | ||
|
||
# Press 2nd time | ||
- set-control: | ||
part-id: btn1 | ||
control: pressed | ||
value: 1 | ||
- delay: 2000ms | ||
- set-control: | ||
part-id: btn1 | ||
control: pressed | ||
|
||
|
||
#### GPIO write - basic test | ||
- wait-serial: "GPIO write - basic START" | ||
- wait-serial: "GPIO LED set to OUTPUT" | ||
- expect-pin: | ||
part-id: led1 | ||
pin: A # Anode pin | ||
value: 0 | ||
- delay: 3000ms | ||
|
||
# Press for the 3rd time | ||
- set-control: | ||
part-id: btn1 | ||
control: pressed | ||
- wait-serial: 'LED set to HIGH' | ||
- expect-pin: | ||
part-id: led1 | ||
pin: A # Anode pin | ||
value: 1 | ||
- wait-serial: "Button pressed 3 times" | ||
- wait-serial: 'LED set to LOW' | ||
- expect-pin: | ||
part-id: led1 | ||
pin: A # Anode pin | ||
value: 0 | ||
|
||
|
||
#### GPIO end test | ||
- wait-serial: "GPIO test END" |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"platforms": { | ||
"hardware": false, | ||
"qemu": false, | ||
"wokwi": true | ||
} | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Replace the raw C assert() with a Unity assertion macro (e.g., TEST_ASSERT_EQUAL) for consistent test reporting.
Copilot uses AI. Check for mistakes.