summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorParth Sane <parthsane@google.com>2024-03-18 15:39:05 +0000
committerParth Sane <parthsane@google.com>2024-03-19 16:44:59 +0000
commit649ef16dc2c4563b809b8bb8acb54806d380630e (patch)
tree93f39d8186b9f6ce6dd2c29905af789b836e3da1
parent1b62c4b8f76854e617941e3fcddeccef97a4191e (diff)
downloadplatform_testing-649ef16dc2c4563b809b8bb8acb54806d380630e.tar.gz
Change dittobench output to logcat and don't wait for completion
Bug: 326389812 Test: Tested on forrest Change-Id: I62f7a9c8ffdb4696e9c5ee2dc307bf841496eada
-rw-r--r--libraries/health/rules/src/android/platform/test/rule/DittoBenchRule.java17
1 files changed, 16 insertions, 1 deletions
diff --git a/libraries/health/rules/src/android/platform/test/rule/DittoBenchRule.java b/libraries/health/rules/src/android/platform/test/rule/DittoBenchRule.java
index 94f4c5008..a7f9612f8 100644
--- a/libraries/health/rules/src/android/platform/test/rule/DittoBenchRule.java
+++ b/libraries/health/rules/src/android/platform/test/rule/DittoBenchRule.java
@@ -15,23 +15,33 @@
*/
package android.platform.test.rule;
+import android.app.UiAutomation;
+import android.os.ParcelFileDescriptor;
+
import androidx.annotation.VisibleForTesting;
+import androidx.test.InstrumentationRegistry;
import org.junit.runner.Description;
+import java.io.IOException;
+
/** This rule will start dittobench using the provided config. */
public class DittoBenchRule extends TestWatcher {
@VisibleForTesting static final String DITTOBENCH_PATH = "dittobench-path";
@VisibleForTesting static final String DITTO_CONFIG_PATH = "ditto-config-path";
String mDittoBenchPath = "/data/local/tmp/dittobench";
String mDittoConfigPath = "/data/local/tmp/config.ditto";
+ ParcelFileDescriptor mOutputFd;
@Override
protected void starting(Description description) {
mDittoBenchPath = getArguments().getString(DITTOBENCH_PATH, "/data/local/tmp/dittobench");
mDittoConfigPath =
getArguments().getString(DITTO_CONFIG_PATH, "/data/local/tmp/config.ditto");
- executeShellCommand(mDittoBenchPath + " " + mDittoConfigPath);
+ String cmd = mDittoBenchPath + " " + mDittoConfigPath + " --log=logcat &";
+ UiAutomation uiAutomation = InstrumentationRegistry.getInstrumentation().getUiAutomation();
+ uiAutomation.adoptShellPermissionIdentity();
+ mOutputFd = uiAutomation.executeShellCommand(cmd);
}
@Override
@@ -42,5 +52,10 @@ public class DittoBenchRule extends TestWatcher {
String dittoBinaryName = splitPath[splitPath.length - 1];
executeShellCommand("pkill " + dittoBinaryName);
}
+ try {
+ mOutputFd.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
}
}