Skip to content

Commit 2db961e

Browse files
committed
Merge branch 'feat/add_command_line_for_testing_lib_compat' into 'main'
feat(ext_cli): add a command to check br lib compatibility See merge request espressif/esp-thread-br!150
2 parents 7a259df + 497e354 commit 2db961e

File tree

6 files changed

+81
-1
lines changed

6 files changed

+81
-1
lines changed

components/esp_ot_cli_extension/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ if(CONFIG_OPENTHREAD_RCP_COMMAND)
2727
list(APPEND srcs "src/esp_ot_rcp_commands.c")
2828
endif()
2929

30+
if(CONFIG_OPENTHREAD_BR_LIB_CHECK)
31+
list(APPEND srcs "src/esp_ot_br_lib_compati_check.c")
32+
endif()
33+
3034
set(include "include")
3135

3236
idf_component_register(SRCS "${srcs}"

components/esp_ot_cli_extension/Kconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,9 @@ menu "OpenThread Extension CLI"
2727
depends on OPENTHREAD_CLI_ESP_EXTENSION && OPENTHREAD_BORDER_ROUTER && AUTO_UPDATE_RCP
2828
default y if AUTO_UPDATE_RCP
2929

30+
config OPENTHREAD_BR_LIB_CHECK
31+
bool "Enable br lib compatibility check command, only for testing"
32+
depends on OPENTHREAD_CLI_ESP_EXTENSION && OPENTHREAD_BORDER_ROUTER
33+
default n
34+
3035
endmenu

components/esp_ot_cli_extension/idf_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "1.2.6"
1+
version: "1.3.0"
22
description: Espressif OpenThread CLI Extension
33
url: https://github.com/espressif/esp-thread-br/tree/main/components/esp_ot_cli_extension
44
dependencies:
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include "esp_log.h"
8+
#include "esp_ot_cli_extension.h"
9+
#include <stdint.h>
10+
#include <openthread/error.h>
11+
#include "openthread/cli.h"
12+
13+
otError esp_openthread_process_br_lib_compatibility_check(void *aContext, uint8_t aArgsLength, char *aArgs[]);
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include "esp_ot_br_lib_compati_check.h"
8+
#include "lwip/netif.h"
9+
10+
#define LOAD_AND_TEST_NETIF_MEMBER(a, out_result) \
11+
do { \
12+
extern bool esp_openthread_check_netif_##a##_offset(size_t offset); \
13+
if (esp_openthread_check_netif_##a##_offset(offsetof(struct netif, a))) { \
14+
ESP_LOGI("OT_TEST", "The offset `%s` checking passed.", #a); \
15+
} else { \
16+
out_result = false; \
17+
} \
18+
} while (0)
19+
20+
otError esp_openthread_process_br_lib_compatibility_check(void *aContext, uint8_t aArgsLength, char *aArgs[])
21+
{
22+
bool test_result = true;
23+
LOAD_AND_TEST_NETIF_MEMBER(ip_addr, test_result);
24+
LOAD_AND_TEST_NETIF_MEMBER(netmask, test_result);
25+
LOAD_AND_TEST_NETIF_MEMBER(gw, test_result);
26+
LOAD_AND_TEST_NETIF_MEMBER(ip6_addr, test_result);
27+
LOAD_AND_TEST_NETIF_MEMBER(ip6_addr_state, test_result);
28+
LOAD_AND_TEST_NETIF_MEMBER(ip6_addr_valid_life, test_result);
29+
LOAD_AND_TEST_NETIF_MEMBER(ip6_addr_pref_life, test_result);
30+
LOAD_AND_TEST_NETIF_MEMBER(input, test_result);
31+
LOAD_AND_TEST_NETIF_MEMBER(output, test_result);
32+
LOAD_AND_TEST_NETIF_MEMBER(linkoutput, test_result);
33+
LOAD_AND_TEST_NETIF_MEMBER(status_callback, test_result);
34+
LOAD_AND_TEST_NETIF_MEMBER(state, test_result);
35+
LOAD_AND_TEST_NETIF_MEMBER(hostname, test_result);
36+
LOAD_AND_TEST_NETIF_MEMBER(hwaddr, test_result);
37+
LOAD_AND_TEST_NETIF_MEMBER(hwaddr_len, test_result);
38+
LOAD_AND_TEST_NETIF_MEMBER(flags, test_result);
39+
LOAD_AND_TEST_NETIF_MEMBER(name, test_result);
40+
LOAD_AND_TEST_NETIF_MEMBER(num, test_result);
41+
LOAD_AND_TEST_NETIF_MEMBER(ip6_autoconfig_enabled, test_result);
42+
extern bool esp_openthread_check_netif_size(size_t netif_t);
43+
if (esp_openthread_check_netif_size(sizeof(struct netif))) {
44+
ESP_LOGI("OT_TEST", "The size of netif struct checking passed.");
45+
} else {
46+
test_result = false;
47+
}
48+
if (test_result) {
49+
ESP_LOGI("OT_TEST", "The br library compatibility checking passed.");
50+
} else {
51+
ESP_LOGE("OT_TEST", "The br library compatibility checking failed.");
52+
}
53+
return OT_ERROR_NONE;
54+
}

components/esp_ot_cli_extension/src/esp_ot_cli_extension.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include "esp_ot_cli_extension.h"
88
#include "esp_openthread.h"
9+
#include "esp_ot_br_lib_compati_check.h"
910
#include "esp_ot_curl.h"
1011
#include "esp_ot_dns64.h"
1112
#include "esp_ot_heap_diag.h"
@@ -49,6 +50,9 @@ static const otCliCommand kCommands[] = {
4950
#if CONFIG_OPENTHREAD_CLI_WIFI
5051
{"wifi", esp_ot_process_wifi_cmd},
5152
#endif // CONFIG_OPENTHREAD_CLI_WIFI
53+
#if CONFIG_OPENTHREAD_BR_LIB_CHECK
54+
{"brlibcheck", esp_openthread_process_br_lib_compatibility_check},
55+
#endif // CONFIG_OPENTHREAD_CLI_WIFI
5256
};
5357

5458
void esp_cli_custom_command_init()

0 commit comments

Comments
 (0)