blob: 3b2872df95f544f33f2a4a94e46022f2491961e2 [file] [log] [blame]
Tom Sepez30762ce2015-04-09 13:37:02 -07001#!/usr/bin/env python
2# Copyright 2015 The PDFium Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6import os
7
8import common
9
10class Suppressor:
Tom Sepez5c1efd42016-01-19 15:05:36 -080011 def __init__(self, finder, feature_string):
12 feature_vector = feature_string.strip().split(",")
tsepez86d945b2016-04-18 17:15:42 -070013 self.has_v8 = "V8" in feature_vector
14 self.has_xfa = "XFA" in feature_vector
15 v8_option = "v8" if self.has_v8 else "nov8"
16 xfa_option = "xfa" if self.has_xfa else "noxfa"
dan sinclair00d40642017-01-30 19:48:54 -080017
Tom Sepezacfe9a72016-01-19 11:28:59 -080018 with open(os.path.join(finder.TestingDir(), 'SUPPRESSIONS')) as f:
19 self.suppression_set = set(self._FilterSuppressions(
Tom Sepez5c1efd42016-01-19 15:05:36 -080020 common.os_name(), v8_option, xfa_option, self._ExtractSuppressions(f)))
Tom Sepez30762ce2015-04-09 13:37:02 -070021
Tom Sepezacfe9a72016-01-19 11:28:59 -080022 def _ExtractSuppressions(self, f):
23 return [y.split(' ') for y in
24 [x.split('#')[0].strip() for x in
25 f.readlines()] if y]
26
27 def _FilterSuppressions(self, os, js, xfa, unfiltered_list):
28 return [x[0] for x in unfiltered_list
29 if self._MatchSuppression(x, os, js, xfa)]
30
31 def _MatchSuppression(self, item, os, js, xfa):
32 os_column = item[1].split(",");
33 js_column = item[2].split(",");
34 xfa_column = item[3].split(",");
35 return (('*' in os_column or os in os_column) and
36 ('*' in js_column or js in js_column) and
37 ('*' in xfa_column or xfa in xfa_column))
Tom Sepez30762ce2015-04-09 13:37:02 -070038
tsepez86d945b2016-04-18 17:15:42 -070039 def IsResultSuppressed(self, input_filename):
Tom Sepezacfe9a72016-01-19 11:28:59 -080040 if input_filename in self.suppression_set:
tsepez86d945b2016-04-18 17:15:42 -070041 print "%s result is suppressed" % input_filename
42 return True
43 return False
44
45 def IsExecutionSuppressed(self, input_filepath):
46 if "xfa_specific" in input_filepath and not self.has_xfa:
47 print "%s execution is suppressed" % input_filepath
Tom Sepez30762ce2015-04-09 13:37:02 -070048 return True
49 return False