11cb0ef41Sopenharmony_ci# Copyright 2016 the V8 project authors. All rights reserved.
21cb0ef41Sopenharmony_ci# Use of this source code is governed by a BSD-style license that can be
31cb0ef41Sopenharmony_ci# found in the LICENSE file.
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ciimport unittest
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ciimport sancov_merger
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_ci# Files on disk after test runner completes. The files are mapped by
111cb0ef41Sopenharmony_ci# executable name -> file list.
121cb0ef41Sopenharmony_ciFILE_MAP = {
131cb0ef41Sopenharmony_ci  'd8': [
141cb0ef41Sopenharmony_ci    'd8.test.1.1.sancov',
151cb0ef41Sopenharmony_ci    'd8.test.2.1.sancov',
161cb0ef41Sopenharmony_ci    'd8.test.3.1.sancov',
171cb0ef41Sopenharmony_ci    'd8.test.4.1.sancov',
181cb0ef41Sopenharmony_ci    'd8.test.5.1.sancov',
191cb0ef41Sopenharmony_ci    'd8.test.5.2.sancov',
201cb0ef41Sopenharmony_ci    'd8.test.6.1.sancov',
211cb0ef41Sopenharmony_ci  ],
221cb0ef41Sopenharmony_ci  'cctest': [
231cb0ef41Sopenharmony_ci    'cctest.test.1.1.sancov',
241cb0ef41Sopenharmony_ci    'cctest.test.2.1.sancov',
251cb0ef41Sopenharmony_ci    'cctest.test.3.1.sancov',
261cb0ef41Sopenharmony_ci    'cctest.test.4.1.sancov',
271cb0ef41Sopenharmony_ci  ],
281cb0ef41Sopenharmony_ci}
291cb0ef41Sopenharmony_ci
301cb0ef41Sopenharmony_ci
311cb0ef41Sopenharmony_ci# Inputs for merge process with 2 cpus. The tuples contain:
321cb0ef41Sopenharmony_ci# (flag, path, executable name, intermediate result index, file list).
331cb0ef41Sopenharmony_ciEXPECTED_INPUTS_2 = [
341cb0ef41Sopenharmony_ci  (False, '/some/path', 'cctest', 0, [
351cb0ef41Sopenharmony_ci    'cctest.test.1.1.sancov',
361cb0ef41Sopenharmony_ci    'cctest.test.2.1.sancov']),
371cb0ef41Sopenharmony_ci  (False, '/some/path', 'cctest', 1, [
381cb0ef41Sopenharmony_ci    'cctest.test.3.1.sancov',
391cb0ef41Sopenharmony_ci    'cctest.test.4.1.sancov']),
401cb0ef41Sopenharmony_ci  (False, '/some/path', 'd8', 0, [
411cb0ef41Sopenharmony_ci    'd8.test.1.1.sancov',
421cb0ef41Sopenharmony_ci    'd8.test.2.1.sancov',
431cb0ef41Sopenharmony_ci    'd8.test.3.1.sancov',
441cb0ef41Sopenharmony_ci    'd8.test.4.1.sancov']),
451cb0ef41Sopenharmony_ci  (False, '/some/path', 'd8', 1, [
461cb0ef41Sopenharmony_ci    'd8.test.5.1.sancov',
471cb0ef41Sopenharmony_ci    'd8.test.5.2.sancov',
481cb0ef41Sopenharmony_ci    'd8.test.6.1.sancov']),
491cb0ef41Sopenharmony_ci]
501cb0ef41Sopenharmony_ci
511cb0ef41Sopenharmony_ci
521cb0ef41Sopenharmony_ci# The same for 4 cpus.
531cb0ef41Sopenharmony_ciEXPECTED_INPUTS_4 = [
541cb0ef41Sopenharmony_ci  (True, '/some/path', 'cctest', 0, [
551cb0ef41Sopenharmony_ci    'cctest.test.1.1.sancov',
561cb0ef41Sopenharmony_ci    'cctest.test.2.1.sancov']),
571cb0ef41Sopenharmony_ci  (True, '/some/path', 'cctest', 1, [
581cb0ef41Sopenharmony_ci    'cctest.test.3.1.sancov',
591cb0ef41Sopenharmony_ci    'cctest.test.4.1.sancov']),
601cb0ef41Sopenharmony_ci  (True, '/some/path', 'd8', 0, [
611cb0ef41Sopenharmony_ci    'd8.test.1.1.sancov',
621cb0ef41Sopenharmony_ci    'd8.test.2.1.sancov']),
631cb0ef41Sopenharmony_ci  (True, '/some/path', 'd8', 1, [
641cb0ef41Sopenharmony_ci    'd8.test.3.1.sancov',
651cb0ef41Sopenharmony_ci    'd8.test.4.1.sancov']),
661cb0ef41Sopenharmony_ci  (True, '/some/path', 'd8', 2, [
671cb0ef41Sopenharmony_ci    'd8.test.5.1.sancov',
681cb0ef41Sopenharmony_ci    'd8.test.5.2.sancov']),
691cb0ef41Sopenharmony_ci  (True, '/some/path', 'd8', 3, [
701cb0ef41Sopenharmony_ci    'd8.test.6.1.sancov'])]
711cb0ef41Sopenharmony_ci
721cb0ef41Sopenharmony_ci
731cb0ef41Sopenharmony_ciclass MergerTests(unittest.TestCase):
741cb0ef41Sopenharmony_ci  def test_generate_inputs_2_cpu(self):
751cb0ef41Sopenharmony_ci    inputs = sancov_merger.generate_inputs(
761cb0ef41Sopenharmony_ci        False, '/some/path', FILE_MAP, 2)
771cb0ef41Sopenharmony_ci    self.assertEquals(EXPECTED_INPUTS_2, inputs)
781cb0ef41Sopenharmony_ci
791cb0ef41Sopenharmony_ci  def test_generate_inputs_4_cpu(self):
801cb0ef41Sopenharmony_ci    inputs = sancov_merger.generate_inputs(
811cb0ef41Sopenharmony_ci        True, '/some/path', FILE_MAP, 4)
821cb0ef41Sopenharmony_ci    self.assertEquals(EXPECTED_INPUTS_4, inputs)
83