Skip to content

Commit

Permalink
Merge branch 'feature/example_config_test_in_ci' into 'master'
Browse files Browse the repository at this point in the history
feat(example): add pytest for ble example config test

Closes BLERP-1190 and BLERP-1224

See merge request espressif/esp-idf!34668
  • Loading branch information
Isl2017 committed Dec 25, 2024
2 parents 5b15320 + a4ff6ba commit 51ccce2
Show file tree
Hide file tree
Showing 59 changed files with 434 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration
#
CONFIG_BT_ENABLED=y
CONFIG_BT_BLE_50_FEATURES_SUPPORTED=n
# CONFIG_BT_BLE_50_FEATURES_SUPPORTED is not set
CONFIG_BT_BLE_42_FEATURES_SUPPORTED=y
# CONFIG_BT_LE_50_FEATURE_SUPPORT is not used on ESP32, ESP32-C3 and ESP32-S3.
CONFIG_BT_LE_50_FEATURE_SUPPORT=n
# CONFIG_BT_LE_50_FEATURE_SUPPORT is not set
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration
#
CONFIG_BT_ENABLED=y
CONFIG_BT_BLE_50_FEATURES_SUPPORTED=n
# CONFIG_BT_BLE_50_FEATURES_SUPPORTED is not set
CONFIG_BT_BLE_42_FEATURES_SUPPORTED=y
# CONFIG_BT_LE_50_FEATURE_SUPPORT is not used on ESP32, ESP32-C3 and ESP32-S3.
CONFIG_BT_LE_50_FEATURE_SUPPORT=n
# CONFIG_BT_LE_50_FEATURE_SUPPORT is not set
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration
#
CONFIG_BT_ENABLED=y
CONFIG_BT_BLE_50_FEATURES_SUPPORTED=n
# CONFIG_BT_BLE_50_FEATURES_SUPPORTED is not set
CONFIG_BT_BLE_42_FEATURES_SUPPORTED=y
# CONFIG_BT_LE_50_FEATURE_SUPPORT is not used on ESP32, ESP32-C3 and ESP32-S3.
CONFIG_BT_LE_50_FEATURE_SUPPORT=n
# CONFIG_BT_LE_50_FEATURE_SUPPORT is not set
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration
#
CONFIG_BT_ENABLED=y
CONFIG_BT_BLE_50_FEATURES_SUPPORTED=n
# CONFIG_BT_BLE_50_FEATURES_SUPPORTED is not set
CONFIG_BT_BLE_42_FEATURES_SUPPORTED=y
# CONFIG_BT_LE_50_FEATURE_SUPPORT is not used on ESP32, ESP32-C3 and ESP32-S3.
CONFIG_BT_LE_50_FEATURE_SUPPORT=n
# CONFIG_BT_LE_50_FEATURE_SUPPORT is not set
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration
#
CONFIG_BT_ENABLED=y
CONFIG_BT_BLE_50_FEATURES_SUPPORTED=n
# CONFIG_BT_BLE_50_FEATURES_SUPPORTED is not set
CONFIG_BT_BLE_42_FEATURES_SUPPORTED=y
# CONFIG_BT_LE_50_FEATURE_SUPPORT is not used on ESP32, ESP32-C3 and ESP32-S3.
CONFIG_BT_LE_50_FEATURE_SUPPORT=n
# CONFIG_BT_LE_50_FEATURE_SUPPORT is not set
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from pytest_embedded_idf.dut import IdfDut


# Case 1: gatt write throughput test
# Case 1: gatt write throughput test(EXAMPLE_CI_ID = 2)
@pytest.mark.esp32
@pytest.mark.esp32c3
@pytest.mark.esp32c6
Expand All @@ -18,10 +18,10 @@
@pytest.mark.esp32s3
@pytest.mark.wifi_two_dut
@pytest.mark.parametrize(
'count, app_path, config, erase_all', [
'count, app_path, config', [
(2,
f'{os.path.join(os.path.dirname(__file__), "throughput_server")}|{os.path.join(os.path.dirname(__file__), "throughput_client")}',
'write', 'y'),
'write'),
],
indirect=True,
)
Expand All @@ -48,15 +48,15 @@ def test_gatt_write_throughput(app_path: str, dut: Tuple[IdfDut, IdfDut]) -> Non
assert throughput > 50000 or throughput < 95000


