Make all test262 tests pass on Windows (#3157)

Changes:
- Implemented jerry_port_get_local_time_zone_adjustment on Windows
- Implemented jerry_port_get_current_time on Windows
- Run test262 tests on Windows in PST/PDT timezone

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
This commit is contained in:
Csaba Osztrogonác
2019-09-26 14:31:22 +02:00
committed by Robert Fancsik
parent 9ab4872244
commit 2b3faf683d
2 changed files with 67 additions and 2 deletions
+44
View File
@@ -16,6 +16,14 @@
#ifdef HAVE_TM_GMTOFF
#include <time.h>
#endif /* HAVE_TM_GMTOFF */
#ifdef _WINDOWS
#include <windows.h>
#include <winbase.h>
#include <winnt.h>
#include <time.h>
#endif /* _WINDOWS */
#ifdef __GNUC__
#include <sys/time.h>
#endif /* __GNUC__ */
@@ -23,6 +31,17 @@
#include "jerryscript-port.h"
#include "jerryscript-port-default.h"
#ifdef _WINDOWS
/* https://support.microsoft.com/en-us/help/167296/how-to-convert-a-unix-time-t-to-a-win32-filetime-or-systemtime */
void UnixTimeToFileTime (LONGLONG t, LPFILETIME pft)
{
LONGLONG ll = t * 10000000 + 116444736000000000;
pft->dwLowDateTime = (DWORD) ll;
pft->dwHighDateTime = ll >> 32;
} /* UnixTimeToFileTime */
#endif /* _WINDOWS */
/**
* Default implementation of jerry_port_get_local_time_zone_adjustment. Uses the 'tm_gmtoff' field
* of 'struct tm' (a GNU extension) filled by 'localtime_r' if available on the
@@ -47,6 +66,25 @@ double jerry_port_get_local_time_zone_adjustment (double unix_ms, /**< ms since
#else /* !HAVE_TM_GMTOFF */
(void) unix_ms;
(void) is_utc;
#ifdef _WINDOWS
FILETIME fileTime, localFileTime;
SYSTEMTIME systemTime, localSystemTime;
ULARGE_INTEGER time, localTime;
_tzset ();
UnixTimeToFileTime ((LONGLONG) (unix_ms / 1000), &fileTime);
if (FileTimeToSystemTime (&fileTime, &systemTime)
&& SystemTimeToTzSpecificLocalTime (0, &systemTime, &localSystemTime)
&& SystemTimeToFileTime (&localSystemTime, &localFileTime))
{
time.LowPart = fileTime.dwLowDateTime;
time.HighPart = fileTime.dwHighDateTime;
localTime.LowPart = localFileTime.dwLowDateTime;
localTime.HighPart = localFileTime.dwHighDateTime;
return ((LONGLONG) localTime.QuadPart - (LONGLONG) time.QuadPart) / 10000;
}
#endif /* _WINDOWS */
return 0.0;
#endif /* HAVE_TM_GMTOFF */
} /* jerry_port_get_local_time_zone_adjustment */
@@ -70,5 +108,11 @@ double jerry_port_get_current_time (void)
}
#endif /* __GNUC__ */
#ifdef _WINDOWS
time_t ltime;
time (&ltime);
return ltime * 1000;
#endif /* _WINDOWS */
return 0.0;
} /* jerry_port_get_current_time */
+23 -2
View File
@@ -15,10 +15,12 @@
# limitations under the License.
from __future__ import print_function
import sys
import os
import subprocess
import shutil
import signal
import subprocess
import sys
def get_platform_cmd_prefix():
if sys.platform == 'win32':
@@ -26,6 +28,16 @@ def get_platform_cmd_prefix():
return ['python2'] # The official test262.py isn't python3 compatible, but has python shebang.
def set_timezone(timezone):
assert sys.platform == 'win32', "set_timezone is Windows only function"
subprocess.call(get_platform_cmd_prefix() + ['tzutil', '/s', timezone])
def set_timezone_and_exit(timezone):
set_timezone(timezone)
sys.exit(1)
def run_test262_tests(runtime, engine, path_to_test262):
if not os.path.isdir(os.path.join(path_to_test262, '.git')):
return_code = subprocess.call(['git', 'clone', 'https://github.com/tc39/test262.git',
@@ -42,6 +54,11 @@ def run_test262_tests(runtime, engine, path_to_test262):
if os.path.isdir(path_to_remove):
shutil.rmtree(path_to_remove)
if sys.platform == 'win32':
original_timezone = subprocess.check_output(get_platform_cmd_prefix() + ['tzutil', '/g'])
set_timezone('Pacific Standard Time')
signal.signal(signal.SIGINT, lambda signal, frame: set_timezone_and_exit(original_timezone))
proc = subprocess.Popen(get_platform_cmd_prefix() +
[os.path.join(path_to_test262, 'tools/packaging/test262.py'),
'--command', (runtime + ' ' + engine).strip(),
@@ -73,6 +90,10 @@ def run_test262_tests(runtime, engine, path_to_test262):
return_code = 1
proc.wait()
if sys.platform == 'win32':
set_timezone(original_timezone)
return return_code