diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-04-18 20:40:27 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-04-18 20:40:27 +0000 |
commit | 237b868db380ff5653d3acbc49f322ba7ed48c2e (patch) | |
tree | bcdbced18e359532fd74ab7b3697e8cd98ee864a | |
parent | 4da605aa3bc4207d456527897d45fe8e1a14bc68 (diff) | |
parent | 14f7f962572dc733aa03f1a6752f980a55046fbc (diff) | |
download | StatsD-237b868db380ff5653d3acbc49f322ba7ed48c2e.tar.gz |
Snap for 9961467 from 14f7f962572dc733aa03f1a6752f980a55046fbc to android12L-tests-releaseandroid-vts-12.1_r9android-vts-12.1_r8android-vts-12.1_r7android-vts-12.1_r10android-cts-12.1_r9android-cts-12.1_r8android-cts-12.1_r7android-cts-12.1_r10android12L-tests-release
Change-Id: I3b050230091d38b51f28ad756ccf93fb4e987e8b
-rw-r--r-- | tests/src/android/cts/statsd/alert/AnomalyDetectionTests.java | 17 | ||||
-rw-r--r-- | tests/src/android/cts/statsd/atom/AtomTestCase.java | 8 |
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. */ |