aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/cts/AndroidTest.xml1
-rw-r--r--test/cts/heapprofd_test_cts.cc20
-rw-r--r--test/cts/test_apps/Android.bp20
-rwxr-xr-xtest/cts/test_apps/AndroidManifest_nonprofileable.xml51
-rw-r--r--test/cts/traced_perf_test_cts.cc17
5 files changed, 109 insertions, 0 deletions
diff --git a/test/cts/AndroidTest.xml b/test/cts/AndroidTest.xml
index 800a6d494..2a9276c6a 100644
--- a/test/cts/AndroidTest.xml
+++ b/test/cts/AndroidTest.xml
@@ -26,6 +26,7 @@
<option name="test-file-name" value="CtsPerfettoDebuggableApp.apk" />
<option name="test-file-name" value="CtsPerfettoReleaseApp.apk" />
<option name="test-file-name" value="CtsPerfettoProfileableApp.apk" />
+ <option name="test-file-name" value="CtsPerfettoNonProfileableApp.apk" />
</target_preparer>
<target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
<option name="cleanup" value="true" />
diff --git a/test/cts/heapprofd_test_cts.cc b/test/cts/heapprofd_test_cts.cc
index 22155176f..273efd893 100644
--- a/test/cts/heapprofd_test_cts.cc
+++ b/test/cts/heapprofd_test_cts.cc
@@ -234,5 +234,25 @@ TEST(HeapprofdCtsTest, ReleaseAppStartup) {
StopApp(app_name);
}
+TEST(HeapprofdCtsTest, NonProfileableAppRuntime) {
+ std::string app_name = "android.perfetto.cts.app.nonprofileable";
+ const auto& packets = ProfileRuntime(app_name);
+ if (IsUserBuild())
+ AssertNoProfileContents(packets);
+ else
+ AssertExpectedAllocationsPresent(packets);
+ StopApp(app_name);
+}
+
+TEST(HeapprofdCtsTest, NonProfileableAppStartup) {
+ std::string app_name = "android.perfetto.cts.app.nonprofileable";
+ const auto& packets = ProfileStartup(app_name);
+ if (IsUserBuild())
+ AssertNoProfileContents(packets);
+ else
+ AssertExpectedAllocationsPresent(packets);
+ StopApp(app_name);
+}
+
} // namespace
} // namespace perfetto
diff --git a/test/cts/test_apps/Android.bp b/test/cts/test_apps/Android.bp
index 4263879db..1172be5b0 100644
--- a/test/cts/test_apps/Android.bp
+++ b/test/cts/test_apps/Android.bp
@@ -80,3 +80,23 @@ android_test_helper_app {
],
jni_uses_platform_apis: true,
}
+
+android_test_helper_app {
+ name: "CtsPerfettoNonProfileableApp",
+ // tag this module as a cts test artifact
+ test_suites: [
+ "cts",
+ "vts10",
+ "general-tests",
+ ],
+
+ manifest: "AndroidManifest_nonprofileable.xml",
+
+ compile_multilib: "both",
+ srcs: ["src/**/*.java"],
+ sdk_version: "current",
+ jni_libs: [
+ "libperfettocts_native",
+ ],
+ jni_uses_platform_apis: true,
+}
diff --git a/test/cts/test_apps/AndroidManifest_nonprofileable.xml b/test/cts/test_apps/AndroidManifest_nonprofileable.xml
new file mode 100755
index 000000000..c4a716d30
--- /dev/null
+++ b/test/cts/test_apps/AndroidManifest_nonprofileable.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="android.perfetto.cts.app.nonprofileable">
+
+ <application>
+ <profileable android:shell="true" android:enabled="false"/>
+ <activity
+ android:name="android.perfetto.cts.app.MainActivity"
+ android:exported="true">
+ </activity>
+ <activity-alias
+ android:name="android.perfetto.cts.app.nonprofileable.MainActivity"
+ android:targetActivity="android.perfetto.cts.app.MainActivity"
+ android:exported="true">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity-alias>
+ <activity
+ android:name="android.perfetto.cts.app.BusyWaitActivity"
+ android:exported="true">
+ </activity>
+ <activity-alias
+ android:name="android.perfetto.cts.app.nonprofileable.BusyWaitActivity"
+ android:targetActivity="android.perfetto.cts.app.BusyWaitActivity"
+ android:exported="true">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity-alias>
+ </application>
+</manifest>
+
diff --git a/test/cts/traced_perf_test_cts.cc b/test/cts/traced_perf_test_cts.cc
index 7b867cdb9..831f8b345 100644
--- a/test/cts/traced_perf_test_cts.cc
+++ b/test/cts/traced_perf_test_cts.cc
@@ -184,6 +184,23 @@ TEST(TracedPerfCtsTest, SystemWideProfileableApp) {
StopApp(app_name);
}
+TEST(TracedPerfCtsTest, SystemWideNonProfileableApp) {
+ if (!HasPerfLsmHooks())
+ GTEST_SKIP() << "skipped due to lack of perf_event_open LSM hooks";
+
+ std::string app_name = "android.perfetto.cts.app.nonprofileable";
+ const auto& packets = ProfileSystemWide(app_name);
+ int app_pid = PidForProcessName(app_name);
+ ASSERT_GT(app_pid, 0) << "failed to find pid for target process";
+
+ if (!IsUserBuild())
+ AssertHasSampledStacksForPid(packets, app_pid);
+ else
+ AssertNoStacksForPid(packets, app_pid);
+ PERFETTO_CHECK(IsAppRunning(app_name));
+ StopApp(app_name);
+}
+
TEST(TracedPerfCtsTest, SystemWideReleaseApp) {
if (!HasPerfLsmHooks())
GTEST_SKIP() << "skipped due to lack of perf_event_open LSM hooks";