forked from espressif/esp-idf
feat(storage/spiffs): add host test for disabled erase check
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2016-2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2016-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@@ -274,10 +274,49 @@ TEST(spiffs, can_read_spiffs_image)
|
|||||||
deinit_spiffs(&fs);
|
deinit_spiffs(&fs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(spiffs, erase_check)
|
||||||
|
{
|
||||||
|
spiffs fs;
|
||||||
|
|
||||||
|
init_spiffs(&fs, 5);
|
||||||
|
|
||||||
|
|
||||||
|
for (int boot_iter = 0; boot_iter <= 10000; ++boot_iter) {
|
||||||
|
for (int write_iter = 0; write_iter < 1000; ++write_iter) {
|
||||||
|
spiffs_file f = SPIFFS_open(&fs, "/test", SPIFFS_CREAT | SPIFFS_TRUNC | SPIFFS_RDWR, 0);
|
||||||
|
if (f < 0) {
|
||||||
|
fprintf(stderr, "Failed to open file\n");
|
||||||
|
#if !CONFIG_ESP_PARTITION_ERASE_CHECK
|
||||||
|
TEST_FAIL();
|
||||||
|
#endif
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const int data_sz = 7 * 1024;
|
||||||
|
char data[data_sz];
|
||||||
|
memset(data, 0x55, data_sz);
|
||||||
|
int cb = SPIFFS_write(&fs, f, data, data_sz);
|
||||||
|
if (cb != data_sz) {
|
||||||
|
fprintf(stderr, "Failed to write file\n");
|
||||||
|
TEST_FAIL();
|
||||||
|
}
|
||||||
|
int rc = SPIFFS_close(&fs, f);
|
||||||
|
if (rc < 0) {
|
||||||
|
fprintf(stderr, "Failed to close file\n");
|
||||||
|
TEST_FAIL();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if CONFIG_ESP_PARTITION_ERASE_CHECK
|
||||||
|
TEST_FAIL();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
TEST_GROUP_RUNNER(spiffs)
|
TEST_GROUP_RUNNER(spiffs)
|
||||||
{
|
{
|
||||||
RUN_TEST_CASE(spiffs, format_disk_open_file_write_and_read_file);
|
RUN_TEST_CASE(spiffs, format_disk_open_file_write_and_read_file);
|
||||||
RUN_TEST_CASE(spiffs, can_read_spiffs_image);
|
RUN_TEST_CASE(spiffs, can_read_spiffs_image);
|
||||||
|
RUN_TEST_CASE(spiffs, erase_check);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void run_all_tests(void)
|
static void run_all_tests(void)
|
||||||
|
@@ -6,5 +6,6 @@ from pytest_embedded import Dut
|
|||||||
|
|
||||||
@pytest.mark.linux
|
@pytest.mark.linux
|
||||||
@pytest.mark.host_test
|
@pytest.mark.host_test
|
||||||
|
@pytest.mark.parametrize('config', ['erase_check', 'no_erase_check'])
|
||||||
def test_spiffs_linux(dut: Dut) -> None:
|
def test_spiffs_linux(dut: Dut) -> None:
|
||||||
dut.expect_unity_test_output(timeout=5)
|
dut.expect_unity_test_output(timeout=5)
|
||||||
|
1
components/spiffs/host_test/sdkconfig.ci.erase_check
Normal file
1
components/spiffs/host_test/sdkconfig.ci.erase_check
Normal file
@@ -0,0 +1 @@
|
|||||||
|
CONFIG_ESP_PARTITION_ERASE_CHECK=y
|
1
components/spiffs/host_test/sdkconfig.ci.no_erase_check
Normal file
1
components/spiffs/host_test/sdkconfig.ci.no_erase_check
Normal file
@@ -0,0 +1 @@
|
|||||||
|
CONFIG_ESP_PARTITION_ERASE_CHECK=n
|
Reference in New Issue
Block a user