aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing
diff options
context:
space:
mode:
authorPrarit Bhargava <prarit@redhat.com>2015-03-18 15:46:33 -0400
committerShuah Khan <shuahkh@osg.samsung.com>2015-03-25 00:02:59 -0400
commit0b63accf87225b5eb7e52814c374cf02d733d4bb (patch)
tree910f533f4eb0323ae0f9b0ee09109306c3eeeea9 /tools/testing
parent4a5fd81507eaea556e533e9ebc8a3cf31fe159d1 (diff)
tools, update rtctest.c to verify passage of time
rtctest.c checks to see if PIE is functioning by testing if 20 interrupts occur at rates from 2HZ to 64HZ. While this check is good, it does not check to see if the correct amount of time has actually passed. This misses situations where the RTC may be operating at a higher or lower frequency than expected. This patch introduces a simple check to verify if the time passed is less than 10% of what was programmed into the RTC. Signed-off-by: Prarit Bhargava <prarit@redhat.com> Acked-by: John Stultz <john.stultz@linaro.org> Cc: corbet@lwn.net Cc: rtc-linux@googlegroups.com Cc: linux-doc@vger.kernel.org Cc: a.zummo@towertech.it Cc: prarit@redhat.com Cc: john.stultz@linaro.org Cc: shuahkh@osg.samsung.com Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
Diffstat (limited to 'tools/testing')
-rw-r--r--tools/testing/selftests/timers/rtctest.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/tools/testing/selftests/timers/rtctest.c b/tools/testing/selftests/timers/rtctest.c
index 1e06f4602195..d80ae852334d 100644
--- a/tools/testing/selftests/timers/rtctest.c
+++ b/tools/testing/selftests/timers/rtctest.c
@@ -36,6 +36,7 @@ int main(int argc, char **argv)
36 unsigned long tmp, data; 36 unsigned long tmp, data;
37 struct rtc_time rtc_tm; 37 struct rtc_time rtc_tm;
38 const char *rtc = default_rtc; 38 const char *rtc = default_rtc;
39 struct timeval start, end, diff;
39 40
40 switch (argc) { 41 switch (argc) {
41 case 2: 42 case 2:
@@ -230,12 +231,24 @@ test_PIE:
230 } 231 }
231 232
232 for (i=1; i<21; i++) { 233 for (i=1; i<21; i++) {
234 gettimeofday(&start, NULL);
233 /* This blocks */ 235 /* This blocks */
234 retval = read(fd, &data, sizeof(unsigned long)); 236 retval = read(fd, &data, sizeof(unsigned long));
235 if (retval == -1) { 237 if (retval == -1) {
236 perror("read"); 238 perror("read");
237 exit(errno); 239 exit(errno);
238 } 240 }
241 gettimeofday(&end, NULL);
242 timersub(&end, &start, &diff);
243 if (diff.tv_sec > 0 ||
244 diff.tv_usec > ((1000000L / tmp) * 1.10)) {
245 fprintf(stderr, "\nPIE delta error: %ld.%06ld should be close to 0.%06ld\n",
246 diff.tv_sec, diff.tv_usec,
247 (1000000L / tmp));
248 fflush(stdout);
249 exit(-1);
250 }
251
239 fprintf(stderr, " %d",i); 252 fprintf(stderr, " %d",i);
240 fflush(stderr); 253 fflush(stderr);
241 irqcount++; 254 irqcount++;