Skip to content

Commit 2464bb9

Browse files
committed
[nrf fromlist] tests: drivers: clock_control: Move test configuration to Kconfig
Improve nrf_clock_control test suite. Instead of selecting tests based on CONFIG_SOC_xxx symbols, define Kconfigs. Added Kconfigs get value from SOC symbols (or can be set with board overlay). Add indication that test case was skipped. Upstream PR #: 109137 Signed-off-by: Sebastian Głąb <sebastian.glab@nordicsemi.no>
1 parent f5ac77b commit 2464bb9

2 files changed

Lines changed: 60 additions & 14 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright (c) 2026 Nordic Semiconductor ASA
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config TEST_FLL16M
5+
bool "Run test on the FLL16M"
6+
default y if SOC_NRF54H20_CPUAPP
7+
help
8+
When set to 'y' tests of FLL16M are executed.
9+
10+
config TEST_HSFLL_APP
11+
bool "Run test on the HSFLL APP"
12+
default y if SOC_NRF54H20_CPUAPP
13+
help
14+
When set to 'y' tests of HSFLL APP are executed.
15+
16+
config TEST_HSFLL_RAD
17+
bool "Run test on the HSFLL RAD"
18+
default y if SOC_NRF54H20_CPURAD
19+
help
20+
When set to 'y' tests of HSFLL RAD are executed.
21+
22+
config TEST_DVFS_INIT
23+
bool "Check DVFS initialization"
24+
default y if SOC_NRF54H20_CPUAPP
25+
help
26+
When set to 'y' DVFS is initialised at the beginning of the test suite.
27+
28+
source "Kconfig.zephyr"

tests/drivers/clock_control/nrf_clock_control/src/main.c

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const struct nrf_clock_spec test_clk_specs_hsfll[] = {
3838
};
3939
#endif
4040

41-
#if CONFIG_BOARD_NRF54H20DK_NRF54H20_CPUAPP
41+
#if defined(CONFIG_TEST_FLL16M)
4242
const struct nrf_clock_spec test_clk_specs_fll16m[] = {
4343
{
4444
.frequency = MHZ(16),
@@ -85,15 +85,19 @@ static const struct test_clk_context invalid_fll16m_test_clk_contexts[] = {
8585
.clk_specs_size = ARRAY_SIZE(invalid_test_clk_specs_fll16m),
8686
},
8787
};
88+
#endif
8889

90+
#if defined(CONFIG_TEST_HSFLL_APP)
8991
static const struct test_clk_context cpuapp_hsfll_test_clk_contexts[] = {
9092
{
9193
.clk_dev = DEVICE_DT_GET(DT_NODELABEL(cpuapp_hsfll)),
9294
.clk_specs = test_clk_specs_hsfll,
9395
.clk_specs_size = ARRAY_SIZE(test_clk_specs_hsfll),
9496
},
9597
};
96-
#elif defined(CONFIG_BOARD_NRF54H20DK_NRF54H20_CPURAD)
98+
#endif
99+
100+
#if defined(CONFIG_TEST_HSFLL_RAD)
97101
static const struct test_clk_context cpurad_hsfll_test_clk_contexts[] = {
98102
{
99103
.clk_dev = DEVICE_DT_GET(DT_NODELABEL(cpurad_hsfll)),
@@ -273,18 +277,23 @@ static void test_clock_control_request(const struct test_clk_context *clk_contex
273277
}
274278
}
275279

276-
#if CONFIG_BOARD_NRF54H20DK_NRF54H20_CPUAPP
277280
ZTEST(nrf2_clock_control, test_cpuapp_hsfll_control)
278281
{
282+
Z_TEST_SKIP_IFNDEF(CONFIG_TEST_HSFLL_APP);
283+
#if defined(CONFIG_TEST_HSFLL_APP)
279284
TC_PRINT("APPLICATION DOMAIN HSFLL test\n");
280285
test_clock_control_request(cpuapp_hsfll_test_clk_contexts,
281286
ARRAY_SIZE(cpuapp_hsfll_test_clk_contexts));
287+
#endif
282288
}
283289

284290
ZTEST(nrf2_clock_control, test_fll16m_control)
285291
{
292+
Z_TEST_SKIP_IFNDEF(CONFIG_TEST_FLL16M);
293+
#if defined(CONFIG_TEST_FLL16M)
286294
TC_PRINT("FLL16M test\n");
287295
test_clock_control_request(fll16m_test_clk_contexts, ARRAY_SIZE(fll16m_test_clk_contexts));
296+
#endif
288297
}
289298

290299
ZTEST(nrf2_clock_control, test_invalid_fll16m_clock_spec_response)
@@ -297,6 +306,8 @@ ZTEST(nrf2_clock_control, test_invalid_fll16m_clock_spec_response)
297306
const struct device *clk_dev;
298307
const struct nrf_clock_spec *clk_spec;
299308

309+
Z_TEST_SKIP_IFNDEF(CONFIG_TEST_FLL16M);
310+
#if defined(CONFIG_TEST_FLL16M)
300311
TC_PRINT("FLL16M invalid clock specification test\n");
301312

302313
for (size_t i = 0; i < ARRAY_SIZE(invalid_fll16m_test_clk_contexts); i++) {
@@ -323,32 +334,36 @@ ZTEST(nrf2_clock_control, test_invalid_fll16m_clock_spec_response)
323334
zassert_ok(res);
324335
}
325336
}
337+
#endif
326338
}
327-
#elif defined(CONFIG_BOARD_NRF54H20DK_NRF54H20_CPURAD)
339+
328340
ZTEST(nrf2_clock_control, test_cpurad_hsfll_control)
329341
{
342+
Z_TEST_SKIP_IFNDEF(CONFIG_TEST_HSFLL_RAD);
343+
#if defined(CONFIG_TEST_HSFLL_RAD)
330344
TC_PRINT("RADIO DOMAIN HSFLL test\n");
331345
test_clock_control_request(cpurad_hsfll_test_clk_contexts,
332346
ARRAY_SIZE(cpurad_hsfll_test_clk_contexts));
333-
}
334347
#endif
348+
}
335349