# Case 2: gatt write throughput test for ESP32C2 26mhz xtal
# Case 2: gatt write throughput test for ESP32C2 26mhz xtal(EXAMPLE_CI_ID = 2)
@pytest.mark.esp32c2
@pytest.mark.wifi_two_dut
@pytest.mark.xtal_26mhz
@pytest.mark.parametrize(
'count, target, baud, app_path, config, erase_all', [
'count, target, baud, app_path, config', [
(2, 'esp32c2|esp32c2', '74880',
f'{os.path.join(os.path.dirname(__file__), "throughput_server")}|{os.path.join(os.path.dirname(__file__), "throughput_client")}',
'esp32c2_xtal26m_write', 'y'),
'esp32c2_xtal26m_write'),
],
indirect=True,
)
Expand All @@ -83,7 +83,7 @@ def test_c2_26mhz_xtal_write_throughput(app_path: str, dut: Tuple[IdfDut, IdfDut
assert throughput > 50000 or throughput < 95000


# Case 3: gatt notify throughput test
# Case 3: gatt notify throughput test(EXAMPLE_CI_ID = 1)
@pytest.mark.esp32
@pytest.mark.esp32c3
@pytest.mark.esp32c6
Expand All @@ -93,10 +93,10 @@ def test_c2_26mhz_xtal_write_throughput(app_path: str, dut: Tuple[IdfDut, IdfDut
@pytest.mark.esp32s3
@pytest.mark.wifi_two_dut
@pytest.mark.parametrize(
'count, app_path, config, erase_all', [
'count, app_path, config', [
(2,
f'{os.path.join(os.path.dirname(__file__), "throughput_server")}|{os.path.join(os.path.dirname(__file__), "throughput_client")}',
'notify', 'y'),
'notify'),
],
indirect=True,
)
Expand Down Expand Up @@ -125,15 +125,15 @@ def test_gatt_notify_throughput(app_path: str, dut: Tuple[IdfDut, IdfDut]) -> No
assert throughput > 50000 or throughput < 95000


# Case 4: gatt notify throughput test for ESP32C2 26mhz xtal
# Case 4: gatt notify throughput test for ESP32C2 26mhz xtal(EXAMPLE_CI_ID = 1)
@pytest.mark.esp32c2
@pytest.mark.wifi_two_dut
@pytest.mark.xtal_26mhz
@pytest.mark.parametrize(
'count, target, baud, app_path, config, erase_all', [
'count, target, baud, app_path, config', [
(2, 'esp32c2|esp32c2', '74880',
f'{os.path.join(os.path.dirname(__file__), "throughput_server")}|{os.path.join(os.path.dirname(__file__), "throughput_client")}',
'esp32c2_xtal26m_notify', 'y'),
'esp32c2_xtal26m_notify'),
],
indirect=True,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ menu "Example 'GATT CLIENT THROUGHPUT' Config"
it can't test both write or notify at the same time at this demo

config EXAMPLE_CI_ID
int
default 60
int "example id for CI test"
default 0
help
This config the example id for CI test. Only for internal used.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

CONFIG_EXAMPLE_CI_ID=1
CONFIG_IDF_TARGET="esp32c2"
CONFIG_XTAL_FREQ_26=y
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CONFIG_EXAMPLE_CI_ID=1
CONFIG_EXAMPLE_CI_ID=2
CONFIG_IDF_TARGET="esp32c2"
CONFIG_XTAL_FREQ_26=y
CONFIG_EXAMPLE_CI_PIPELINE_ID=${CI_PIPELINE_ID}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CONFIG_EXAMPLE_CI_ID=1
CONFIG_EXAMPLE_CI_ID=2
CONFIG_EXAMPLE_CI_PIPELINE_ID=${CI_PIPELINE_ID}
CONFIG_EXAMPLE_GATTC_WRITE_THROUGHPUT=y
CONFIG_EXAMPLE_GATTS_NOTIFY_THROUGHPUT=n
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration
#
CONFIG_BT_ENABLED=y
CONFIG_BT_BLE_50_FEATURES_SUPPORTED=n
# CONFIG_BT_BLE_50_FEATURES_SUPPORTED is not set
CONFIG_BT_BLE_42_FEATURES_SUPPORTED=y
# CONFIG_BT_LE_50_FEATURE_SUPPORT is not used on ESP32, ESP32-C3 and ESP32-S3.
CONFIG_BT_LE_50_FEATURE_SUPPORT=n
# CONFIG_BT_LE_50_FEATURE_SUPPORT is not set
CONFIG_EXAMPLE_GATTS_NOTIFY_THROUGHPUT=y
CONFIG_EXAMPLE_GATTC_WRITE_THROUGHPUT=n
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ menu "Example 'GATT SERVER THROUGHPUT' Config"
it can't test both write or notify at the same time at this demo

config EXAMPLE_CI_ID
int
default 60
int "example id for CI test"
default 0
help
This config the example id for CI test. Only for internal used.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CONFIG_EXAMPLE_CI_ID=1
CONFIG_EXAMPLE_CI_ID=2
CONFIG_IDF_TARGET="esp32c2"
CONFIG_XTAL_FREQ_26=y
CONFIG_EXAMPLE_CI_PIPELINE_ID=${CI_PIPELINE_ID}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CONFIG_EXAMPLE_CI_ID=1
CONFIG_EXAMPLE_CI_ID=2
CONFIG_EXAMPLE_CI_PIPELINE_ID=${CI_PIPELINE_ID}
CONFIG_EXAMPLE_GATTC_WRITE_THROUGHPUT=y
CONFIG_EXAMPLE_GATTS_NOTIFY_THROUGHPUT=n
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
CONFIG_EXAMPLE_GATTS_NOTIFY_THROUGHPUT=y
CONFIG_EXAMPLE_GATTC_WRITE_THROUGHPUT=n
CONFIG_BT_ENABLED=y
CONFIG_BT_BLE_50_FEATURES_SUPPORTED=n
# CONFIG_BT_BLE_50_FEATURES_SUPPORTED is not set
CONFIG_BT_BLE_42_FEATURES_SUPPORTED=y
# CONFIG_BT_LE_50_FEATURE_SUPPORT is not used on ESP32, ESP32-C3 and ESP32-S3.
CONFIG_BT_LE_50_FEATURE_SUPPORT=n
# CONFIG_BT_LE_50_FEATURE_SUPPORT is not set
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ menu "Example Configuration"
default n

config EXAMPLE_CI_ID
int
default 70
int "example id for CI test"
default 0
help
This config the example id for CI test. Only for internal used.

Expand All @@ -16,4 +16,9 @@ menu "Example Configuration"
help
This config the pipeline id for CI test. Only for internal used.

config EXAMPLE_INIT_DEINIT_LOOP
bool "Perform init deinit of bluedroid host in a loop"
default n
help
This config perform host init deinit loop for CI test. Only for internal used
endmenu
17 changes: 17 additions & 0 deletions examples/bluetooth/bluedroid/ble/gatt_client/main/gattc_demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
#define PROFILE_NUM 1
#define PROFILE_A_APP_ID 0
#define INVALID_HANDLE 0
#if CONFIG_EXAMPLE_INIT_DEINIT_LOOP
#define EXAMPLE_TEST_COUNT 50
#endif

static char remote_device_name[ESP_BLE_ADV_NAME_LEN_MAX] = "ESP_GATTS_DEMO";
static bool connect = false;
Expand Down Expand Up @@ -493,6 +496,20 @@ void app_main(void)
ESP_LOGE(GATTC_TAG, "%s enable bluetooth failed: %s", __func__, esp_err_to_name(ret));
return;
}

#if CONFIG_EXAMPLE_INIT_DEINIT_LOOP
for(int i = 0; i < EXAMPLE_TEST_COUNT; i++) {
ESP_ERROR_CHECK( esp_bluedroid_disable() );
ESP_ERROR_CHECK( esp_bluedroid_deinit() );
vTaskDelay(10/portTICK_PERIOD_MS);
ESP_LOGI(GATTC_TAG, "Free memory: %" PRIu32 " bytes", esp_get_free_heap_size());
ESP_ERROR_CHECK( esp_bluedroid_init() );
ESP_ERROR_CHECK( esp_bluedroid_enable() );
vTaskDelay(10/portTICK_PERIOD_MS);
}
return;
#endif

// Note: Avoid performing time-consuming operations within callback functions.
// Register the callback function to the gap module
ret = esp_ble_gap_register_callback(esp_gap_cb);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CONFIG_EXAMPLE_CI_ID=4
CONFIG_EXAMPLE_CI_PIPELINE_ID=${CI_PIPELINE_ID}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CONFIG_EXAMPLE_CI_ID=4
CONFIG_IDF_TARGET="esp32c2"
CONFIG_XTAL_FREQ_26=y
CONFIG_EXAMPLE_CI_PIPELINE_ID=${CI_PIPELINE_ID}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# CONFIG_BT_GATTS_ENABLE is not set
# CONFIG_BT_GATTC_ENABLE is not set
# CONFIG_BT_BLE_SMP_ENABLE is not set
# CONFIG_BT_BLE_42_FEATURES_SUPPORTED is not set
# CONFIG_BT_BLE_50_FEATURES_SUPPORTED is not set
CONFIG_IDF_TARGET="esp32c2"
CONFIG_XTAL_FREQ_26=y
CONFIG_EXAMPLE_INIT_DEINIT_LOOP=y
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

CONFIG_EXAMPLE_CI_ID=1
CONFIG_EXAMPLE_CI_ID=3
CONFIG_IDF_TARGET="esp32c2"
CONFIG_XTAL_FREQ_26=y
CONFIG_EXAMPLE_CI_PIPELINE_ID=${CI_PIPELINE_ID}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# CONFIG_BT_GATTS_ENABLE is not set
# CONFIG_BT_GATTC_ENABLE is not set
# CONFIG_BT_BLE_SMP_ENABLE is not set
# CONFIG_BT_BLE_42_FEATURES_SUPPORTED is not set
# CONFIG_BT_BLE_50_FEATURES_SUPPORTED is not set
CONFIG_EXAMPLE_INIT_DEINIT_LOOP=y
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
CONFIG_EXAMPLE_CI_ID=1
CONFIG_EXAMPLE_CI_ID=3
CONFIG_EXAMPLE_CI_PIPELINE_ID=${CI_PIPELINE_ID}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration
#
CONFIG_BT_ENABLED=y
CONFIG_BT_BLE_50_FEATURES_SUPPORTED=n
# CONFIG_BT_BLE_50_FEATURES_SUPPORTED is not set
CONFIG_BT_BLE_42_FEATURES_SUPPORTED=y
# CONFIG_BT_LE_50_FEATURE_SUPPORT is not used on ESP32, ESP32-C3 and ESP32-S3.
CONFIG_BT_LE_50_FEATURE_SUPPORT=n
# CONFIG_BT_LE_50_FEATURE_SUPPORT is not set
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
menu "Example 'GATT SECURITY CLIENT' Config"

config EXAMPLE_CI_ID
int
default 80
int "example id for CI test"
default 0
help
This config the example id for CI test. Only for internal used.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CONFIG_EXAMPLE_CI_ID=1
CONFIG_EXAMPLE_CI_ID=5
CONFIG_IDF_TARGET="esp32c2"
CONFIG_XTAL_FREQ_26=y
CONFIG_EXAMPLE_CI_PIPELINE_ID=${CI_PIPELINE_ID}
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@

CONFIG_EXAMPLE_CI_ID=1
CONFIG_EXAMPLE_CI_ID=5
CONFIG_EXAMPLE_CI_PIPELINE_ID=${CI_PIPELINE_ID}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration
#
CONFIG_BT_ENABLED=y
CONFIG_BT_BLE_50_FEATURES_SUPPORTED=n
# CONFIG_BT_BLE_50_FEATURES_SUPPORTED is not set
CONFIG_BT_BLE_42_FEATURES_SUPPORTED=y
# CONFIG_BT_LE_50_FEATURE_SUPPORT is not used on ESP32, ESP32-C3 and ESP32-S3.
CONFIG_BT_LE_50_FEATURE_SUPPORT=n
# CONFIG_BT_LE_50_FEATURE_SUPPORT is not set
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
menu "Example 'GATT SECURITY SERVER' Config"

config EXAMPLE_CI_ID
int
int "example id for CI test"
default 80
help
This config the example id for CI test. Only for internal used.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CONFIG_EXAMPLE_CI_ID=1
CONFIG_EXAMPLE_CI_ID=5
CONFIG_IDF_TARGET="esp32c2"
CONFIG_XTAL_FREQ_26=y
CONFIG_EXAMPLE_CI_PIPELINE_ID=${CI_PIPELINE_ID}
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@

CONFIG_EXAMPLE_CI_ID=1
CONFIG_EXAMPLE_CI_ID=5
CONFIG_EXAMPLE_CI_PIPELINE_ID=${CI_PIPELINE_ID}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration
#
CONFIG_BT_ENABLED=y
CONFIG_BT_BLE_50_FEATURES_SUPPORTED=n
# CONFIG_BT_BLE_50_FEATURES_SUPPORTED is not set
CONFIG_BT_BLE_42_FEATURES_SUPPORTED=y
# CONFIG_BT_LE_50_FEATURE_SUPPORT is not used on ESP32, ESP32-C3 and ESP32-S3.
CONFIG_BT_LE_50_FEATURE_SUPPORT=n
# CONFIG_BT_LE_50_FEATURE_SUPPORT is not set
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ menu "Example 'GATT SERVER' Config"
overhead at runtime.

config EXAMPLE_CI_ID
int
default 70
int "example id for CI test"
default 0
help
This config the example id for CI test. Only for internal used.

Expand Down
13 changes: 13 additions & 0 deletions examples/bluetooth/bluedroid/ble/gatt_server/sdkconfig.ci.cfg_test
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
CONFIG_EXAMPLE_CI_ID=4
CONFIG_EXAMPLE_CI_PIPELINE_ID=${CI_PIPELINE_ID}
CONFIG_BT_BLUEDROID_MEM_DEBUG=y
CONFIG_BT_GATTS_PPCP_CHAR_GAP=y
CONFIG_BT_BLE_BLUFI_ENABLE=y
CONFIG_BT_GATTS_ROBUST_CACHING_ENABLED=y
CONFIG_BT_GATTC_CACHE_NVS_FLASH=y
CONFIG_BT_SMP_SLAVE_CON_PARAMS_UPD_ENABLE=y
CONFIG_BT_BLE_SMP_ID_RESET_ENABLE=y
CONFIG_BT_BLE_HOST_QUEUE_CONG_CHECK=y
CONFIG_BT_BLE_ACT_SCAN_REP_ADV_SCAN=y
CONFIG_BT_BLE_HIGH_DUTY_ADV_INTERVAL=y
CONFIG_BT_ABORT_WHEN_ALLOCATION_FAILS=y
Loading

0 comments on commit 51ccce2

Please sign in to comment.