OLD | NEW |
---|---|
1 # Copyright 2016 the V8 project authors. All rights reserved. | 1 # Copyright 2016 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 import os | |
6 import subprocess | |
7 import sys | |
5 import unittest | 8 import unittest |
6 | 9 |
10 import v8_foozzie | |
7 import v8_suppressions | 11 import v8_suppressions |
8 | 12 |
9 class FuzzerTest(unittest.TestCase): | 13 BASE_DIR = os.path.dirname(os.path.abspath(__file__)) |
14 FOOZZIE = os.path.join(BASE_DIR, 'v8_foozzie.py') | |
15 TEST_DATA = os.path.join(BASE_DIR, 'testdata') | |
16 | |
17 class UnitTest(unittest.TestCase): | |
10 def testDiff(self): | 18 def testDiff(self): |
11 # TODO(machenbach): Mock out suppression configuration. | 19 # TODO(machenbach): Mock out suppression configuration. |
12 suppress = v8_suppressions.get_suppression( | 20 suppress = v8_suppressions.get_suppression( |
13 'x64', 'fullcode', 'x64', 'default') | 21 'x64', 'fullcode', 'x64', 'default') |
14 one = '' | 22 one = '' |
15 two = '' | 23 two = '' |
16 diff = None | 24 diff = None |
17 self.assertEquals(diff, suppress.diff(one, two)) | 25 self.assertEquals(diff, suppress.diff(one, two)) |
18 | 26 |
19 one = 'a \n b\nc();' | 27 one = 'a \n b\nc();' |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
68 undefined | 76 undefined |
69 somefile.js: TypeError: undefined is not a constructor | 77 somefile.js: TypeError: undefined is not a constructor |
70 """ | 78 """ |
71 two = """ | 79 two = """ |
72 undefined | 80 undefined |
73 otherfile.js: TypeError: undefined is not a constructor | 81 otherfile.js: TypeError: undefined is not a constructor |
74 """ | 82 """ |
75 diff = """- somefile.js: TypeError: undefined is not a constructor | 83 diff = """- somefile.js: TypeError: undefined is not a constructor |
76 + otherfile.js: TypeError: undefined is not a constructor""" | 84 + otherfile.js: TypeError: undefined is not a constructor""" |
77 self.assertEquals(diff, suppress.diff(one, two)) | 85 self.assertEquals(diff, suppress.diff(one, two)) |
86 | |
87 | |
88 def run_foozzie(first_d8, second_d8): | |
89 return subprocess.check_output([ | |
90 sys.executable, FOOZZIE, | |
91 '--random-seed', '12345', | |
92 '--first-d8', os.path.join(TEST_DATA, first_d8), | |
93 '--second-d8', os.path.join(TEST_DATA, second_d8), | |
94 '--second-config', 'ignition_staging', | |
95 os.path.join(TEST_DATA, 'fuzz-test1.js'), | |
96 ]) | |
97 | |
98 | |
99 class SystemTest(unittest.TestCase): | |
100 def testSyntaxErrorDiffPass(self): | |
101 stdout = run_foozzie('test_d8_1.py', 'test_d8_2.py') | |
102 self.assertEquals('# V8 correctness - pass\n', stdout) | |
103 | |
104 def testDifferentOutputFail(self): | |
105 with open(os.path.join(TEST_DATA, 'failure_output.txt')) as f: | |
106 expected_output = f.read() | |
107 try: | |
108 run_foozzie('test_d8_1.py', 'test_d8_3.py') | |
109 assert False | |
tandrii(chromium)
2016/12/19 13:25:34
assertionError is also Exception, so better:
with
Michael Achenbach
2016/12/20 09:22:29
Done.
| |
110 except Exception as e: | |
111 self.assertEquals(v8_foozzie.RETURN_FAIL, e.returncode) | |
112 self.assertEquals(expected_output, e.output) | |
OLD | NEW |