8169003: LogDecorations.iso8601_utctime_test fails if numeric locale uses "," as separator between integer and fraction part
authorkzhaldyb
Fri, 25 Nov 2016 20:00:51 +0300
changeset 42612 87ca7feb68bf
parent 42611 0de1eb277c95
child 42613 29c73ac33ad3
8169003: LogDecorations.iso8601_utctime_test fails if numeric locale uses "," as separator between integer and fraction part Reviewed-by: mlarsson, iignatyev
hotspot/test/native/logging/test_logDecorations.cpp
--- a/hotspot/test/native/logging/test_logDecorations.cpp	Tue Nov 29 08:48:14 2016 +0100
+++ b/hotspot/test/native/logging/test_logDecorations.cpp	Fri Nov 25 20:00:51 2016 +0300
@@ -131,10 +131,9 @@
   time_t expected_ts = time(NULL);
 
   // Verify format
-  int y, M, d, h, m;
-  double s;
-  int read = sscanf(timestr, "%d-%d-%dT%d:%d:%lf", &y, &M, &d, &h, &m, &s);
-  ASSERT_EQ(6, read) << "Invalid format: " << timestr;
+  int y, M, d, h, m, s, ms;
+  int read = sscanf(timestr, "%d-%d-%dT%d:%d:%d.%d", &y, &M, &d, &h, &m, &s, &ms);
+  ASSERT_EQ(7, read) << "Invalid format: " << timestr;
 
   // Verify reported time & date
   struct tm reported_time = {0};
@@ -167,17 +166,16 @@
 
   // Verify format
   char trailing_character;
-  int y, M, d, h, m, offset;
-  double s;
-  int read = sscanf(timestr, "%d-%d-%dT%d:%d:%lf%c%d", &y, &M, &d, &h, &m, &s, &trailing_character, &offset);
-  ASSERT_GT(read, 7) << "Invalid format: " << timestr;
+  int y, M, d, h, m, s, ms, offset;
+
+  int read = sscanf(timestr, "%d-%d-%dT%d:%d:%d.%d%c%d", &y, &M, &d, &h, &m, &s, &ms, &trailing_character, &offset);
+
+  ASSERT_EQ(9, read) << "Invalid format: " << timestr;
 
   // Ensure time is UTC (no offset)
-  if (trailing_character == '+') {
-    ASSERT_EQ(0, offset) << "Invalid offset: " << timestr;
-  } else {
-    ASSERT_EQ('Z', trailing_character) << "Invalid offset: " << timestr;
-  }
+  ASSERT_EQ('+', trailing_character) << "Invalid trailing character for UTC: "
+          << trailing_character;
+  ASSERT_EQ(0, offset) << "Invalid offset: " << timestr;
 
   struct tm reported_time = {0};
   reported_time.tm_year = y - 1900;