diff options
author | android-build-prod (mdb) <android-build-team-robot@google.com> | 2020-09-09 20:04:18 +0000 |
---|---|---|
committer | android-build-prod (mdb) <android-build-team-robot@google.com> | 2020-09-09 20:04:18 +0000 |
commit | 01ca5fd002ac79afe79838ebb7910f3ee148756a (patch) | |
tree | c788af005003edf9201e21ea11f482c4a4796410 | |
parent | 8606f450e56833cba797da6003a0178b75a589f0 (diff) | |
parent | 350ec5e167dbdbf2edf281a7dd9232e38af47a0c (diff) | |
download | linux-kselftest-01ca5fd002ac79afe79838ebb7910f3ee148756a.tar.gz |
Snap for 6822779 from 350ec5e167dbdbf2edf281a7dd9232e38af47a0c to android10-tests-releaseandroid-vts-10.0_r9android-vts-10.0_r8android-vts-10.0_r7android-vts-10.0_r6android-vts-10.0_r16android-vts-10.0_r15android-vts-10.0_r14android-vts-10.0_r13android-vts-10.0_r12android-vts-10.0_r11android-vts-10.0_r10android-cts-10.0_r9android-cts-10.0_r8android-cts-10.0_r7android-cts-10.0_r6android-cts-10.0_r16android-cts-10.0_r15android-cts-10.0_r14android-cts-10.0_r13android-cts-10.0_r12android-cts-10.0_r11android-cts-10.0_r10
Change-Id: I3df997ea7f205983dc32c90380fe59ffbf481981
-rw-r--r-- | tools/testing/selftests/rtc/rtctest.c | 32 |
1 files changed, 8 insertions, 24 deletions
diff --git a/tools/testing/selftests/rtc/rtctest.c b/tools/testing/selftests/rtc/rtctest.c index 2c61bd22e26e..77c574b42694 100644 --- a/tools/testing/selftests/rtc/rtctest.c +++ b/tools/testing/selftests/rtc/rtctest.c @@ -5,14 +5,13 @@ * Copyright (c) 2018 Alexandre Belloni <alexandre.belloni@bootlin.com> */ -#include <dirent.h> #include <errno.h> #include <fcntl.h> #include <linux/rtc.h> #include <stdio.h> #include <stdlib.h> -#include <string.h> #include <sys/ioctl.h> +#include <sys/stat.h> #include <sys/time.h> #include <sys/types.h> #include <time.h> @@ -25,25 +24,6 @@ static char *rtc_file = "/dev/rtc0"; -/* Returns 1 if file matching /dev/rtc* is found, else 0. */ -static int has_rtc(void) -{ - DIR *dev_dir; - struct dirent *dir; - - dev_dir = opendir("/dev"); - if (!dev_dir) - return 0; - while ((dir = readdir(dev_dir))) { - if (!strncmp(dir->d_name, "rtc", 3)) { - closedir(dev_dir); - return 1; - } - } - closedir(dev_dir); - return 0; -} - FIXTURE(rtc) { int fd; }; @@ -61,9 +41,6 @@ TEST_F(rtc, date_read) { int rc; struct rtc_time rtc_tm; - if (!has_rtc()) - return; - /* Read the RTC time/date */ rc = ioctl(self->fd, RTC_RD_TIME, &rtc_tm); ASSERT_NE(-1, rc); @@ -249,6 +226,8 @@ __constructor_order_last(void) int main(int argc, char **argv) { + struct stat st; + switch (argc) { case 2: rtc_file = argv[1]; @@ -260,5 +239,10 @@ int main(int argc, char **argv) return 1; } + if (stat(rtc_file, &st) < 0 || !S_ISCHR(st.st_mode)) { + printf("no RTC present\n"); + return 0; + } + return test_harness_run(argc, argv); } |