aboutsummaryrefslogtreecommitdiff
path: root/debug_info_test/debug_info_test.py
diff options
context:
space:
mode:
authorSadaf Ebrahimi <sadafebrahimi@google.com>2022-11-11 23:35:38 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2022-11-11 23:35:38 +0000
commit40214b48188358a80b7478bfff21d4814dd9177c (patch)
tree77dc031614745bb406dbd90cea9a082a1b5cdd54 /debug_info_test/debug_info_test.py
parenta51582ad9cb50ec284f4718765bd5d31fa0069d4 (diff)
parent584b8e46d146a2bcfeffd64448a2d8e92904168d (diff)
downloadtoolchain-utils-40214b48188358a80b7478bfff21d4814dd9177c.tar.gz
Original change: https://android-review.googlesource.com/c/platform/external/toolchain-utils/+/2292563 Change-Id: Ida212764c332af8ba8ab8aaa62a7d2a007e3314e Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
Diffstat (limited to 'debug_info_test/debug_info_test.py')
-rwxr-xr-xdebug_info_test/debug_info_test.py87
1 files changed, 45 insertions, 42 deletions
diff --git a/debug_info_test/debug_info_test.py b/debug_info_test/debug_info_test.py
index ae7e9f48..c324bf4c 100755
--- a/debug_info_test/debug_info_test.py
+++ b/debug_info_test/debug_info_test.py
@@ -1,67 +1,70 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
-# Copyright 2018 The Chromium OS Authors. All rights reserved.
+# Copyright 2018 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Test for debug info."""
-from __future__ import print_function
import os
import subprocess
import sys
-import check_icf
import check_cus
import check_exist
+import check_icf
+
elf_checks = [
- check_exist.check_exist_all, check_cus.check_compile_units,
- check_icf.check_identical_code_folding
+ check_exist.check_exist_all,
+ check_cus.check_compile_units,
+ check_icf.check_identical_code_folding,
]
def scanelf(root):
- """Find ELFs in root.
+ """Find ELFs in root.
- Args:
- root: root dir to start with the search.
+ 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,
- encoding='utf-8')
- return [l.strip() for l in p.stdout]
+ Returns:
+ Filenames of ELFs in root.
+ """
+ p = subprocess.Popen(
+ ["scanelf", "-y", "-B", "-F", "%F", "-R", root],
+ stdout=subprocess.PIPE,
+ encoding="utf-8",
+ )
+ 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))
+ 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))