1# Copyright 2017 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
5from ..local import statusfile
6from ..outproc import base as outproc_base
7from ..testproc import base as testproc_base
8from ..testproc.result import Result
9
10
11# Only check the exit code of the predictable_wrapper in
12# verify-predictable mode. Negative tests are not supported as they
13# usually also don't print allocation hashes. There are two versions of
14# negative tests: one specified by the test, the other specified through
15# the status file (e.g. known bugs).
16
17
18def get_outproc(test):
19  return OutProc(test.output_proc)
20
21
22class OutProc(outproc_base.BaseOutProc):
23  """Output processor wrapper for predictable mode. It has custom process and
24  has_unexpected_output implementation, but for all other methods it simply
25  calls wrapped output processor.
26  """
27  def __init__(self, _outproc):
28    super(OutProc, self).__init__()
29    self._outproc = _outproc
30
31  def has_unexpected_output(self, output):
32    return output.exit_code != 0
33
34  def get_outcome(self, output):
35    return self._outproc.get_outcome(output)
36
37  @property
38  def negative(self):
39    return self._outproc.negative
40
41  @property
42  def expected_outcomes(self):
43    return self._outproc.expected_outcomes
44
45
46class PredictableFilterProc(testproc_base.TestProcFilter):
47  def _filter(self, test):
48    return (statusfile.FAIL in test.expected_outcomes or
49            test.output_proc.negative)
50