This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH v3 1/4] [BZ #14161] tst-strptime2.c: add %z minute and range limit tests


This is part of a fix for [BZ #16141] strptime %z offset restriction.

Add tests to time/tst-strptime2.c to explicitly test the following
areas of strptime's %z input field descriptor:

1) Correct conversion for minutes portion of timezone offset string into
seconds part of the timezone offset.

* New offsets tested are +1157, +1158, and +1159.
* Two of the new offsets fail, showing that strptime incorrectly
  calculates the seconds from minutes not divisible by 3 (+1158, +1159).
* tst-strptime2 failure output is as follows:

  round 9: tm_gmtoff is 43056
  round 10: tm_gmtoff is 43128

2) Validate offset range of -1200 to +1200.

* New tests show that strptime validates the current range limits.
* New offsets tested are +1200, -1200, +1201, and -1201.
* A later patch will remove range limit testing.

James

2014-12-03  James Perkins  james@loowit.net

	* time/strptime2.c (tests[]): Add tests for the strptime %z
	input field descriptor, specifically conversion of minutes
	to seconds and validation of offset range.

---
 time/tst-strptime2.c |    7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/time/tst-strptime2.c b/time/tst-strptime2.c
index bcd6cc8..5f9860a 100644
--- a/time/tst-strptime2.c
+++ b/time/tst-strptime2.c
@@ -17,6 +17,13 @@ static const struct
     { "1113472456 -1030", -37800 },
     { "1113472456 +0030", 1800 },
     { "1113472456 -0030", -1800 },
+    { "1113472456 +1157", 43020 },
+    { "1113472456 +1158", 43080 },
+    { "1113472456 +1159", 43140 },
+    { "1113472456 +1200", 43200 },
+    { "1113472456 -1200", -43200 },
+    { "1113472456 +1201", LONG_MAX },
+    { "1113472456 -1201", LONG_MAX },
     { "1113472456 -1330", LONG_MAX },
     { "1113472456 +1330", LONG_MAX },
     { "1113472456 -1060", LONG_MAX },
-- 
1.7.9.5


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]