Skip to content

Commit 18647f5

Browse files
pdgendtMaureenHelm
authored andcommitted
tests: drivers: counter: Generic seconds counter test
This commit reworks the CMOS test to a generic seconds counter test. And it adds a test case for the iMX RT1064 SNVS RTC. Tested with mimxrt1064_evk Signed-off-by: Pieter De Gendt <[email protected]>
1 parent 4d161a3 commit 18647f5

File tree

7 files changed

+41
-16
lines changed

7 files changed

+41
-16
lines changed

tests/drivers/counter/counter_cmos/testcase.yaml

Lines changed: 0 additions & 4 deletions
This file was deleted.

tests/drivers/counter/counter_cmos/CMakeLists.txt renamed to tests/drivers/counter/counter_seconds/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
cmake_minimum_required(VERSION 3.20.0)
55

66
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
7-
project(counter_cmos)
7+
project(counter_seconds)
88

99
target_sources(app PRIVATE src/main.c)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CONFIG_COUNTER_MCUX_SNVS=y
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/* Copyright (c) 2021 Basalte bv
2+
* SPDX-License-Identifier: Apache-2.0
3+
*/
4+
5+
/ {
6+
aliases {
7+
rtc-0 = &snvs_rtc;
8+
};
9+
};
10+
11+
&snvs_rtc {
12+
status = "okay";
13+
};
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
CONFIG_COUNTER=y
22
CONFIG_ZTEST=y
3-
CONFIG_COUNTER_CMOS=y

tests/drivers/counter/counter_cmos/src/main.c renamed to tests/drivers/counter/counter_seconds/src/main.c

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,32 @@
1111
* Basic test to ensure that the clock is ticking at roughly 1Hz.
1212
*/
1313

14+
#ifdef CONFIG_COUNTER_CMOS
15+
#define DEVICE_LABEL "CMOS"
16+
#else
17+
#define DEVICE_LABEL DT_LABEL(DT_ALIAS(rtc_0))
18+
#endif
19+
1420
#define DELAY_MS 1200 /* pause 1.2 seconds should always pass */
1521
#define MIN_BOUND 1 /* counter must report at least MIN_BOUND .. */
1622
#define MAX_BOUND 2 /* .. but at most MAX_BOUND seconds elapsed */
1723

18-
void test_cmos_rate(void)
24+
void test_seconds_rate(void)
1925
{
20-
const struct device *cmos;
26+
const struct device *dev;
2127
uint32_t start, elapsed;
2228
int err;
2329

24-
cmos = device_get_binding("CMOS");
25-
zassert_true(cmos != NULL, "can't find CMOS counter device");
30+
dev = device_get_binding(DEVICE_LABEL);
31+
zassert_true(dev != NULL, "can't find counter device");
2632

27-
err = counter_get_value(cmos, &start);
28-
zassert_true(err == 0, "failed to read CMOS counter device");
33+
err = counter_get_value(dev, &start);
34+
zassert_true(err == 0, "failed to read counter device");
2935

3036
k_msleep(DELAY_MS);
3137

32-
err = counter_get_value(cmos, &elapsed);
33-
zassert_true(err == 0, "failed to read CMOS counter device");
38+
err = counter_get_value(dev, &elapsed);
39+
zassert_true(err == 0, "failed to read counter device");
3440
elapsed -= start;
3541

3642
zassert_true(elapsed >= MIN_BOUND, "busted minimum bound");
@@ -39,6 +45,6 @@ void test_cmos_rate(void)
3945

4046
void test_main(void)
4147
{
42-
ztest_test_suite(test_cmos_counter, ztest_unit_test(test_cmos_rate));
43-
ztest_run_test_suite(test_cmos_counter);
48+
ztest_test_suite(test_seconds_counter, ztest_unit_test(test_seconds_rate));
49+
ztest_run_test_suite(test_seconds_counter);
4450
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
tests:
2+
drivers.counter.cmos:
3+
tags: drivers
4+
arch_allow: x86
5+
extra_configs:
6+
- CONFIG_COUNTER_CMOS=y
7+
8+
drivers.counter.mcux.snvs.rtc:
9+
tags: drivers
10+
platform_allow: mimxrt1064_evk

0 commit comments

Comments
 (0)