This is an archive of the discontinued LLVM Phabricator instance.

libc++: Don't let time_put test use implementation dependent constructs
ClosedPublic

Authored by ed on Mar 15 2015, 12:09 PM.

Details

Summary

The time_put test doesn't seem to work on Linux and CloudABI. For Linux we already have an XFAIL. Closer inspection seems to reveal that this test does not pass for a couple of reasons.

First of all, the tm_yday field is set to an invalid value. The strftime() function doesn't behave consistently across platforms in case the values in the tm structure are incoherent. Fix up this field to have the value 121, which corresponds with tm_mday and tm_year. This of course affects the output of time_put for some modifiers, so update the tests accordingly.

Second, some of the tests actually use modifiers that are only present on BSD derived systems. They are not part of the C standard/POSIX. Simply remove them.

Finally, some of the tests actually use invalid modifiers, causing a malformed format string to be passed to strftime(). Remove these tests as well.

Diff Detail

Repository
rL LLVM

Event Timeline

ed updated this revision to Diff 21999.Mar 15 2015, 12:09 PM
ed retitled this revision from to libc++: Don't let time_put test use implementation dependent constructs.
ed updated this object.
ed edited the test plan for this revision. (Show Details)
ed added reviewers: mclow.lists, jroelofs.
ed set the repository for this revision to rL LLVM.
ed added a subscriber: Unknown Object (MLST).
jroelofs edited edge metadata.Mar 16 2015, 8:38 AM

Second, some of the tests actually use modifiers that are only present on BSD derived systems. They are not part of the C standard/POSIX. Simply remove them.

They're probably still useful on those platforms... perhaps put them under an #ifdef for that platform, along with a comment saying that they're a bsd extension?

test/std/localization/locale.categories/category.time/locale.time.put/locale.time.put.members/put2.pass.cpp
186

Can you point to the docs saying that these modifiers are invalid?

Jonathan, Marshall, do you happen to use Linux? If so, could you please test this on Linux for me? Thanks!

I'm usually on OS X, but I've got an ubuntu vm I can try it on... I'll check this evening.

ed added a comment.Mar 16 2015, 9:05 AM

Second, some of the tests actually use modifiers that are only present on BSD derived systems. They are not part of the C standard/POSIX. Simply remove them.

They're probably still useful on those platforms... perhaps put them under an #ifdef for that platform, along with a comment saying that they're a bsd extension?

We could consider doing this, but in my opinion this would only make sense if there is something actionable on our side in case one of these tests starts to fail. Right now time_put::put() calls strftime() directly without pre-processing the arguments in any way. If FreeBSD or Mac OS X would suddenly decide to remove support for the non-standard %v modifier, is there a chance that we would add a workaround for it by adding pre-processing to time_put::put()? My assumption is that we wouldn't bother, so I would rather remove these tests.

That said, if someone really cares about these tests, we could consider putting them in a separate test, so it remains clear which behavior is standard and which is not.

test/std/localization/locale.categories/category.time/locale.time.put/locale.time.put.members/put2.pass.cpp
186

Sure!

C++14 N3797, section 22.4.5.3.2, the description of time_put::put():

"Formatting is controlled by the parameters format and modifier, interpreted identically as the format
specifiers in the string argument to the standard library function strftime()."

ISO/IEC 9899:2011, section 7.27.3.5, the description of strftime():

The %OB, %k, %l, %s, %v, %J and %J% modifiers are not listed in the table.

That said, POSIX has made some extensions to strftime: http://pubs.opengroup.org/onlinepubs/9699919799/functions/strftime.html

This table also doesn't list these modifiers.

EricWF edited edge metadata.Mar 16 2015, 9:27 AM

Attaching a related code review. This way my attempt to fix these tests. (yours seems more thorough).

http://reviews.llvm.org/D4999

Also I'll test this on Linux. I have test machines for Ubuntu, FreeBSD 10 and OS X.

The changes work for me on linux.

ed added a comment.Mar 18 2015, 5:06 AM

The changes work for me on linux.

Awesome! Thanks for letting me know. Jonathan, shall I go ahead and push this change in?

This revision was automatically updated to reflect the committed changes.