hotspot/test/native/logging/test_logDecorations.cpp
changeset 42612 87ca7feb68bf
parent 42066 46f6db750b17
equal deleted inserted replaced
42611:0de1eb277c95 42612:87ca7feb68bf
   129 
   129 
   130   const char *timestr = decorations.decoration(LogDecorators::time_decorator);
   130   const char *timestr = decorations.decoration(LogDecorators::time_decorator);
   131   time_t expected_ts = time(NULL);
   131   time_t expected_ts = time(NULL);
   132 
   132 
   133   // Verify format
   133   // Verify format
   134   int y, M, d, h, m;
   134   int y, M, d, h, m, s, ms;
   135   double s;
   135   int read = sscanf(timestr, "%d-%d-%dT%d:%d:%d.%d", &y, &M, &d, &h, &m, &s, &ms);
   136   int read = sscanf(timestr, "%d-%d-%dT%d:%d:%lf", &y, &M, &d, &h, &m, &s);
   136   ASSERT_EQ(7, read) << "Invalid format: " << timestr;
   137   ASSERT_EQ(6, read) << "Invalid format: " << timestr;
       
   138 
   137 
   139   // Verify reported time & date
   138   // Verify reported time & date
   140   struct tm reported_time = {0};
   139   struct tm reported_time = {0};
   141   reported_time.tm_year = y - 1900;
   140   reported_time.tm_year = y - 1900;
   142   reported_time.tm_mon = M - 1;
   141   reported_time.tm_mon = M - 1;
   165   const char *timestr = decorations.decoration(LogDecorators::utctime_decorator);
   164   const char *timestr = decorations.decoration(LogDecorators::utctime_decorator);
   166   time_t expected_ts = time(NULL);
   165   time_t expected_ts = time(NULL);
   167 
   166 
   168   // Verify format
   167   // Verify format
   169   char trailing_character;
   168   char trailing_character;
   170   int y, M, d, h, m, offset;
   169   int y, M, d, h, m, s, ms, offset;
   171   double s;
   170 
   172   int read = sscanf(timestr, "%d-%d-%dT%d:%d:%lf%c%d", &y, &M, &d, &h, &m, &s, &trailing_character, &offset);
   171   int read = sscanf(timestr, "%d-%d-%dT%d:%d:%d.%d%c%d", &y, &M, &d, &h, &m, &s, &ms, &trailing_character, &offset);
   173   ASSERT_GT(read, 7) << "Invalid format: " << timestr;
   172 
       
   173   ASSERT_EQ(9, read) << "Invalid format: " << timestr;
   174 
   174 
   175   // Ensure time is UTC (no offset)
   175   // Ensure time is UTC (no offset)
   176   if (trailing_character == '+') {
   176   ASSERT_EQ('+', trailing_character) << "Invalid trailing character for UTC: "
   177     ASSERT_EQ(0, offset) << "Invalid offset: " << timestr;
   177           << trailing_character;
   178   } else {
   178   ASSERT_EQ(0, offset) << "Invalid offset: " << timestr;
   179     ASSERT_EQ('Z', trailing_character) << "Invalid offset: " << timestr;
       
   180   }
       
   181 
   179 
   182   struct tm reported_time = {0};
   180   struct tm reported_time = {0};
   183   reported_time.tm_year = y - 1900;
   181   reported_time.tm_year = y - 1900;
   184   reported_time.tm_mon = M - 1;
   182   reported_time.tm_mon = M - 1;
   185   reported_time.tm_mday = d;
   183   reported_time.tm_mday = d;