Skip to content

Commit

Permalink
linux-target: fixed driver mock being broken due to changes in driver…
Browse files Browse the repository at this point in the history
… folder structure

Closes #10749
  • Loading branch information
ESP-Marius committed Feb 15, 2023
1 parent 27be8a1 commit b68b0ea
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 8 deletions.
19 changes: 11 additions & 8 deletions tools/mocks/driver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,20 @@ message(STATUS "building DRIVER MOCKS (only SPI, I2C and GPIO driver)")
idf_component_get_property(original_driver_dir driver COMPONENT_OVERRIDEN_DIR)

set(include_dirs
"${original_driver_dir}/include"
"${original_driver_dir}/include/driver"
"${CMAKE_CURRENT_SOURCE_DIR}/../hal/include"
"${CMAKE_CURRENT_SOURCE_DIR}/../esp_hw_support/include")
"${original_driver_dir}/i2c/include/driver"
"${original_driver_dir}/spi/include/driver"
"${original_driver_dir}/gpio/include/driver"
"${original_driver_dir}/i2c/include"
"${original_driver_dir}/spi/include"
"${original_driver_dir}/gpio/include"
"${CMAKE_CURRENT_SOURCE_DIR}/../hal/include")

idf_component_mock(INCLUDE_DIRS ${include_dirs}
REQUIRES freertos
MOCK_HEADER_FILES
${original_driver_dir}/include/driver/spi_master.h
${original_driver_dir}/include/driver/spi_common.h
${original_driver_dir}/include/driver/i2c.h
${original_driver_dir}/include/driver/gpio.h)
${original_driver_dir}/spi/include/driver/spi_master.h
${original_driver_dir}/spi/include/driver/spi_common.h
${original_driver_dir}/i2c/include/driver/i2c.h
${original_driver_dir}/gpio/include/driver/gpio.h)

target_compile_definitions(${COMPONENT_LIB} PUBLIC SOC_I2C_NUM=2)
4 changes: 4 additions & 0 deletions tools/test_apps/.build-test-rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ tools/test_apps/build_system/ldgen_test:
temporary: true
reason: target esp32c2 is not supported yet

tools/test_apps/linux_compatible/driver_mock:
enable:
- if: IDF_TARGET == "linux"

tools/test_apps/linux_compatible/hello_world_linux_compatible:
enable:
- if: INCLUDE_DEFAULT == 1 or IDF_TARGET == "linux"
Expand Down
10 changes: 10 additions & 0 deletions tools/test_apps/linux_compatible/driver_mock/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# The following lines of boilerplate have to be in your project's
# CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.16)

include($ENV{IDF_PATH}/tools/cmake/project.cmake)

set(COMPONENTS main)
list(APPEND EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/tools/mocks/driver)

project(linux_driver_mock)
2 changes: 2 additions & 0 deletions tools/test_apps/linux_compatible/driver_mock/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
| Supported Targets | Linux |
| ----------------- | ----- |
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
idf_component_register(SRCS "driver_mock_main.c"
INCLUDE_DIRS ""
REQUIRES driver)
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: CC0-1.0
*/

/* Test that mock headers can be included */
#include "driver/i2c.h"
#include "driver/i2c.h"
#include "driver/spi_master.h"
#include "driver/spi_common.h"

void app_main(void)
{
/*Test that mock functions exist*/
i2c_driver_delete(0);
}

0 comments on commit b68b0ea

Please sign in to comment.