Skip to content

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
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions tests/validation/adc/adc.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#include <Arduino.h>
#include <unity.h>

#define BTN 0
#define LED 4

#if CONFIG_IDF_TARGET_ESP32P4
#define POT_PIN 53
#else
#define POT_PIN 2
#endif



void setUp(void) {}

void tearDown(void) {}

void test_adc_potentiometer(void) {
Serial.println("ADC potentiometer test START");

// Configure ADC
analogReadResolution(12); // Set ADC resolution to 12 bits (0-4095)
analogSetAttenuation(ADC_11db); // Set attenuation for full 3.3V range

Serial.println("Reading ADC values from potentiometer on GPIO2");

// Take multiple readings to test different potentiometer positions
for (int i = 0; i < 5; i++) {
int adcValue = analogRead(POT_PIN);
float voltage = (adcValue * 3.3) / 4095.0;

Serial.print("ADC Reading ");
Serial.print(i + 1);
Serial.print(": ");
Serial.print(adcValue);
Serial.print(" (");
Serial.print(voltage, 2);
Serial.println("V)");

// Test that ADC reading is within valid range
TEST_ASSERT_GREATER_OR_EQUAL(0, adcValue);
TEST_ASSERT_LESS_OR_EQUAL(4095, adcValue);

delay(1000); // Wait 1 second between readings
}

Serial.println("ADC potentiometer test completed successfully");
}


void setup() {
Serial.begin(115200);
while (!Serial) {
;
}

UNITY_BEGIN();
RUN_TEST(test_adc_potentiometer);
UNITY_END();

Serial.println("ADC test END");
}

