selftests: rtc: skip when RTC is not present
There is no point in failing the tests when RTC is not present. 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> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
This commit is contained in:
committed by
Shuah Khan
parent
a1d6cd88c8
commit
35eee9a363
@@ -31,7 +31,6 @@ FIXTURE(rtc) {
|
|||||||
|
|
||||||
FIXTURE_SETUP(rtc) {
|
FIXTURE_SETUP(rtc) {
|
||||||
self->fd = open(rtc_file, O_RDONLY);
|
self->fd = open(rtc_file, O_RDONLY);
|
||||||
ASSERT_NE(-1, self->fd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FIXTURE_TEARDOWN(rtc) {
|
FIXTURE_TEARDOWN(rtc) {
|
||||||
@@ -42,6 +41,10 @@ TEST_F(rtc, date_read) {
|
|||||||
int rc;
|
int rc;
|
||||||
struct rtc_time rtc_tm;
|
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 */
|
/* Read the RTC time/date */
|
||||||
rc = ioctl(self->fd, RTC_RD_TIME, &rtc_tm);
|
rc = ioctl(self->fd, RTC_RD_TIME, &rtc_tm);
|
||||||
ASSERT_NE(-1, rc);
|
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;
|
struct rtc_time rtc_tm;
|
||||||
time_t start_rtc_read, prev_rtc_read;
|
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).",
|
TH_LOG("Continuously reading RTC time for %ds (with %dms breaks after every read).",
|
||||||
READ_LOOP_DURATION_SEC, READ_LOOP_SLEEP_MS);
|
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;
|
int i, rc, irq = 0;
|
||||||
unsigned long data;
|
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 */
|
/* Turn on update interrupts */
|
||||||
rc = ioctl(self->fd, RTC_UIE_ON, 0);
|
rc = ioctl(self->fd, RTC_UIE_ON, 0);
|
||||||
if (rc == -1) {
|
if (rc == -1) {
|
||||||
@@ -144,6 +155,10 @@ TEST_F(rtc, uie_select) {
|
|||||||
int i, rc, irq = 0;
|
int i, rc, irq = 0;
|
||||||
unsigned long data;
|
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 */
|
/* Turn on update interrupts */
|
||||||
rc = ioctl(self->fd, RTC_UIE_ON, 0);
|
rc = ioctl(self->fd, RTC_UIE_ON, 0);
|
||||||
if (rc == -1) {
|
if (rc == -1) {
|
||||||
@@ -183,6 +198,10 @@ TEST_F(rtc, alarm_alm_set) {
|
|||||||
time_t secs, new;
|
time_t secs, new;
|
||||||
int rc;
|
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);
|
rc = ioctl(self->fd, RTC_RD_TIME, &tm);
|
||||||
ASSERT_NE(-1, rc);
|
ASSERT_NE(-1, rc);
|
||||||
|
|
||||||
@@ -237,6 +256,10 @@ TEST_F(rtc, alarm_wkalm_set) {
|
|||||||
time_t secs, new;
|
time_t secs, new;
|
||||||
int rc;
|
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);
|
rc = ioctl(self->fd, RTC_RD_TIME, &alarm.time);
|
||||||
ASSERT_NE(-1, rc);
|
ASSERT_NE(-1, rc);
|
||||||
|
|
||||||
@@ -285,6 +308,10 @@ TEST_F_TIMEOUT(rtc, alarm_alm_set_minute, 65) {
|
|||||||
time_t secs, new;
|
time_t secs, new;
|
||||||
int rc;
|
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);
|
rc = ioctl(self->fd, RTC_RD_TIME, &tm);
|
||||||
ASSERT_NE(-1, rc);
|
ASSERT_NE(-1, rc);
|
||||||
|
|
||||||
@@ -339,6 +366,10 @@ TEST_F_TIMEOUT(rtc, alarm_wkalm_set_minute, 65) {
|
|||||||
time_t secs, new;
|
time_t secs, new;
|
||||||
int rc;
|
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);
|
rc = ioctl(self->fd, RTC_RD_TIME, &alarm.time);
|
||||||
ASSERT_NE(-1, rc);
|
ASSERT_NE(-1, rc);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user