fix(tsens): Remove temperature sensor phy consist test on c2

This commit is contained in:
C.S.M
2026-05-27 15:41:24 +08:00
parent a409bb50c5
commit 80329e89d8
3 changed files with 1 additions and 173 deletions
@@ -1,6 +1,5 @@
set(srcs "test_app_main.c"
"test_temperature_sensor.cpp"
"test_temperature_phy.cpp")
"test_temperature_sensor.cpp")
if(CONFIG_SOC_TEMPERATURE_SENSOR_SUPPORT_ETM)
list(APPEND srcs "test_temperature_etm.cpp")
@@ -1,154 +0,0 @@
/*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdio.h>
#include <string.h>
#include "unity.h"
#include "esp_mac.h"
#include "esp_wifi.h"
#include "esp_wifi_types.h"
#include "esp_log.h"
#include "test_utils.h"
#include "esp_netif.h"
#include "nvs_flash.h"
#include "freertos/task.h"
#include "freertos/event_groups.h"
#include "hal/temperature_sensor_periph.h"
#include "unity.h"
#include "unity_test_utils.h"
#include "driver/temperature_sensor.h"
#if SOC_WIFI_SUPPORTED
#ifndef TEST_SUFFIX_STR
#define TEST_SUFFIX_STR "_0000"
#endif
#define TEST_DEFAULT_SSID "SSID_" CONFIG_IDF_TARGET TEST_SUFFIX_STR
#define TEST_DEFAULT_PWD "PASS_" CONFIG_IDF_TARGET TEST_SUFFIX_STR
#define TEST_DEFAULT_CHANNEL (1)
static const char* TAG = "test_temperature&phy";
// helper struct to get the value in temperature sensor handle
struct temperature_sensor_obj_t {
const temperature_sensor_attribute_t *tsens_attribute;
};
static void start_wifi_as_softap(void)
{
uint8_t ssid_len = strlen(TEST_DEFAULT_SSID);
wifi_config_t w_config = {}; // Zero-initialize the structure
// Assign members
strncpy((char *)w_config.ap.ssid, TEST_DEFAULT_SSID, sizeof(w_config.ap.ssid) - 1);
w_config.ap.ssid[sizeof(w_config.ap.ssid) - 1] = 0; // Ensure null termination
strncpy((char *)w_config.ap.password, TEST_DEFAULT_PWD, sizeof(w_config.ap.password) - 1);
w_config.ap.password[sizeof(w_config.ap.password) - 1] = 0; // Ensure null termination
w_config.ap.ssid_len = ssid_len;
w_config.ap.channel = TEST_DEFAULT_CHANNEL;
w_config.ap.authmode = WIFI_AUTH_WPA2_PSK;
w_config.ap.ssid_hidden = false;
w_config.ap.max_connection = 4;
w_config.ap.beacon_interval = 100;
TEST_ESP_OK(esp_wifi_set_mode(WIFI_MODE_AP));
TEST_ESP_OK(esp_wifi_set_config(WIFI_IF_AP, &w_config));
TEST_ESP_OK(esp_wifi_start());
ESP_LOGI(TAG, "start wifi softap: %s", TEST_DEFAULT_SSID);
}
static void start_wifi_as_sta(void)
{
TEST_ESP_OK(esp_wifi_set_mode(WIFI_MODE_STA));
TEST_ESP_OK(esp_wifi_start());
}
static void stop_wifi(void)
{
TEST_ESP_OK(esp_wifi_stop());
vTaskDelay(500 / portTICK_PERIOD_MS);
}
static void wifi_connect(void)
{
wifi_config_t w_config = {}; // Zero-initialize the structure
// Assign members
strncpy((char *)w_config.sta.ssid, TEST_DEFAULT_SSID, sizeof(w_config.sta.ssid) - 1);
w_config.sta.ssid[sizeof(w_config.sta.ssid) - 1] = 0; // Ensure null termination
strncpy((char *)w_config.sta.password, TEST_DEFAULT_PWD, sizeof(w_config.sta.password) - 1);
w_config.sta.password[sizeof(w_config.sta.password) - 1] = 0; // Ensure null termination
TEST_ESP_OK(esp_wifi_set_config(WIFI_IF_STA, &w_config));
TEST_ESP_OK(esp_wifi_connect());
ESP_LOGI(TAG, "start esp_wifi_connect: %s", TEST_DEFAULT_SSID);
}
static void test_wifi_establish_sta(void)
{
TEST_ESP_OK(nvs_flash_init());
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
cfg.nvs_enable = false;
TEST_ESP_OK(esp_wifi_init(&cfg));
start_wifi_as_sta();
unity_wait_for_signal("AP start");
// make sure softap has started
vTaskDelay(1000 / portTICK_PERIOD_MS);
wifi_connect();
unity_send_signal("connect");
unity_wait_for_signal("tsens test done");
// do not auto reconnect after connected
stop_wifi();
TEST_ESP_OK(esp_wifi_deinit());
TEST_ESP_OK(nvs_flash_deinit());
}
static void test_wifi_temperature_softap(void)
{
temperature_sensor_handle_t temp_sensor = NULL;
// Initialize it in an bad value.
temperature_sensor_config_t temp_sensor_config = TEMPERATURE_SENSOR_CONFIG_DEFAULT(-40, -30);
float tsens_value;
TEST_ESP_OK(temperature_sensor_install(&temp_sensor_config, &temp_sensor));
ESP_LOGI(TAG, "Enable temperature sensor");
TEST_ESP_OK(temperature_sensor_enable(temp_sensor));
TEST_ASSERT_EQUAL_INT(10, temp_sensor->tsens_attribute->reg_val);
TEST_ESP_OK(temperature_sensor_get_celsius(temp_sensor, &tsens_value));
ESP_LOGI(TAG, "Temperature value %.02f ℃", tsens_value);
// Update to the correct one automatically.
TEST_ASSERT_EQUAL_INT(15, temp_sensor->tsens_attribute->reg_val);
int cnt = 10;
TEST_ESP_OK(nvs_flash_init());
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
cfg.nvs_enable = false;
TEST_ESP_OK(esp_wifi_init(&cfg));
start_wifi_as_softap();
unity_send_signal("AP start");
unity_wait_for_signal("connect");
while (cnt--) {
TEST_ESP_OK(temperature_sensor_get_celsius(temp_sensor, &tsens_value));
ESP_LOGI(TAG, "Temperature value %.02f ℃", tsens_value);
if (tsens_value < 20 || tsens_value > 50) {
ESP_LOGE(TAG, "Temperature value is completely wrong");
abort();
}
vTaskDelay(pdMS_TO_TICKS(1000));
}
TEST_ESP_OK(temperature_sensor_disable(temp_sensor));
TEST_ESP_OK(temperature_sensor_uninstall(temp_sensor));
unity_send_signal("tsens test done");
stop_wifi();
TEST_ESP_OK(esp_wifi_deinit());
TEST_ESP_OK(nvs_flash_deinit());
}
TEST_CASE_MULTIPLE_DEVICES("test temperature sensor work together with wifi", "[test_env=tsens_phy]", test_wifi_establish_sta, test_wifi_temperature_softap);
#endif
@@ -2,7 +2,6 @@
# SPDX-License-Identifier: CC0-1.0
import pytest
from pytest_embedded import Dut
from pytest_embedded_idf.unity_tester import CaseTester
from pytest_embedded_idf.utils import idf_parametrize
from pytest_embedded_idf.utils import soc_filtered_targets
@@ -54,19 +53,3 @@ def test_temperature_sensor_driver_esp32c5_rev1(dut: Dut) -> None:
@idf_parametrize('target', ['esp32c6', 'esp32h2', 'esp32p4', 'esp32c5', 'esp32c61', 'esp32s31'], indirect=['target'])
def test_temperature_sensor_cbs(dut: Dut) -> None:
dut.run_all_single_board_cases()
@pytest.mark.two_duts
@pytest.mark.parametrize('count', [2], indirect=True)
@pytest.mark.parametrize(
'config',
[
'release',
],
indirect=True,
)
@idf_parametrize('target', ['esp32s2', 'esp32c3', 'esp32s3', 'esp32c2', 'esp32c6', 'esp32c61'], indirect=['target'])
def test_temperature_phy_cases(case_tester: CaseTester) -> None: # type: ignore
for case in case_tester.test_menu:
if case.attributes.get('test_env', 'two_duts') == 'two_duts':
case_tester.run_multi_dev_case(case=case, reset=True)