Skip to content

Added NVS test sketch + test script #6885

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 12 commits into from
Aug 15, 2022
39 changes: 39 additions & 0 deletions tests/nvs/cfg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"targets": [
{
"name": "esp32",
"fqbn":[
"espressif:esp32:esp32:PSRAM=enabled,PartitionScheme=huge_app,FlashMode=dio",
"espressif:esp32:esp32:PSRAM=enabled,PartitionScheme=huge_app,FlashMode=dout,FlashFreq=40",
"espressif:esp32:esp32:PSRAM=enabled,PartitionScheme=huge_app,FlashMode=qio",
"espressif:esp32:esp32:PSRAM=enabled,PartitionScheme=huge_app,FlashMode=qout,FlashFreq=40"
]
},
{
"name": "esp32s2",
"fqbn": [
"espressif:esp32:esp32s2:PSRAM=enabled,PartitionScheme=huge_app,FlashMode=dio",
"espressif:esp32:esp32s2:PSRAM=enabled,PartitionScheme=huge_app,FlashMode=dout,FlashFreq=40",
"espressif:esp32:esp32s2:PSRAM=enabled,PartitionScheme=huge_app,FlashMode=qio",
"espressif:esp32:esp32s2:PSRAM=enabled,PartitionScheme=huge_app,FlashMode=qout,FlashFreq=40"
]
},
{
"name": "esp32c3",
"fqbn": [
"espressif:esp32:esp32c3:PartitionScheme=huge_app,FlashMode=dio",
"espressif:esp32:esp32c3:PartitionScheme=huge_app,FlashMode=dout,FlashFreq=40",
"espressif:esp32:esp32c3:PartitionScheme=huge_app,FlashMode=qio",
"espressif:esp32:esp32c3:PartitionScheme=huge_app,FlashMode=qout,FlashFreq=40"
]
},
{
"name": "esp32s3",
"fqbn": [
"espressif:esp32:esp32s3:PSRAM=opi,USBMode=default,PartitionScheme=huge_app,FlashMode=qio",
"espressif:esp32:esp32s3:PSRAM=opi,USBMode=default,PartitionScheme=huge_app,FlashMode=qio120",
"espressif:esp32:esp32s3:PSRAM=opi,USBMode=default,PartitionScheme=huge_app,FlashMode=dio"
]
}
]
}
36 changes: 36 additions & 0 deletions tests/nvs/nvs.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include <Preferences.h>

Preferences preferences;

void setup() {
Serial.begin(115200);

while (!Serial) {
;
}

preferences.begin("my-app", false);

// Get the counter value, if the key does not exist, return a default value of 0
unsigned int counter = preferences.getUInt("counter", 0);

// Print the counter to Serial Monitor
Serial.printf("Current counter value: %u\n", counter);

// Increase counter by 1
counter++;

// Store the counter to the Preferences
preferences.putUInt("counter", counter);

// Close the Preferences
preferences.end();

// Wait 1 second
delay(1000);

// Restart ESP
ESP.restart();
}

void loop() {}
7 changes: 7 additions & 0 deletions tests/nvs/test_nvs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
def test_nvs(dut):
dut.expect('Current counter value: 0')
dut.expect('Current counter value: 1')
dut.expect('Current counter value: 2')
dut.expect('Current counter value: 3')
dut.expect('Current counter value: 4')
dut.expect('Current counter value: 5')