blob: a313f0509fe08fc0f6e3327306375015ffe38032 [file] [log] [blame]
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001# Copyright 2012 the V8 project authors. All rights reserved.
2# Redistribution and use in source and binary forms, with or without
3# modification, are permitted provided that the following conditions are
4# met:
5#
6# * Redistributions of source code must retain the above copyright
7# notice, this list of conditions and the following disclaimer.
8# * Redistributions in binary form must reproduce the above
9# copyright notice, this list of conditions and the following
10# disclaimer in the documentation and/or other materials provided
11# with the distribution.
12# * Neither the name of Google Inc. nor the names of its
13# contributors may be used to endorse or promote products derived
14# from this software without specific prior written permission.
15#
16# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28
29# These outcomes can occur in a TestCase's outcomes list:
30SKIP = "SKIP"
31FAIL = "FAIL"
32PASS = "PASS"
33OKAY = "OKAY"
34TIMEOUT = "TIMEOUT"
35CRASH = "CRASH"
36SLOW = "SLOW"
37FLAKY = "FLAKY"
Emily Bernierd0a1eb72015-03-24 16:35:39 -040038FAST_VARIANTS = "FAST_VARIANTS"
Ben Murdochb8a8cc12014-11-26 15:28:44 +000039NO_VARIANTS = "NO_VARIANTS"
40# These are just for the status files and are mapped below in DEFS:
41FAIL_OK = "FAIL_OK"
42PASS_OR_FAIL = "PASS_OR_FAIL"
43
44ALWAYS = "ALWAYS"
45
46KEYWORDS = {}
47for key in [SKIP, FAIL, PASS, OKAY, TIMEOUT, CRASH, SLOW, FLAKY, FAIL_OK,
Emily Bernierd0a1eb72015-03-24 16:35:39 -040048 FAST_VARIANTS, NO_VARIANTS, PASS_OR_FAIL, ALWAYS]:
Ben Murdochb8a8cc12014-11-26 15:28:44 +000049 KEYWORDS[key] = key
50
51DEFS = {FAIL_OK: [FAIL, OKAY],
52 PASS_OR_FAIL: [PASS, FAIL]}
53
54# Support arches, modes to be written as keywords instead of strings.
55VARIABLES = {ALWAYS: True}
56for var in ["debug", "release", "android_arm", "android_arm64", "android_ia32", "android_x87",
57 "arm", "arm64", "ia32", "mips", "mipsel", "mips64el", "x64", "x87", "nacl_ia32",
58 "nacl_x64", "macos", "windows", "linux"]:
59 VARIABLES[var] = var
60
61
62def DoSkip(outcomes):
63 return SKIP in outcomes
64
65
66def IsSlow(outcomes):
67 return SLOW in outcomes
68
69
70def OnlyStandardVariant(outcomes):
71 return NO_VARIANTS in outcomes
72
73
Emily Bernierd0a1eb72015-03-24 16:35:39 -040074def OnlyFastVariants(outcomes):
75 return FAST_VARIANTS in outcomes
76
77
Ben Murdochb8a8cc12014-11-26 15:28:44 +000078def IsFlaky(outcomes):
79 return FLAKY in outcomes
80
81
82def IsPassOrFail(outcomes):
83 return ((PASS in outcomes) and (FAIL in outcomes) and
84 (not CRASH in outcomes) and (not OKAY in outcomes))
85
86
87def IsFailOk(outcomes):
88 return (FAIL in outcomes) and (OKAY in outcomes)
89
90
91def _AddOutcome(result, new):
92 global DEFS
93 if new in DEFS:
94 mapped = DEFS[new]
95 if type(mapped) == list:
96 for m in mapped:
97 _AddOutcome(result, m)
98 elif type(mapped) == str:
99 _AddOutcome(result, mapped)
100 else:
101 result.add(new)
102
103
104def _ParseOutcomeList(rule, outcomes, target_dict, variables):
105 result = set([])
106 if type(outcomes) == str:
107 outcomes = [outcomes]
108 for item in outcomes:
109 if type(item) == str:
110 _AddOutcome(result, item)
111 elif type(item) == list:
112 if not eval(item[0], variables): continue
113 for outcome in item[1:]:
114 assert type(outcome) == str
115 _AddOutcome(result, outcome)
116 else:
117 assert False
118 if len(result) == 0: return
119 if rule in target_dict:
120 target_dict[rule] |= result
121 else:
122 target_dict[rule] = result
123
124
125def ReadStatusFile(path, variables):
126 with open(path) as f:
127 global KEYWORDS
128 contents = eval(f.read(), KEYWORDS)
129
130 rules = {}
131 wildcards = {}
132 variables.update(VARIABLES)
133 for section in contents:
134 assert type(section) == list
135 assert len(section) == 2
136 if not eval(section[0], variables): continue
137 section = section[1]
138 assert type(section) == dict
139 for rule in section:
140 assert type(rule) == str
141 if rule[-1] == '*':
142 _ParseOutcomeList(rule, section[rule], wildcards, variables)
143 else:
144 _ParseOutcomeList(rule, section[rule], rules, variables)
145 return rules, wildcards