xref: /aosp_15_r20/art/runtime/common_runtime_test.h (revision 795d594fd825385562da6b089ea9b2033f3abf5a)
1*795d594fSAndroid Build Coastguard Worker /*
2*795d594fSAndroid Build Coastguard Worker  * Copyright (C) 2011 The Android Open Source Project
3*795d594fSAndroid Build Coastguard Worker  *
4*795d594fSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*795d594fSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*795d594fSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*795d594fSAndroid Build Coastguard Worker  *
8*795d594fSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*795d594fSAndroid Build Coastguard Worker  *
10*795d594fSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*795d594fSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*795d594fSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*795d594fSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*795d594fSAndroid Build Coastguard Worker  * limitations under the License.
15*795d594fSAndroid Build Coastguard Worker  */
16*795d594fSAndroid Build Coastguard Worker 
17*795d594fSAndroid Build Coastguard Worker #ifndef ART_RUNTIME_COMMON_RUNTIME_TEST_H_
18*795d594fSAndroid Build Coastguard Worker #define ART_RUNTIME_COMMON_RUNTIME_TEST_H_
19*795d594fSAndroid Build Coastguard Worker 
20*795d594fSAndroid Build Coastguard Worker #include <gtest/gtest.h>
21*795d594fSAndroid Build Coastguard Worker #include <jni.h>
22*795d594fSAndroid Build Coastguard Worker 
23*795d594fSAndroid Build Coastguard Worker #include <functional>
24*795d594fSAndroid Build Coastguard Worker #include <string>
25*795d594fSAndroid Build Coastguard Worker 
26*795d594fSAndroid Build Coastguard Worker #include <android-base/logging.h>
27*795d594fSAndroid Build Coastguard Worker 
28*795d594fSAndroid Build Coastguard Worker #include "arch/instruction_set.h"
29*795d594fSAndroid Build Coastguard Worker #include "base/common_art_test.h"
30*795d594fSAndroid Build Coastguard Worker #include "base/locks.h"
31*795d594fSAndroid Build Coastguard Worker #include "base/macros.h"
32*795d594fSAndroid Build Coastguard Worker #include "base/os.h"
33*795d594fSAndroid Build Coastguard Worker #include "base/unix_file/fd_file.h"
34*795d594fSAndroid Build Coastguard Worker #include "dex/art_dex_file_loader.h"
35*795d594fSAndroid Build Coastguard Worker // TODO: Add inl file and avoid including inl.
36*795d594fSAndroid Build Coastguard Worker #include "obj_ptr-inl.h"
37*795d594fSAndroid Build Coastguard Worker #include "runtime_globals.h"
38*795d594fSAndroid Build Coastguard Worker #include "scoped_thread_state_change-inl.h"
39*795d594fSAndroid Build Coastguard Worker 
40*795d594fSAndroid Build Coastguard Worker namespace art HIDDEN {
41*795d594fSAndroid Build Coastguard Worker 
42*795d594fSAndroid Build Coastguard Worker class MethodReference;
43*795d594fSAndroid Build Coastguard Worker class TypeReference;
44*795d594fSAndroid Build Coastguard Worker 
45*795d594fSAndroid Build Coastguard Worker using LogSeverity = android::base::LogSeverity;
46*795d594fSAndroid Build Coastguard Worker using ScopedLogSeverity = android::base::ScopedLogSeverity;
47*795d594fSAndroid Build Coastguard Worker 
48*795d594fSAndroid Build Coastguard Worker template<class MirrorType>
MakeObjPtr(MirrorType * ptr)49*795d594fSAndroid Build Coastguard Worker static inline ObjPtr<MirrorType> MakeObjPtr(MirrorType* ptr) REQUIRES_SHARED(Locks::mutator_lock_) {
50*795d594fSAndroid Build Coastguard Worker   return ptr;
51*795d594fSAndroid Build Coastguard Worker }
52*795d594fSAndroid Build Coastguard Worker 
53*795d594fSAndroid Build Coastguard Worker template<class MirrorType>
MakeObjPtr(ObjPtr<MirrorType> ptr)54*795d594fSAndroid Build Coastguard Worker static inline ObjPtr<MirrorType> MakeObjPtr(ObjPtr<MirrorType> ptr)
55*795d594fSAndroid Build Coastguard Worker     REQUIRES_SHARED(Locks::mutator_lock_) {
56*795d594fSAndroid Build Coastguard Worker   return ptr;
57*795d594fSAndroid Build Coastguard Worker }
58*795d594fSAndroid Build Coastguard Worker 
59*795d594fSAndroid Build Coastguard Worker // OBJ pointer helpers to avoid needing .Decode everywhere.
60*795d594fSAndroid Build Coastguard Worker #define EXPECT_OBJ_PTR_EQ(a, b) EXPECT_EQ(MakeObjPtr(a).Ptr(), MakeObjPtr(b).Ptr())
61*795d594fSAndroid Build Coastguard Worker #define ASSERT_OBJ_PTR_EQ(a, b) ASSERT_EQ(MakeObjPtr(a).Ptr(), MakeObjPtr(b).Ptr())
62*795d594fSAndroid Build Coastguard Worker #define EXPECT_OBJ_PTR_NE(a, b) EXPECT_NE(MakeObjPtr(a).Ptr(), MakeObjPtr(b).Ptr())
63*795d594fSAndroid Build Coastguard Worker #define ASSERT_OBJ_PTR_NE(a, b) ASSERT_NE(MakeObjPtr(a).Ptr(), MakeObjPtr(b).Ptr())
64*795d594fSAndroid Build Coastguard Worker 
65*795d594fSAndroid Build Coastguard Worker class ClassLinker;
66*795d594fSAndroid Build Coastguard Worker class CompilerCallbacks;
67*795d594fSAndroid Build Coastguard Worker class DexFile;
68*795d594fSAndroid Build Coastguard Worker class JavaVMExt;
69*795d594fSAndroid Build Coastguard Worker class Runtime;
70*795d594fSAndroid Build Coastguard Worker using RuntimeOptions = std::vector<std::pair<std::string, const void*>>;
71*795d594fSAndroid Build Coastguard Worker class Thread;
72*795d594fSAndroid Build Coastguard Worker class VariableSizedHandleScope;
73*795d594fSAndroid Build Coastguard Worker 
74*795d594fSAndroid Build Coastguard Worker class CommonRuntimeTestImpl : public CommonArtTestImpl {
75*795d594fSAndroid Build Coastguard Worker  public:
76*795d594fSAndroid Build Coastguard Worker   CommonRuntimeTestImpl();
77*795d594fSAndroid Build Coastguard Worker   virtual ~CommonRuntimeTestImpl();
78*795d594fSAndroid Build Coastguard Worker 
79*795d594fSAndroid Build Coastguard Worker   // A helper function to fill the heap.
80*795d594fSAndroid Build Coastguard Worker   static void FillHeap(Thread* self,
81*795d594fSAndroid Build Coastguard Worker                        ClassLinker* class_linker,
82*795d594fSAndroid Build Coastguard Worker                        VariableSizedHandleScope* handle_scope)
83*795d594fSAndroid Build Coastguard Worker       REQUIRES_SHARED(Locks::mutator_lock_);
84*795d594fSAndroid Build Coastguard Worker   // A helper to set up a small heap (4M) to make FillHeap faster.
85*795d594fSAndroid Build Coastguard Worker   static void SetUpRuntimeOptionsForFillHeap(RuntimeOptions *options);
86*795d594fSAndroid Build Coastguard Worker 
87*795d594fSAndroid Build Coastguard Worker   template <typename Mutator>
MutateDexFile(File * output_dex,const std::string & input_jar,const Mutator & mutator)88*795d594fSAndroid Build Coastguard Worker   bool MutateDexFile(File* output_dex, const std::string& input_jar, const Mutator& mutator) {
89*795d594fSAndroid Build Coastguard Worker     std::vector<std::unique_ptr<const DexFile>> dex_files;
90*795d594fSAndroid Build Coastguard Worker     std::string error_msg;
91*795d594fSAndroid Build Coastguard Worker     ArtDexFileLoader dex_file_loader(input_jar);
92*795d594fSAndroid Build Coastguard Worker     CHECK(dex_file_loader.Open(/*verify=*/true,
93*795d594fSAndroid Build Coastguard Worker                                /*verify_checksum=*/true,
94*795d594fSAndroid Build Coastguard Worker                                &error_msg,
95*795d594fSAndroid Build Coastguard Worker                                &dex_files))
96*795d594fSAndroid Build Coastguard Worker         << error_msg;
97*795d594fSAndroid Build Coastguard Worker     EXPECT_EQ(dex_files.size(), 1u) << "Only one input dex is supported";
98*795d594fSAndroid Build Coastguard Worker     const std::unique_ptr<const DexFile>& dex = dex_files[0];
99*795d594fSAndroid Build Coastguard Worker     CHECK(dex->EnableWrite()) << "Failed to enable write";
100*795d594fSAndroid Build Coastguard Worker     DexFile* dex_file = const_cast<DexFile*>(dex.get());
101*795d594fSAndroid Build Coastguard Worker     mutator(dex_file);
102*795d594fSAndroid Build Coastguard Worker     const_cast<DexFile::Header&>(dex_file->GetHeader()).checksum_ = dex_file->CalculateChecksum();
103*795d594fSAndroid Build Coastguard Worker     if (!output_dex->WriteFully(dex->Begin(), dex->Size())) {
104*795d594fSAndroid Build Coastguard Worker       return false;
105*795d594fSAndroid Build Coastguard Worker     }
106*795d594fSAndroid Build Coastguard Worker     if (output_dex->Flush() != 0) {
107*795d594fSAndroid Build Coastguard Worker       PLOG(FATAL) << "Could not flush the output file.";
108*795d594fSAndroid Build Coastguard Worker     }
109*795d594fSAndroid Build Coastguard Worker     return true;
110*795d594fSAndroid Build Coastguard Worker   }
111*795d594fSAndroid Build Coastguard Worker 
112*795d594fSAndroid Build Coastguard Worker   void MakeInterpreted(ObjPtr<mirror::Class> klass)
113*795d594fSAndroid Build Coastguard Worker       REQUIRES_SHARED(Locks::mutator_lock_);
114*795d594fSAndroid Build Coastguard Worker 
115*795d594fSAndroid Build Coastguard Worker   bool StartDex2OatCommandLine(/*out*/std::vector<std::string>* argv,
116*795d594fSAndroid Build Coastguard Worker                                /*out*/std::string* error_msg,
117*795d594fSAndroid Build Coastguard Worker                                bool use_runtime_bcp_and_image = true);
118*795d594fSAndroid Build Coastguard Worker 
119*795d594fSAndroid Build Coastguard Worker   bool CompileBootImage(const std::vector<std::string>& extra_args,
120*795d594fSAndroid Build Coastguard Worker                         const std::string& image_file_name_prefix,
121*795d594fSAndroid Build Coastguard Worker                         ArrayRef<const std::string> dex_files,
122*795d594fSAndroid Build Coastguard Worker                         ArrayRef<const std::string> dex_locations,
123*795d594fSAndroid Build Coastguard Worker                         std::string* error_msg,
124*795d594fSAndroid Build Coastguard Worker                         const std::string& use_fd_prefix = "");
125*795d594fSAndroid Build Coastguard Worker 
126*795d594fSAndroid Build Coastguard Worker   bool CompileBootImage(const std::vector<std::string>& extra_args,
127*795d594fSAndroid Build Coastguard Worker                         const std::string& image_file_name_prefix,
128*795d594fSAndroid Build Coastguard Worker                         ArrayRef<const std::string> dex_files,
129*795d594fSAndroid Build Coastguard Worker                         std::string* error_msg,
130*795d594fSAndroid Build Coastguard Worker                         const std::string& use_fd_prefix = "") {
131*795d594fSAndroid Build Coastguard Worker     return CompileBootImage(
132*795d594fSAndroid Build Coastguard Worker         extra_args, image_file_name_prefix, dex_files, dex_files, error_msg, use_fd_prefix);
133*795d594fSAndroid Build Coastguard Worker   }
134*795d594fSAndroid Build Coastguard Worker 
135*795d594fSAndroid Build Coastguard Worker   bool RunDex2Oat(const std::vector<std::string>& args, std::string* error_msg);
136*795d594fSAndroid Build Coastguard Worker 
137*795d594fSAndroid Build Coastguard Worker  protected:
138*795d594fSAndroid Build Coastguard Worker   // Allow subclases such as CommonCompilerTest to add extra options.
SetUpRuntimeOptions(RuntimeOptions * options)139*795d594fSAndroid Build Coastguard Worker   virtual void SetUpRuntimeOptions([[maybe_unused]] RuntimeOptions* options) {}
140*795d594fSAndroid Build Coastguard Worker 
141*795d594fSAndroid Build Coastguard Worker   // Called before the runtime is created.
PreRuntimeCreate()142*795d594fSAndroid Build Coastguard Worker   virtual void PreRuntimeCreate() {}
143*795d594fSAndroid Build Coastguard Worker 
144*795d594fSAndroid Build Coastguard Worker   // Called after the runtime is created.
PostRuntimeCreate()145*795d594fSAndroid Build Coastguard Worker   virtual void PostRuntimeCreate() {}
146*795d594fSAndroid Build Coastguard Worker 
147*795d594fSAndroid Build Coastguard Worker   // Loads the test dex file identified by the given dex_name into a PathClassLoader.
148*795d594fSAndroid Build Coastguard Worker   // Returns the created class loader.
149*795d594fSAndroid Build Coastguard Worker   jobject LoadDex(const char* dex_name) REQUIRES_SHARED(Locks::mutator_lock_);
150*795d594fSAndroid Build Coastguard Worker   // Loads the test dex file identified by the given first_dex_name and second_dex_name
151*795d594fSAndroid Build Coastguard Worker   // into a PathClassLoader. Returns the created class loader.
152*795d594fSAndroid Build Coastguard Worker   jobject LoadMultiDex(const char* first_dex_name, const char* second_dex_name)
153*795d594fSAndroid Build Coastguard Worker       REQUIRES_SHARED(Locks::mutator_lock_);
154*795d594fSAndroid Build Coastguard Worker 
155*795d594fSAndroid Build Coastguard Worker   // The following helper functions return global JNI references to the class loader.
156*795d594fSAndroid Build Coastguard Worker   jobject LoadDexInPathClassLoader(const std::string& dex_name,
157*795d594fSAndroid Build Coastguard Worker                                    jobject parent_loader,
158*795d594fSAndroid Build Coastguard Worker                                    jobject shared_libraries = nullptr,
159*795d594fSAndroid Build Coastguard Worker                                    jobject shared_libraries_after = nullptr);
160*795d594fSAndroid Build Coastguard Worker   jobject LoadDexInPathClassLoader(const std::vector<std::string>& dex_names,
161*795d594fSAndroid Build Coastguard Worker                                    jobject parent_loader,
162*795d594fSAndroid Build Coastguard Worker                                    jobject shared_libraries = nullptr,
163*795d594fSAndroid Build Coastguard Worker                                    jobject shared_libraries_after = nullptr);
164*795d594fSAndroid Build Coastguard Worker   jobject LoadDexInDelegateLastClassLoader(const std::string& dex_name, jobject parent_loader);
165*795d594fSAndroid Build Coastguard Worker   jobject LoadDexInInMemoryDexClassLoader(const std::string& dex_name, jobject parent_loader);
166*795d594fSAndroid Build Coastguard Worker   jobject LoadDexInWellKnownClassLoader(ScopedObjectAccess& soa,
167*795d594fSAndroid Build Coastguard Worker                                         const std::vector<std::string>& dex_names,
168*795d594fSAndroid Build Coastguard Worker                                         ObjPtr<mirror::Class> loader_class,
169*795d594fSAndroid Build Coastguard Worker                                         jobject parent_loader,
170*795d594fSAndroid Build Coastguard Worker                                         jobject shared_libraries = nullptr,
171*795d594fSAndroid Build Coastguard Worker                                         jobject shared_libraries_after = nullptr)
172*795d594fSAndroid Build Coastguard Worker       REQUIRES_SHARED(Locks::mutator_lock_);
173*795d594fSAndroid Build Coastguard Worker 
174*795d594fSAndroid Build Coastguard Worker   void VisitDexes(ArrayRef<const std::string> dexes,
175*795d594fSAndroid Build Coastguard Worker                   const std::function<void(MethodReference)>& method_visitor,
176*795d594fSAndroid Build Coastguard Worker                   const std::function<void(TypeReference)>& class_visitor,
177*795d594fSAndroid Build Coastguard Worker                   size_t method_frequency = 1u,
178*795d594fSAndroid Build Coastguard Worker                   size_t class_frequency = 1u);
179*795d594fSAndroid Build Coastguard Worker 
180*795d594fSAndroid Build Coastguard Worker   void GenerateProfile(ArrayRef<const std::string> dexes,
181*795d594fSAndroid Build Coastguard Worker                        File* out_file,
182*795d594fSAndroid Build Coastguard Worker                        size_t method_frequency = 1u,
183*795d594fSAndroid Build Coastguard Worker                        size_t type_frequency = 1u,
184*795d594fSAndroid Build Coastguard Worker                        bool for_boot_image = false);
185*795d594fSAndroid Build Coastguard Worker   void GenerateBootProfile(ArrayRef<const std::string> dexes,
186*795d594fSAndroid Build Coastguard Worker                            File* out_file,
187*795d594fSAndroid Build Coastguard Worker                            size_t method_frequency = 1u,
188*795d594fSAndroid Build Coastguard Worker                            size_t type_frequency = 1u) {
189*795d594fSAndroid Build Coastguard Worker     return GenerateProfile(
190*795d594fSAndroid Build Coastguard Worker         dexes, out_file, method_frequency, type_frequency, /*for_boot_image=*/ true);
191*795d594fSAndroid Build Coastguard Worker   }
192*795d594fSAndroid Build Coastguard Worker 
193*795d594fSAndroid Build Coastguard Worker   ObjPtr<mirror::Class> FindClass(const char* descriptor,
194*795d594fSAndroid Build Coastguard Worker                                   Handle<mirror::ClassLoader> class_loader) const
195*795d594fSAndroid Build Coastguard Worker       REQUIRES_SHARED(Locks::mutator_lock_);
196*795d594fSAndroid Build Coastguard Worker 
197*795d594fSAndroid Build Coastguard Worker   std::unique_ptr<Runtime> runtime_;
198*795d594fSAndroid Build Coastguard Worker 
199*795d594fSAndroid Build Coastguard Worker   // The class_linker_, java_lang_dex_file_, and boot_class_path_ are all
200*795d594fSAndroid Build Coastguard Worker   // owned by the runtime.
201*795d594fSAndroid Build Coastguard Worker   ClassLinker* class_linker_;
202*795d594fSAndroid Build Coastguard Worker   const DexFile* java_lang_dex_file_;
203*795d594fSAndroid Build Coastguard Worker   std::vector<const DexFile*> boot_class_path_;
204*795d594fSAndroid Build Coastguard Worker 
205*795d594fSAndroid Build Coastguard Worker   // Get the dex files from a PathClassLoader or DelegateLastClassLoader.
206*795d594fSAndroid Build Coastguard Worker   // This only looks into the current class loader and does not recurse into the parents.
207*795d594fSAndroid Build Coastguard Worker   std::vector<const DexFile*> GetDexFiles(jobject jclass_loader);
208*795d594fSAndroid Build Coastguard Worker   std::vector<const DexFile*> GetDexFiles(Thread* self, Handle<mirror::ClassLoader> class_loader)
209*795d594fSAndroid Build Coastguard Worker       REQUIRES_SHARED(Locks::mutator_lock_);
210*795d594fSAndroid Build Coastguard Worker 
211*795d594fSAndroid Build Coastguard Worker   // Get the first dex file from a PathClassLoader. Will abort if it is null.
212*795d594fSAndroid Build Coastguard Worker   const DexFile* GetFirstDexFile(jobject jclass_loader);
213*795d594fSAndroid Build Coastguard Worker 
214*795d594fSAndroid Build Coastguard Worker   std::unique_ptr<CompilerCallbacks> callbacks_;
215*795d594fSAndroid Build Coastguard Worker 
216*795d594fSAndroid Build Coastguard Worker   bool use_boot_image_;
217*795d594fSAndroid Build Coastguard Worker 
218*795d594fSAndroid Build Coastguard Worker   virtual void SetUp();
219*795d594fSAndroid Build Coastguard Worker 
220*795d594fSAndroid Build Coastguard Worker   virtual void TearDown();
221*795d594fSAndroid Build Coastguard Worker 
222*795d594fSAndroid Build Coastguard Worker   // Called to finish up runtime creation and filling test fields. By default runs root
223*795d594fSAndroid Build Coastguard Worker   // initializers, initialize well-known classes, and creates the heap thread pool.
224*795d594fSAndroid Build Coastguard Worker   virtual void FinalizeSetup();
225*795d594fSAndroid Build Coastguard Worker 
226*795d594fSAndroid Build Coastguard Worker   // Returns the directory where the pre-compiled boot.art can be found.
227*795d594fSAndroid Build Coastguard Worker   static std::string GetImageLocation();
228*795d594fSAndroid Build Coastguard Worker   static std::string GetSystemImageFile();
229*795d594fSAndroid Build Coastguard Worker };
230*795d594fSAndroid Build Coastguard Worker 
231*795d594fSAndroid Build Coastguard Worker template <typename TestType>
232*795d594fSAndroid Build Coastguard Worker class CommonRuntimeTestBase : public TestType, public CommonRuntimeTestImpl {
233*795d594fSAndroid Build Coastguard Worker  public:
CommonRuntimeTestBase()234*795d594fSAndroid Build Coastguard Worker   CommonRuntimeTestBase() {}
~CommonRuntimeTestBase()235*795d594fSAndroid Build Coastguard Worker   virtual ~CommonRuntimeTestBase() {}
236*795d594fSAndroid Build Coastguard Worker 
237*795d594fSAndroid Build Coastguard Worker  protected:
SetUp()238*795d594fSAndroid Build Coastguard Worker   void SetUp() override {
239*795d594fSAndroid Build Coastguard Worker     CommonRuntimeTestImpl::SetUp();
240*795d594fSAndroid Build Coastguard Worker   }
241*795d594fSAndroid Build Coastguard Worker 
TearDown()242*795d594fSAndroid Build Coastguard Worker   void TearDown() override {
243*795d594fSAndroid Build Coastguard Worker     CommonRuntimeTestImpl::TearDown();
244*795d594fSAndroid Build Coastguard Worker   }
245*795d594fSAndroid Build Coastguard Worker };
246*795d594fSAndroid Build Coastguard Worker 
247*795d594fSAndroid Build Coastguard Worker using CommonRuntimeTest = CommonRuntimeTestBase<testing::Test>;
248*795d594fSAndroid Build Coastguard Worker 
249*795d594fSAndroid Build Coastguard Worker template <typename Param>
250*795d594fSAndroid Build Coastguard Worker using CommonRuntimeTestWithParam = CommonRuntimeTestBase<testing::TestWithParam<Param>>;
251*795d594fSAndroid Build Coastguard Worker 
252*795d594fSAndroid Build Coastguard Worker // Sets a CheckJni abort hook to catch failures. Note that this will cause CheckJNI to carry on
253*795d594fSAndroid Build Coastguard Worker // rather than aborting, so be careful!
254*795d594fSAndroid Build Coastguard Worker class CheckJniAbortCatcher {
255*795d594fSAndroid Build Coastguard Worker  public:
256*795d594fSAndroid Build Coastguard Worker   CheckJniAbortCatcher();
257*795d594fSAndroid Build Coastguard Worker 
258*795d594fSAndroid Build Coastguard Worker   ~CheckJniAbortCatcher();
259*795d594fSAndroid Build Coastguard Worker 
260*795d594fSAndroid Build Coastguard Worker   void Check(const std::string& expected_text);
261*795d594fSAndroid Build Coastguard Worker   void Check(const char* expected_text);
262*795d594fSAndroid Build Coastguard Worker 
263*795d594fSAndroid Build Coastguard Worker  private:
264*795d594fSAndroid Build Coastguard Worker   static void Hook(void* data, const std::string& reason);
265*795d594fSAndroid Build Coastguard Worker 
266*795d594fSAndroid Build Coastguard Worker   JavaVMExt* const vm_;
267*795d594fSAndroid Build Coastguard Worker   std::string actual_;
268*795d594fSAndroid Build Coastguard Worker 
269*795d594fSAndroid Build Coastguard Worker   DISALLOW_COPY_AND_ASSIGN(CheckJniAbortCatcher);
270*795d594fSAndroid Build Coastguard Worker };
271*795d594fSAndroid Build Coastguard Worker 
272*795d594fSAndroid Build Coastguard Worker #define TEST_DISABLED() GTEST_SKIP() << "WARNING: TEST DISABLED";
273*795d594fSAndroid Build Coastguard Worker 
274*795d594fSAndroid Build Coastguard Worker #define TEST_DISABLED_FOR_ARM()                                                        \
275*795d594fSAndroid Build Coastguard Worker   if (kRuntimeISA == InstructionSet::kArm || kRuntimeISA == InstructionSet::kThumb2) { \
276*795d594fSAndroid Build Coastguard Worker     GTEST_SKIP() << "WARNING: TEST DISABLED FOR ARM";                                  \
277*795d594fSAndroid Build Coastguard Worker   }
278*795d594fSAndroid Build Coastguard Worker 
279*795d594fSAndroid Build Coastguard Worker #define TEST_DISABLED_FOR_ARM64()                       \
280*795d594fSAndroid Build Coastguard Worker   if (kRuntimeISA == InstructionSet::kArm64) {          \
281*795d594fSAndroid Build Coastguard Worker     GTEST_SKIP() << "WARNING: TEST DISABLED FOR ARM64"; \
282*795d594fSAndroid Build Coastguard Worker   }
283*795d594fSAndroid Build Coastguard Worker 
284*795d594fSAndroid Build Coastguard Worker #define TEST_DISABLED_FOR_RISCV64()                       \
285*795d594fSAndroid Build Coastguard Worker   if (kRuntimeISA == InstructionSet::kRiscv64) {          \
286*795d594fSAndroid Build Coastguard Worker     GTEST_SKIP() << "WARNING: TEST DISABLED FOR RISCV64"; \
287*795d594fSAndroid Build Coastguard Worker   }
288*795d594fSAndroid Build Coastguard Worker 
289*795d594fSAndroid Build Coastguard Worker #define TEST_DISABLED_FOR_X86()                       \
290*795d594fSAndroid Build Coastguard Worker   if (kRuntimeISA == InstructionSet::kX86) {          \
291*795d594fSAndroid Build Coastguard Worker     GTEST_SKIP() << "WARNING: TEST DISABLED FOR X86"; \
292*795d594fSAndroid Build Coastguard Worker   }
293*795d594fSAndroid Build Coastguard Worker 
294*795d594fSAndroid Build Coastguard Worker #define TEST_DISABLED_FOR_X86_64()                       \
295*795d594fSAndroid Build Coastguard Worker   if (kRuntimeISA == InstructionSet::kX86_64) {          \
296*795d594fSAndroid Build Coastguard Worker     GTEST_SKIP() << "WARNING: TEST DISABLED FOR X86_64"; \
297*795d594fSAndroid Build Coastguard Worker   }
298*795d594fSAndroid Build Coastguard Worker 
299*795d594fSAndroid Build Coastguard Worker #define TEST_DISABLED_WITHOUT_BAKER_READ_BARRIERS()                             \
300*795d594fSAndroid Build Coastguard Worker   if (!gUseReadBarrier || !kUseBakerReadBarrier) {                              \
301*795d594fSAndroid Build Coastguard Worker     GTEST_SKIP() << "WARNING: TEST DISABLED FOR GC WITHOUT BAKER READ BARRIER"; \
302*795d594fSAndroid Build Coastguard Worker   }
303*795d594fSAndroid Build Coastguard Worker 
304*795d594fSAndroid Build Coastguard Worker #define TEST_DISABLED_FOR_MEMORY_TOOL_WITH_HEAP_POISONING_WITHOUT_READ_BARRIERS()              \
305*795d594fSAndroid Build Coastguard Worker   if (kRunningOnMemoryTool && kPoisonHeapReferences && !gUseReadBarrier) {                     \
306*795d594fSAndroid Build Coastguard Worker     GTEST_SKIP()                                                                               \
307*795d594fSAndroid Build Coastguard Worker         << "WARNING: TEST DISABLED FOR MEMORY TOOL WITH HEAP POISONING WITHOUT READ BARRIERS"; \
308*795d594fSAndroid Build Coastguard Worker   }
309*795d594fSAndroid Build Coastguard Worker 
310*795d594fSAndroid Build Coastguard Worker #define TEST_DISABLED_FOR_KERNELS_WITH_CACHE_SEGFAULT()                                   \
311*795d594fSAndroid Build Coastguard Worker   if (CacheOperationsMaySegFault()) {                                                     \
312*795d594fSAndroid Build Coastguard Worker     GTEST_SKIP() << "WARNING: TEST DISABLED ON KERNEL THAT SEGFAULT ON CACHE OPERATIONS"; \
313*795d594fSAndroid Build Coastguard Worker   }
314*795d594fSAndroid Build Coastguard Worker 
315*795d594fSAndroid Build Coastguard Worker #define TEST_DISABLED_ON_VM() \
316*795d594fSAndroid Build Coastguard Worker   if (RunningOnVM()) {        \
317*795d594fSAndroid Build Coastguard Worker     GTEST_SKIP();             \
318*795d594fSAndroid Build Coastguard Worker   }
319*795d594fSAndroid Build Coastguard Worker 
320*795d594fSAndroid Build Coastguard Worker }  // namespace art
321*795d594fSAndroid Build Coastguard Worker 
322*795d594fSAndroid Build Coastguard Worker #endif  // ART_RUNTIME_COMMON_RUNTIME_TEST_H_
323