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