-
Notifications
You must be signed in to change notification settings - Fork 7.4k
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
Mock esp_wifi (IDFGH-9190) #10582
Comments
A compiling mock - otherwise untested. Note - need to set $ cat host_test/CMakelists.txt
cmake_minimum_required(VERSION 3.16)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
set(COMPONENTS main)
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/freertos/")
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/esp_wifi/")
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/esp_hw_support/")
idf_build_set_property(COMPILE_DEFINITIONS "-DCONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=10" APPEND)
idf_build_set_property(COMPILE_DEFINITIONS "-DCONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=32" APPEND)
idf_build_set_property(COMPILE_DEFINITIONS "-DCONFIG_ESP32_WIFI_TX_BUFFER_TYPE=1" APPEND)
project(wifi_ap_host_test)
idf_build_set_property(COMPILE_OPTIONS "-Warray-parameter=0" APPEND) and the diff --git a/tools/mocks/esp_netif/CMakeLists.txt b/tools/mocks/esp_netif/CMakeLists.txt
new file mode 100644
index 0000000000..c86e61136e
--- /dev/null
+++ b/tools/mocks/esp_netif/CMakeLists.txt
@@ -0,0 +1,10 @@
+# NOTE: This kind of mocking currently works on Linux targets only.
+# On Espressif chips, too many dependencies are missing at the moment.
+message(STATUS "building ESP NETIF MOCKS")
+
+idf_component_get_property(original_esp_netif_dir esp_netif COMPONENT_OVERRIDEN_DIR)
+
+idf_component_mock(INCLUDE_DIRS "${original_esp_netif_dir}/include"
+ REQUIRES esp_event esp_hw_support
+ MOCK_HEADER_FILES ${original_esp_netif_dir}/include/esp_netif.h
+ )
diff --git a/tools/mocks/esp_netif/mock/mock_config.yaml b/tools/mocks/esp_netif/mock/mock_config.yaml
new file mode 100644
index 0000000000..596255b0ce
--- /dev/null
+++ b/tools/mocks/esp_netif/mock/mock_config.yaml
@@ -0,0 +1,9 @@
+ :cmock:
+ :plugins:
+ - expect
+ - expect_any_args
+ - return_thru_ptr
+ - array
+ - ignore
+ - ignore_arg
+ - callback
diff --git a/tools/mocks/esp_wifi/CMakeLists.txt b/tools/mocks/esp_wifi/CMakeLists.txt
new file mode 100644
index 0000000000..250664d3a2
--- /dev/null
+++ b/tools/mocks/esp_wifi/CMakeLists.txt
@@ -0,0 +1,10 @@
+# NOTE: This kind of mocking currently works on Linux targets only.
+# On Espressif chips, too many dependencies are missing at the moment.
+message(STATUS "building ESP WIFI MOCKS")
+
+idf_component_get_property(original_esp_wifi_dir esp_wifi COMPONENT_OVERRIDEN_DIR)
+
+idf_component_mock(INCLUDE_DIRS "${original_esp_wifi_dir}/include" "./include"
+ REQUIRES esp_event esp_hw_support esp_netif
+ MOCK_HEADER_FILES ${original_esp_wifi_dir}/include/esp_wifi.h
+ )
diff --git a/tools/mocks/esp_wifi/include/machine/endian.h b/tools/mocks/esp_wifi/include/machine/endian.h
new file mode 100644
index 0000000000..228316d612
--- /dev/null
+++ b/tools/mocks/esp_wifi/include/machine/endian.h
@@ -0,0 +1,2 @@
+#pragma once
+#include_next <endian.h>
diff --git a/tools/mocks/esp_wifi/mock/mock_config.yaml b/tools/mocks/esp_wifi/mock/mock_config.yaml
new file mode 100644
index 0000000000..596255b0ce
--- /dev/null
+++ b/tools/mocks/esp_wifi/mock/mock_config.yaml
@@ -0,0 +1,9 @@
+ :cmock:
+ :plugins:
+ - expect
+ - expect_any_args
+ - return_thru_ptr
+ - array
+ - ignore
+ - ignore_arg
+ - callback |
@ljden WiFi Mock is on our list, however, I can't give you an exact timeline. We'll keep you updated. |
@ljden We have a solution for mocking WiFi which will be similar to what you already tried. I think we should have this on master soon. |
@ljden We have merged a mock implementation internally. It will soon be available on master. |
Closing the issue since the mock was merged internally. It will be available with the next GH sync. |
Is your feature request related to a problem?
I would like to mock esp_wifi for host testing my AP manager
Describe the solution you'd like.
No response
Describe alternatives you've considered.
No response
Additional context.
I gave ti a bit of a go but got stuck. So far, I have:
and added to my
host_test/CMakeLists.txt
But I am failing on finding
machine/endian.h
Not sure if I'm on the right track and how to fix the current error. I suspect I need to do something similar to the mqtt mock but I don't fully understand the host test infrastructure
The text was updated successfully, but these errors were encountered: