1
1
#!/usr/bin/env python3
2
2
#
3
- # Copyright (C) 202121 The Android Open Source Project
3
+ # Copyright (C) 2021 The Android Open Source Project
4
4
#
5
5
# Licensed under the Apache License, Version 2.0 (the "License");
6
6
# you may not use this file except in compliance with the License.
32
32
# or from all processes on the device:
33
33
# $ acov-llvm.py flush
34
34
#
35
- # 4. pull coverage from device and generate coverage report
35
+ # 4. Pull coverage from device and generate coverage report
36
36
# $ acov-llvm.py report -s <one-or-more-source-paths-in-$ANDROID_BUILD_TOP \
37
37
# -b <one-or-more-binaries-in-$OUT> \
38
38
# E.g.:
39
- # development/scripts/ acov-llvm.py report \
39
+ # acov-llvm.py report \
40
40
# -s bionic \
41
41
# -b \
42
42
# $OUT/symbols/apex/com.android.runtime/lib/bionic/libc.so \
@@ -84,9 +84,19 @@ def check_output(cmd, *args, **kwargs):
84
84
cmd , * args , ** kwargs , check = True , stdout = subprocess .PIPE ).stdout
85
85
86
86
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
+
87
97
def adb_shell (cmd , * args , ** kwargs ):
88
98
"""call 'adb shell <cmd>' with logging."""
89
- return check_output ([ 'adb' , 'shell' ] + cmd , * args , ** kwargs )
99
+ return adb ([ 'shell' ] + cmd , * args , ** kwargs )
90
100
91
101
92
102
def send_flush_signal (pids = None ):
@@ -123,7 +133,7 @@ def _has_handler_sig37(pid):
123
133
124
134
125
135
def do_clean_device (args ):
126
- adb_shell ([ 'root' ] )
136
+ adb_root ( )
127
137
128
138
logging .info ('resetting coverage on device' )
129
139
send_flush_signal ()
@@ -137,7 +147,7 @@ def do_clean_device(args):
137
147
138
148
139
149
def do_flush (args ):
140
- adb_shell ([ 'root' ] )
150
+ adb_root ( )
141
151
142
152
if args .procnames :
143
153
pids = adb_shell (['pidof' ] + args .procnames , text = True ).split ()
@@ -154,7 +164,7 @@ def do_flush(args):
154
164
155
165
156
166
def do_report (args ):
157
- adb_shell ([ 'root' ] )
167
+ adb_root ( )
158
168
159
169
temp_dir = tempfile .mkdtemp (
160
170
prefix = 'covreport-' , dir = os .environ .get ('ANDROID_BUILD_TOP' , None ))
0 commit comments