Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 9798898

Browse files
roland-levillainGerrit Code Review
authored andcommitted
Merge "Fix adb root invocations in script acov-llvm.py."
2 parents f205499 + d203b9e commit 9798898

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

scripts/acov-llvm.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
22
#
3-
# Copyright (C) 202121 The Android Open Source Project
3+
# Copyright (C) 2021 The Android Open Source Project
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.
@@ -32,11 +32,11 @@
3232
# or from all processes on the device:
3333
# $ acov-llvm.py flush
3434
#
35-
# 4. pull coverage from device and generate coverage report
35+
# 4. Pull coverage from device and generate coverage report
3636
# $ acov-llvm.py report -s <one-or-more-source-paths-in-$ANDROID_BUILD_TOP \
3737
# -b <one-or-more-binaries-in-$OUT> \
3838
# E.g.:
39-
# development/scripts/acov-llvm.py report \
39+
# acov-llvm.py report \
4040
# -s bionic \
4141
# -b \
4242
# $OUT/symbols/apex/com.android.runtime/lib/bionic/libc.so \
@@ -84,9 +84,19 @@ def check_output(cmd, *args, **kwargs):
8484
cmd, *args, **kwargs, check=True, stdout=subprocess.PIPE).stdout
8585

8686

87+
def adb(cmd, *args, **kwargs):
88+
"""call 'adb <cmd>' with logging."""
89+
return check_output(['adb'] + cmd, *args, **kwargs)
90+
91+
92+
def adb_root(*args, **kwargs):
93+
"""call 'adb root' with logging."""
94+
return adb(['root'], *args, **kwargs)
95+
96+
8797
def adb_shell(cmd, *args, **kwargs):
8898
"""call 'adb shell <cmd>' with logging."""
89-
return check_output(['adb', 'shell'] + cmd, *args, **kwargs)
99+
return adb(['shell'] + cmd, *args, **kwargs)
90100

91101

92102
def send_flush_signal(pids=None):
@@ -123,7 +133,7 @@ def _has_handler_sig37(pid):
123133

124134

125135
def do_clean_device(args):
126-
adb_shell(['root'])
136+
adb_root()
127137

128138
logging.info('resetting coverage on device')
129139
send_flush_signal()
@@ -137,7 +147,7 @@ def do_clean_device(args):
137147

138148

139149
def do_flush(args):
140-
adb_shell(['root'])
150+
adb_root()
141151

142152
if args.procnames:
143153
pids = adb_shell(['pidof'] + args.procnames, text=True).split()
@@ -154,7 +164,7 @@ def do_flush(args):
154164

155165

156166
def do_report(args):
157-
adb_shell(['root'])
167+
adb_root()
158168

159169
temp_dir = tempfile.mkdtemp(
160170
prefix='covreport-', dir=os.environ.get('ANDROID_BUILD_TOP', None))

0 commit comments

Comments
 (0)