Commit a6e7608
committed
Fix issue with forwarding arguments with space
The Android Platform has a [very naive options parsing implemented within the instrumentation code](https://cs.android.com/android/platform/superproject/main/+/main:frameworks/base/cmds/am/src/com/android/commands/am/Am.java;l=160-204;drc=61197364367c9e404c7da6900658f1b16c42d0da;bpv=0;bpt=0?q=am.java&ss=android%2Fplatform%2Fsuperproject%2Fmain) where it assumes that arguments delimited by strings live in their own index (e.g. "am A B" is translated to 3 different strings of "am", "A", "B"). This is clearly illustrated by the usage of `opt.equals("..")` where spaces break that assumption. However, the bigger issue here is the error-reporting for this is horrible because it's being reported via `System.err` which the shell executor will give back to the Orchestrator, which puts it in a file that is not used at all! This behaviour should be changed and `stderr` must be printed out to the logcat. However, that's a separate issue
The previous trial to fix this have tried to throw an exception whenever white space was found. However, it seems that Kotlin allows test methods with space in them. In order to avoid falling into the same mistake, I did the following:
1. I avoided throwing an exception. This will allow unexpected corner-cases to keep working. However, if they are destined to fail then debugging will be a headache.
2. Only data that is ingested through `ORCHESTRATOR_FORWARDED_INSTRUMENTATION_ARGS` is processed. This is because keys can only exist in the value of that key, which is what can cause problems. Other sources of data don't need processing as they're not keys but values which the option parser can deal with.
PiperOrigin-RevId: 7591945851 parent c711332 commit a6e7608
File tree
4 files changed
+48
-2
lines changed- runner/android_test_orchestrator
- javatests/androidx/test/orchestrator
- java/androidx/test/orchestrator
4 files changed
+48
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
9 | 13 | | |
10 | 14 | | |
11 | 15 | | |
| |||
Lines changed: 15 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| |||
187 | 188 | | |
188 | 189 | | |
189 | 190 | | |
190 | | - | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
191 | 196 | | |
192 | 197 | | |
193 | 198 | | |
194 | 199 | | |
195 | 200 | | |
196 | 201 | | |
197 | | - | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
198 | 211 | | |
199 | 212 | | |
200 | 213 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| 58 | + | |
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
| |||
Lines changed: 28 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
202 | 203 | | |
203 | 204 | | |
204 | 205 | | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
205 | 233 | | |
206 | 234 | | |
207 | 235 | | |
| |||
0 commit comments