tests: power_states: Verifies the transition to all available power states
During the test, pytest detects each step and calculates the RMS (Root Mean Square) current for every detected state. The test then compares the calculated RMS values against the expected values. Signed-off-by: Arkadiusz Cholewinski <arkadiuszx.cholewinski@intel.com>
This commit is contained in:
parent
35b13e1629
commit
513eb43377
5 changed files with 128 additions and 0 deletions
9
tests/subsys/pm/power_states/CMakeLists.txt
Normal file
9
tests/subsys/pm/power_states/CMakeLists.txt
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
# Copyright (c) 2025 Intel Corporation
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.20.0)
|
||||||
|
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||||
|
project(power_states)
|
||||||
|
|
||||||
|
FILE(GLOB app_sources src/*.c)
|
||||||
|
target_sources(app PRIVATE ${app_sources})
|
29
tests/subsys/pm/power_states/boards/stm32l562e_dk.overlay
Normal file
29
tests/subsys/pm/power_states/boards/stm32l562e_dk.overlay
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2025 Intel Corporation
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
/ {
|
||||||
|
zephyr,user {
|
||||||
|
k_idle_state_min_residency_time = <400000>;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
&stop0{
|
||||||
|
compatible = "zephyr,power-state";
|
||||||
|
power-state-name = "suspend-to-idle";
|
||||||
|
substate-id = <1>;
|
||||||
|
min-residency-us = <500000>;
|
||||||
|
};
|
||||||
|
&stop1{
|
||||||
|
compatible = "zephyr,power-state";
|
||||||
|
power-state-name = "suspend-to-idle";
|
||||||
|
substate-id = <2>;
|
||||||
|
min-residency-us = <1000000>;
|
||||||
|
};
|
||||||
|
&stop2{
|
||||||
|
compatible = "zephyr,power-state";
|
||||||
|
power-state-name = "suspend-to-idle";
|
||||||
|
substate-id = <3>;
|
||||||
|
min-residency-us = <1500000>;
|
||||||
|
};
|
4
tests/subsys/pm/power_states/prj.conf
Normal file
4
tests/subsys/pm/power_states/prj.conf
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
# Copyright (c) 2025 Intel Corporation
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
CONFIG_PM=y
|
36
tests/subsys/pm/power_states/src/main.c
Normal file
36
tests/subsys/pm/power_states/src/main.c
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2025 Intel Corporation
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
#include <zephyr/kernel.h>
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
int k_idle_min_residency_time =
|
||||||
|
DT_PROP(DT_PATH(zephyr_user), k_idle_state_min_residency_time);
|
||||||
|
int stop0_min_residency_time = DT_PROP(DT_NODELABEL(stop0), min_residency_us);
|
||||||
|
int stop1_min_residency_time = DT_PROP(DT_NODELABEL(stop1), min_residency_us);
|
||||||
|
int stop2_min_residency_time = DT_PROP(DT_NODELABEL(stop2), min_residency_us);
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
printk("\nGoing to k_cpu_idle.\n");
|
||||||
|
k_usleep(k_idle_min_residency_time);
|
||||||
|
printk("\nWake Up.\n");
|
||||||
|
printk("\nGoing to state 0.\n");
|
||||||
|
k_usleep(stop0_min_residency_time);
|
||||||
|
printk("\nWake Up.\n");
|
||||||
|
printk("\nGoing to state 1.\n");
|
||||||
|
k_usleep(stop1_min_residency_time);
|
||||||
|
printk("\nWake Up.\n");
|
||||||
|
printk("\nGoing to state 2.\n");
|
||||||
|
k_usleep(stop2_min_residency_time);
|
||||||
|
printk("\nWake Up.\n");
|
||||||
|
|
||||||
|
/* Anti-sleeping loop */
|
||||||
|
while (1) {
|
||||||
|
arch_nop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
50
tests/subsys/pm/power_states/testcase.yaml
Normal file
50
tests/subsys/pm/power_states/testcase.yaml
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
# Copyright (c) 2025 Intel Corporation
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
common:
|
||||||
|
harness: power
|
||||||
|
harness_config:
|
||||||
|
fixture: pm_probe
|
||||||
|
pytest_dut_scope: session
|
||||||
|
power_measurements:
|
||||||
|
elements_to_trim: 100
|
||||||
|
min_peak_distance: 40
|
||||||
|
min_peak_height: 0.008
|
||||||
|
peak_padding: 40
|
||||||
|
measurement_duration: 6
|
||||||
|
num_of_transitions: 4
|
||||||
|
expected_rms_values: [56.0, 4.0, 1.4, 0.26, 140]
|
||||||
|
tolerance_percentage: 10
|
||||||
|
|
||||||
|
tests:
|
||||||
|
pm.power_states:
|
||||||
|
platform_allow:
|
||||||
|
- stm32l562e_dk
|
||||||
|
tags:
|
||||||
|
- pm
|
||||||
|
|
||||||
|
pm.power_states.pm_device:
|
||||||
|
platform_allow:
|
||||||
|
- stm32l562e_dk
|
||||||
|
tags:
|
||||||
|
- pm
|
||||||
|
extra_args:
|
||||||
|
- CONFIG_PM_DEVICE=y
|
||||||
|
|
||||||
|
pm.power_states.pm_device_runtime:
|
||||||
|
platform_allow:
|
||||||
|
- stm32l562e_dk
|
||||||
|
tags:
|
||||||
|
- pm
|
||||||
|
extra_args:
|
||||||
|
- CONFIG_PM_DEVICE=y
|
||||||
|
- CONFIG_PM_DEVICE_RUNTIME=y
|
||||||
|
|
||||||
|
pm.power_states.pm_device_system_managed:
|
||||||
|
platform_allow:
|
||||||
|
- stm32l562e_dk
|
||||||
|
tags:
|
||||||
|
- pm
|
||||||
|
extra_args:
|
||||||
|
- CONFIG_PM_DEVICE=y
|
||||||
|
- CONFIG_PM_DEVICE_SYSTEM_MANAGED=y
|
Loading…
Add table
Add a link
Reference in a new issue