summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-04-18 20:40:27 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-04-18 20:40:27 +0000
commit237b868db380ff5653d3acbc49f322ba7ed48c2e (patch)
treebcdbced18e359532fd74ab7b3697e8cd98ee864a
parent4da605aa3bc4207d456527897d45fe8e1a14bc68 (diff)
parent14f7f962572dc733aa03f1a6752f980a55046fbc (diff)
downloadStatsD-237b868db380ff5653d3acbc49f322ba7ed48c2e.tar.gz
Change-Id: I3b050230091d38b51f28ad756ccf93fb4e987e8b
-rw-r--r--tests/src/android/cts/statsd/alert/AnomalyDetectionTests.java17
-rw-r--r--tests/src/android/cts/statsd/atom/AtomTestCase.java8
2 files changed, 24 insertions, 1 deletions
diff --git a/tests/src/android/cts/statsd/alert/AnomalyDetectionTests.java b/tests/src/android/cts/statsd/alert/AnomalyDetectionTests.java
index f08a553e..ea47cc31 100644
--- a/tests/src/android/cts/statsd/alert/AnomalyDetectionTests.java
+++ b/tests/src/android/cts/statsd/alert/AnomalyDetectionTests.java
@@ -64,19 +64,34 @@ public class AnomalyDetectionTests extends AtomTestCase {
private static final int ANOMALY_EVENT_ID = 101;
private static final int INCIDENTD_SECTION = -1;
+ private boolean defaultSystemTracingConfigurationHasChanged = false;
+
@Override
protected void setUp() throws Exception {
super.setUp();
if (!INCIDENTD_TESTS_ENABLED) {
CLog.w(TAG, TAG + " anomaly tests are disabled by a flag. Change flag to true to run");
}
+ if (PERFETTO_TESTS_ENABLED) {
+ // Default Android configuration can only change for device type that doesn't require SystemTracingEnabled
+ // by default in CDD.
+ String chars = getDevice().getProperty("ro.build.characteristics");
+ if (!isSystemTracingEnabled() && chars.contains("automotive")) {
+ enableSystemTracing();
+ defaultSystemTracingConfigurationHasChanged = true;
+ }
+ }
}
@Override
protected void tearDown() throws Exception {
super.tearDown();
if (PERFETTO_TESTS_ENABLED) {
- //Deadline to finish trace collection
+ // Disable SystemTracing if previously enabled at test setUp()
+ if (defaultSystemTracingConfigurationHasChanged) {
+ disableSystemTracing();
+ }
+ // Deadline to finish trace collection
final long deadLine = System.currentTimeMillis() + 10000;
while (isSystemTracingEnabled()) {
if (System.currentTimeMillis() > deadLine) {
diff --git a/tests/src/android/cts/statsd/atom/AtomTestCase.java b/tests/src/android/cts/statsd/atom/AtomTestCase.java
index 03802948..51ba9774 100644
--- a/tests/src/android/cts/statsd/atom/AtomTestCase.java
+++ b/tests/src/android/cts/statsd/atom/AtomTestCase.java
@@ -241,6 +241,14 @@ public class AtomTestCase extends BaseTestCase {
+ " cat " + path + " ; else echo -1 ; fi");
}
+ protected void enableSystemTracing() throws Exception {
+ getDevice().executeShellCommand("setprop persist.traced.enable 1");
+ }
+
+ protected void disableSystemTracing() throws Exception {
+ getDevice().executeShellCommand("setprop persist.traced.enable 0");
+ }
+
/**
* Determines whether perfetto enabled the kernel ftrace tracer.
*/