diff options
author | Justin Giorgi <jgiorgi@google.com> | 2017-06-13 14:24:00 -0700 |
---|---|---|
committer | Justin Giorgi <jgiorgi@google.com> | 2017-06-16 20:35:23 +0000 |
commit | 504a704fbfc1bdf68a1d7eb59e951d415bfe68e9 (patch) | |
tree | fccf6cc5160d09313a76113b7e4e42fc13632806 /src/com/android/tradefed/targetprep | |
parent | c87467bf1b7be7cd0e796412c8c06fa08f3ef779 (diff) | |
download | tradefederation-504a704fbfc1bdf68a1d7eb59e951d415bfe68e9.tar.gz |
Throw exceptions when APKs are missing/unreadable.
Test: Added unit tests.
Bug: b/62573359
Change-Id: I9a4c0d9f6f671e494bd71efc561c86bc7268f6a3
(cherry picked from commit 8a791d1216b95ba9c8fab8ff7d4e63cb548715eb)
Diffstat (limited to 'src/com/android/tradefed/targetprep')
-rw-r--r-- | src/com/android/tradefed/targetprep/TestAppInstallSetup.java | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/src/com/android/tradefed/targetprep/TestAppInstallSetup.java b/src/com/android/tradefed/targetprep/TestAppInstallSetup.java index 166925ee4..eab1b5db3 100644 --- a/src/com/android/tradefed/targetprep/TestAppInstallSetup.java +++ b/src/com/android/tradefed/targetprep/TestAppInstallSetup.java @@ -60,6 +60,12 @@ public class TestAppInstallSetup implements ITargetCleaner, IAbiReceiver { importance = Importance.IF_UNSET) private Collection<String> mTestFileNames = new ArrayList<String>(); + @Option( + name = "throw-if-not-found", + description = "Throw exception if the specified file is not found." + ) + private boolean mThrowIfNoFile = true; + @Option(name = AbiFormatter.FORCE_ABI_STRING, description = AbiFormatter.FORCE_ABI_DESCRIPTION, importance = Importance.IF_UNSET) @@ -160,12 +166,24 @@ public class TestAppInstallSetup implements ITargetCleaner, IAbiReceiver { } File testAppFile = getLocalPathForFilename(buildInfo, testAppName, device); if (testAppFile == null) { - CLog.d("Test app %s was not found", testAppName); - continue; + if (mThrowIfNoFile) { + throw new TargetSetupError( + String.format("Test app %s was not found.", testAppName), + device.getDeviceDescriptor()); + } else { + CLog.d("Test app %s was not found.", testAppName); + continue; + } } if (!testAppFile.canRead()) { - CLog.d("Could not read file %s", testAppName); - continue; + if (mThrowIfNoFile) { + throw new TargetSetupError( + String.format("Could not read file %s.", testAppName), + device.getDeviceDescriptor()); + } else { + CLog.d("Could not read file %s.", testAppName); + continue; + } } // resolve abi flags if (mAbi != null && mForceAbi != null) { |