[foreign] test_time timezone trouble (TZ)

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Fri Sep 21 23:18:14 UTC 2018

Maybe an easier solution would be to tweak the test to use gmtime() 
instead of localtime() and then stick to GMT? That ought to be more robust?


On 21/09/18 20:44, Jorn Vernee wrote:
> Hello guys,
> I was running into a problem with the test_time test in StdLibTest. 
> The generator for test values was apparently generating invalid 
> values. After fixing that, all the test iterations were failing 
> because the hours were off by one (the output of 
> LocalDateTime.getHours() is being compared to the output of 
> localtime().hour()). Good thing somebody else on the internet seems to 
> have had the same problem [1]. TL;DR when using the MSVC version of 
> localtime, and when running in cygwin, the function tries to interpret 
> the TZ environment variable, but since that has a unix format 
> (courtesy of cygwin), the interpretation fails and defaults to GMT. 
> When TZ is not set, it defaults to the system default timezone, which 
> is also what's being tested against.
> I can get the tests to pass by using `unset TZ` in the cygwin terminal 
> before running them, but I'd have to do that every time I reboot it. I 
> was trying to unset TZ automatically by using jtreq `@run shell 
> unsettz.sh` where unsettz.sh is a file containing just the command 
> `unset TZ`. It seems to be running successfully according to the test 
> output:
> ACTION: shell -- Passed. Execution successful
> REASON: User specified action: run shell unsettz.sh
> TIME:   0.126 seconds
> messages:
> command: shell unsettz.sh
> reason: User specified action: run shell unsettz.sh
> elapsed time (seconds): 0.126
> But it doesn't seem to affect the tests itself, and they still fail 
> (still off by 1 hour).
> I was wondering if there is a way to let jtreg control environment 
> variables? Or maybe you can suggest a different solution?
> The jtreg guide [2] mentions that TZ will be propagated from Windows 
> 'if set', but I need it to be not set, or automatically set to the 
> system's default time zone (by default it's blank).
> (other than that, tests are looking good: `passed: 24; failed: 4; 
> error: 1`. I just need to fix structs by value, which on Windows 
> cheats and just passes a pointer. 2 failing tests are from jextract 
> missing)
> Thanks,
> Jorn
> [1] : https://stackoverflow.com/q/11655003
> [2] : http://openjdk.java.net/jtreg/tag-spec.html

More information about the panama-dev mailing list