OSDN Git Service

rtc_time: test agent timeouts
authorMark Salyzyn <salyzyn@google.com>
Thu, 11 Feb 2016 23:04:35 +0000 (15:04 -0800)
committerMark Salyzyn <salyzyn@google.com>
Thu, 11 Feb 2016 23:47:23 +0000 (15:47 -0800)
(cherry pick from commit 9258225ece5d6816ddf9a45e45fb694142c32761)

Break the test up into four, keeping each well below the 60 second
timeout for the test agents. Overhead for the splitting up is an
additional 10 seconds in order to complete all four of the tests
instead of one. typical single test completion is 22.5 seconds.

Change-Id: If8e9a6c7dfd505a9fbc73e9248be4eb2b61521e5

tests/timetest/rtc_test.cpp

index d1c9eaf..26ca13a 100644 (file)
@@ -77,7 +77,7 @@ static int set_hwtime(struct rtc_time *tm) {
   return hwtime(O_WRONLY, RTC_SET_TIME, tm);
 }
 
-TEST(time, rtc_rollover) {
+static void rtc_rollover(int start, int end) {
   struct rtc_time roll;
   memset(&roll, 0, sizeof(roll));
   ASSERT_LE(0, rd_hwtime(&roll));
@@ -118,7 +118,7 @@ TEST(time, rtc_rollover) {
   roll.tm_isdst = 0;
 
   bool eacces = true;
-  for (roll.tm_year = 70; roll.tm_year < 137; ++roll.tm_year) {
+  for (roll.tm_year = start; roll.tm_year < end; ++roll.tm_year) {
     struct rtc_time tm = roll;
     int __set_hwtime = set_hwtime(&tm);
     // Allowed to be 100% denied for writing
@@ -126,8 +126,8 @@ TEST(time, rtc_rollover) {
       continue;
     }
     eacces = false;
-    // below 2015, permitted to error out.
-    if ((__set_hwtime == -EINVAL) && (roll.tm_year < 115)) {
+    // below 2016, permitted to error out.
+    if ((__set_hwtime == -EINVAL) && (roll.tm_year < 116)) {
       continue;
     }
     ASSERT_LE(0, __set_hwtime);
@@ -180,3 +180,19 @@ TEST(time, rtc_rollover) {
     ASSERT_EQ(save.tm_year, roll.tm_year);
   }
 }
+
+TEST(time, rtc_rollover_1970_1990) {
+  rtc_rollover(70, 90);
+}
+
+TEST(time, rtc_rollover_1990_2010) {
+  rtc_rollover(90, 110);
+}
+
+TEST(time, rtc_rollover_2010_2030) {
+  rtc_rollover(110, 130);
+}
+
+TEST(time, rtc_rollover_2030_2037) {
+  rtc_rollover(130, 137);
+}