deps: update v8 to 4.3.61.21
[platform/upstream/nodejs.git] / deps / v8 / tools / testrunner / local / statusfile.py
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
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:
30 SKIP = "SKIP"
31 FAIL = "FAIL"
32 PASS = "PASS"
33 OKAY = "OKAY"
34 TIMEOUT = "TIMEOUT"
35 CRASH = "CRASH"
36 SLOW = "SLOW"
37 FLAKY = "FLAKY"
38 FAST_VARIANTS = "FAST_VARIANTS"
39 NO_VARIANTS = "NO_VARIANTS"
40 # These are just for the status files and are mapped below in DEFS:
41 FAIL_OK = "FAIL_OK"
42 PASS_OR_FAIL = "PASS_OR_FAIL"
43
44 ALWAYS = "ALWAYS"
45
46 KEYWORDS = {}
47 for key in [SKIP, FAIL, PASS, OKAY, TIMEOUT, CRASH, SLOW, FLAKY, FAIL_OK,
48             FAST_VARIANTS, NO_VARIANTS, PASS_OR_FAIL, ALWAYS]:
49   KEYWORDS[key] = key
50
51 DEFS = {FAIL_OK: [FAIL, OKAY],
52         PASS_OR_FAIL: [PASS, FAIL]}
53
54 # Support arches, modes to be written as keywords instead of strings.
55 VARIABLES = {ALWAYS: True}
56 for var in ["debug", "release", "big", "little",
57             "android_arm", "android_arm64", "android_ia32", "android_x87",
58             "android_x64", "arm", "arm64", "ia32", "mips", "mipsel",
59             "mips64el", "x64", "x87", "nacl_ia32", "nacl_x64", "ppc", "ppc64",
60             "macos", "windows", "linux", "aix"]:
61   VARIABLES[var] = var
62
63
64 def DoSkip(outcomes):
65   return SKIP in outcomes
66
67
68 def IsSlow(outcomes):
69   return SLOW in outcomes
70
71
72 def OnlyStandardVariant(outcomes):
73   return NO_VARIANTS in outcomes
74
75
76 def OnlyFastVariants(outcomes):
77   return FAST_VARIANTS in outcomes
78
79
80 def IsFlaky(outcomes):
81   return FLAKY in outcomes
82
83
84 def IsPassOrFail(outcomes):
85   return ((PASS in outcomes) and (FAIL in outcomes) and
86           (not CRASH in outcomes) and (not OKAY in outcomes))
87
88
89 def IsFailOk(outcomes):
90     return (FAIL in outcomes) and (OKAY in outcomes)
91
92
93 def _AddOutcome(result, new):
94   global DEFS
95   if new in DEFS:
96     mapped = DEFS[new]
97     if type(mapped) == list:
98       for m in mapped:
99         _AddOutcome(result, m)
100     elif type(mapped) == str:
101       _AddOutcome(result, mapped)
102   else:
103     result.add(new)
104
105
106 def _ParseOutcomeList(rule, outcomes, target_dict, variables):
107   result = set([])
108   if type(outcomes) == str:
109    outcomes = [outcomes]
110   for item in outcomes:
111     if type(item) == str:
112       _AddOutcome(result, item)
113     elif type(item) == list:
114       if not eval(item[0], variables): continue
115       for outcome in item[1:]:
116         assert type(outcome) == str
117         _AddOutcome(result, outcome)
118     else:
119       assert False
120   if len(result) == 0: return
121   if rule in target_dict:
122     target_dict[rule] |= result
123   else:
124     target_dict[rule] = result
125
126
127 def ReadStatusFile(path, variables):
128   with open(path) as f:
129     global KEYWORDS
130     contents = eval(f.read(), KEYWORDS)
131
132   rules = {}
133   wildcards = {}
134   variables.update(VARIABLES)
135   for section in contents:
136     assert type(section) == list
137     assert len(section) == 2
138     if not eval(section[0], variables): continue
139     section = section[1]
140     assert type(section) == dict
141     for rule in section:
142       assert type(rule) == str
143       if rule[-1] == '*':
144         _ParseOutcomeList(rule, section[rule], wildcards, variables)
145       else:
146         _ParseOutcomeList(rule, section[rule], rules, variables)
147   return rules, wildcards