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 unittest | 5 import unittest |
6 | 6 |
7 import sancov_merger | 7 import sancov_merger |
8 | 8 |
9 | 9 |
10 # Files on disk after test runner completes. The files are mapped by | 10 # Files on disk after test runner completes. The files are mapped by |
11 # executable name -> file list. | 11 # executable name -> file list. |
12 FILE_MAP = { | 12 FILE_MAP = { |
13 'd8': [ | 13 'd8': [ |
14 'd8.test.1.sancov', | 14 'd8.test.1.1.sancov', |
15 'd8.test.2.sancov', | 15 'd8.test.2.1.sancov', |
16 'd8.test.3.sancov', | 16 'd8.test.3.1.sancov', |
17 'd8.test.4.sancov', | 17 'd8.test.4.1.sancov', |
18 'd8.test.5.sancov', | 18 'd8.test.5.1.sancov', |
19 'd8.test.6.sancov', | 19 'd8.test.5.2.sancov', |
20 'd8.test.7.sancov', | 20 'd8.test.6.1.sancov', |
21 ], | 21 ], |
22 'cctest': [ | 22 'cctest': [ |
23 'cctest.test.1.sancov', | 23 'cctest.test.1.1.sancov', |
24 'cctest.test.2.sancov', | 24 'cctest.test.2.1.sancov', |
25 'cctest.test.3.sancov', | 25 'cctest.test.3.1.sancov', |
26 'cctest.test.4.sancov', | 26 'cctest.test.4.1.sancov', |
27 ], | 27 ], |
28 } | 28 } |
29 | 29 |
30 | 30 |
31 # Inputs for merge process with 2 cpus. The tuples contain: | 31 # Inputs for merge process with 2 cpus. The tuples contain: |
32 # (flag, path, executable name, intermediate result index, file list). | 32 # (flag, path, executable name, intermediate result index, file list). |
33 EXPECTED_INPUTS_2 = [ | 33 EXPECTED_INPUTS_2 = [ |
34 (False, '/some/path', 'cctest', 0, [ | 34 (False, '/some/path', 'cctest', 0, [ |
35 'cctest.test.1.sancov', | 35 'cctest.test.1.1.sancov', |
36 'cctest.test.2.sancov']), | 36 'cctest.test.2.1.sancov']), |
37 (False, '/some/path', 'cctest', 1, [ | 37 (False, '/some/path', 'cctest', 1, [ |
38 'cctest.test.3.sancov', | 38 'cctest.test.3.1.sancov', |
39 'cctest.test.4.sancov']), | 39 'cctest.test.4.1.sancov']), |
40 (False, '/some/path', 'd8', 0, [ | 40 (False, '/some/path', 'd8', 0, [ |
41 'd8.test.1.sancov', | 41 'd8.test.1.1.sancov', |
42 'd8.test.2.sancov', | 42 'd8.test.2.1.sancov', |
43 'd8.test.3.sancov', | 43 'd8.test.3.1.sancov', |
44 'd8.test.4.sancov']), | 44 'd8.test.4.1.sancov']), |
45 (False, '/some/path', 'd8', 1, [ | 45 (False, '/some/path', 'd8', 1, [ |
46 'd8.test.5.sancov', | 46 'd8.test.5.1.sancov', |
47 'd8.test.6.sancov', | 47 'd8.test.5.2.sancov', |
48 'd8.test.7.sancov']), | 48 'd8.test.6.1.sancov']), |
49 ] | 49 ] |
50 | 50 |
51 | 51 |
52 # The same for 4 cpus. | 52 # The same for 4 cpus. |
53 EXPECTED_INPUTS_4 = [ | 53 EXPECTED_INPUTS_4 = [ |
54 (True, '/some/path', 'cctest', 0, [ | 54 (True, '/some/path', 'cctest', 0, [ |
55 'cctest.test.1.sancov', | 55 'cctest.test.1.1.sancov', |
56 'cctest.test.2.sancov']), | 56 'cctest.test.2.1.sancov']), |
57 (True, '/some/path', 'cctest', 1, [ | 57 (True, '/some/path', 'cctest', 1, [ |
58 'cctest.test.3.sancov', | 58 'cctest.test.3.1.sancov', |
59 'cctest.test.4.sancov']), | 59 'cctest.test.4.1.sancov']), |
60 (True, '/some/path', 'd8', 0, [ | 60 (True, '/some/path', 'd8', 0, [ |
61 'd8.test.1.sancov', | 61 'd8.test.1.1.sancov', |
62 'd8.test.2.sancov']), | 62 'd8.test.2.1.sancov']), |
63 (True, '/some/path', 'd8', 1, [ | 63 (True, '/some/path', 'd8', 1, [ |
64 'd8.test.3.sancov', | 64 'd8.test.3.1.sancov', |
65 'd8.test.4.sancov']), | 65 'd8.test.4.1.sancov']), |
66 (True, '/some/path', 'd8', 2, [ | 66 (True, '/some/path', 'd8', 2, [ |
67 'd8.test.5.sancov', | 67 'd8.test.5.1.sancov', |
68 'd8.test.6.sancov']), | 68 'd8.test.5.2.sancov']), |
69 (True, '/some/path', 'd8', 3, [ | 69 (True, '/some/path', 'd8', 3, [ |
70 'd8.test.7.sancov'])] | 70 'd8.test.6.1.sancov'])] |
71 | 71 |
72 | 72 |
73 class MergerTests(unittest.TestCase): | 73 class MergerTests(unittest.TestCase): |
74 def test_generate_inputs_2_cpu(self): | 74 def test_generate_inputs_2_cpu(self): |
75 inputs = sancov_merger.generate_inputs( | 75 inputs = sancov_merger.generate_inputs( |
76 False, '/some/path', FILE_MAP, 2) | 76 False, '/some/path', FILE_MAP, 2) |
77 self.assertEquals(EXPECTED_INPUTS_2, inputs) | 77 self.assertEquals(EXPECTED_INPUTS_2, inputs) |
78 | 78 |
79 def test_generate_inputs_4_cpu(self): | 79 def test_generate_inputs_4_cpu(self): |
80 inputs = sancov_merger.generate_inputs( | 80 inputs = sancov_merger.generate_inputs( |
81 True, '/some/path', FILE_MAP, 4) | 81 True, '/some/path', FILE_MAP, 4) |
82 self.assertEquals(EXPECTED_INPUTS_4, inputs) | 82 self.assertEquals(EXPECTED_INPUTS_4, inputs) |
OLD | NEW |