Просмотр исходного кода

Merge branch 'feature/esp_common_linux_in_host_tests' into 'master'

[nvs]: use real esp_common on host tests

See merge request espressif/esp-idf!14408
Jakob Hasse 4 лет назад
Родитель
Сommit
9bb2fc2afd

+ 2 - 2
components/nvs_flash/CMakeLists.txt

@@ -13,12 +13,12 @@ set(srcs "src/nvs_api.cpp"
          "src/nvs_partition_manager.cpp"
          "src/nvs_types.cpp")
 
-set(public_req spi_flash)
+set(public_req "spi_flash")
 
 # Current linux-based builds don't have common components.
 # Add the necessary ones manually:
 if(${target} STREQUAL "linux")
-    list(APPEND public_req "esp_rom" "log")
+    list(APPEND public_req "esp_rom" "esp_common" "log")
 endif()
 
 set(include_dirs "include")

+ 6 - 4
components/spi_flash/CMakeLists.txt

@@ -30,15 +30,17 @@ if(${spi_flash_mock})
              "${MOCK_GEN_DIR}/Mockesp_spi_flash.c"
              "${MOCK_GEN_DIR}/Mockesp_flash.c")
 
+    set(requires "cmock")
+
     if(${target} STREQUAL "linux")
         list(APPEND include_dirs
-            "${CMAKE_CURRENT_SOURCE_DIR}/../spi_flash/sim/stubs/soc/include"
-            "${CMAKE_CURRENT_SOURCE_DIR}/../spi_flash/sim/stubs/xtensa")
+            "${CMAKE_CURRENT_SOURCE_DIR}/../spi_flash/sim/stubs/soc/include")
+        list(APPEND requires "esp_common")
     endif()
 
     idf_component_register(SRCS "${srcs}"
-                        INCLUDE_DIRS ${include_dirs}
-                        REQUIRES cmock)
+                        INCLUDE_DIRS "${include_dirs}"
+                        REQUIRES "${requires}")
 
     add_custom_command(
         OUTPUT ruby_found SYMBOLIC

+ 0 - 144
components/spi_flash/sim/stubs/esp_common/esp_err.h

@@ -1,144 +0,0 @@
-/*
- * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
- *
- * SPDX-License-Identifier: Apache-2.0
- *
- * This is a STUB FILE HEADER used when compiling ESP-IDF to run tests on the host system.
- * The header file used normally for ESP-IDF has the same name but is located elsewhere.
- */
-#pragma once
-
-#include <stdint.h>
-#include <stdio.h>
-#include <assert.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef int32_t esp_err_t;
-
-/* Definitions for error constants. */
-#define ESP_OK          0       /*!< esp_err_t value indicating success (no error) */
-#define ESP_FAIL        -1      /*!< Generic esp_err_t code indicating failure */
-
-#define ESP_ERR_NO_MEM              0x101   /*!< Out of memory */
-#define ESP_ERR_INVALID_ARG         0x102   /*!< Invalid argument */
-#define ESP_ERR_INVALID_STATE       0x103   /*!< Invalid state */
-#define ESP_ERR_INVALID_SIZE        0x104   /*!< Invalid size */
-#define ESP_ERR_NOT_FOUND           0x105   /*!< Requested resource not found */
-#define ESP_ERR_NOT_SUPPORTED       0x106   /*!< Operation or feature not supported */
-#define ESP_ERR_TIMEOUT             0x107   /*!< Operation timed out */
-#define ESP_ERR_INVALID_RESPONSE    0x108   /*!< Received response was invalid */
-#define ESP_ERR_INVALID_CRC         0x109   /*!< CRC or checksum was invalid */
-#define ESP_ERR_INVALID_VERSION     0x10A   /*!< Version was invalid */
-#define ESP_ERR_INVALID_MAC         0x10B   /*!< MAC address was invalid */
-
-#define ESP_ERR_WIFI_BASE           0x3000  /*!< Starting number of WiFi error codes */
-#define ESP_ERR_MESH_BASE           0x4000  /*!< Starting number of MESH error codes */
-#define ESP_ERR_FLASH_BASE          0x6000  /*!< Starting number of flash error codes */
-
-/**
-  * @brief Returns string for esp_err_t error codes
-  *
-  * This function finds the error code in a pre-generated lookup-table and
-  * returns its string representation.
-  *
-  * The function is generated by the Python script
-  * tools/gen_esp_err_to_name.py which should be run each time an esp_err_t
-  * error is modified, created or removed from the IDF project.
-  *
-  * @param code esp_err_t error code
-  * @return string error message
-  */
-const char *esp_err_to_name(esp_err_t code);
-
-/**
-  * @brief Returns string for esp_err_t and system error codes
-  *
-  * This function finds the error code in a pre-generated lookup-table of
-  * esp_err_t errors and returns its string representation. If the error code
-  * is not found then it is attempted to be found among system errors.
-  *
-  * The function is generated by the Python script
-  * tools/gen_esp_err_to_name.py which should be run each time an esp_err_t
-  * error is modified, created or removed from the IDF project.
-  *
-  * @param code esp_err_t error code
-  * @param[out] buf buffer where the error message should be written
-  * @param buflen Size of buffer buf. At most buflen bytes are written into the buf buffer (including the terminating null byte).
-  * @return buf containing the string error message
-  */
-const char *esp_err_to_name_r(esp_err_t code, char *buf, size_t buflen);
-
-/** @cond */
-void _esp_error_check_failed(esp_err_t rc, const char *file, int line, const char *function, const char *expression) __attribute__((noreturn));
-
-/** @cond */
-void _esp_error_check_failed_without_abort(esp_err_t rc, const char *file, int line, const char *function, const char *expression);
-
-#ifndef __ASSERT_FUNC
-/* This won't happen on IDF, which defines __ASSERT_FUNC in assert.h, but it does happen when building on the host which
-   uses /usr/include/assert.h or equivalent.
-*/
-#ifdef __ASSERT_FUNCTION
-#define __ASSERT_FUNC __ASSERT_FUNCTION /* used in glibc assert.h */
-#else
-#define __ASSERT_FUNC "??"
-#endif
-#endif
-/** @endcond */
-
-/**
- * Macro which can be used to check the error code,
- * and terminate the program in case the code is not ESP_OK.
- * Prints the error code, error location, and the failed statement to serial output.
- *
- * Disabled if assertions are disabled.
- */
-#ifdef NDEBUG
-#define ESP_ERROR_CHECK(x) do {                                         \
-        esp_err_t __err_rc = (x);                                       \
-        (void) sizeof(__err_rc);                                        \
-    } while(0)
-#elif defined(CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT)
-#define ESP_ERROR_CHECK(x) do {                                         \
-        esp_err_t __err_rc = (x);                                       \
-        if (__err_rc != ESP_OK) {                                       \
-            abort();                                                    \
-        }                                                               \
-    } while(0)
-#else
-#define ESP_ERROR_CHECK(x) do {                                         \
-        esp_err_t __err_rc = (x);                                       \
-        if (__err_rc != ESP_OK) {                                       \
-            _esp_error_check_failed(__err_rc, __FILE__, __LINE__,       \
-                                    __ASSERT_FUNC, #x);                 \
-        }                                                               \
-    } while(0)
-#endif
-
-/**
- * Macro which can be used to check the error code. Prints the error code, error location, and the failed statement to
- * serial output.
- * In comparison with ESP_ERROR_CHECK(), this prints the same error message but isn't terminating the program.
- */
-#ifdef NDEBUG
-#define ESP_ERROR_CHECK_WITHOUT_ABORT(x) ({                                         \
-        esp_err_t __err_rc = (x);                                                   \
-        __err_rc;                                                                   \
-    })
-#else
-#define ESP_ERROR_CHECK_WITHOUT_ABORT(x) ({                                         \
-        esp_err_t __err_rc = (x);                                                   \
-        if (__err_rc != ESP_OK) {                                                   \
-            _esp_error_check_failed_without_abort(__err_rc, __FILE__, __LINE__,     \
-                                    __ASSERT_FUNC, #x);                             \
-        }                                                                           \
-        __err_rc;                                                                   \
-    })
-#endif //NDEBUG
-
-#ifdef __cplusplus
-}
-#endif