void loop() {}
7 changes: 7 additions & 0 deletions tests/validation/adc/ci.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"platforms": {
"hardware": false,
"qemu": false,
"wokwi": true
}
}
24 changes: 24 additions & 0 deletions tests/validation/adc/diagram.esp32.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"version": 1,
"author": "Jakub Andrýsek",
"editor": "wokwi",
"parts": [
{ "type": "board-esp32-devkit-c-v4", "id": "esp", "top": 0, "left": 0, "attrs": {} },
{
"type": "wokwi-potentiometer",
"id": "pot1",
"top": 143.8,
"left": 165.3,
"rotate": 90,
"attrs": {}
}
],
"connections": [
[ "esp:TX", "$serialMonitor:RX", "", [] ],
[ "esp:RX", "$serialMonitor:TX", "", [] ],
[ "pot1:GND", "esp:GND.2", "black", [ "h-48", "v-143.82" ] ],
[ "pot1:VCC", "esp:5V", "red", [ "h0" ] ],
[ "esp:2", "pot1:SIG", "green", [ "h0" ] ]
],
"dependencies": {}
}
24 changes: 24 additions & 0 deletions tests/validation/adc/diagram.esp32c3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"version": 1,
"author": "Jakub Andrýsek",
"editor": "wokwi",
"parts": [
{ "type": "board-esp32-c3-devkitm-1", "id": "esp", "top": 0, "left": 0, "attrs": {} },
{
"type": "wokwi-potentiometer",
"id": "pot1",
"top": 143.8,
"left": 165.3,
"rotate": 90,
"attrs": {}
}
],
"connections": [
[ "esp:TX", "$serialMonitor:RX", "", [] ],
[ "esp:RX", "$serialMonitor:TX", "", [] ],
[ "pot1:GND", "esp:GND.2", "black", [ "h-48", "v-143.82" ] ],
[ "pot1:VCC", "esp:3V3", "red", [ "h0" ] ],
[ "esp:2", "pot1:SIG", "green", [ "h0" ] ]
],
"dependencies": {}
}
24 changes: 24 additions & 0 deletions tests/validation/adc/diagram.esp32c6.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"version": 1,
"author": "Jakub Andrýsek",
"editor": "wokwi",
"parts": [
{ "type": "board-esp32-c6-devkitc-1", "id": "esp", "top": 0, "left": 0, "attrs": {} },
{
"type": "wokwi-potentiometer",
"id": "pot1",
"top": 143.8,
"left": 165.3,
"rotate": 90,
"attrs": {}
}
],
"connections": [
[ "esp:TX", "$serialMonitor:RX", "", [] ],
[ "esp:RX", "$serialMonitor:TX", "", [] ],
[ "pot1:GND", "esp:GND.2", "black", [ "h-48", "v-143.82" ] ],
[ "pot1:VCC", "esp:3V3", "red", [ "h0" ] ],
[ "esp:2", "pot1:SIG", "green", [ "h0" ] ]
],
"dependencies": {}
}
24 changes: 24 additions & 0 deletions tests/validation/adc/diagram.esp32h2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"version": 1,
"author": "Jakub Andrýsek",
"editor": "wokwi",
"parts": [
{ "type": "board-esp32-h2-devkitm-1", "id": "esp", "top": 0, "left": 0, "attrs": {} },
{
"type": "wokwi-potentiometer",
"id": "pot1",
"top": 143.8,
"left": 165.3,
"rotate": 90,
"attrs": {}
}
],
"connections": [
[ "esp:TX", "$serialMonitor:RX", "", [] ],
[ "esp:RX", "$serialMonitor:TX", "", [] ],
[ "pot1:GND", "esp:GND.2", "black", [ "h-48", "v-143.82" ] ],
[ "pot1:VCC", "esp:3V3", "red", [ "h0" ] ],
[ "esp:2", "pot1:SIG", "green", [ "h0" ] ]
],
"dependencies": {}
}
18 changes: 18 additions & 0 deletions tests/validation/adc/diagram.esp32p4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"version": 1,
"author": "Jakub Andrýsek",
"editor": "wokwi",
"parts": [
{ "type": "board-esp32-p4-function-ev", "id": "esp", "top": 0, "left": 0, "attrs": {} },
{ "type": "wokwi-potentiometer", "id": "pot1", "top": -115.4, "left": 261.3, "attrs": {} }
],
"connections": [
[ "esp:37", "$serialMonitor:RX", "", [] ],
[ "esp:38", "$serialMonitor:TX", "", [] ],
[ "pot1:GND", "esp:GND.2", "black", [ "h-48", "v-143.82" ] ],
[ "pot1:VCC", "esp:3V3", "red", [ "h0" ] ],
[ "esp:53", "pot1:SIG", "green", [ "h0" ] ],
[ "esp:5V.2", "pot1:VCC", "red", [ "v-27.92", "h119.07" ] ]
],
"dependencies": {}
}
24 changes: 24 additions & 0 deletions tests/validation/adc/diagram.esp32s2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"version": 1,
"author": "Jakub Andrýsek",
"editor": "wokwi",
"parts": [
{ "type": "board-esp32-s2-devkitm-1", "id": "esp", "top": 0, "left": 0, "attrs": {} },
{
"type": "wokwi-potentiometer",
"id": "pot1",
"top": 143.8,
"left": 165.3,
"rotate": 90,
"attrs": {}
}
],
"connections": [
[ "esp:TX", "$serialMonitor:RX", "", [] ],
[ "esp:RX", "$serialMonitor:TX", "", [] ],
[ "pot1:GND", "esp:GND.2", "black", [ "h-48", "v-143.82" ] ],
[ "pot1:VCC", "esp:3V3", "red", [ "h0" ] ],
[ "esp:2", "pot1:SIG", "green", [ "h0" ] ]
],
"dependencies": {}
}
24 changes: 24 additions & 0 deletions tests/validation/adc/diagram.esp32s3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"version": 1,
"author": "Jakub Andrýsek",
"editor": "wokwi",
"parts": [
{ "type": "board-esp32-s3-devkitc-1", "id": "esp", "top": 0, "left": 0, "attrs": {} },
{
"type": "wokwi-potentiometer",
"id": "pot1",
"top": 143.8,
"left": 165.3,
"rotate": 90,
"attrs": {}
}
],
"connections": [
[ "esp:TX", "$serialMonitor:RX", "", [] ],
[ "esp:RX", "$serialMonitor:TX", "", [] ],
[ "pot1:GND", "esp:GND.2", "black", [ "h-48", "v-143.82" ] ],
[ "pot1:VCC", "esp:5V", "red", [ "h0" ] ],
[ "esp:2", "pot1:SIG", "green", [ "h0" ] ]
],
"dependencies": {}
}
43 changes: 43 additions & 0 deletions tests/validation/adc/scenario.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: ADC potentiometer test
version: 1
author: Jakub Andrysek ([email protected])

steps:
#### ADC potentiometer test
- wait-serial: "ADC potentiometer test START"
- wait-serial: "Reading ADC values from potentiometer on GPIO2"

