aboutsummaryrefslogtreecommitdiff
path: root/debug_info_test/debug_info_test.py
diff options
context:
space:
mode:
authorTing-Yuan Huang <laszio@chromium.org>2018-02-28 14:35:48 -0800
committerchrome-bot <chrome-bot@chromium.org>2018-03-02 20:47:16 -0800
commit340542b21c30cd62a68d19f086edef36d849971b (patch)
treecae122ce8c6126141c298516d0575a067a9efe7d /debug_info_test/debug_info_test.py
parentedcf3d33a602438104cafd76f534fa8007e9de7b (diff)
downloadtoolchain-utils-340542b21c30cd62a68d19f086edef36d849971b.tar.gz
debug_info_test: Run tests based on debug info
debug_info_test calls tests on the given ELF files. When a directory is supplied, all ELFs will be searched and tested recursively. BUG=chromium:817648 TEST=debug_info_test /build/kip/usr/lib/debug Change-Id: Ibcb1ac2de19df9227eb6e242d611ec841d4b589f Reviewed-on: https://chromium-review.googlesource.com/942465 Commit-Ready: Ting-Yuan Huang <laszio@chromium.org> Tested-by: Ting-Yuan Huang <laszio@chromium.org> Reviewed-by: Ting-Yuan Huang <laszio@chromium.org> Reviewed-by: Yunlian Jiang <yunlian@chromium.org>
Diffstat (limited to 'debug_info_test/debug_info_test.py')
-rwxr-xr-xdebug_info_test/debug_info_test.py53
1 files changed, 53 insertions, 0 deletions
diff --git a/debug_info_test/debug_info_test.py b/debug_info_test/debug_info_test.py
new file mode 100755
index 00000000..cf3148db
--- /dev/null
+++ b/debug_info_test/debug_info_test.py
@@ -0,0 +1,53 @@
+#!/usr/bin/python
+
+# Copyright 2018 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import os
+import subprocess
+import sys
+
+import check_cus
+
+elf_checks = [check_cus.check_compile_units]
+
+def scanelf(root):
+ """find ELFs in root
+
+ Args:
+ root: root dir to start with the search.
+ Returns:
+ Filenames of ELFs in root.
+ """
+ p = subprocess.Popen(['scanelf', '-y', '-B', '-F', '%F', '-R', root],
+ stdout=subprocess.PIPE)
+ return [l.strip() for l in p.stdout]
+
+def Main(argv):
+ if len(argv) < 2:
+ print('usage: %s [file|dir]')
+ return 1
+
+ files = []
+ cand = argv[1]
+ if os.path.isfile(cand):
+ files = [cand]
+ elif os.path.isdir(cand):
+ files = scanelf(cand)
+ else:
+ print('usage: %s [file|dir]')
+ return 1
+
+ failed = False
+ for f in files:
+ for c in elf_checks:
+ if not c(f):
+ failed = True
+
+ if failed:
+ return 1
+ return 0
+
+if __name__ == '__main__':
+ sys.exit(Main(sys.argv))