1
# 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
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.
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.
29
# These imports are required for the on-demand conversion from
30
# old to new status file format.
31
from os.path import exists
32
from os.path import getmtime
34
from . import old_statusfile
37
# These outcomes can occur in a TestCase's outcomes list:
45
# These are just for the status files and are mapped below in DEFS:
47
PASS_OR_FAIL = "PASS_OR_FAIL"
52
for key in [SKIP, FAIL, PASS, OKAY, TIMEOUT, CRASH, SLOW, FAIL_OK,
53
PASS_OR_FAIL, ALWAYS]:
56
DEFS = {FAIL_OK: [FAIL, OKAY],
57
PASS_OR_FAIL: [PASS, FAIL]}
59
# Support arches, modes to be written as keywords instead of strings.
60
VARIABLES = {ALWAYS: True}
61
for var in ["debug", "release", "android_arm", "android_ia32", "arm", "ia32",
67
return SKIP in outcomes or SLOW in outcomes
70
def IsFlaky(outcomes):
71
return ((PASS in outcomes) and (FAIL in outcomes) and
72
(not CRASH in outcomes) and (not OKAY in outcomes))
75
def IsFailOk(outcomes):
76
return (FAIL in outcomes) and (OKAY in outcomes)
79
def _AddOutcome(result, new):
83
if type(mapped) == list:
85
_AddOutcome(result, m)
86
elif type(mapped) == str:
87
_AddOutcome(result, mapped)
92
def _ParseOutcomeList(rule, outcomes, target_dict, variables):
94
if type(outcomes) == str:
98
_AddOutcome(result, item)
99
elif type(item) == list:
100
if not eval(item[0], variables): continue
101
for outcome in item[1:]:
102
assert type(outcome) == str
103
_AddOutcome(result, outcome)
106
if len(result) == 0: return
107
if rule in target_dict:
108
target_dict[rule] |= result
110
target_dict[rule] = result
113
def ReadStatusFile(path, variables):
114
# As long as the old-format .status files are authoritative, just
115
# create the converted version on demand and cache it to speed up
117
if path.endswith(".status"):
119
if not exists(newpath) or getmtime(newpath) < getmtime(path):
120
print "Converting status file."
121
converted = old_statusfile.ConvertNotation(path).GetOutput()
122
with open(newpath, 'w') as f:
126
with open(path) as f:
128
contents = eval(f.read(), KEYWORDS)
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
138
assert type(section) == dict
140
assert type(rule) == str
142
_ParseOutcomeList(rule, section[rule], wildcards, variables)
144
_ParseOutcomeList(rule, section[rule], rules, variables)
145
return rules, wildcards