+ 0 - 144
components/spi_flash/sim/stubs/xtensa/esp_attr.h

@@ -1,144 +0,0 @@
-/*
- * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
- *
- * SPDX-License-Identifier: Apache-2.0
- *
- * This is a STUB FILE HEADER used when compiling ESP-IDF to run tests on the host system.
- * The header file used normally for ESP-IDF has the same name but is located elsewhere.
- */
-#ifndef __ESP_ATTR_H__
-#define __ESP_ATTR_H__
-
-#include "sdkconfig.h"
-
-#define ROMFN_ATTR
-
-//Normally, the linker script will put all code and rodata in flash,
-//and all variables in shared RAM. These macros can be used to redirect
-//particular functions/variables to other memory regions.
-
-// Forces code into IRAM instead of flash
-#define IRAM_ATTR _SECTION_ATTR_IMPL(".iram1", __COUNTER__)
-
-// Forces data into DRAM instead of flash
-#define DRAM_ATTR _SECTION_ATTR_IMPL(".dram1", __COUNTER__)
-
-#ifdef CONFIG_ESP32_IRAM_AS_8BIT_ACCESSIBLE_MEMORY
-// Forces data into IRAM instead of DRAM
-#define IRAM_DATA_ATTR __attribute__((section(".iram.data")))
-
-// Forces data into IRAM instead of DRAM and map it to coredump
-#define COREDUMP_IRAM_DATA_ATTR _SECTION_ATTR_IMPL(".iram.data.coredump", __COUNTER__)
-
-// Forces bss into IRAM instead of DRAM
-#define IRAM_BSS_ATTR __attribute__((section(".iram.bss")))
-#else
-#define COREDUMP_IRAM_DATA_ATTR
-#define IRAM_DATA_ATTR
-
-#define IRAM_BSS_ATTR
-#endif
-
-// Forces data to be 4 bytes aligned
-#define WORD_ALIGNED_ATTR __attribute__((aligned(4)))
-
-// Forces data to be placed to DMA-capable places
-#define DMA_ATTR WORD_ALIGNED_ATTR DRAM_ATTR
-
-// Forces a function to be inlined
-#define FORCE_INLINE_ATTR static inline __attribute__((always_inline))
-
-// Forces a string into DRAM instead of flash
-// Use as esp_rom_printf(DRAM_STR("Hello world!\n"));
-#define DRAM_STR(str) (__extension__({static const DRAM_ATTR char __c[] = (str); (const char *)&__c;}))
-
-// Forces code into RTC fast memory. See "docs/deep-sleep-stub.rst"
-#define RTC_IRAM_ATTR _SECTION_ATTR_IMPL(".rtc.text", __COUNTER__)
-
-#if CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY
-// Forces bss variable into external memory. "
-#define EXT_RAM_ATTR _SECTION_ATTR_IMPL(".ext_ram.bss", __COUNTER__)
-#else
-#define EXT_RAM_ATTR
-#endif
-
-// Forces data into RTC slow memory. See "docs/deep-sleep-stub.rst"
-// Any variable marked with this attribute will keep its value
-// during a deep sleep / wake cycle.
-#define RTC_DATA_ATTR _SECTION_ATTR_IMPL(".rtc.data", __COUNTER__)
-
-// Forces read-only data into RTC memory. See "docs/deep-sleep-stub.rst"
-#define RTC_RODATA_ATTR _SECTION_ATTR_IMPL(".rtc.rodata", __COUNTER__)
-
-// Allows to place data into RTC_SLOW memory.
-#define RTC_SLOW_ATTR _SECTION_ATTR_IMPL(".rtc.force_slow", __COUNTER__)
-
-// Allows to place data into RTC_FAST memory.
-#define RTC_FAST_ATTR _SECTION_ATTR_IMPL(".rtc.force_fast", __COUNTER__)
-
-// Forces data into noinit section to avoid initialization after restart.
-#define __NOINIT_ATTR _SECTION_ATTR_IMPL(".noinit", __COUNTER__)
-
-// Forces data into RTC slow memory of .noinit section.
-// Any variable marked with this attribute will keep its value
-// after restart or during a deep sleep / wake cycle.
-#define RTC_NOINIT_ATTR  _SECTION_ATTR_IMPL(".rtc_noinit", __COUNTER__)
-
-// Forces code into DRAM instead of flash and map it to coredump
-#define COREDUMP_DRAM_ATTR _SECTION_ATTR_IMPL(".dram1.coredump", __COUNTER__)
-
-// Forces data into RTC memory and map it to coredump
-#define COREDUMP_RTC_DATA_ATTR _SECTION_ATTR_IMPL(".rtc.coredump", __COUNTER__)
-
-// Allows to place data into RTC_FAST memory and map it to coredump
-#define COREDUMP_RTC_FAST_ATTR _SECTION_ATTR_IMPL(".rtc.fast.coredump", __COUNTER__)
-
-// Forces to not inline function
-#define NOINLINE_ATTR __attribute__((noinline))
-
-// This allows using enum as flags in C++
-// Format: FLAG_ATTR(flag_enum_t)
-#ifdef __cplusplus
-
-// Inline is required here to avoid multiple definition error in linker
-#define FLAG_ATTR_IMPL(TYPE, INT_TYPE) \
-FORCE_INLINE_ATTR constexpr TYPE operator~ (TYPE a) { return (TYPE)~(INT_TYPE)a; } \
-FORCE_INLINE_ATTR constexpr TYPE operator| (TYPE a, TYPE b) { return (TYPE)((INT_TYPE)a | (INT_TYPE)b); } \
-FORCE_INLINE_ATTR constexpr TYPE operator& (TYPE a, TYPE b) { return (TYPE)((INT_TYPE)a & (INT_TYPE)b); } \
-FORCE_INLINE_ATTR constexpr TYPE operator^ (TYPE a, TYPE b) { return (TYPE)((INT_TYPE)a ^ (INT_TYPE)b); } \
-FORCE_INLINE_ATTR constexpr TYPE operator>> (TYPE a, int b) { return (TYPE)((INT_TYPE)a >> b); } \
-FORCE_INLINE_ATTR constexpr TYPE operator<< (TYPE a, int b) { return (TYPE)((INT_TYPE)a << b); } \
-FORCE_INLINE_ATTR TYPE& operator|=(TYPE& a, TYPE b) { a = a | b; return a; } \
-FORCE_INLINE_ATTR TYPE& operator&=(TYPE& a, TYPE b) { a = a & b; return a; } \
-FORCE_INLINE_ATTR TYPE& operator^=(TYPE& a, TYPE b) { a = a ^ b; return a; } \
-FORCE_INLINE_ATTR TYPE& operator>>=(TYPE& a, int b) { a >>= b; return a; } \
-FORCE_INLINE_ATTR TYPE& operator<<=(TYPE& a, int b) { a <<= b; return a; }
-
-#define FLAG_ATTR_U32(TYPE) FLAG_ATTR_IMPL(TYPE, uint32_t)
-#define FLAG_ATTR FLAG_ATTR_U32
-
-#else
-#define FLAG_ATTR(TYPE)
-#endif
-
-// Implementation for a unique custom section
-//
-// This prevents gcc producing "x causes a section type conflict with y"
-// errors if two variables in the same source file have different linkage (maybe const & non-const) but are placed in the same custom section
-//
-// Using unique sections also means --gc-sections can remove unused
-// data with a custom section type set
-#define _SECTION_ATTR_IMPL(SECTION, COUNTER) __attribute__((section(SECTION "." _COUNTER_STRINGIFY(COUNTER))))
-
-#define _COUNTER_STRINGIFY(COUNTER) #COUNTER
-
-/* Use IDF_DEPRECATED attribute to mark anything deprecated from use in
-   ESP-IDF's own source code, but not deprecated for external users.
-*/
-#ifdef IDF_CI_BUILD
-#define IDF_DEPRECATED(REASON) __attribute__((deprecated(REASON)))
-#else
-#define IDF_DEPRECATED(REASON)
-#endif
-
-#endif /* __ESP_ATTR_H__ */

+ 5 - 3
components/unity/CMakeLists.txt

@@ -5,6 +5,8 @@ set(includes
     "include"
     "unity/src")
 
+set(requires "")
+
 if(CONFIG_UNITY_ENABLE_BACKTRACE_ON_FAIL)
     list(APPEND COMPONENT_PRIV_INCLUDEDIRS "include/priv")
 endif()
@@ -19,14 +21,14 @@ if(CONFIG_UNITY_ENABLE_FIXTURE)
 endif()
 
 if(${IDF_TARGET} STREQUAL "linux")
-    idf_component_get_property(spi_flash_dir spi_flash COMPONENT_DIR)
-    list(APPEND includes "${spi_flash_dir}/sim/stubs/esp_common")
+    list(APPEND requires "esp_common")
 else()
     list(APPEND srcs "unity_port_esp32.c")
 endif()
 
 idf_component_register(SRCS "${srcs}"
-                    INCLUDE_DIRS ${includes})
+                    INCLUDE_DIRS ${includes}
+                    REQUIRES ${requires})
 
 if(NOT ${IDF_TARGET} STREQUAL "linux")
     target_compile_definitions(${COMPONENT_LIB} PUBLIC