Matt Nelson
05/17/2025, 2:17 PMjw
05/17/2025, 2:42 PMjw
05/17/2025, 2:43 PMjw
05/17/2025, 2:56 PM// The exit code of a command is not available through ddmlib. Additionally, on older devices,
// 'adb shell' always returns 0 as an exit code even when the real value was non-zero.
// We print the exit code so it can be read from stdout to work around both problems.
val output = device.executeShellCommand(
"dalvikvm $extraArgs -classpath $DEVICE_DEX_PATH $entryPoint; echo $?")
// Those problematic older devices also write exceptions to stdout instead of stderr. Take the
// last non-empty stdout line to parse as the exit code.
val exitCodeString = output.trim().lines().last()
return exitCodeString == "0"jw
05/17/2025, 2:56 PMhfhbd
05/18/2025, 9:15 AMMatt Nelson
05/18/2025, 12:04 PMjniLibs
such that my instrumentation tests on the emulator run em via java.lang.Process
after locating them in Context.applicationInfo.nativeLibraryDir
.
Am able to pass in expected test values via process environment variables and what not, too.
Check it out!
https://github.com/05nelsonm/kmp-file/pull/85/commits/390f40e9749bff7d679567127c883b206ab00dc0