Skip to content

Commit

Permalink
Merge branch 'feature/wl_host_test_cmake' into 'master'
Browse files Browse the repository at this point in the history
Storage: Migrate WL host test to CMake

See merge request espressif/esp-idf!23015
  • Loading branch information
rrtandler committed Apr 13, 2023
2 parents 7d41c5b + 0402874 commit d8b8ab5
Show file tree
Hide file tree
Showing 16 changed files with 482 additions and 230 deletions.
10 changes: 0 additions & 10 deletions .gitlab/ci/host-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,6 @@ test_partition_table_on_host:
- cd components/partition_table/test_gen_esp32part_host
- ./gen_esp32part_tests.py

test_wl_on_host:
extends: .host_test_template
artifacts:
paths:
- components/wear_levelling/test_wl_host/coverage_report.zip
expire_in: 1 week
script:
- cd components/wear_levelling/test_wl_host
- make test

test_fatfs_on_host:
extends: .host_test_template
script:
Expand Down
2 changes: 2 additions & 0 deletions components/spi_flash/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
idf_build_get_property(target IDF_TARGET)
if(${target} STREQUAL "linux")
idf_component_register(INCLUDE_DIRS include
PRIV_INCLUDE_DIRS include/spi_flash)
return()
endif()

Expand Down
4 changes: 4 additions & 0 deletions components/wear_levelling/.build-test-rules.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Documentation: .gitlab/ci/README.md#manifest-file-to-control-the-buildtest-apps

components/wear_levelling/host_test:
enable:
- if: IDF_TARGET == "linux"
reason: only test on linux
components/wear_levelling/test_apps:
enable:
- if: IDF_TARGET in ["esp32", "esp32c3"]
Expand Down
6 changes: 3 additions & 3 deletions components/wear_levelling/WL_Flash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ esp_err_t WL_Flash::init()
WL_RESULT_CHECK(result);
result = this->flash_drv->write(this->addr_state2, &this->state, sizeof(wl_state_t));
WL_RESULT_CHECK(result);
for (size_t i = 0; i < ((this->cfg.full_mem_size / this->cfg.sector_size)*this->cfg.wr_size); i++) {
for (size_t i = 0; i < ((this->cfg.full_mem_size / this->cfg.sector_size)); i++) {
bool pos_bits;
result = this->flash_drv->read(this->addr_state1 + sizeof(wl_state_t) + i * this->cfg.wr_size, this->temp_buff, this->cfg.wr_size);
WL_RESULT_CHECK(result);
Expand Down Expand Up @@ -187,7 +187,7 @@ esp_err_t WL_Flash::init()
WL_RESULT_CHECK(result);
result = this->flash_drv->write(this->addr_state2, &this->state, sizeof(wl_state_t));
WL_RESULT_CHECK(result);
for (size_t i = 0; i < ((this->cfg.full_mem_size / this->cfg.sector_size) * this->cfg.wr_size); i++) {
for (size_t i = 0; i < ((this->cfg.full_mem_size / this->cfg.sector_size)); i++) {
bool pos_bits;
result = this->flash_drv->read(this->addr_state1 + sizeof(wl_state_t) + i * this->cfg.wr_size, this->temp_buff, this->cfg.wr_size);
WL_RESULT_CHECK(result);
Expand All @@ -204,7 +204,7 @@ esp_err_t WL_Flash::init()
WL_RESULT_CHECK(result);
result = this->flash_drv->write(this->addr_state1, state_copy, sizeof(wl_state_t));
WL_RESULT_CHECK(result);
for (size_t i = 0; i < ((this->cfg.full_mem_size / this->cfg.sector_size) * this->cfg.wr_size); i++) {
for (size_t i = 0; i < ((this->cfg.full_mem_size / this->cfg.sector_size)); i++) {
bool pos_bits;
result = this->flash_drv->read(this->addr_state2 + sizeof(wl_state_t) + i * this->cfg.wr_size, this->temp_buff, this->cfg.wr_size);

Expand Down
4 changes: 2 additions & 2 deletions components/wear_levelling/crc32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include "crc32.h"
#include "esp32/rom/crc.h"
#include "esp_rom_crc.h"

unsigned int crc32::crc32_le(unsigned int crc, unsigned char const *buf, unsigned int len)
{
return ::crc32_le(crc, buf, len);
return ::esp_rom_crc32_le(crc, buf, len);
}
10 changes: 10 additions & 0 deletions components/wear_levelling/host_test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 3.16)

include($ENV{IDF_PATH}/tools/cmake/project.cmake)
set(COMPONENTS main)
# Freertos is included via common components. However, CATCH isn't compatible with the FreeRTOS component yet, hence
# using the FreeRTOS mock component.
# target.
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/freertos/")

project(wear_levelling_host_test)
2 changes: 2 additions & 0 deletions components/wear_levelling/host_test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
| Supported Targets | Linux |
| ----------------- | ----- |
8 changes: 8 additions & 0 deletions components/wear_levelling/host_test/main/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
idf_component_register(SRCS "main.cpp"
"test_wl.cpp"
INCLUDE_DIRS "$ENV{IDF_PATH}/tools/catch"
PRIV_INCLUDE_DIRS "../../private_include"
"../.."
REQUIRES wear_levelling
WHOLE_ARCHIVE
)
Loading

0 comments on commit d8b8ab5

Please sign in to comment.