mirror of
https://github.com/0xFEEDC0DE64/arduino-esp32.git
synced 2025-07-30 18:57:14 +02:00
Add initial hardware testing support (#6313)
- Added workflow triggered by cron or label "hil_test" - Added examples with both pytest and unity
This commit is contained in:
committed by
GitHub
parent
4da1051266
commit
96f8f5e3ef
2
tests/.gitignore
vendored
Normal file
2
tests/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
build/
|
||||
__pycache__/
|
12
tests/hello_world/hello_world.ino
Normal file
12
tests/hello_world/hello_world.ino
Normal file
@ -0,0 +1,12 @@
|
||||
void setup(){
|
||||
// Open serial communications and wait for port to open:
|
||||
Serial.begin(115200);
|
||||
while (!Serial) {
|
||||
;
|
||||
}
|
||||
|
||||
Serial.println("Hello Arduino!");
|
||||
}
|
||||
|
||||
void loop(){
|
||||
}
|
2
tests/hello_world/test_hello_world.py
Normal file
2
tests/hello_world/test_hello_world.py
Normal file
@ -0,0 +1,2 @@
|
||||
def test_hello_world(dut):
|
||||
dut.expect('Hello Arduino!')
|
13
tests/pytest.ini
Normal file
13
tests/pytest.ini
Normal file
@ -0,0 +1,13 @@
|
||||
[pytest]
|
||||
addopts = --embedded-services esp,arduino
|
||||
|
||||
# log related
|
||||
log_cli = True
|
||||
log_cli_level = INFO
|
||||
log_cli_format = %(asctime)s %(levelname)s %(message)s
|
||||
log_cli_date_format = %Y-%m-%d %H:%M:%S
|
||||
|
||||
log_file = test.log
|
||||
log_file_level = INFO
|
||||
log_file_format = %(asctime)s %(levelname)s %(message)s
|
||||
log_file_date_format = %Y-%m-%d %H:%M:%S
|
13
tests/requirements.txt
Normal file
13
tests/requirements.txt
Normal file
@ -0,0 +1,13 @@
|
||||
pyserial>=3.0
|
||||
esptool>=3.1
|
||||
pytest-cov
|
||||
cryptography<3.4; platform_machine == "armv7l"
|
||||
|
||||
pytest>=6.2.0
|
||||
pexpect>=4.4
|
||||
|
||||
pytest-embedded>=0.5.1
|
||||
pytest-embedded-serial>=0.5.1
|
||||
pytest-embedded-serial-esp>=0.5.1
|
||||
pytest-embedded-arduino>=0.5.1
|
||||
|
2
tests/unity/test_unity.py
Normal file
2
tests/unity/test_unity.py
Normal file
@ -0,0 +1,2 @@
|
||||
def test_unity(dut):
|
||||
dut.expect_unity_test_output(timeout=240)
|
33
tests/unity/unity.ino
Normal file
33
tests/unity/unity.ino
Normal file
@ -0,0 +1,33 @@
|
||||
#include <unity.h>
|
||||
|
||||
|
||||
/* These functions are intended to be called before and after each test. */
|
||||
void setUp(void) {
|
||||
}
|
||||
|
||||
void tearDown(void){
|
||||
}
|
||||
|
||||
|
||||
void test_pass(void){
|
||||
TEST_ASSERT_EQUAL(1, 1);
|
||||
}
|
||||
|
||||
void test_fail(void){
|
||||
TEST_ASSERT_EQUAL(1, 1);
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
while (!Serial) {
|
||||
;
|
||||
}
|
||||
|
||||
UNITY_BEGIN();
|
||||
RUN_TEST(test_pass);
|
||||
RUN_TEST(test_fail);
|
||||
UNITY_END();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
}
|
Reference in New Issue
Block a user