Move ReflectionTest.StaticMainMethod to compiler/.
And clean up some related code.
Test: m test-art-host-gtest
Test: atest art_standalone_runtime_tests
Test: atest art_standalone_compiler_tests
Test: atest ArtGtestsTargetChroot
Change-Id: I6b60e553dad7111f6247fbd873cd46af11f00276
diff --git a/runtime/Android.bp b/runtime/Android.bp
index a9a4424..2acf8f4 100644
--- a/runtime/Android.bp
+++ b/runtime/Android.bp
@@ -746,6 +746,7 @@
":art-gtest-jars-MyClass",
":art-gtest-jars-MyClassNatives",
":art-gtest-jars-Nested",
+ ":art-gtest-jars-NonStaticLeafMethods",
":art-gtest-jars-Packages",
":art-gtest-jars-ProfileTestMultiDex",
":art-gtest-jars-ProtoCompare",
@@ -842,6 +843,7 @@
"prebuilt_tools_test.cc",
"proxy_test.cc",
"reference_table_test.cc",
+ "reflection_test.cc",
"runtime_callbacks_test.cc",
"runtime_test.cc",
"subtype_check_info_test.cc",
@@ -900,59 +902,6 @@
test_config: "art_standalone_runtime_tests.xml",
}
-art_cc_defaults {
- name: "art_runtime_compiler_tests_defaults",
- tidy_timeout_srcs: [
- "reflection_test.cc",
- ],
- srcs: [
- "reflection_test.cc",
- ],
- data: [
- ":art-gtest-jars-Main",
- ":art-gtest-jars-NonStaticLeafMethods",
- ":art-gtest-jars-StaticLeafMethods",
- ],
-}
-
-// Version of ART gtest `art_runtime_compiler_tests` bundled with the ART APEX on target.
-// TODO(b/192274705): Remove this module when the migration to standalone ART gtests is complete.
-art_cc_test {
- name: "art_runtime_compiler_tests",
- defaults: [
- "art_gtest_defaults",
- "art_runtime_compiler_tests_defaults",
- ],
- shared_libs: [
- "libartd-compiler",
- ],
- target: {
- host: {
- required: ["dex2oatd"],
- },
- },
-}
-
-// Standalone version of ART gtest `art_runtime_compiler_tests`, not bundled with the ART APEX on
-// target.
-art_cc_test {
- name: "art_standalone_runtime_compiler_tests",
- defaults: [
- "art_standalone_gtest_defaults",
- "art_runtime_compiler_tests_defaults",
- ],
- data: [":generate-boot-image"],
- shared_libs: [
- "libart-compiler",
- ],
- target: {
- host: {
- required: ["dex2oat"],
- },
- },
- test_config: "art_standalone_runtime_compiler_tests.xml",
-}
-
genrule {
name: "libart_mterp.x86ng",
out: ["mterp_x86ng.S"],
diff --git a/runtime/art_standalone_runtime_compiler_tests.xml b/runtime/art_standalone_runtime_compiler_tests.xml
deleted file mode 100644
index 3ae3a82..0000000
--- a/runtime/art_standalone_runtime_compiler_tests.xml
+++ /dev/null
@@ -1,61 +0,0 @@
-<?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.
--->
-<configuration description="Runs art_standalone_runtime_compiler_tests.">
- <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
- <option name="cleanup" value="true" />
- <option name="push" value="art_standalone_runtime_compiler_tests->/data/local/tmp/art_standalone_runtime_compiler_tests/art_standalone_runtime_compiler_tests" />
- <option name="append-bitness" value="true" />
- </target_preparer>
-
- <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
- <option name="cleanup" value="true" />
- <option name="push" value="art-gtest-jars-Main.jar->/data/local/tmp/art_standalone_runtime_compiler_tests/art-gtest-jars-Main.jar" />
- <option name="push" value="art-gtest-jars-NonStaticLeafMethods.jar->/data/local/tmp/art_standalone_runtime_compiler_tests/art-gtest-jars-NonStaticLeafMethods.jar" />
- <option name="push" value="art-gtest-jars-StaticLeafMethods.jar->/data/local/tmp/art_standalone_runtime_compiler_tests/art-gtest-jars-StaticLeafMethods.jar" />
- </target_preparer>
-
- <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
- <option name="cleanup" value="true" />
- <option name="append-bitness" value="true" />
- <option name="push-file" key="generate-boot-image" value="/data/local/tmp/art_standalone_runtime_compiler_tests/generate-boot-image" />
- </target_preparer>
-
- <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
- <option name="throw-if-cmd-fail" value="true" />
- <option name="run-command" value="mkdir -p /data/local/tmp/art_standalone_runtime_compiler_tests/art_boot_images" />
- <option name="run-command" value="/data/local/tmp/art_standalone_runtime_compiler_tests/generate-boot-image --output-dir=/data/local/tmp/art_standalone_runtime_compiler_tests/art_boot_images" />
- <option name="teardown-command" value="rm -rf /data/local/tmp/art_standalone_runtime_compiler_tests/art_boot_images" />
- </target_preparer>
-
- <test class="com.android.tradefed.testtype.GTest" >
- <option name="native-test-device-path" value="/data/local/tmp/art_standalone_runtime_compiler_tests" />
- <option name="module-name" value="art_standalone_runtime_compiler_tests" />
- <option name="ld-library-path-32" value="/apex/com.android.art/lib" />
- <option name="ld-library-path-64" value="/apex/com.android.art/lib64" />
- </test>
-
- <!-- When this test is run in a Mainline context (e.g. with `mts-tradefed`), only enable it if
- one of the Mainline modules below is present on the device used for testing. -->
- <object type="module_controller" class="com.android.tradefed.testtype.suite.module.MainlineTestModuleController">
- <!-- ART Mainline Module (internal version). -->
- <option name="mainline-module-package-name" value="com.google.android.art" />
- <!-- ART Mainline Module (external (AOSP) version). -->
- <option name="mainline-module-package-name" value="com.android.art" />
- </object>
-
- <!-- Only run tests if the device under test is SDK version 31 (Android 12) or above. -->
- <object type="module_controller" class="com.android.tradefed.testtype.suite.module.Sdk31ModuleController" />
-</configuration>
diff --git a/runtime/art_standalone_runtime_tests.xml b/runtime/art_standalone_runtime_tests.xml
index 36c16aa..0772562 100644
--- a/runtime/art_standalone_runtime_tests.xml
+++ b/runtime/art_standalone_runtime_tests.xml
@@ -48,6 +48,7 @@
<option name="push" value="art-gtest-jars-MyClass.jar->/data/local/tmp/art_standalone_runtime_tests/art-gtest-jars-MyClass.jar" />
<option name="push" value="art-gtest-jars-MyClassNatives.jar->/data/local/tmp/art_standalone_runtime_tests/art-gtest-jars-MyClassNatives.jar" />
<option name="push" value="art-gtest-jars-Nested.jar->/data/local/tmp/art_standalone_runtime_tests/art-gtest-jars-Nested.jar" />
+ <option name="push" value="art-gtest-jars-NonStaticLeafMethods.jar->/data/local/tmp/art_standalone_runtime_tests/art-gtest-jars-NonStaticLeafMethods.jar" />
<option name="push" value="art-gtest-jars-Packages.jar->/data/local/tmp/art_standalone_runtime_tests/art-gtest-jars-Packages.jar" />
<option name="push" value="art-gtest-jars-ProfileTestMultiDex.jar->/data/local/tmp/art_standalone_runtime_tests/art-gtest-jars-ProfileTestMultiDex.jar" />
<option name="push" value="art-gtest-jars-ProtoCompare.jar->/data/local/tmp/art_standalone_runtime_tests/art-gtest-jars-ProtoCompare.jar" />
diff --git a/runtime/reflection_test.cc b/runtime/reflection_test.cc
index 8a76855..4a24d2a 100644
--- a/runtime/reflection_test.cc
+++ b/runtime/reflection_test.cc
@@ -21,7 +21,7 @@
#include "art_method-inl.h"
#include "base/enums.h"
-#include "common_compiler_test.h"
+#include "common_runtime_test.h"
#include "dex/descriptors_names.h"
#include "jni/java_vm_ext.h"
#include "jni/jni_internal.h"
@@ -31,11 +31,10 @@
namespace art {
-// TODO: Convert to CommonRuntimeTest. Currently CompileDirectMethod is used in one test.
-class ReflectionTest : public CommonCompilerTest {
+class ReflectionTest : public CommonRuntimeTest {
protected:
void SetUp() override {
- CommonCompilerTest::SetUp();
+ CommonRuntimeTest::SetUp();
vm_ = Runtime::Current()->GetJavaVM();
@@ -76,7 +75,7 @@
void TearDown() override {
CleanUpJniEnv();
- CommonCompilerTest::TearDown();
+ CommonRuntimeTest::TearDown();
}
jclass GetPrimitiveClass(char descriptor) {
@@ -511,33 +510,6 @@
jclass sioobe_;
};
-TEST_F(ReflectionTest, StaticMainMethod) {
- ScopedObjectAccess soa(Thread::Current());
- jobject jclass_loader = LoadDex("Main");
- StackHandleScope<1> hs(soa.Self());
- Handle<mirror::ClassLoader> class_loader(
- hs.NewHandle(soa.Decode<mirror::ClassLoader>(jclass_loader)));
- CompileDirectMethod(class_loader, "Main", "main", "([Ljava/lang/String;)V");
-
- ObjPtr<mirror::Class> klass = class_linker_->FindClass(soa.Self(), "LMain;", class_loader);
- ASSERT_TRUE(klass != nullptr);
-
- ArtMethod* method = klass->FindClassMethod("main",
- "([Ljava/lang/String;)V",
- kRuntimePointerSize);
- ASSERT_TRUE(method != nullptr);
- ASSERT_TRUE(method->IsStatic());
-
- // Start runtime.
- bool started = runtime_->Start();
- CHECK(started);
- soa.Self()->TransitionFromSuspendedToRunnable();
-
- jvalue args[1];
- args[0].l = nullptr;
- InvokeWithJValues(soa, nullptr, jni::EncodeArtMethod(method), args);
-}
-
TEST_F(ReflectionTest, StaticNopMethod) {
InvokeNopMethod(true);
}