# Set potentiometer to different positions and wait for readings
- set-control:
part-id: pot1
control: position
value: 0.0
- wait-serial: "ADC Reading 1:"

- set-control:
part-id: pot1
control: position
value: 0.25
- wait-serial: "ADC Reading 2:"

- set-control:
part-id: pot1
control: position
value: 0.5
- wait-serial: "ADC Reading 3:"

- set-control:
part-id: pot1
control: position
value: 0.75
- wait-serial: "ADC Reading 4:"

- set-control:
part-id: pot1
control: position
value: 1.0
- wait-serial: "ADC Reading 5:"

- wait-serial: "ADC potentiometer test completed successfully"

- wait-serial: "ADC test END"
5 changes: 5 additions & 0 deletions tests/validation/adc/test_adc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import logging


def test_gpio_interrupt(dut):
dut.expect_exact("ADC test END")
18 changes: 14 additions & 4 deletions tests/validation/gpio/diagram.esp32.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,26 @@
{
"type": "wokwi-pushbutton",
"id": "btn1",
"top": -13,
"left": -19.2,
"top": 83,
"left": 9.6,
"attrs": { "color": "green" }
},
{
"type": "wokwi-led",
"id": "led1",
"top": -39.6,
"left": -41.4,
"rotate": 90,
"attrs": { "color": "red" }
}
],
"connections": [
[ "esp32:RX", "$serialMonitor:TX", "", [] ],
[ "esp32:TX", "$serialMonitor:RX", "", [] ],
[ "btn1:1.l", "esp32:0", "blue", [ "h-19.2", "v48", "h-38.4" ] ],
[ "btn1:2.r", "esp32:GND.1", "black", [ "h19.4", "v173", "h-269.2", "v-98.23" ] ]
[ "btn1:2.r", "esp32:GND.1", "black", [ "h19.4", "v173", "h-269.2", "v-98.23" ] ],
[ "esp32:GND.2", "led1:C", "black", [ "v0" ] ],
[ "esp32:4", "led1:A", "green", [ "h0" ] ]
],
"dependencies": {}
}
}
14 changes: 12 additions & 2 deletions tests/validation/gpio/diagram.esp32c3.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,23 @@
"top": -22.6,
"left": -19.2,
"attrs": { "color": "green" }
},
{
"type": "wokwi-led",
"id": "led1",
"top": 28,
"left": -286.6,
"rotate": 270,
"attrs": { "color": "red" }
}
],
"connections": [
[ "esp32:RX", "$serialMonitor:TX", "", [] ],
[ "esp32:TX", "$serialMonitor:RX", "", [] ],
[ "btn1:1.l", "esp32:0", "blue", [ "h-28.8", "v144", "h-144", "v-95.7" ] ],
[ "btn1:2.r", "esp32:GND.1", "black", [ "h19.4", "v173", "h-269.2", "v-98.23" ] ]
[ "btn1:2.r", "esp32:GND.1", "black", [ "h19.4", "v173", "h-269.2", "v-98.23" ] ],
[ "esp32:GND.4", "led1:C", "black", [ "h0" ] ],
[ "esp32:4", "led1:A", "green", [ "v0" ] ]
],
"dependencies": {}
}
}
14 changes: 12 additions & 2 deletions tests/validation/gpio/diagram.esp32c6.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,23 @@
"top": -22.6,
"left": -19.2,
"attrs": { "color": "green" }
},
{
"type": "wokwi-led",
"id": "led1",
"top": 56.8,
"left": -286.6,
"rotate": 270,
"attrs": { "color": "red" }
}
],
"connections": [
[ "esp32:RX", "$serialMonitor:TX", "", [] ],
[ "esp32:TX", "$serialMonitor:RX", "", [] ],
[ "btn1:1.l", "esp32:0", "blue", [ "h-19.2", "v-96", "h-163.2", "v93.77" ] ],
[ "btn1:2.r", "esp32:GND.1", "black", [ "h19.4", "v173", "h-269.2", "v-98.23" ] ]
[ "btn1:2.r", "esp32:GND.1", "black", [ "h19.4", "v173", "h-269.2", "v-98.23" ] ],
[ "esp32:GND.1", "led1:C", "black", [ "h0" ] ],
[ "esp32:4", "led1:A", "green", [ "h0" ] ]
],
"dependencies": {}
}
}
Loading