11cb0ef41Sopenharmony_ci# Copyright 2018 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_cifrom . import base 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ciclass LoadProc(base.TestProc): 91cb0ef41Sopenharmony_ci """First processor in the chain that passes all tests to the next processor. 101cb0ef41Sopenharmony_ci """ 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_ci def __init__(self, tests): 131cb0ef41Sopenharmony_ci super(LoadProc, self).__init__() 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ci self.tests = tests 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_ci def load_initial_tests(self, initial_batch_size): 181cb0ef41Sopenharmony_ci """ 191cb0ef41Sopenharmony_ci Args: 201cb0ef41Sopenharmony_ci exec_proc: execution processor that the tests are being loaded into 211cb0ef41Sopenharmony_ci initial_batch_size: initial number of tests to load 221cb0ef41Sopenharmony_ci """ 231cb0ef41Sopenharmony_ci loaded_tests = 0 241cb0ef41Sopenharmony_ci while loaded_tests < initial_batch_size: 251cb0ef41Sopenharmony_ci try: 261cb0ef41Sopenharmony_ci t = next(self.tests) 271cb0ef41Sopenharmony_ci except StopIteration: 281cb0ef41Sopenharmony_ci return 291cb0ef41Sopenharmony_ci 301cb0ef41Sopenharmony_ci if self._send_test(t): 311cb0ef41Sopenharmony_ci loaded_tests += 1 321cb0ef41Sopenharmony_ci 331cb0ef41Sopenharmony_ci def next_test(self, test): 341cb0ef41Sopenharmony_ci assert False, 'Nothing can be connected to the LoadProc' 351cb0ef41Sopenharmony_ci 361cb0ef41Sopenharmony_ci def result_for(self, test, result): 371cb0ef41Sopenharmony_ci try: 381cb0ef41Sopenharmony_ci while not self._send_test(next(self.tests)): 391cb0ef41Sopenharmony_ci pass 401cb0ef41Sopenharmony_ci except StopIteration: 411cb0ef41Sopenharmony_ci # No more tests to load. 421cb0ef41Sopenharmony_ci pass 43