Skip to content

Commit 1ad9998

Browse files
jjang417shuahkh
authored andcommitted
selftest: rtc: Check if could access /dev/rtc0 before testing
The rtctest requires the read permission on /dev/rtc0. The rtctest will be skipped if the /dev/rtc0 is not readable. Reviewed-by: Koba Ko <[email protected]> Reviewed-by: Matthew R. Ochs <[email protected]> Signed-off-by: Joseph Jang <[email protected]> Acked-by: Alexandre Belloni <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
1 parent 9852d85 commit 1ad9998

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

tools/testing/selftests/rtc/rtctest.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,8 @@ TEST_F_TIMEOUT(rtc, alarm_wkalm_set_minute, 65) {
412412

413413
int main(int argc, char **argv)
414414
{
415+
int ret = -1;
416+
415417
switch (argc) {
416418
case 2:
417419
rtc_file = argv[1];
@@ -423,5 +425,12 @@ int main(int argc, char **argv)
423425
return 1;
424426
}
425427

426-
return test_harness_run(argc, argv);
428+
/* Run the test if rtc_file is accessible */
429+
if (access(rtc_file, R_OK) == 0)
430+
ret = test_harness_run(argc, argv);
431+
else
432+
ksft_exit_skip("[SKIP]: Cannot access rtc file %s - Exiting\n",
433+
rtc_file);
434+
435+
return ret;
427436
}

0 commit comments

Comments
 (0)