Merge "Merge remote-tracking branch oreo-mr1-cts-dev into master"
diff --git a/prod-tests/src/com/android/performance/tests/EmmcPerformanceTest.java b/prod-tests/src/com/android/performance/tests/EmmcPerformanceTest.java
index 81eebc2..cc264df 100644
--- a/prod-tests/src/com/android/performance/tests/EmmcPerformanceTest.java
+++ b/prod-tests/src/com/android/performance/tests/EmmcPerformanceTest.java
@@ -349,6 +349,9 @@
* Setup the device for tests by unmounting partitions and maxing the cpu speed.
*/
private void setUp() throws DeviceNotAvailableException {
+ if (mAutoDiscoverCacheInfo) {
+ discoverCacheInfo();
+ }
mTestDevice.executeShellCommand("umount /sdcard");
mTestDevice.executeShellCommand("umount /data");
mTestDevice.executeShellCommand("umount /cache");
@@ -365,51 +368,52 @@
}
mSpUtil.setArgumentList(mSimpleperfArgu);
}
+ }
- if (mAutoDiscoverCacheInfo) {
- // Attempt to detect cache path automatically
- // Expected output look similar to the following:
- //
- // > ... vdc dump | grep cache
- // 0 4123 /dev/block/platform/soc/7824900.sdhci/by-name/cache /cache ext4 rw, \
- // seclabel,nosuid,nodev,noatime,discard,data=ordered 0 0
- if (mTestDevice.enableAdbRoot()) {
- String output = mTestDevice.executeShellCommand("vdc dump | grep cache");
- CLog.d("Output from shell command 'vdc dump | grep cache': %s", output);
- String[] segments = output.split("\\s+");
- if (segments.length >= 3) {
- mCache = segments[2];
- } else {
- CLog.w("Fail to detect cache path. Fall back to use '%s'", mCache);
- }
+ /**
+ * Attempt to detect cache path and cache partition size automatically
+ */
+ private void discoverCacheInfo() throws DeviceNotAvailableException {
+ // Expected output look similar to the following:
+ //
+ // > ... vdc dump | grep cache
+ // 0 4123 /dev/block/platform/soc/7824900.sdhci/by-name/cache /cache ext4 rw, \
+ // seclabel,nosuid,nodev,noatime,discard,data=ordered 0 0
+ if (mTestDevice.enableAdbRoot()) {
+ String output = mTestDevice.executeShellCommand("vdc dump | grep cache");
+ CLog.d("Output from shell command 'vdc dump | grep cache':\n%s", output);
+ String[] segments = output.split("\\s+");
+ if (segments.length >= 3) {
+ mCache = segments[2];
} else {
- CLog.d("Cannot get cache path because device %s is not rooted.",
- mTestDevice.getSerialNumber());
+ CLog.w("Fail to detect cache path. Fall back to use '%s'", mCache);
}
+ } else {
+ CLog.d("Cannot get cache path because device %s is not rooted.",
+ mTestDevice.getSerialNumber());
+ }
- // Attempt to detect cache partition size automatically
- // Expected output looks similar to the following:
- //
- // > ... df cache
- // Filesystem 1K-blocks Used Available Use% Mounted on
- // /dev/block/mmcblk0p34 60400 56 60344 1% /cache
- String output = mTestDevice.executeShellCommand("df cache");
- CLog.d(String.format("Output from shell command 'df cache':\n%s", output));
- String[] lines = output.split("\r?\n");
- if (lines.length >= 2) {
- String[] segments = lines[1].split("\\s+");
- if (segments.length >= 2) {
- if (lines[0].toLowerCase().contains("1k-blocks")) {
- mCachePartitionSize = Integer.parseInt(segments[1]) / 1024;
- } else {
- throw new IllegalArgumentException("Unknown unit for the cache size.");
- }
+ // Expected output looks similar to the following:
+ //
+ // > ... df cache
+ // Filesystem 1K-blocks Used Available Use% Mounted on
+ // /dev/block/mmcblk0p34 60400 56 60344 1% /cache
+ String output = mTestDevice.executeShellCommand("df cache");
+ CLog.d(String.format("Output from shell command 'df cache':\n%s", output));
+ String[] lines = output.split("\r?\n");
+ if (lines.length >= 2) {
+ String[] segments = lines[1].split("\\s+");
+ if (segments.length >= 2) {
+ if (lines[0].toLowerCase().contains("1k-blocks")) {
+ mCachePartitionSize = Integer.parseInt(segments[1]) / 1024;
+ } else {
+ throw new IllegalArgumentException("Unknown unit for the cache size.");
}
}
-
- CLog.d("cache-device is set to %s ...", mCache);
- CLog.d("cache-partition-size is set to %d ...", mCachePartitionSize);
}
+
+ CLog.d("cache-device is set to %s ...", mCache);
+ CLog.d("cache-partition-size is set to %d ...", mCachePartitionSize);
}
/**
diff --git a/src/com/android/tradefed/targetprep/InstrumentationPreparer.java b/src/com/android/tradefed/targetprep/InstrumentationPreparer.java
index d86219b..37e48bb 100644
--- a/src/com/android/tradefed/targetprep/InstrumentationPreparer.java
+++ b/src/com/android/tradefed/targetprep/InstrumentationPreparer.java
@@ -60,26 +60,26 @@
description="The test method name to run.")
private String mMethodName = null;
- /**
- * @deprecated use shell-timeout or test-timeout option instead.
- */
- @Deprecated
- @Option(name = "timeout",
- description="Deprecated - Use \"shell-timeout\" or \"test-timeout\" instead.")
- private Integer mTimeout = null;
+ @Option(
+ name = "shell-timeout",
+ description =
+ "The defined timeout (in milliseconds) is used as a maximum waiting time "
+ + "when expecting the command output from the device. At any time, if the "
+ + "shell command does not output anything for a period longer than defined "
+ + "timeout the TF run terminates. For no timeout, set to 0.",
+ isTimeVal = true
+ )
+ private long mShellTimeout = 10 * 60 * 1000L; // default to 10 minutes
- @Option(name = "shell-timeout",
- description="The defined timeout (in milliseconds) is used as a maximum waiting time "
- + "when expecting the command output from the device. At any time, if the "
- + "shell command does not output anything for a period longer than defined "
- + "timeout the TF run terminates. For no timeout, set to 0.")
- private long mShellTimeout = 10 * 60 * 1000; // default to 10 minutes
-
- @Option(name = "test-timeout",
- description="Sets timeout (in milliseconds) that will be applied to each test. In the "
- + "event of a test timeout it will log the results and proceed with executing "
- + "the next test. For no timeout, set to 0.")
- private int mTestTimeout = 10 * 60 * 1000; // default to 10 minutes
+ @Option(
+ name = "test-timeout",
+ description =
+ "Sets timeout (in milliseconds) that will be applied to each test. In the "
+ + "event of a test timeout it will log the results and proceed with executing "
+ + "the next test. For no timeout, set to 0.",
+ isTimeVal = true
+ )
+ private long mTestTimeout = 10 * 60 * 1000L; // default to 10 minutes
@Option(name = "instrumentation-arg",
description = "Instrumentation arguments to provide.")
@@ -90,9 +90,12 @@
"The max number of attempts to make to run the instrumentation successfully.")
private int mAttempts = 1;
- @Option(name = "delay-before-retry",
- description = "Time to delay before retrying another instrumentation attempt, in msecs")
- private long mRetryDelayMs = 0;
+ @Option(
+ name = "delay-before-retry",
+ description = "Time to delay before retrying another instrumentation attempt.",
+ isTimeVal = true
+ )
+ private long mRetryDelayMs = 0L;
@Override
public void setUp(ITestDevice device, IBuildInfo buildInfo) throws TargetSetupError, BuildError,
@@ -125,11 +128,6 @@
test.setRunnerName(mRunnerName);
test.setClassName(mClassName);
test.setMethodName(mMethodName);
- if (mTimeout != null) {
- CLog.w("\"timeout\" argument is deprecated and should not be used! \"shell-timeout\""
- + " argument value is overwritten with %d ms", mTimeout);
- setShellTimeout(mTimeout);
- }
test.setShellTimeout(mShellTimeout);
test.setTestTimeout(mTestTimeout);
for (Map.Entry<String, String> entry : mInstrArgMap.entrySet()) {
diff --git a/src/com/android/tradefed/testtype/InstrumentationTest.java b/src/com/android/tradefed/testtype/InstrumentationTest.java
index fac7099..788c2e8 100644
--- a/src/com/android/tradefed/testtype/InstrumentationTest.java
+++ b/src/com/android/tradefed/testtype/InstrumentationTest.java
@@ -114,7 +114,7 @@
+ "timeout the TF run terminates. For no timeout, set to 0.",
isTimeVal = true
)
- private long mShellTimeout = 10 * 60 * 1000; // default to 10 minutes
+ private long mShellTimeout = 10 * 60 * 1000L; // default to 10 minutes
@Option(
name = "test-timeout",
@@ -124,7 +124,7 @@
+ "next test. For no timeout, set to 0.",
isTimeVal = true
)
- private long mTestTimeout = 5 * 60 * 1000; // default to 5 minutes
+ private long mTestTimeout = 5 * 60 * 1000L; // default to 5 minutes
@Option(
name = "max-timeout",
@@ -385,10 +385,8 @@
mShellTimeout = timeout;
}
- /**
- * Optionally, set the maximum time (in milliseconds) for each individual test run.
- */
- public void setTestTimeout(int timeout) {
+ /** Optionally, set the maximum time (in milliseconds) for each individual test run. */
+ public void setTestTimeout(long timeout) {
mTestTimeout = timeout;
}
diff --git a/src/com/android/tradefed/util/AaptParser.java b/src/com/android/tradefed/util/AaptParser.java
index a69dd7e..58a8b39 100644
--- a/src/com/android/tradefed/util/AaptParser.java
+++ b/src/com/android/tradefed/util/AaptParser.java
@@ -103,21 +103,31 @@
* @return the {@link AaptParser} or <code>null</code> if failed to extract the information
*/
public static AaptParser parse(File apkFile) {
- CommandResult result = RunUtil.getDefault().runTimedCmd(AAPT_TIMEOUT_MS,
- "aapt", "dump", "badging", apkFile.getAbsolutePath());
+ CommandResult result =
+ RunUtil.getDefault()
+ .runTimedCmdRetry(
+ AAPT_TIMEOUT_MS,
+ 0L,
+ 2,
+ "aapt",
+ "dump",
+ "badging",
+ apkFile.getAbsolutePath());
String stderr = result.getStderr();
- if (stderr != null && stderr.length() > 0) {
+ if (stderr != null && !stderr.isEmpty()) {
CLog.e("aapt dump badging stderr: %s", stderr);
}
- if (result.getStatus() == CommandStatus.SUCCESS) {
+ if (CommandStatus.SUCCESS.equals(result.getStatus())) {
AaptParser p = new AaptParser();
if (p.parse(result.getStdout()))
return p;
return null;
}
- CLog.e("Failed to run aapt on %s", apkFile.getAbsoluteFile());
+ CLog.e(
+ "Failed to run aapt on %s. stdout: %s",
+ apkFile.getAbsoluteFile(), result.getStdout());
return null;
}