Skip to content

Commit 0b93c2f

Browse files
ZhaoxiangJinnashif
authored andcommitted
tests: on_demand: Add test for P-states order
Ensure that the P-states defined in devicetree for the CPU frequency scaling on-demand policy are in decreasing order of load thresholds. This is important because the on-demand policy relies on this order to select the appropriate P-state based on current CPU load. Signed-off-by: Zhaoxiang Jin <Zhaoxiang.Jin_1@nxp.com>
1 parent 2194069 commit 0b93c2f

File tree

1 file changed

+15
-0
lines changed
  • tests/subsys/cpu_freq/policies/on_demand/src

1 file changed

+15
-0
lines changed

tests/subsys/cpu_freq/policies/on_demand/src/main.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,21 @@ LOG_MODULE_REGISTER(cpu_freq_on_demand_test, LOG_LEVEL_INF);
1515

1616
#define WAIT_US 1000
1717

18+
extern const struct pstate *soc_pstates[];
19+
extern const size_t soc_pstates_count;
20+
21+
/*
22+
* Test that P-states are defined in decreasing load_threshold order in devicetree.
23+
*/
24+
ZTEST(cpu_freq_on_demand, test_pstates_order)
25+
{
26+
for (int i = 1; i < soc_pstates_count; ++i) {
27+
zassert_true(soc_pstates[i]->load_threshold <
28+
soc_pstates[i-1]->load_threshold,
29+
"P-states must be in decreasing threshold order");
30+
}
31+
}
32+
1833
/*
1934
* Test APIs of on_demand CPU frequency policy.
2035
*/

0 commit comments

Comments
 (0)