Revert "[test] Move timeout control to timeout processor"

This reverts commit 4de2be999d.

Reason for revert: Testing stops too early now, e.g. here after 2 min:
https://build.chromium.org/p/client.v8.clusterfuzz/builders/V8%20NumFuzz/builds/32

Original change's description:
> [test] Move timeout control to timeout processor
> 
> Bug: v8:6917
> Change-Id: I03be38be952f0d59eb20fa98102ef09ca795de40
> Reviewed-on: https://chromium-review.googlesource.com/883446
> Commit-Queue: Michał Majewski <majeski@google.com>
> Reviewed-by: Michael Achenbach <machenbach@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#50848}

TBR=machenbach@chromium.org,sergiyb@chromium.org,majeski@google.com

Change-Id: I6a925866476c69b3b50aa08e99facca0eaaa396b
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: v8:6917
Reviewed-on: https://chromium-review.googlesource.com/884082
Reviewed-by: Michael Achenbach <machenbach@chromium.org>
Commit-Queue: Michael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50851}
This commit is contained in:
Michael Achenbach 2018-01-24 19:29:58 +00:00 committed by Commit Bot
parent da4553b13c
commit c077ff54ae
4 changed files with 15 additions and 51 deletions

View File

@ -24,7 +24,6 @@ from testrunner.testproc.filter import StatusFileFilterProc, NameFilterProc
from testrunner.testproc.loader import LoadProc
from testrunner.testproc.progress import ResultsTracker, TestsCounter
from testrunner.testproc.rerun import RerunProc
from testrunner.testproc.timeout import TimeoutProc
DEFAULT_SUITES = ["mjsunit", "webkit", "benchmarks"]
@ -99,11 +98,10 @@ class NumFuzzer(base_runner.BaseTestRunner):
"between deopt points")
parser.add_option("--tests-count", default=5, type="int",
help="Number of tests to generate from each base test. "
"Can be combined with --total-timeout-sec with "
"value 0 to provide infinite number of subtests.")
help="Number of tests to generate from each base test")
parser.add_option("--total-timeout-sec", default=0, type="int",
help="How long should fuzzer run")
help="How long should fuzzer run. It overrides "
"--tests-count")
# Combine multiple tests
parser.add_option("--combine-tests", default=False, action="store_true",
@ -167,7 +165,6 @@ class NumFuzzer(base_runner.BaseTestRunner):
fuzzer_proc,
] + indicators + [
results,
self._create_timeout_proc(options),
self._create_rerun_proc(options),
execproc,
]
@ -275,11 +272,6 @@ class NumFuzzer(base_runner.BaseTestRunner):
add('deopt', options.stress_deopt, options.stress_deopt_min)
return fuzzers
def _create_timeout_proc(self, options):
if not options.total_timeout_sec:
return None
return TimeoutProc(options.total_timeout_sec)
def _create_rerun_proc(self, options):
if not options.rerun_failures_count:
return None

View File

@ -42,7 +42,6 @@ class TestProc(object):
def __init__(self):
self._prev_proc = None
self._next_proc = None
self._stopped = False
self._requirement = DROP_RESULT
self._prev_requirement = None
self._reduce_result = lambda result: result
@ -93,15 +92,6 @@ class TestProc(object):
if self._prev_proc:
self._prev_proc.heartbeat()
def stop(self):
self._stopped = True
if self._prev_proc:
self._prev_proc.stop()
@property
def is_stopped(self):
return self._stopped
### Communication
def _send_test(self, test):

View File

@ -65,14 +65,17 @@ class FuzzerProc(base.TestProcProducer):
self._disable_analysis = disable_analysis
self._gens = {}
self._start_time = None
self._stop = False
def setup(self, requirement=base.DROP_RESULT):
# Fuzzer is optimized to not store the results
assert requirement == base.DROP_RESULT
super(FuzzerProc, self).setup(requirement)
def _next_test(self, test):
if self.is_stopped:
return
if not self._start_time:
self._start_time = time.time()
analysis_subtest = self._create_analysis_subtest(test)
if analysis_subtest:
@ -97,6 +100,11 @@ class FuzzerProc(base.TestProcProducer):
def _result_for(self, test, subtest, result):
if self._fuzz_duration_sec and not self._stop:
if int(time.time() - self._start_time) > self._fuzz_duration_sec:
print '>>> Stopping fuzzing'
self._stop = True
if not self._disable_analysis:
if result is not None:
# Analysis phase, for fuzzing we drop the result.
@ -130,7 +138,7 @@ class FuzzerProc(base.TestProcProducer):
return
i = 0
while not self._count or i < self._count:
while (self._fuzz_duration_sec and not self._stop) or i < self._count:
main_index = self._rng.choice(indexes)
_, main_gen = gens[main_index]
@ -147,7 +155,7 @@ class FuzzerProc(base.TestProcProducer):
i += 1
def _try_send_next_test(self, test):
if not self.is_stopped:
if not self._stop:
for subtest in self._gens[test.procid]:
self._send_test(subtest)
return

View File

@ -1,26 +0,0 @@
# Copyright 2018 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 time
from . import base
# TODO(majeski): Signal handler
class TimeoutProc(base.TestProcObserver):
def __init__(self, duration_sec):
super(TimeoutProc, self).__init__()
self._duration_sec = duration_sec
self._start = time.time()
def _on_next_test(self, test):
self._on_event()
def _on_result_for(self, test, result):
self._on_event()
def _on_event(self):
if not self.is_stopped:
if time.time() - self._start > self._duration_sec:
self.stop()