336-
337-
338-
#if defined(CONFIG_CLOCK_CONTROL_NRF_HSFLL_GLOBAL)
339350
ZTEST(nrf2_clock_control, test_global_hsfll_control)
340351
{
352+
Z_TEST_SKIP_IFNDEF(CONFIG_CLOCK_CONTROL_NRF_HSFLL_GLOBAL);
353+
#if defined(CONFIG_CLOCK_CONTROL_NRF_HSFLL_GLOBAL)
341354
TC_PRINT("Global HSFLL test\n");
342355
test_clock_control_request(global_hsfll_test_clk_contexts,
343356
ARRAY_SIZE(global_hsfll_test_clk_contexts));
344-
}
345357
#endif
358+
}
346359

347-
#if defined(CONFIG_CLOCK_CONTROL_NRF_LFCLK)
348360
ZTEST(nrf2_clock_control, test_lfclk_control)
349361
{
362+
Z_TEST_SKIP_IFNDEF(CONFIG_CLOCK_CONTROL_NRF_LFCLK);
363+
#if defined(CONFIG_CLOCK_CONTROL_NRF_LFCLK)
350364
TC_PRINT("LFCLK test\n");
351365
test_clock_control_request(lfclk_test_clk_contexts, ARRAY_SIZE(lfclk_test_clk_contexts));
366+
#endif
352367
}
353368

354369
ZTEST(nrf2_clock_control, test_safe_request_cancellation)
@@ -360,6 +375,8 @@ ZTEST(nrf2_clock_control, test_safe_request_cancellation)
360375
const struct device *clk_dev = clk_context->clk_dev;
361376
const struct nrf_clock_spec *clk_spec = &test_clk_specs_lfclk[0];
362377

378+
Z_TEST_SKIP_IFNDEF(CONFIG_CLOCK_CONTROL_NRF_LFCLK);
379+
#if defined(CONFIG_CLOCK_CONTROL_NRF_LFCLK)
363380
zassert_true(device_is_ready(clk_dev),
364381
"%s is not ready", clk_dev->name);
365382

@@ -374,21 +391,22 @@ ZTEST(nrf2_clock_control, test_safe_request_cancellation)
374391
ret = nrf_clock_control_cancel_or_release(clk_dev, clk_spec, &cli);
375392
TC_PRINT("Clock control safe cancellation return value: %d\n", ret);
376393
zassert_between_inclusive(ret, ONOFF_STATE_ON, ONOFF_STATE_TO_ON);
377-
}
378394
#endif
395+
}
379396

380-
#if defined(CONFIG_CLOCK_CONTROL_NRF_AUXPLL)
381397
ZTEST(nrf2_clock_control, test_auxpll_control)
382398
{
399+
Z_TEST_SKIP_IFNDEF(CONFIG_CLOCK_CONTROL_NRF_AUXPLL);
400+
#if defined(CONFIG_CLOCK_CONTROL_NRF_AUXPLL)
383401
TC_PRINT("AUXPLL control test\n");
384402
test_clock_control_request(auxpll_test_clk_contexts,
385403
ARRAY_SIZE(auxpll_test_clk_contexts));
386-
}
387404
#endif
405+
}
388406

389407
static void *setup(void)
390408
{
391-
#if defined(CONFIG_BOARD_NRF54H20DK_NRF54H20_CPUAPP)
409+
#if defined(CONFIG_TEST_DVFS_INIT)
392410
const struct device *clk_dev = DEVICE_DT_GET(DT_NODELABEL(cpuapp_hsfll));
393411
const struct nrf_clock_spec clk_spec = {
394412
.frequency = MHZ(64),

0 commit comments

Comments
 (0)