|
| 1 | +# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +import sys |
| 16 | +import re |
| 17 | + |
| 18 | + |
| 19 | +def escape(input): |
| 20 | + o = input.replace("\n", "") |
| 21 | + o = o.replace("\r", "") |
| 22 | + return o |
| 23 | + |
| 24 | + |
| 25 | +def main(): |
| 26 | + usage = """Usage: |
| 27 | +1. Download the Paddle_PR_CI_*.log from TeamCity |
| 28 | +2. run: python check_ctest_hung.py Paddle_PR_CI_*.log |
| 29 | +3. If there is hung ctest, the result likes: |
| 30 | +Diff: set(['test_parallel_executor_crf']) |
| 31 | + """ |
| 32 | + if len(sys.argv) < 2: |
| 33 | + print(usage) |
| 34 | + exit(0) |
| 35 | + |
| 36 | + logfile = sys.argv[1] |
| 37 | + started = set() |
| 38 | + passed = set() |
| 39 | + with open(logfile, "r") as fn: |
| 40 | + for l in fn.readlines(): |
| 41 | + if l.find("Test ") != -1 and \ |
| 42 | + l.find("Passed") != -1: |
| 43 | + m = re.search("Test\s+#[0-9]*\:\s([a-z0-9_]+)", escape(l)) |
| 44 | + passed.add(m.group(1)) |
| 45 | + if l.find("Start ") != -1: |
| 46 | + start_parts = escape(l).split(" ") |
| 47 | + m = re.search("Start\s+[0-9]+\:\s([a-z0-9_]+)", escape(l)) |
| 48 | + started.add(m.group(1)) |
| 49 | + print "Diff: ", started - passed |
| 50 | + |
| 51 | + |
| 52 | +if __name__ == "__main__": |
| 53 | + main() |
0 commit comments