Add script that will print hanging tests given the output from the bots

Will search for tests that has a 'Start executing test ...' but no
corresponding 'Done executing test ...'

Change-Id: I1d307c7d711eb2b05ce5fa051dcf73812589ca01
diff --git a/tools/find_haning_test.py b/tools/find_haning_test.py
new file mode 100755
index 0000000..29e78aa
--- /dev/null
+++ b/tools/find_haning_test.py
@@ -0,0 +1,50 @@
+#!/usr/bin/env python
+# Copyright (c) 2019, the R8 project authors. Please see the AUTHORS file
+# for details. All rights reserved. Use of this source code is governed by a
+# BSD-style license that can be found in the LICENSE file.
+
+import argparse
+import sys
+import urllib
+
+def ParseOptions():
+  parser = argparse.ArgumentParser(
+      description = 'Find tests started but not done from bot stdout.')
+  return parser.parse_known_args()
+
+def get_started(stdout):
+  # Lines look like:
+  # Start executing test runBigInteger_ZERO_A01 [com.android.tools.r8.jctf.r8cf.math.BigInteger.ZERO.BigInteger_ZERO_A01]
+  start_lines = []
+  for line in stdout:
+    if line.startswith('Start executing test'):
+      split = line.split(' ')
+      start_lines.append('%s %s' % (split[3], split[4].strip()))
+  return start_lines
+
+def get_ended(stdout):
+  # Lines look like:
+  # Done executing test runBigInteger_subtract_A01 [com.android.tools.r8.jctf.r8cf.math.BigInteger.subtractLjava_math_BigInteger.BigInteger_subtract_A01] with result: SUCCESS
+  done_lines = []
+  for line in stdout:
+    if line.startswith('Done executing test'):
+      split = line.split(' ')
+      done_lines.append('%s %s' % (split[3], split[4].strip()))
+  return done_lines
+
+def Main():
+  (options, args) = ParseOptions()
+  if len(args) != 1:
+    raise "fail"
+
+  with open(args[0], 'r') as f:
+    lines = f.readlines()
+  started = get_started(lines)
+  ended = get_ended(lines)
+  for test in started:
+    if not test in ended:
+      print 'Test %s started but did not end' % test
+
+
+if __name__ == '__main__':
+  sys.exit(Main())