Skip to content

Commit f9b05c0

Browse files
committed
CI: Add peripheral manager test
1 parent c4fd383 commit f9b05c0

File tree

2 files changed

+95
-0
lines changed

2 files changed

+95
-0
lines changed

Diff for: tests/periman/periman.ino

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/* Peripheral Manager test
2+
*
3+
* This test is using Serial to check if the peripheral manager is able to
4+
* attach and detach peripherals correctly on shared pins.
5+
*/
6+
7+
#include <unity.h>
8+
#include "HardwareSerial.h"
9+
#include "Wire.h"
10+
11+
/* Global variables */
12+
13+
String last_test = "";
14+
15+
/* Utility functions */
16+
17+
extern int8_t uart_get_RxPin(uint8_t uart_num);
18+
extern int8_t uart_get_TxPin(uint8_t uart_num);
19+
20+
/* Unity functions */
21+
22+
// This function is automatically called by unity before each test is run
23+
void setUp(void) {}
24+
25+
// This function is automatically called by unity after each test is run
26+
void tearDown(void) {
27+
Serial.print(last_test);
28+
Serial.println(" test: This should not be printed");
29+
Serial.flush();
30+
31+
Serial.setPins(SOC_RX0, SOC_TX0);
32+
delay(100);
33+
Serial.print(last_test);
34+
Serial.println(" test: This should be printed");
35+
Serial.flush();
36+
}
37+
38+
/* Test functions */
39+
/* These functions must only init the peripheral on the same pins and update "last_test" */
40+
41+
#if SOC_I2C_SUPPORTED
42+
void i2c_test(void) {
43+
last_test = "I2C";
44+
Wire.begin(SOC_RX0, SOC_TX0);
45+
}
46+
#endif
47+
48+
#if SOC_RMT_SUPPORTED
49+
void rmt_test(void) {
50+
last_test = "RMT";
51+
if (!rmtInit(SOC_RX0, RMT_TX_MODE, RMT_MEM_NUM_BLOCKS_1, 10000000)) {
52+
TEST_FAIL_MESSAGE("RMT init failed");
53+
}
54+
if (!rmtInit(SOC_TX0, RMT_TX_MODE, RMT_MEM_NUM_BLOCKS_1, 10000000)) {
55+
TEST_FAIL_MESSAGE("RMT init failed");
56+
}
57+
}
58+
#endif
59+
60+
#if SOC_LEDC_SUPPORTED
61+
void ledc_test(void) {
62+
last_test = "LEDC";
63+
ledcAttach(SOC_RX0, 5000, 12);
64+
ledcAttach(SOC_TX0, 5000, 12);
65+
}
66+
#endif
67+
68+
/* Main functions */
69+
70+
void setup() {
71+
Serial.begin(115200);
72+
while(!Serial) { delay(10); }
73+
74+
UNITY_BEGIN();
75+
76+
#if SOC_I2C_SUPPORTED
77+
RUN_TEST(i2c_test);
78+
#endif
79+
80+
#if SOC_LEDC_SUPPORTED
81+
RUN_TEST(ledc_test);
82+
#endif
83+
84+
#if SOC_RMT_SUPPORTED
85+
RUN_TEST(rmt_test);
86+
#endif
87+
88+
UNITY_END();
89+
}
90+
91+
void loop() {}

Diff for: tests/periman/test_periman.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
def test_periman(dut):
2+
dut.expect("I2C test: This should be printed")
3+
dut.expect("LEDC test: This should be printed")
4+
dut.expect("RMT test: This should be printed")

0 commit comments

Comments
 (0)