2016-03-08 10:47:58 +00:00
|
|
|
# Copyright 2016 the V8 project authors. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
import sancov_merger
|
|
|
|
|
|
|
|
|
|
|
|
# Files on disk after test runner completes. The files are mapped by
|
|
|
|
# executable name -> file list.
|
|
|
|
FILE_MAP = {
|
|
|
|
'd8': [
|
2016-10-14 10:00:03 +00:00
|
|
|
'd8.test.1.1.sancov',
|
|
|
|
'd8.test.2.1.sancov',
|
|
|
|
'd8.test.3.1.sancov',
|
|
|
|
'd8.test.4.1.sancov',
|
|
|
|
'd8.test.5.1.sancov',
|
|
|
|
'd8.test.5.2.sancov',
|
|
|
|
'd8.test.6.1.sancov',
|
2016-03-08 10:47:58 +00:00
|
|
|
],
|
|
|
|
'cctest': [
|
2016-10-14 10:00:03 +00:00
|
|
|
'cctest.test.1.1.sancov',
|
|
|
|
'cctest.test.2.1.sancov',
|
|
|
|
'cctest.test.3.1.sancov',
|
|
|
|
'cctest.test.4.1.sancov',
|
2016-03-08 10:47:58 +00:00
|
|
|
],
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Inputs for merge process with 2 cpus. The tuples contain:
|
|
|
|
# (flag, path, executable name, intermediate result index, file list).
|
|
|
|
EXPECTED_INPUTS_2 = [
|
|
|
|
(False, '/some/path', 'cctest', 0, [
|
2016-10-14 10:00:03 +00:00
|
|
|
'cctest.test.1.1.sancov',
|
|
|
|
'cctest.test.2.1.sancov']),
|
2016-03-08 10:47:58 +00:00
|
|
|
(False, '/some/path', 'cctest', 1, [
|
2016-10-14 10:00:03 +00:00
|
|
|
'cctest.test.3.1.sancov',
|
|
|
|
'cctest.test.4.1.sancov']),
|
2016-03-08 10:47:58 +00:00
|
|
|
(False, '/some/path', 'd8', 0, [
|
2016-10-14 10:00:03 +00:00
|
|
|
'd8.test.1.1.sancov',
|
|
|
|
'd8.test.2.1.sancov',
|
|
|
|
'd8.test.3.1.sancov',
|
|
|
|
'd8.test.4.1.sancov']),
|
2016-03-08 10:47:58 +00:00
|
|
|
(False, '/some/path', 'd8', 1, [
|
2016-10-14 10:00:03 +00:00
|
|
|
'd8.test.5.1.sancov',
|
|
|
|
'd8.test.5.2.sancov',
|
|
|
|
'd8.test.6.1.sancov']),
|
2016-03-08 10:47:58 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
# The same for 4 cpus.
|
|
|
|
EXPECTED_INPUTS_4 = [
|
|
|
|
(True, '/some/path', 'cctest', 0, [
|
2016-10-14 10:00:03 +00:00
|
|
|
'cctest.test.1.1.sancov',
|
|
|
|
'cctest.test.2.1.sancov']),
|
2016-03-08 10:47:58 +00:00
|
|
|
(True, '/some/path', 'cctest', 1, [
|
2016-10-14 10:00:03 +00:00
|
|
|
'cctest.test.3.1.sancov',
|
|
|
|
'cctest.test.4.1.sancov']),
|
2016-03-08 10:47:58 +00:00
|
|
|
(True, '/some/path', 'd8', 0, [
|
2016-10-14 10:00:03 +00:00
|
|
|
'd8.test.1.1.sancov',
|
|
|
|
'd8.test.2.1.sancov']),
|
2016-03-08 10:47:58 +00:00
|
|
|
(True, '/some/path', 'd8', 1, [
|
2016-10-14 10:00:03 +00:00
|
|
|
'd8.test.3.1.sancov',
|
|
|
|
'd8.test.4.1.sancov']),
|
2016-03-08 10:47:58 +00:00
|
|
|
(True, '/some/path', 'd8', 2, [
|
2016-10-14 10:00:03 +00:00
|
|
|
'd8.test.5.1.sancov',
|
|
|
|
'd8.test.5.2.sancov']),
|
2016-03-08 10:47:58 +00:00
|
|
|
(True, '/some/path', 'd8', 3, [
|
2016-10-14 10:00:03 +00:00
|
|
|
'd8.test.6.1.sancov'])]
|
2016-03-08 10:47:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
class MergerTests(unittest.TestCase):
|
|
|
|
def test_generate_inputs_2_cpu(self):
|
|
|
|
inputs = sancov_merger.generate_inputs(
|
|
|
|
False, '/some/path', FILE_MAP, 2)
|
|
|
|
self.assertEquals(EXPECTED_INPUTS_2, inputs)
|
|
|
|
|
|
|
|
def test_generate_inputs_4_cpu(self):
|
|
|
|
inputs = sancov_merger.generate_inputs(
|
|
|
|
True, '/some/path', FILE_MAP, 4)
|
|
|
|
self.assertEquals(EXPECTED_INPUTS_4, inputs)
|