Skipping device reboot after managed profile apps installation. am: e6f8d45ec4 am: 7c24d7dec6 am: 3e520918ff am: bb826e6518 am: 08c8650ef1
Original change: https://android-review.googlesource.com/c/platform/tools/tradefederation/contrib/+/2777549
Change-Id: I09bd6da1b22f7f9316a45ecca6b9bd8ad7d3be0a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/src/com/android/performance/tests/BootTimeTest.java b/src/com/android/performance/tests/BootTimeTest.java
index 1ef102b..ec9aa99 100644
--- a/src/com/android/performance/tests/BootTimeTest.java
+++ b/src/com/android/performance/tests/BootTimeTest.java
@@ -109,7 +109,7 @@
private static final String LOGCAT_FILE = "Successive_reboots_logcat";
private static final String LOGCAT_UNLOCK_FILE = "Successive_reboots_unlock_logcat";
private static final String BOOT_COMPLETE_ACTION = "sys.boot_completed=1";
- private static final String RUNNER = "android.support.test.runner.AndroidJUnitRunner";
+ private static final String RUNNER = "androidx.test.runner.AndroidJUnitRunner";
private static final String PACKAGE_NAME = "com.android.boothelper";
private static final String CLASS_NAME = "com.android.boothelper.BootHelperTest";
private static final String SETUP_PIN_TEST = "setupLockScreenPin";
@@ -192,6 +192,8 @@
"Logging for this PID.*\\s+([0-9]+)$",
Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);
+ private static final String METRIC_COUNT = "MetricCount";
+
@Option(name = "test-run-name", description = "run name to report to result reporters")
private String mTestRunName = BOOTTIME_TEST;
@@ -245,6 +247,12 @@
private long mBootDelayTime = 2000;
@Option(
+ name = "after-boot-delay",
+ isTimeVal = true,
+ description = "Time to wait immediately after the successive boots.")
+ private long mAfterBootDelayTime = 0;
+
+ @Option(
name = "post-initial-boot-idle",
isTimeVal = true,
description =
@@ -334,6 +342,13 @@
description = "Run logcat --statistics command and collect data")
private boolean mCollectLogcat = false;
+ @Option(
+ name = "metric-prefix-pattern-for-count",
+ description =
+ "A list of metric prefix pattern that will be used to count number of metrics"
+ + " generated in the test")
+ private List<String> mMetricPrefixPatternForCount = new ArrayList<>();
+
private IBuildInfo mBuildInfo;
private IConfiguration mConfiguration;
private TestInformation mTestInfo;
@@ -620,8 +635,15 @@
double onlineTime = INVALID_TIME_DURATION;
double bootTime = INVALID_TIME_DURATION;
String testId = String.format("%s.%s$%d", BOOTTIME_TEST, BOOTTIME_TEST, (count + 1));
- TestDescription successiveBootIterationTestId =
- new TestDescription(testId, String.format("%s", SUCCESSIVE_BOOT_TEST));
+ TestDescription successiveBootIterationTestId;
+ if (!dismissPin) {
+ successiveBootIterationTestId =
+ new TestDescription(testId, String.format("%s", SUCCESSIVE_BOOT_TEST));
+ } else {
+ successiveBootIterationTestId =
+ new TestDescription(
+ testId, String.format("%s", SUCCESSIVE_BOOT_UNLOCK_TEST));
+ }
if (mBootTimePerIteration) {
listener.testStarted(successiveBootIterationTestId);
}
@@ -677,12 +699,13 @@
if (mBootloaderInfo) analyzeBootloaderTimingInfo();
if (dismissPin) {
+ getRunUtil().sleep(2000);
mRunner = createRemoteAndroidTestRunner(UNLOCK_PIN_TEST);
getDevice().runInstrumentationTests(mRunner, new CollectingTestListener());
- // Wait for 15 secs after every unlock to make sure home screen is loaded
- // and logs are printed
- getRunUtil().sleep(15000);
}
+
+ CLog.v("Waiting for %d msecs immediately after successive boot.", mAfterBootDelayTime);
+ getRunUtil().sleep(mAfterBootDelayTime);
if (onlineTime != INVALID_TIME_DURATION) {
if (mBootInfo.containsKey(SUCCESSIVE_ONLINE)) {
mBootInfo.get(SUCCESSIVE_ONLINE).add(onlineTime);
@@ -739,6 +762,22 @@
if (!collectLogcatInfoResult.isEmpty()) {
iterationResult.putAll(collectLogcatInfoResult);
}
+ // If metric-prefix-pattern-for-count is present, calculate the count
+ // of all metrics with the prefix pattern and add the count as a new metric to the
+ // iterationResult map.
+ if (!mMetricPrefixPatternForCount.isEmpty()) {
+ for (String metricPrefixPattern : mMetricPrefixPatternForCount) {
+ long metricCount =
+ iterationResult.entrySet().stream()
+ .filter(
+ (entry) ->
+ entry.getKey()
+ .startsWith(metricPrefixPattern))
+ .count();
+ iterationResult.put(
+ metricPrefixPattern + METRIC_COUNT, Long.toString(metricCount));
+ }
+ }
listener.testEnded(successiveBootIterationTestId, iterationResult);
}
@@ -848,10 +887,13 @@
Matcher matcherPid = LOGCAT_STATISTICS_PID_PATTERN.matcher(outputList[i]);
pidFound = matcherPid.find();
if (!pidFound) continue;
- CLog.d("logcat statistics pid %d output = %s", pid, outputList[i]);
+ CLog.d(
+ "Process %s with pid %d : logcat statistics output = %s",
+ processName, pid, outputList[i]);
results.put(
String.join(METRIC_KEY_SEPARATOR, LOGCAT_STATISTICS_SIZE, processName),
matcherPid.group(1).trim());
+ break;
}
if (!pidFound) {
// the process doesn't found in the logcat statistics output
@@ -860,7 +902,6 @@
processName, pid);
}
}
-
return results;
}