summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Dieter Hsu <dieterhsu@google.com> 2020-06-18 23:11:31 +0800
committer Gavin Corkery <gavincorkery@google.com> 2020-09-29 18:54:28 +0100
commit31f9d09ba9835eafd7db45c2b75a711a31e21f98 (patch)
treedc87b997a0184927217123fbf8c730261e6147c0
parent6300a62dbbc19db8ad337f6d0a7144181491b9e5 (diff)
Run bugreport unit test without script
Replacing run.sh with fully integrated AndroidTest config to be able to run auto test by test mapping. Move the test class to the directory according to the package. This fix the issue source code is referenced correctly from testing result. Bug: 159404894 Test: atest BugreportManagerTestCases Change-Id: Id930abc40c52441c6dd1c1e6cdc3c0f34a36bfca Merged-In: Id930abc40c52441c6dd1c1e6cdc3c0f34a36bfca (cherry picked from commit 7a0bac8d75d30973a6dcab361732d6adf75b83bf)
-rw-r--r--core/tests/bugreports/Android.bp6
-rw-r--r--core/tests/bugreports/AndroidTest.xml13
-rwxr-xr-xcore/tests/bugreports/run.sh61
-rw-r--r--core/tests/bugreports/src/com/android/os/bugreports/tests/BugreportManagerTest.java (renamed from core/tests/bugreports/src/android/server/bugreports/BugreportManagerTest.java)0
4 files changed, 15 insertions, 65 deletions
diff --git a/core/tests/bugreports/Android.bp b/core/tests/bugreports/Android.bp
index e9d5bb135e02..1edd9623ed2d 100644
--- a/core/tests/bugreports/Android.bp
+++ b/core/tests/bugreports/Android.bp
@@ -15,12 +15,18 @@
android_test {
name: "BugreportManagerTestCases",
srcs: ["src/**/*.java"],
+ data: [":bugreport_artifacts"],
libs: [
"android.test.runner",
"android.test.base",
],
static_libs: ["androidx.test.rules", "truth-prebuilt"],
+ test_suites: ["general-tests"],
sdk_version: "test_current",
platform_apis: true,
}
+filegroup {
+ name: "bugreport_artifacts",
+ srcs: ["config/test-sysconfig.xml"],
+}
diff --git a/core/tests/bugreports/AndroidTest.xml b/core/tests/bugreports/AndroidTest.xml
index 410ca6043583..2c2f0d69e347 100644
--- a/core/tests/bugreports/AndroidTest.xml
+++ b/core/tests/bugreports/AndroidTest.xml
@@ -21,11 +21,16 @@
<option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
<option name="config-descriptor:metadata" key="parameter" value="not_multi_abi" />
- <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
- <option name="cleanup-apks" value="true"/>
- <option name="test-file-name" value="BugreportManagerTestCases.apk"/>
+ <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer" />
+ <target_preparer class="com.android.tradefed.targetprep.PushFilePreparer">
+ <option name="push-file" key="test-sysconfig.xml" value="/system/etc/sysconfig/allow-br-from-tests.xml" />
+ <option name="push-file" key="BugreportManagerTestCases.apk" value="/system/priv-app/BugreportManagerTestCases.apk" />
+ <option name="abort-on-push-failure" value="true" />
+ <option name="cleanup" value="true" />
+ <option name="remount-system" value="true" />
</target_preparer>
-
+ <target_preparer class="com.android.tradefed.targetprep.RebootTargetPreparer" />
+
<test class="com.android.tradefed.testtype.AndroidJUnitTest">
<option name="package" value="com.android.os.bugreports.tests"/>
<!-- test-timeout unit is ms, value = 30 min -->
diff --git a/core/tests/bugreports/run.sh b/core/tests/bugreports/run.sh
deleted file mode 100755
index 010339836538..000000000000
--- a/core/tests/bugreports/run.sh
+++ /dev/null
@@ -1,61 +0,0 @@
-#!/bin/bash
-
-# Copyright (C) 2019 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.
-
-# Script to run bugreport unitests
-# Must run on a rooted device.
-# Must run lunch before running the script
-# Usage: ${ANDROID_BUILD_TOP}/frameworks/base/core/tests/bugreports/run.sh
-
-# NOTE: This script replaces the framework-sysconfig.xml on your device, so use with caution.
-# It tries to replace it when done, but if the script does not finish cleanly
-# (for e.g. force stopped mid-way) your device will be left in an inconsistent state.
-# Reflashing will restore the right config.
-
-TMP_SYS_CONFIG=/var/tmp/framework-sysconfig.xml
-
-if [[ -z $ANDROID_PRODUCT_OUT ]]; then
- echo "Please lunch before running this test."
- exit 0
-fi
-
-# Print every command to console.
-set -x
-
-make -j BugreportManagerTestCases &&
- adb root &&
- adb remount &&
- adb wait-for-device &&
- # Save the sysconfig file in a tmp location and push the test config in
- adb pull /system/etc/sysconfig/framework-sysconfig.xml "${TMP_SYS_CONFIG}" &&
- adb push $ANDROID_BUILD_TOP/frameworks/base/core/tests/bugreports/config/test-sysconfig.xml /system/etc/sysconfig/framework-sysconfig.xml &&
- # The test app needs to be a priv-app.
- adb push $OUT/testcases/BugreportManagerTestCases/*/BugreportManagerTestCases.apk /system/priv-app ||
- exit 1
-
-adb reboot &&
-adb wait-for-device &&
-atest BugreportManagerTest || echo "Tests FAILED!"
-
-# Restore the saved config file
-if [ -f "${TMP_SYS_CONFIG}" ]; then
- SIZE=$(stat --printf="%s" "${TMP_SYS_CONFIG}")
- if [ SIZE > 0 ]; then
- adb remount &&
- adb wait-for-device &&
- adb push "${TMP_SYS_CONFIG}" /system/etc/sysconfig/framework-sysconfig.xml &&
- rm "${TMP_SYS_CONFIG}"
- fi
-fi
diff --git a/core/tests/bugreports/src/android/server/bugreports/BugreportManagerTest.java b/core/tests/bugreports/src/com/android/os/bugreports/tests/BugreportManagerTest.java
index 153337727e96..153337727e96 100644
--- a/core/tests/bugreports/src/android/server/bugreports/BugreportManagerTest.java
+++ b/core/tests/bugreports/src/com/android/os/bugreports/tests/BugreportManagerTest.java