OLD | NEW |
1 # Copyright 2011 the V8 project authors. All rights reserved. | 1 # Copyright 2011 the V8 project authors. All rights reserved. |
2 # Redistribution and use in source and binary forms, with or without | 2 # Redistribution and use in source and binary forms, with or without |
3 # modification, are permitted provided that the following conditions are | 3 # modification, are permitted provided that the following conditions are |
4 # met: | 4 # met: |
5 # | 5 # |
6 # * Redistributions of source code must retain the above copyright | 6 # * Redistributions of source code must retain the above copyright |
7 # notice, this list of conditions and the following disclaimer. | 7 # notice, this list of conditions and the following disclaimer. |
8 # * Redistributions in binary form must reproduce the above | 8 # * Redistributions in binary form must reproduce the above |
9 # copyright notice, this list of conditions and the following | 9 # copyright notice, this list of conditions and the following |
10 # disclaimer in the documentation and/or other materials provided | 10 # disclaimer in the documentation and/or other materials provided |
(...skipping 11 matching lines...) Expand all Loading... |
22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 | 28 |
29 import test | 29 import test |
30 import os | 30 import os |
31 from os.path import join, exists | 31 from os.path import join, exists |
| 32 import urllib |
| 33 import hashlib |
| 34 import tarfile |
32 | 35 |
33 | 36 |
| 37 TEST_262_ARCHIVE_REVISION = '3a890174343c' # This is the r309 revision. |
| 38 TEST_262_ARCHIVE_MD5 = 'be5d4cfbe69cef70430907b8f3a92b50' |
| 39 TEST_262_URL = 'http://hg.ecmascript.org/tests/test262/archive/%s.tar.bz2' |
34 TEST_262_HARNESS = ['sta.js'] | 40 TEST_262_HARNESS = ['sta.js'] |
35 | 41 |
36 | 42 |
37 class Test262TestCase(test.TestCase): | 43 class Test262TestCase(test.TestCase): |
38 | 44 |
39 def __init__(self, filename, path, context, root, mode, framework): | 45 def __init__(self, filename, path, context, root, mode, framework): |
40 super(Test262TestCase, self).__init__(context, path, mode) | 46 super(Test262TestCase, self).__init__(context, path, mode) |
41 self.filename = filename | 47 self.filename = filename |
42 self.framework = framework | 48 self.framework = framework |
43 self.root = root | 49 self.root = root |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 files.sort() | 92 files.sort() |
87 for file in files: | 93 for file in files: |
88 if file.endswith('.js'): | 94 if file.endswith('.js'): |
89 test_path = ['test262', file[:-3]] | 95 test_path = ['test262', file[:-3]] |
90 if self.Contains(path, test_path): | 96 if self.Contains(path, test_path): |
91 test = Test262TestCase(join(root, file), test_path, self.context, | 97 test = Test262TestCase(join(root, file), test_path, self.context, |
92 self.root, mode, harness) | 98 self.root, mode, harness) |
93 tests.append(test) | 99 tests.append(test) |
94 return tests | 100 return tests |
95 | 101 |
| 102 def DownloadData(self): |
| 103 revision = TEST_262_ARCHIVE_REVISION |
| 104 archive_url = TEST_262_URL % revision |
| 105 archive_name = join(self.root, 'test262-%s.tar.bz2' % revision) |
| 106 directory_name = join(self.root, "test262-%s" % revision) |
| 107 if not exists(directory_name) or not exists(archive_name): |
| 108 if not exists(archive_name): |
| 109 print "Downloading test data from %s ..." % archive_url |
| 110 urllib.urlretrieve(archive_url, archive_name) |
| 111 if not exists(directory_name): |
| 112 print "Extracting test262-%s.tar.bz2 ..." % revision |
| 113 md5 = hashlib.md5() |
| 114 with open(archive_name,'rb') as f: |
| 115 for chunk in iter(lambda: f.read(8192), ''): |
| 116 md5.update(chunk) |
| 117 if md5.hexdigest() != TEST_262_ARCHIVE_MD5: |
| 118 raise Exception("Hash mismatch of test data file") |
| 119 archive = tarfile.open(archive_name, 'r:bz2') |
| 120 archive.extractall(join(self.root)) |
| 121 if not exists(join(self.root, 'data')): |
| 122 os.symlink(directory_name, join(self.root, 'data')) |
| 123 |
96 def GetBuildRequirements(self): | 124 def GetBuildRequirements(self): |
97 return ['d8'] | 125 return ['d8'] |
98 | 126 |
99 def GetTestStatus(self, sections, defs): | 127 def GetTestStatus(self, sections, defs): |
100 status_file = join(self.root, 'test262.status') | 128 status_file = join(self.root, 'test262.status') |
101 if exists(status_file): | 129 if exists(status_file): |
102 test.ReadConfigurationInto(status_file, sections, defs) | 130 test.ReadConfigurationInto(status_file, sections, defs) |
103 | 131 |
104 | |
105 def GetConfiguration(context, root): | 132 def GetConfiguration(context, root): |
106 return Test262TestConfiguration(context, root) | 133 return Test262TestConfiguration(context, root) |
OLD | NEW |