| OLD | NEW |
| 1 # Copyright 2014 the V8 project authors. All rights reserved. | 1 # Copyright 2014 the V8 project authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 | 5 |
| 6 import hashlib | |
| 7 import os | 6 import os |
| 8 import shutil | 7 import shutil |
| 9 import sys | 8 import sys |
| 10 import tarfile | |
| 11 import imp | |
| 12 | 9 |
| 13 from testrunner.local import testsuite | 10 from testrunner.local import testsuite |
| 14 from testrunner.local import utils | |
| 15 from testrunner.objects import testcase | 11 from testrunner.objects import testcase |
| 16 | 12 |
| 17 SIMDJS_ARCHIVE_REVISION = "c8ef63c728283debc25891123eb00482fee4b8cd" | |
| 18 SIMDJS_ARCHIVE_MD5 = "4c3120d1f5b8027b4a38b931119c89bd" | |
| 19 SIMDJS_URL = ("https://github.com/tc39/ecmascript_simd/archive/%s.tar.gz") | |
| 20 | |
| 21 SIMDJS_SUITE_PATH = ["data", "src"] | 13 SIMDJS_SUITE_PATH = ["data", "src"] |
| 22 | 14 |
| 23 | 15 |
| 24 class SimdJsTestSuite(testsuite.TestSuite): | 16 class SimdJsTestSuite(testsuite.TestSuite): |
| 25 | 17 |
| 26 def __init__(self, name, root): | 18 def __init__(self, name, root): |
| 27 super(SimdJsTestSuite, self).__init__(name, root) | 19 super(SimdJsTestSuite, self).__init__(name, root) |
| 28 self.testroot = os.path.join(self.root, *SIMDJS_SUITE_PATH) | 20 self.testroot = os.path.join(self.root, *SIMDJS_SUITE_PATH) |
| 29 self.ParseTestRecord = None | 21 self.ParseTestRecord = None |
| 30 | 22 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 55 | 47 |
| 56 def IsNegativeTest(self, testcase): | 48 def IsNegativeTest(self, testcase): |
| 57 return False | 49 return False |
| 58 | 50 |
| 59 def IsFailureOutput(self, output, testpath): | 51 def IsFailureOutput(self, output, testpath): |
| 60 if output.exit_code != 0: | 52 if output.exit_code != 0: |
| 61 return True | 53 return True |
| 62 return "FAILED!" in output.stdout | 54 return "FAILED!" in output.stdout |
| 63 | 55 |
| 64 def DownloadData(self): | 56 def DownloadData(self): |
| 65 revision = SIMDJS_ARCHIVE_REVISION | 57 print "SimdJs download is deprecated. It's part of DEPS." |
| 66 archive_url = SIMDJS_URL % revision | |
| 67 | 58 |
| 68 archive_prefix = "ecmascript_simd-" | 59 # Clean up old directories and archive files. |
| 69 archive_name = os.path.join( | |
| 70 self.root, "%s%s.tar.gz" % (archive_prefix, revision)) | |
| 71 directory_name = os.path.join(self.root, "data") | |
| 72 directory_old_name = os.path.join(self.root, "data.old") | 60 directory_old_name = os.path.join(self.root, "data.old") |
| 73 versionfile = os.path.join(self.root, "CHECKED_OUT_VERSION") | 61 if os.path.exists(directory_old_name): |
| 62 shutil.rmtree(directory_old_name) |
| 74 | 63 |
| 75 checked_out_version = None | |
| 76 checked_out_url = None | |
| 77 checked_out_revision = None | |
| 78 if os.path.exists(versionfile): | |
| 79 with open(versionfile) as f: | |
| 80 try: | |
| 81 (checked_out_version, | |
| 82 checked_out_url, | |
| 83 checked_out_revision) = f.read().splitlines() | |
| 84 except ValueError: | |
| 85 pass | |
| 86 if (checked_out_version != SIMDJS_ARCHIVE_MD5 or | |
| 87 checked_out_url != archive_url or | |
| 88 checked_out_revision != revision): | |
| 89 if os.path.exists(archive_name): | |
| 90 print "Clobbering %s because CHECK_OUT_VERSION is out of date" % ( | |
| 91 archive_name) | |
| 92 os.remove(archive_name) | |
| 93 | |
| 94 # Clobber if the test is in an outdated state, i.e. if there are any other | |
| 95 # archive files present. | |
| 96 archive_files = [f for f in os.listdir(self.root) | 64 archive_files = [f for f in os.listdir(self.root) |
| 97 if f.startswith(archive_prefix)] | 65 if f.startswith("ecmascript_simd-")] |
| 98 if (len(archive_files) > 1 or | 66 if len(archive_files) > 0: |
| 99 os.path.basename(archive_name) not in archive_files): | |
| 100 print "Clobber outdated test archives ..." | 67 print "Clobber outdated test archives ..." |
| 101 for f in archive_files: | 68 for f in archive_files: |
| 102 print "Removing %s" % f | |
| 103 os.remove(os.path.join(self.root, f)) | 69 os.remove(os.path.join(self.root, f)) |
| 104 | 70 |
| 105 if not os.path.exists(archive_name): | |
| 106 print "Downloading test data from %s ..." % archive_url | |
| 107 utils.URLRetrieve(archive_url, archive_name) | |
| 108 if os.path.exists(directory_name): | |
| 109 if os.path.exists(directory_old_name): | |
| 110 shutil.rmtree(directory_old_name) | |
| 111 os.rename(directory_name, directory_old_name) | |
| 112 if not os.path.exists(directory_name): | |
| 113 print "Extracting ecmascript_simd-%s.tar.gz ..." % revision | |
| 114 md5 = hashlib.md5() | |
| 115 with open(archive_name, "rb") as f: | |
| 116 for chunk in iter(lambda: f.read(8192), ""): | |
| 117 md5.update(chunk) | |
| 118 print "MD5 hash is %s" % md5.hexdigest() | |
| 119 if md5.hexdigest() != SIMDJS_ARCHIVE_MD5: | |
| 120 os.remove(archive_name) | |
| 121 print "MD5 expected %s" % SIMDJS_ARCHIVE_MD5 | |
| 122 raise Exception("MD5 hash mismatch of test data file") | |
| 123 archive = tarfile.open(archive_name, "r:gz") | |
| 124 if sys.platform in ("win32", "cygwin"): | |
| 125 # Magic incantation to allow longer path names on Windows. | |
| 126 archive.extractall(u"\\\\?\\%s" % self.root) | |
| 127 else: | |
| 128 archive.extractall(self.root) | |
| 129 os.rename(os.path.join(self.root, "ecmascript_simd-%s" % revision), | |
| 130 directory_name) | |
| 131 | |
| 132 with open(versionfile, "w") as f: | |
| 133 f.write(SIMDJS_ARCHIVE_MD5 + '\n') | |
| 134 f.write(archive_url + '\n') | |
| 135 f.write(revision + '\n') | |
| 136 | |
| 137 | 71 |
| 138 def GetSuite(name, root): | 72 def GetSuite(name, root): |
| 139 return SimdJsTestSuite(name, root) | 73 return SimdJsTestSuite(name, root) |
| OLD | NEW |