summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJoseph Jang <jjang@nvidia.com>2024-05-24 04:38:07 +0300
committerShuah Khan <skhan@linuxfoundation.org>2024-09-30 20:32:07 +0300
commit1ad999870a86d58246b6a614a435d055a9edf269 (patch)
treeeeded32d5c81a5bb1066f75f0c4f25bc3646c2a0 /tools
parent9852d85ec9d492ebef56dc5f229416c925758edc (diff)
downloadlinux-1ad999870a86d58246b6a614a435d055a9edf269.tar.xz
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 <kobak@nvidia.com> Reviewed-by: Matthew R. Ochs <mochs@nvidia.com> Signed-off-by: Joseph Jang <jjang@nvidia.com> Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/testing/selftests/rtc/rtctest.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/tools/testing/selftests/rtc/rtctest.c b/tools/testing/selftests/rtc/rtctest.c
index 9647b14b47c5..38a8e67de77d 100644
--- a/tools/testing/selftests/rtc/rtctest.c
+++ b/tools/testing/selftests/rtc/rtctest.c
@@ -412,6 +412,8 @@ TEST_F_TIMEOUT(rtc, alarm_wkalm_set_minute, 65) {
int main(int argc, char **argv)
{
+ int ret = -1;
+
switch (argc) {
case 2:
rtc_file = argv[1];
@@ -423,5 +425,12 @@ int main(int argc, char **argv)
return 1;
}
- return test_harness_run(argc, argv);
+ /* Run the test if rtc_file is accessible */
+ if (access(rtc_file, R_OK) == 0)
+ ret = test_harness_run(argc, argv);
+ else
+ ksft_exit_skip("[SKIP]: Cannot access rtc file %s - Exiting\n",
+ rtc_file);
+
+ return ret;
}