Skip to content

Commit 513eb43

Browse files
gbarkadiuszkartben
authored andcommitted
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>
1 parent 35b13e1 commit 513eb43

File tree

5 files changed

+128
-0
lines changed

5 files changed

+128
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright (c) 2025 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
cmake_minimum_required(VERSION 3.20.0)
5+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
6+
project(power_states)
7+
8+
FILE(GLOB app_sources src/*.c)
9+
target_sources(app PRIVATE ${app_sources})
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright (c) 2025 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
/ {
7+
zephyr,user {
8+
k_idle_state_min_residency_time = <400000>;
9+
};
10+
};
11+
12+
&stop0{
13+
compatible = "zephyr,power-state";
14+
power-state-name = "suspend-to-idle";
15+
substate-id = <1>;
16+
min-residency-us = <500000>;
17+
};
18+
&stop1{
19+
compatible = "zephyr,power-state";
20+
power-state-name = "suspend-to-idle";
21+
substate-id = <2>;
22+
min-residency-us = <1000000>;
23+
};
24+
&stop2{
25+
compatible = "zephyr,power-state";
26+
power-state-name = "suspend-to-idle";
27+
substate-id = <3>;
28+
min-residency-us = <1500000>;
29+
};

tests/subsys/pm/power_states/prj.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Copyright (c) 2025 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
CONFIG_PM=y
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright (c) 2025 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
#include <zephyr/kernel.h>
7+
8+
int main(void)
9+
{
10+
int k_idle_min_residency_time =
11+
DT_PROP(DT_PATH(zephyr_user), k_idle_state_min_residency_time);
12+
int stop0_min_residency_time = DT_PROP(DT_NODELABEL(stop0), min_residency_us);
13+
int stop1_min_residency_time = DT_PROP(DT_NODELABEL(stop1), min_residency_us);
14+
int stop2_min_residency_time = DT_PROP(DT_NODELABEL(stop2), min_residency_us);
15+
16+
while (1) {
17+
printk("\nGoing to k_cpu_idle.\n");
18+
k_usleep(k_idle_min_residency_time);
19+
printk("\nWake Up.\n");
20+
printk("\nGoing to state 0.\n");
21+
k_usleep(stop0_min_residency_time);
22+
printk("\nWake Up.\n");
23+
printk("\nGoing to state 1.\n");
24+
k_usleep(stop1_min_residency_time);
25+
printk("\nWake Up.\n");
26+
printk("\nGoing to state 2.\n");
27+
k_usleep(stop2_min_residency_time);
28+
printk("\nWake Up.\n");
29+
30+
/* Anti-sleeping loop */
31+
while (1) {
32+
arch_nop();
33+
}
34+
}
35+
return 0;
36+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Copyright (c) 2025 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
common:
5+
harness: power
6+
harness_config:
7+
fixture: pm_probe
8+
pytest_dut_scope: session
9+
power_measurements:
10+
elements_to_trim: 100
11+
min_peak_distance: 40
12+
min_peak_height: 0.008
13+
peak_padding: 40
14+
measurement_duration: 6
15+
num_of_transitions: 4
16+
expected_rms_values: [56.0, 4.0, 1.4, 0.26, 140]
17+
tolerance_percentage: 10
18+
19+
tests:
20+
pm.power_states:
21+
platform_allow:
22+
- stm32l562e_dk
23+
tags:
24+
- pm
25+
26+
pm.power_states.pm_device:
27+
platform_allow:
28+
- stm32l562e_dk
29+
tags:
30+
- pm
31+
extra_args:
32+
- CONFIG_PM_DEVICE=y
33+
34+
pm.power_states.pm_device_runtime:
35+
platform_allow:
36+
- stm32l562e_dk
37+
tags:
38+
- pm
39+
extra_args:
40+
- CONFIG_PM_DEVICE=y
41+
- CONFIG_PM_DEVICE_RUNTIME=y
42+
43+
pm.power_states.pm_device_system_managed:
44+
platform_allow:
45+
- stm32l562e_dk
46+
tags:
47+
- pm
48+
extra_args:
49+
- CONFIG_PM_DEVICE=y
50+
- CONFIG_PM_DEVICE_SYSTEM_MANAGED=y

0 commit comments

Comments
 (0)