Skip to content

Commit

Permalink
Merge branch 'feat/add_command_line_for_testing_lib_compat' into 'main'
Browse files Browse the repository at this point in the history
feat(ext_cli): add a command to check br lib compatibility

See merge request espressif/esp-thread-br!150
  • Loading branch information
chshu committed Feb 8, 2025
2 parents 7a259df + 497e354 commit 2db961e
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 1 deletion.
4 changes: 4 additions & 0 deletions components/esp_ot_cli_extension/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ if(CONFIG_OPENTHREAD_RCP_COMMAND)
list(APPEND srcs "src/esp_ot_rcp_commands.c")
endif()

if(CONFIG_OPENTHREAD_BR_LIB_CHECK)
list(APPEND srcs "src/esp_ot_br_lib_compati_check.c")
endif()

set(include "include")

idf_component_register(SRCS "${srcs}"
Expand Down
5 changes: 5 additions & 0 deletions components/esp_ot_cli_extension/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,9 @@ menu "OpenThread Extension CLI"
depends on OPENTHREAD_CLI_ESP_EXTENSION && OPENTHREAD_BORDER_ROUTER && AUTO_UPDATE_RCP
default y if AUTO_UPDATE_RCP

config OPENTHREAD_BR_LIB_CHECK
bool "Enable br lib compatibility check command, only for testing"
depends on OPENTHREAD_CLI_ESP_EXTENSION && OPENTHREAD_BORDER_ROUTER
default n

endmenu
2 changes: 1 addition & 1 deletion components/esp_ot_cli_extension/idf_component.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "1.2.6"
version: "1.3.0"
description: Espressif OpenThread CLI Extension
url: https://github.com/espressif/esp-thread-br/tree/main/components/esp_ot_cli_extension
dependencies:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/

#include "esp_log.h"
#include "esp_ot_cli_extension.h"
#include <stdint.h>
#include <openthread/error.h>
#include "openthread/cli.h"

otError esp_openthread_process_br_lib_compatibility_check(void *aContext, uint8_t aArgsLength, char *aArgs[]);
54 changes: 54 additions & 0 deletions components/esp_ot_cli_extension/src/esp_ot_br_lib_compati_check.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/

#include "esp_ot_br_lib_compati_check.h"
#include "lwip/netif.h"

#define LOAD_AND_TEST_NETIF_MEMBER(a, out_result) \
do { \
extern bool esp_openthread_check_netif_##a##_offset(size_t offset); \
if (esp_openthread_check_netif_##a##_offset(offsetof(struct netif, a))) { \
ESP_LOGI("OT_TEST", "The offset `%s` checking passed.", #a); \
} else { \
out_result = false; \
} \
} while (0)

otError esp_openthread_process_br_lib_compatibility_check(void *aContext, uint8_t aArgsLength, char *aArgs[])
{
bool test_result = true;
LOAD_AND_TEST_NETIF_MEMBER(ip_addr, test_result);
LOAD_AND_TEST_NETIF_MEMBER(netmask, test_result);
LOAD_AND_TEST_NETIF_MEMBER(gw, test_result);
LOAD_AND_TEST_NETIF_MEMBER(ip6_addr, test_result);
LOAD_AND_TEST_NETIF_MEMBER(ip6_addr_state, test_result);
LOAD_AND_TEST_NETIF_MEMBER(ip6_addr_valid_life, test_result);
LOAD_AND_TEST_NETIF_MEMBER(ip6_addr_pref_life, test_result);
LOAD_AND_TEST_NETIF_MEMBER(input, test_result);
LOAD_AND_TEST_NETIF_MEMBER(output, test_result);
LOAD_AND_TEST_NETIF_MEMBER(linkoutput, test_result);
LOAD_AND_TEST_NETIF_MEMBER(status_callback, test_result);
LOAD_AND_TEST_NETIF_MEMBER(state, test_result);
LOAD_AND_TEST_NETIF_MEMBER(hostname, test_result);
LOAD_AND_TEST_NETIF_MEMBER(hwaddr, test_result);
LOAD_AND_TEST_NETIF_MEMBER(hwaddr_len, test_result);
LOAD_AND_TEST_NETIF_MEMBER(flags, test_result);
LOAD_AND_TEST_NETIF_MEMBER(name, test_result);
LOAD_AND_TEST_NETIF_MEMBER(num, test_result);
LOAD_AND_TEST_NETIF_MEMBER(ip6_autoconfig_enabled, test_result);
extern bool esp_openthread_check_netif_size(size_t netif_t);
if (esp_openthread_check_netif_size(sizeof(struct netif))) {
ESP_LOGI("OT_TEST", "The size of netif struct checking passed.");
} else {
test_result = false;
}
if (test_result) {
ESP_LOGI("OT_TEST", "The br library compatibility checking passed.");
} else {
ESP_LOGE("OT_TEST", "The br library compatibility checking failed.");
}
return OT_ERROR_NONE;
}
4 changes: 4 additions & 0 deletions components/esp_ot_cli_extension/src/esp_ot_cli_extension.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "esp_ot_cli_extension.h"
#include "esp_openthread.h"
#include "esp_ot_br_lib_compati_check.h"
#include "esp_ot_curl.h"
#include "esp_ot_dns64.h"
#include "esp_ot_heap_diag.h"
Expand Down Expand Up @@ -49,6 +50,9 @@ static const otCliCommand kCommands[] = {
#if CONFIG_OPENTHREAD_CLI_WIFI
{"wifi", esp_ot_process_wifi_cmd},
#endif // CONFIG_OPENTHREAD_CLI_WIFI
#if CONFIG_OPENTHREAD_BR_LIB_CHECK
{"brlibcheck", esp_openthread_process_br_lib_compatibility_check},
#endif // CONFIG_OPENTHREAD_CLI_WIFI
};

void esp_cli_custom_command_init()
Expand Down

0 comments on commit 2db961e

Please sign in to comment.