* [PATCH] selftests: rtc: skip when RTC is not present
@ 2022-11-15 20:04 alexandre.belloni
2022-11-15 20:10 ` Shuah Khan
0 siblings, 1 reply; 3+ messages in thread
From: alexandre.belloni @ 2022-11-15 20:04 UTC (permalink / raw)
To: Alessandro Zummo, Alexandre Belloni, Shuah Khan
Cc: Linux Kernel Functional Testing, Daniel Diaz, linux-rtc,
linux-kselftest, linux-kernel
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
There is not point in failing the tests when there the RTC is not present,
simply skip the test.
Reported-by: Linux Kernel Functional Testing <lkft@linaro.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Tested-by: Daniel Diaz <daniel.diaz@linaro.org>
---
tools/testing/selftests/rtc/rtctest.c | 33 ++++++++++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/rtc/rtctest.c b/tools/testing/selftests/rtc/rtctest.c
index 2b9d929a24ed..63ce02d1d5cc 100644
--- a/tools/testing/selftests/rtc/rtctest.c
+++ b/tools/testing/selftests/rtc/rtctest.c
@@ -31,7 +31,6 @@ FIXTURE(rtc) {
FIXTURE_SETUP(rtc) {
self->fd = open(rtc_file, O_RDONLY);
- ASSERT_NE(-1, self->fd);
}
FIXTURE_TEARDOWN(rtc) {
@@ -42,6 +41,10 @@ TEST_F(rtc, date_read) {
int rc;
struct rtc_time rtc_tm;
+ if (self->fd == -1 && errno == ENOENT)
+ SKIP(return, "Skipping test since %s does not exist", rtc_file);
+ ASSERT_NE(-1, self->fd);
+
/* Read the RTC time/date */
rc = ioctl(self->fd, RTC_RD_TIME, &rtc_tm);
ASSERT_NE(-1, rc);
@@ -85,6 +88,10 @@ TEST_F_TIMEOUT(rtc, date_read_loop, READ_LOOP_DURATION_SEC + 2) {
struct rtc_time rtc_tm;
time_t start_rtc_read, prev_rtc_read;
+ if (self->fd == -1 && errno == ENOENT)
+ SKIP(return, "Skipping test since %s does not exist", rtc_file);
+ ASSERT_NE(-1, self->fd);
+
TH_LOG("Continuously reading RTC time for %ds (with %dms breaks after every read).",
READ_LOOP_DURATION_SEC, READ_LOOP_SLEEP_MS);
@@ -119,6 +126,10 @@ TEST_F_TIMEOUT(rtc, uie_read, NUM_UIE + 2) {
int i, rc, irq = 0;
unsigned long data;
+ if (self->fd == -1 && errno == ENOENT)
+ SKIP(return, "Skipping test since %s does not exist", rtc_file);
+ ASSERT_NE(-1, self->fd);
+
/* Turn on update interrupts */
rc = ioctl(self->fd, RTC_UIE_ON, 0);
if (rc == -1) {
@@ -144,6 +155,10 @@ TEST_F(rtc, uie_select) {
int i, rc, irq = 0;
unsigned long data;
+ if (self->fd == -1 && errno == ENOENT)
+ SKIP(return, "Skipping test since %s does not exist", rtc_file);
+ ASSERT_NE(-1, self->fd);
+
/* Turn on update interrupts */
rc = ioctl(self->fd, RTC_UIE_ON, 0);
if (rc == -1) {
@@ -183,6 +198,10 @@ TEST_F(rtc, alarm_alm_set) {
time_t secs, new;
int rc;
+ if (self->fd == -1 && errno == ENOENT)
+ SKIP(return, "Skipping test since %s does not exist", rtc_file);
+ ASSERT_NE(-1, self->fd);
+
rc = ioctl(self->fd, RTC_RD_TIME, &tm);
ASSERT_NE(-1, rc);
@@ -237,6 +256,10 @@ TEST_F(rtc, alarm_wkalm_set) {
time_t secs, new;
int rc;
+ if (self->fd == -1 && errno == ENOENT)
+ SKIP(return, "Skipping test since %s does not exist", rtc_file);
+ ASSERT_NE(-1, self->fd);
+
rc = ioctl(self->fd, RTC_RD_TIME, &alarm.time);
ASSERT_NE(-1, rc);
@@ -285,6 +308,10 @@ TEST_F_TIMEOUT(rtc, alarm_alm_set_minute, 65) {
time_t secs, new;
int rc;
+ if (self->fd == -1 && errno == ENOENT)
+ SKIP(return, "Skipping test since %s does not exist", rtc_file);
+ ASSERT_NE(-1, self->fd);
+
rc = ioctl(self->fd, RTC_RD_TIME, &tm);
ASSERT_NE(-1, rc);
@@ -339,6 +366,10 @@ TEST_F_TIMEOUT(rtc, alarm_wkalm_set_minute, 65) {
time_t secs, new;
int rc;
+ if (self->fd == -1 && errno == ENOENT)
+ SKIP(return, "Skipping test since %s does not exist", rtc_file);
+ ASSERT_NE(-1, self->fd);
+
rc = ioctl(self->fd, RTC_RD_TIME, &alarm.time);
ASSERT_NE(-1, rc);
--
2.38.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] selftests: rtc: skip when RTC is not present
2022-11-15 20:04 [PATCH] selftests: rtc: skip when RTC is not present alexandre.belloni
@ 2022-11-15 20:10 ` Shuah Khan
2022-11-15 20:22 ` Alexandre Belloni
0 siblings, 1 reply; 3+ messages in thread
From: Shuah Khan @ 2022-11-15 20:10 UTC (permalink / raw)
To: alexandre.belloni, Alessandro Zummo, Shuah Khan
Cc: Linux Kernel Functional Testing, Daniel Diaz, linux-rtc,
linux-kselftest, linux-kernel, Shuah Khan
On 11/15/22 13:04, alexandre.belloni@bootlin.com wrote:
> From: Alexandre Belloni <alexandre.belloni@bootlin.com>
>
> There is not point in failing the tests when there the RTC is not present,
> simply skip the test.
>
Could be rephrased to read:
There is no point in failing the tests when RTC is not present.
I can fix them when I apply the patch or send me v2
> Reported-by: Linux Kernel Functional Testing <lkft@linaro.org>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
> Tested-by: Daniel Diaz <daniel.diaz@linaro.org>
> ---
thanks,
-- Shuah
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] selftests: rtc: skip when RTC is not present
2022-11-15 20:10 ` Shuah Khan
@ 2022-11-15 20:22 ` Alexandre Belloni
0 siblings, 0 replies; 3+ messages in thread
From: Alexandre Belloni @ 2022-11-15 20:22 UTC (permalink / raw)
To: Shuah Khan
Cc: Alessandro Zummo, Shuah Khan, Linux Kernel Functional Testing,
Daniel Diaz, linux-rtc, linux-kselftest, linux-kernel
On 15/11/2022 13:10:45-0700, Shuah Khan wrote:
> On 11/15/22 13:04, alexandre.belloni@bootlin.com wrote:
> > From: Alexandre Belloni <alexandre.belloni@bootlin.com>
> >
> > There is not point in failing the tests when there the RTC is not present,
> > simply skip the test.
> >
> Could be rephrased to read:
>
> There is no point in failing the tests when RTC is not present.
>
> I can fix them when I apply the patch or send me v2
Sorry, I wrote that quickly a few days ago and didn't check again. v2 is
sent.
>
>
> > Reported-by: Linux Kernel Functional Testing <lkft@linaro.org>
> > Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
> > Tested-by: Daniel Diaz <daniel.diaz@linaro.org>
> > ---
>
> thanks,
> -- Shuah
>
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-11-15 20:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-15 20:04 [PATCH] selftests: rtc: skip when RTC is not present alexandre.belloni
2022-11-15 20:10 ` Shuah Khan
2022-11-15 20:22 ` Alexandre Belloni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).