Relocate NNAPI statsdatom tests to its own directory
Prior to this change, NeuralNetworksStatsTests existed under
cts/hostsidetests/statsdatom/src/android/cts/statsdatom/neuralnetworks.
However, because it belonged to the CtsStatsdAtomHostTestCases module,
it was not able to be marked as a "mts" or "mts-neuralnetworks"
test_suite without affecting other teams' tests.
This CL relocates NeuralNetworksStatsTests to
cts/hostsidetests/neuralnetworks under the new module
CtsNnapiHostTestCases, and marks the test as "mts" and
"mts-neuralnetworks" test_suite.
Bug: 195113404
Test: mma
Test: atest NeuralNetworksStatsTests
Change-Id: I54605080012d1835119b35e76c555011094fdf1c
diff --git a/hostsidetests/neuralnetworks/Android.bp b/hostsidetests/neuralnetworks/Android.bp
new file mode 100644
index 0000000..ba128cf
--- /dev/null
+++ b/hostsidetests/neuralnetworks/Android.bp
@@ -0,0 +1,38 @@
+// Copyright (C) 2022 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.
+
+package {
+ default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+java_test_host {
+ name: "CtsNNAPIStatsdAtomHostTestCases",
+ defaults: ["cts_defaults"],
+ srcs: ["src/**/*.java"],
+ test_suites: [
+ "cts",
+ "general-tests",
+ "mts",
+ "mts-neuralnetworks",
+ ],
+ libs: [
+ "tradefed",
+ ],
+ static_libs: [
+ "cts-statsd-atom-host-test-utils",
+ ],
+ data: [
+ ":CtsNnapiStatsdAtomApp",
+ ],
+}
diff --git a/hostsidetests/neuralnetworks/AndroidTest.xml b/hostsidetests/neuralnetworks/AndroidTest.xml
new file mode 100644
index 0000000..29bc369
--- /dev/null
+++ b/hostsidetests/neuralnetworks/AndroidTest.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2022 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.
+-->
+<configuration description="Config for CTS NNAPI statsd atom host test cases">
+ <option name="test-suite-tag" value="cts" />
+ <option name="config-descriptor:metadata" key="component" value="neuralnetworks" />
+ <option name="config-descriptor:metadata" key="parameter" value="instant_app" />
+ <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+ <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
+ <option name="config-descriptor:metadata" key="mainline-param" value="com.google.android.neuralnetworks.apex" />
+ <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+ <option name="jar" value="CtsNNAPIStatsdAtomHostTestCases.jar" />
+ </test>
+
+ <object type="module_controller" class="com.android.tradefed.testtype.suite.module.MainlineTestModuleController">
+ <option name="mainline-module-package-name" value="com.google.android.neuralnetworks" />
+ </object>
+</configuration>
diff --git a/hostsidetests/statsdatom/src/android/cts/statsdatom/neuralnetworks/OWNERS b/hostsidetests/neuralnetworks/OWNERS
similarity index 69%
rename from hostsidetests/statsdatom/src/android/cts/statsdatom/neuralnetworks/OWNERS
rename to hostsidetests/neuralnetworks/OWNERS
index d659373..04c5d72 100644
--- a/hostsidetests/statsdatom/src/android/cts/statsdatom/neuralnetworks/OWNERS
+++ b/hostsidetests/neuralnetworks/OWNERS
@@ -1,3 +1,2 @@
-# These atom tests are owned by the NNAPI team.
# Bug component: 195575
include platform/packages/modules/NeuralNetworks:/NNAPI_OWNERS # Neuralnetworks team
diff --git a/hostsidetests/neuralnetworks/TEST_MAPPING b/hostsidetests/neuralnetworks/TEST_MAPPING
new file mode 100644
index 0000000..6bcf80c
--- /dev/null
+++ b/hostsidetests/neuralnetworks/TEST_MAPPING
@@ -0,0 +1,12 @@
+{
+ "mainline-presubmit": [
+ {
+ "name": "CtsNNAPIStatsdAtomHostTestCases[com.google.android.neuralnetworks.apex]"
+ }
+ ],
+ "presubmit": [
+ {
+ "name": "CtsNNAPIStatsdAtomHostTestCases"
+ }
+ ]
+}
diff --git a/hostsidetests/neuralnetworks/app/Android.bp b/hostsidetests/neuralnetworks/app/Android.bp
new file mode 100644
index 0000000..1a9f00c
--- /dev/null
+++ b/hostsidetests/neuralnetworks/app/Android.bp
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+
+package {
+ default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+cc_library_shared {
+ name: "libneuralnetworkshelper_statsdatom",
+ srcs: ["jni/trigger_libneuralnetworks_atoms.cpp"],
+ cflags: [
+ "-Wall",
+ "-Werror",
+ ],
+ header_libs: ["jni_headers"],
+ shared_libs: [
+ "liblog",
+ "libnativewindow",
+ "libneuralnetworks",
+ ],
+ static_libs: ["libbase_ndk"],
+ stl: "c++_static",
+ sdk_version: "current",
+ min_sdk_version: "29",
+}
+
+android_test_helper_app {
+ name: "CtsNnapiStatsdAtomApp",
+ defaults: ["cts_defaults"],
+ platform_apis: true,
+ min_sdk_version: "29",
+ srcs: [
+ "src/**/*.java",
+ ],
+ privileged: true,
+ jni_libs: [
+ "libneuralnetworkshelper_statsdatom",
+ ],
+ compile_multilib: "both",
+ v4_signature: true,
+}
diff --git a/hostsidetests/neuralnetworks/app/AndroidManifest.xml b/hostsidetests/neuralnetworks/app/AndroidManifest.xml
new file mode 100755
index 0000000..6d5ab81
--- /dev/null
+++ b/hostsidetests/neuralnetworks/app/AndroidManifest.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2022 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="com.android.nn.stats.app">
+
+ <uses-sdk android:minSdkVersion="29" android:targetSdkVersion="31" />
+
+ <application>
+ <activity android:name=".NnapiDeviceActivity"
+ android:exported="true">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN"/>
+ <category android:name="android.intent.category.LAUNCHER"/>
+ </intent-filter>
+ </activity>
+ </application>
+
+</manifest>
diff --git a/hostsidetests/statsdatom/apps/statsdapp/jni/trigger_libneuralnetworks_atoms.cpp b/hostsidetests/neuralnetworks/app/jni/trigger_libneuralnetworks_atoms.cpp
similarity index 98%
rename from hostsidetests/statsdatom/apps/statsdapp/jni/trigger_libneuralnetworks_atoms.cpp
rename to hostsidetests/neuralnetworks/app/jni/trigger_libneuralnetworks_atoms.cpp
index d74eef1..e756494 100644
--- a/hostsidetests/statsdatom/apps/statsdapp/jni/trigger_libneuralnetworks_atoms.cpp
+++ b/hostsidetests/neuralnetworks/app/jni/trigger_libneuralnetworks_atoms.cpp
@@ -245,7 +245,7 @@
} // namespace
extern "C" JNIEXPORT void JNICALL
-Java_com_android_server_cts_device_statsdatom_StatsdCtsForegroundActivity_trigger_1libneuralnetworks_1atoms(
+Java_com_android_nn_stats_app_NnapiDeviceActivity_trigger_1libneuralnetworks_1atoms(
JNIEnv*, jobject /*this*/) {
compilationSuccess();
compilationFailure();
diff --git a/hostsidetests/neuralnetworks/app/src/com/android/nn/stats/app/NnapiDeviceActivity.java b/hostsidetests/neuralnetworks/app/src/com/android/nn/stats/app/NnapiDeviceActivity.java
new file mode 100644
index 0000000..50ecafa
--- /dev/null
+++ b/hostsidetests/neuralnetworks/app/src/com/android/nn/stats/app/NnapiDeviceActivity.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+
+package com.android.nn.stats.app;
+
+import android.app.Activity;
+import android.os.Bundle;
+
+/**
+ * A simple activity which triggers libneuralnetworks.so to push WestWorld atoms.
+ */
+public class NnapiDeviceActivity extends Activity {
+
+ static {
+ System.loadLibrary("neuralnetworkshelper_statsdatom");
+ }
+
+ @Override
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+ trigger_libneuralnetworks_atoms();
+ }
+
+ private native void trigger_libneuralnetworks_atoms();
+}
diff --git a/hostsidetests/statsdatom/src/android/cts/statsdatom/neuralnetworks/NeuralNetworksStatsTests.java b/hostsidetests/neuralnetworks/src/com/android/nn/host/cts/NeuralNetworksStatsTests.java
similarity index 92%
rename from hostsidetests/statsdatom/src/android/cts/statsdatom/neuralnetworks/NeuralNetworksStatsTests.java
rename to hostsidetests/neuralnetworks/src/com/android/nn/host/cts/NeuralNetworksStatsTests.java
index 6bc5b05..ebe35c4 100644
--- a/hostsidetests/statsdatom/src/android/cts/statsdatom/neuralnetworks/NeuralNetworksStatsTests.java
+++ b/hostsidetests/neuralnetworks/src/com/android/nn/host/cts/NeuralNetworksStatsTests.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package android.cts.statsdatom.neuralnetworks;
+package com.android.nn.host.cts;
import static com.google.common.truth.Truth.assertThat;
@@ -36,6 +36,8 @@
import java.util.List;
public class NeuralNetworksStatsTests extends DeviceTestCase implements IBuildReceiver {
+ private static final String APP_APK_NAME = "CtsNnapiStatsdAtomApp.apk";
+ private static final String APP_PKG_NAME = "com.android.nn.stats.app";
private static final String PROPERTY_NNAPI_TELEMETRY_ENABLE =
"persist.device_config.nnapi_native.telemetry_enable";
@@ -47,7 +49,7 @@
assertThat(mCtsBuild).isNotNull();
ConfigUtils.removeConfig(getDevice());
ReportUtils.clearReports(getDevice());
- DeviceUtils.installStatsdTestApp(getDevice(), mCtsBuild);
+ DeviceUtils.installTestApp(getDevice(), APP_APK_NAME, APP_PKG_NAME, mCtsBuild);
Thread.sleep(AtomTestUtils.WAIT_TIME_LONG);
}
@@ -55,7 +57,7 @@
protected void tearDown() throws Exception {
ConfigUtils.removeConfig(getDevice());
ReportUtils.clearReports(getDevice());
- DeviceUtils.uninstallStatsdTestApp(getDevice());
+ DeviceUtils.uninstallTestApp(getDevice(), APP_PKG_NAME);
super.tearDown();
}
@@ -77,11 +79,11 @@
if (!isNnapiLoggingEnabled()) return;
final int atomTag = Atom.NEURALNETWORKS_COMPILATION_COMPLETED_FIELD_NUMBER;
- ConfigUtils.uploadConfigForPushedAtomWithUid(getDevice(), DeviceUtils.STATSD_ATOM_TEST_PKG,
+ ConfigUtils.uploadConfigForPushedAtomWithUid(getDevice(), APP_PKG_NAME,
atomTag, /*uidInAttributionChain=*/false);
- DeviceUtils.runActivity(getDevice(), DeviceUtils.STATSD_ATOM_TEST_PKG,
- "StatsdCtsForegroundActivity", "action", "action.trigger_libneuralnetworks_atoms",
+ DeviceUtils.runActivity(getDevice(), APP_PKG_NAME,
+ "NnapiDeviceActivity", "action", "action.trigger_libneuralnetworks_atoms",
/* waitTimeMs= */ 5000L);
// Sorted list of events in order in which they occurred.
@@ -126,11 +128,11 @@
if (!isNnapiLoggingEnabled()) return;
final int atomTag = Atom.NEURALNETWORKS_COMPILATION_FAILED_FIELD_NUMBER;
- ConfigUtils.uploadConfigForPushedAtomWithUid(getDevice(), DeviceUtils.STATSD_ATOM_TEST_PKG,
+ ConfigUtils.uploadConfigForPushedAtomWithUid(getDevice(), APP_PKG_NAME,
atomTag, /*uidInAttributionChain=*/false);
- DeviceUtils.runActivity(getDevice(), DeviceUtils.STATSD_ATOM_TEST_PKG,
- "StatsdCtsForegroundActivity", "action", "action.trigger_libneuralnetworks_atoms",
+ DeviceUtils.runActivity(getDevice(), APP_PKG_NAME,
+ "NnapiDeviceActivity", "action", "action.trigger_libneuralnetworks_atoms",
/* waitTimeMs= */ 5000L);
// Sorted list of events in order in which they occurred.
@@ -170,11 +172,11 @@
if (!isNnapiLoggingEnabled()) return;
final int atomTag = Atom.NEURALNETWORKS_EXECUTION_COMPLETED_FIELD_NUMBER;
- ConfigUtils.uploadConfigForPushedAtomWithUid(getDevice(), DeviceUtils.STATSD_ATOM_TEST_PKG,
+ ConfigUtils.uploadConfigForPushedAtomWithUid(getDevice(), APP_PKG_NAME,
atomTag, /*uidInAttributionChain=*/false);
- DeviceUtils.runActivity(getDevice(), DeviceUtils.STATSD_ATOM_TEST_PKG,
- "StatsdCtsForegroundActivity", "action", "action.trigger_libneuralnetworks_atoms",
+ DeviceUtils.runActivity(getDevice(), APP_PKG_NAME,
+ "NnapiDeviceActivity", "action", "action.trigger_libneuralnetworks_atoms",
/* waitTimeMs= */ 5000L);
// Sorted list of events in order in which they occurred.
@@ -229,11 +231,11 @@
if (!isNnapiLoggingEnabled()) return;
final int atomTag = Atom.NEURALNETWORKS_EXECUTION_FAILED_FIELD_NUMBER;
- ConfigUtils.uploadConfigForPushedAtomWithUid(getDevice(), DeviceUtils.STATSD_ATOM_TEST_PKG,
+ ConfigUtils.uploadConfigForPushedAtomWithUid(getDevice(), APP_PKG_NAME,
atomTag, /*uidInAttributionChain=*/false);
- DeviceUtils.runActivity(getDevice(), DeviceUtils.STATSD_ATOM_TEST_PKG,
- "StatsdCtsForegroundActivity", "action", "action.trigger_libneuralnetworks_atoms",
+ DeviceUtils.runActivity(getDevice(), APP_PKG_NAME,
+ "NnapiDeviceActivity", "action", "action.trigger_libneuralnetworks_atoms",
/* waitTimeMs= */ 5000L);
// Sorted list of events in order in which they occurred.
diff --git a/hostsidetests/statsdatom/Android.bp b/hostsidetests/statsdatom/Android.bp
index 93b4c45..1f793b3 100644
--- a/hostsidetests/statsdatom/Android.bp
+++ b/hostsidetests/statsdatom/Android.bp
@@ -39,7 +39,6 @@
"src/**/media/*.java",
"src/**/memory/*.java",
"src/**/net/*.java",
- "src/**/neuralnetworks/*.java",
"src/**/notification/*.java",
"src/**/perfetto/*.java",
"src/**/permissionstate/*.java",
diff --git a/hostsidetests/statsdatom/apps/statsdapp/Android.bp b/hostsidetests/statsdatom/apps/statsdapp/Android.bp
index c0aacf6..2cd2fa0 100644
--- a/hostsidetests/statsdatom/apps/statsdapp/Android.bp
+++ b/hostsidetests/statsdatom/apps/statsdapp/Android.bp
@@ -43,24 +43,6 @@
sdk_version: "current",
}
-cc_library_shared {
- name: "libneuralnetworkshelper_statsdatom",
- srcs: ["jni/trigger_libneuralnetworks_atoms.cpp"],
- cflags: [
- "-Wall",
- "-Werror",
- ],
- header_libs: ["jni_headers"],
- shared_libs: [
- "liblog",
- "libnativewindow",
- "libneuralnetworks",
- ],
- static_libs: ["libbase_ndk"],
- stl: "c++_static",
- sdk_version: "current",
-}
-
android_test_helper_app {
name: "CtsStatsdAtomApp",
defaults: ["cts_defaults"],
@@ -86,7 +68,6 @@
jni_libs: [
"liblmkhelper_statsdatom",
"libcrashhelper",
- "libneuralnetworkshelper_statsdatom",
],
compile_multilib: "both",
v4_signature: true,
diff --git a/hostsidetests/statsdatom/apps/statsdapp/src/com/android/server/cts/device/statsdatom/StatsdCtsForegroundActivity.java b/hostsidetests/statsdatom/apps/statsdapp/src/com/android/server/cts/device/statsdatom/StatsdCtsForegroundActivity.java
index a5fddf8..df11114 100644
--- a/hostsidetests/statsdatom/apps/statsdapp/src/com/android/server/cts/device/statsdatom/StatsdCtsForegroundActivity.java
+++ b/hostsidetests/statsdatom/apps/statsdapp/src/com/android/server/cts/device/statsdatom/StatsdCtsForegroundActivity.java
@@ -52,8 +52,6 @@
public static final String ACTION_POLL_NETWORK_STATS = "action.poll_network_stats";
public static final String ACTION_LMK = "action.lmk";
public static final String ACTION_DRAIN_POWER = "action.drain_power";
- public static final String ACTION_TRIGGER_LIBNERUALNETWORKS_ATOMS =
- "action.trigger_libneuralnetworks_atoms";
public static final int SLEEP_OF_ACTION_SLEEP_WHILE_TOP = 2_000;
public static final int SLEEP_OF_ACTION_SHOW_APPLICATION_OVERLAY = 2_000;
@@ -61,7 +59,6 @@
static {
System.loadLibrary("crashhelper");
- System.loadLibrary("neuralnetworkshelper_statsdatom");
}
@Override
@@ -111,9 +108,6 @@
case ACTION_DRAIN_POWER:
doBusyWork();
break;
- case ACTION_TRIGGER_LIBNERUALNETWORKS_ATOMS:
- trigger_libneuralnetworks_atoms();
- break;
default:
Log.e(TAG, "Intent had invalid action " + action);
finish();
@@ -247,6 +241,4 @@
}
private native void segfault();
-
- private native void trigger_libneuralnetworks_atoms();
}