Add test module for running gtests in chroot.
Bug: 147819342
Bug: 147821328
Test: atest ArtGtestsTargetInstallApex
Test: atest ArtGtestsTargetChroot
Change-Id: If4efdfa9fe52e4ddb5c6a3ed409a27935b17cebf
diff --git a/build/Android.gtest.mk b/build/Android.gtest.mk
index 47dc61d..3eefe14 100644
--- a/build/Android.gtest.mk
+++ b/build/Android.gtest.mk
@@ -66,6 +66,25 @@
include $(CLEAR_VARS)
###################################################################################################
+# Create a phony module that contains data needed for ART chroot-based testing.
+include $(CLEAR_VARS)
+LOCAL_MODULE := art_chroot
+LOCAL_MODULE_TAGS := tests
+LOCAL_MODULE_CLASS := NATIVE_TESTS
+LOCAL_MODULE_SUFFIX := .txt
+LOCAL_COMPATIBILITY_SUITE := general-tests
+LOCAL_COMPATIBILITY_SUPPORT_FILES := \
+ $(foreach apex,$(TESTING_ART_APEX) $(RUNTIME_APEX) $(CONSCRYPT_APEX) $(I18N_APEX),\
+ $(PRODUCT_OUT)/system/apex/$(apex).apex:system/apex/$(apex).apex)
+include $(BUILD_SYSTEM)/base_rules.mk
+
+$(LOCAL_BUILT_MODULE):
+ @mkdir -p $(dir $@)
+ echo "This directory contains common data and tools needed for ART target tests" > $@
+
+include $(CLEAR_VARS)
+###################################################################################################
+
# The path for which all the dex files are relative, not actually the current directory.
LOCAL_PATH := art/test
diff --git a/test/Android.bp b/test/Android.bp
index 68c5110..b3889f3 100644
--- a/test/Android.bp
+++ b/test/Android.bp
@@ -977,15 +977,26 @@
}
art_cc_test {
- name: "ArtGtestsTarget",
+ name: "ArtGtestsTargetInstallApex",
data: [
// We need the ART testing apex, which contains all gtest binaries.
- // Note that due to linker constraints the gtests must be in the apex.
+ // Note that due to build system and linker constraints the gtests must be in the apex.
":com.android.art.testing",
- ":art-gtest-jars",
],
+ // It seems that only device-tests build can create a valid apex.
test_suites: ["device-tests"],
- test_config: "gtests-target.xml",
+ test_config: "art-gtests-target-install-apex.xml",
+}
+
+art_cc_test {
+ name: "ArtGtestsTargetChroot",
+ data: [
+ // We need the ART testing apex, which contains all gtest binaries.
+ // Note that due to build system and linker constraints the gtests must be in the apex.
+ ":com.android.art.testing",
+ ],
+ test_suites: ["general-tests"],
+ test_config: "art-gtests-target-chroot.xml",
}
filegroup {
diff --git a/test/art-gtests-target-chroot.xml b/test/art-gtests-target-chroot.xml
new file mode 100644
index 0000000..647130f
--- /dev/null
+++ b/test/art-gtests-target-chroot.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2020 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="ART gtests for target (using chroot)">
+ <option name="test-suite-tag" value="art-target-gtest-chroot" />
+ <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer" />
+ <target_preparer class="com.android.tradefed.targetprep.DisableSELinuxTargetPreparer" />
+ <target_preparer class="com.android.tradefed.targetprep.ArtChrootPreparer" />
+ <test class="com.android.tradefed.testtype.ArtGTest" >
+ <!-- TODO(b/147821328): These tests do not work since they need to write to /system -->
+ <option name="exclude-filter" value="HiddenApiTest.DexDomain_System*:OatFileAssistantTest.SystemFrameworkDir" />
+ <!-- TODO(b/167660924): These tests fail during remote execution (but pass locally) -->
+ <option name="exclude-filter" value="DexAnalyzeTest*:DexDiagTest*:DexDumpTest*:DexLayoutTest*:DexListTest*:OatDumpTest*" />
+ <option name="native-test-timeout" value="600000" />
+ <option name="native-test-device-path" value="/data/local/tmp/art-test-chroot/apex/com.android.art/bin/art" />
+ </test>
+</configuration>
diff --git a/test/gtests-target.xml b/test/art-gtests-target-install-apex.xml
similarity index 83%
rename from test/gtests-target.xml
rename to test/art-gtests-target-install-apex.xml
index aa2cefa..7ba0170 100644
--- a/test/gtests-target.xml
+++ b/test/art-gtests-target-install-apex.xml
@@ -13,13 +13,14 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<configuration description="ART gtests">
+<configuration description="ART gtests for target (using apex installation)">
<option name="test-suite-tag" value="art" />
+ <option name="test-suite-tag" value="art-target-gtest-install-apex" />
<target_preparer class="com.android.tradefed.targetprep.InstallApexModuleTargetPreparer" >
<option name="test-file-name" value="com.android.art.testing.apex" />
</target_preparer>
<test class="com.android.tradefed.testtype.GTest" >
- <!-- TODO: These tests do not work since they need to write to /system -->
+ <!-- TODO(b/147821328): These tests do not work since they need to write to /system -->
<option name="exclude-filter" value="HiddenApiTest.DexDomain_System*:OatFileAssistantTest.SystemFrameworkDir" />
<option name="native-test-timeout" value="600000" /> <!-- 10 min -->
<option name="native-test-device-path" value="/apex/com.android.art/bin/art" />