Brian Carlstrom | a1ce1fe | 2014-02-24 23:23:58 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef ART_RUNTIME_COMMON_RUNTIME_TEST_H_ |
| 18 | #define ART_RUNTIME_COMMON_RUNTIME_TEST_H_ |
| 19 | |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 20 | #include <gtest/gtest.h> |
| 21 | #include <jni.h> |
Brian Carlstrom | a1ce1fe | 2014-02-24 23:23:58 -0800 | [diff] [blame] | 22 | |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 23 | #include <string> |
| 24 | |
Andreas Gampe | 170331f | 2017-12-07 18:41:03 -0800 | [diff] [blame] | 25 | #include <android-base/logging.h> |
| 26 | |
David Srbecky | 3e52aa4 | 2015-04-12 07:45:18 +0100 | [diff] [blame] | 27 | #include "arch/instruction_set.h" |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 28 | #include "base/mutex.h" |
Mathieu Chartier | 2c4b084 | 2017-12-13 11:49:51 -0800 | [diff] [blame^] | 29 | #include "cdex/compact_dex_level.h" |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 30 | #include "globals.h" |
Mathieu Chartier | 3398c78 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 31 | // TODO: Add inl file and avoid including inl. |
| 32 | #include "obj_ptr-inl.h" |
Brian Carlstrom | a1ce1fe | 2014-02-24 23:23:58 -0800 | [diff] [blame] | 33 | #include "os.h" |
Calin Juravle | c79470d | 2017-07-12 17:37:42 -0700 | [diff] [blame] | 34 | #include "scoped_thread_state_change-inl.h" |
Brian Carlstrom | a1ce1fe | 2014-02-24 23:23:58 -0800 | [diff] [blame] | 35 | |
| 36 | namespace art { |
| 37 | |
Andreas Gampe | 170331f | 2017-12-07 18:41:03 -0800 | [diff] [blame] | 38 | using LogSeverity = android::base::LogSeverity; |
| 39 | using ScopedLogSeverity = android::base::ScopedLogSeverity; |
| 40 | |
Mathieu Chartier | 3398c78 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 41 | // OBJ pointer helpers to avoid needing .Decode everywhere. |
Mathieu Chartier | 1cc62e4 | 2016-10-03 18:01:28 -0700 | [diff] [blame] | 42 | #define EXPECT_OBJ_PTR_EQ(a, b) EXPECT_EQ(MakeObjPtr(a).Ptr(), MakeObjPtr(b).Ptr()); |
| 43 | #define ASSERT_OBJ_PTR_EQ(a, b) ASSERT_EQ(MakeObjPtr(a).Ptr(), MakeObjPtr(b).Ptr()); |
| 44 | #define EXPECT_OBJ_PTR_NE(a, b) EXPECT_NE(MakeObjPtr(a).Ptr(), MakeObjPtr(b).Ptr()); |
| 45 | #define ASSERT_OBJ_PTR_NE(a, b) ASSERT_NE(MakeObjPtr(a).Ptr(), MakeObjPtr(b).Ptr()); |
Mathieu Chartier | 3398c78 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 46 | |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 47 | class ClassLinker; |
| 48 | class CompilerCallbacks; |
| 49 | class DexFile; |
| 50 | class JavaVMExt; |
| 51 | class Runtime; |
| 52 | typedef std::vector<std::pair<std::string, const void*>> RuntimeOptions; |
Andreas Gampe | 26761f7 | 2017-07-20 18:00:39 -0700 | [diff] [blame] | 53 | class Thread; |
| 54 | class VariableSizedHandleScope; |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 55 | |
Alex Light | a01b524 | 2017-03-27 10:15:27 -0700 | [diff] [blame] | 56 | uint8_t* DecodeBase64(const char* src, size_t* dst_size); |
| 57 | |
Brian Carlstrom | a1ce1fe | 2014-02-24 23:23:58 -0800 | [diff] [blame] | 58 | class ScratchFile { |
| 59 | public: |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 60 | ScratchFile(); |
Brian Carlstrom | a1ce1fe | 2014-02-24 23:23:58 -0800 | [diff] [blame] | 61 | |
Mathieu Chartier | 866d874 | 2016-09-21 15:24:18 -0700 | [diff] [blame] | 62 | explicit ScratchFile(const std::string& filename); |
| 63 | |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 64 | ScratchFile(const ScratchFile& other, const char* suffix); |
Nicolas Geoffray | 9583fbc | 2014-02-28 15:21:07 +0000 | [diff] [blame] | 65 | |
Andreas Gampe | 0afd1be | 2016-11-03 17:24:45 -0700 | [diff] [blame] | 66 | ScratchFile(ScratchFile&& other); |
Mathieu Chartier | 866d874 | 2016-09-21 15:24:18 -0700 | [diff] [blame] | 67 | |
| 68 | ScratchFile& operator=(ScratchFile&& other); |
| 69 | |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 70 | explicit ScratchFile(File* file); |
Brian Carlstrom | 0e12bdc | 2014-05-14 17:44:28 -0700 | [diff] [blame] | 71 | |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 72 | ~ScratchFile(); |
Brian Carlstrom | a1ce1fe | 2014-02-24 23:23:58 -0800 | [diff] [blame] | 73 | |
| 74 | const std::string& GetFilename() const { |
| 75 | return filename_; |
| 76 | } |
| 77 | |
| 78 | File* GetFile() const { |
| 79 | return file_.get(); |
| 80 | } |
| 81 | |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 82 | int GetFd() const; |
Brian Carlstrom | a1ce1fe | 2014-02-24 23:23:58 -0800 | [diff] [blame] | 83 | |
Andreas Gampe | e21dc3d | 2014-12-08 16:59:43 -0800 | [diff] [blame] | 84 | void Close(); |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 85 | void Unlink(); |
Brian Carlstrom | 0e12bdc | 2014-05-14 17:44:28 -0700 | [diff] [blame] | 86 | |
Brian Carlstrom | a1ce1fe | 2014-02-24 23:23:58 -0800 | [diff] [blame] | 87 | private: |
| 88 | std::string filename_; |
Ian Rogers | 700a402 | 2014-05-19 16:49:03 -0700 | [diff] [blame] | 89 | std::unique_ptr<File> file_; |
Brian Carlstrom | a1ce1fe | 2014-02-24 23:23:58 -0800 | [diff] [blame] | 90 | }; |
| 91 | |
Mathieu Chartier | 91c9116 | 2016-01-15 09:48:15 -0800 | [diff] [blame] | 92 | class CommonRuntimeTestImpl { |
Brian Carlstrom | a1ce1fe | 2014-02-24 23:23:58 -0800 | [diff] [blame] | 93 | public: |
Mathieu Chartier | 91c9116 | 2016-01-15 09:48:15 -0800 | [diff] [blame] | 94 | CommonRuntimeTestImpl(); |
| 95 | virtual ~CommonRuntimeTestImpl(); |
Andreas Gampe | 7747c8d | 2014-08-06 14:53:03 -0700 | [diff] [blame] | 96 | static void SetUpAndroidRoot(); |
| 97 | |
| 98 | // Note: setting up ANDROID_DATA may create a temporary directory. If this is used in a |
| 99 | // non-derived class, be sure to also call the corresponding tear-down below. |
| 100 | static void SetUpAndroidData(std::string& android_data); |
| 101 | |
| 102 | static void TearDownAndroidData(const std::string& android_data, bool fail_on_error); |
Brian Carlstrom | a1ce1fe | 2014-02-24 23:23:58 -0800 | [diff] [blame] | 103 | |
Narayan Kamath | d1ef436 | 2015-11-12 11:49:06 +0000 | [diff] [blame] | 104 | // Gets the paths of the libcore dex files. |
| 105 | static std::vector<std::string> GetLibCoreDexFileNames(); |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 106 | |
David Srbecky | 3e52aa4 | 2015-04-12 07:45:18 +0100 | [diff] [blame] | 107 | // Returns bin directory which contains host's prebuild tools. |
| 108 | static std::string GetAndroidHostToolsDir(); |
| 109 | |
Mathieu Chartier | d00e02b | 2017-05-24 12:04:13 -0700 | [diff] [blame] | 110 | // Returns bin directory which contains target's prebuild tools. |
David Srbecky | 3e52aa4 | 2015-04-12 07:45:18 +0100 | [diff] [blame] | 111 | static std::string GetAndroidTargetToolsDir(InstructionSet isa); |
| 112 | |
Mathieu Chartier | d00e02b | 2017-05-24 12:04:13 -0700 | [diff] [blame] | 113 | // Retuerns the filename for a test dex (i.e. XandY or ManyMethods). |
| 114 | std::string GetTestDexFileName(const char* name) const; |
| 115 | |
Andreas Gampe | 26761f7 | 2017-07-20 18:00:39 -0700 | [diff] [blame] | 116 | // A helper function to fill the heap. |
| 117 | static void FillHeap(Thread* self, |
| 118 | ClassLinker* class_linker, |
| 119 | VariableSizedHandleScope* handle_scope) |
| 120 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 121 | // A helper to set up a small heap (4M) to make FillHeap faster. |
| 122 | static void SetUpRuntimeOptionsForFillHeap(RuntimeOptions *options); |
| 123 | |
Brian Carlstrom | a1ce1fe | 2014-02-24 23:23:58 -0800 | [diff] [blame] | 124 | protected: |
Mathieu Chartier | 91c9116 | 2016-01-15 09:48:15 -0800 | [diff] [blame] | 125 | // Allow subclases such as CommonCompilerTest to add extra options. |
| 126 | virtual void SetUpRuntimeOptions(RuntimeOptions* options ATTRIBUTE_UNUSED) {} |
| 127 | |
| 128 | // Called before the runtime is created. |
| 129 | virtual void PreRuntimeCreate() {} |
| 130 | |
| 131 | // Called after the runtime is created. |
| 132 | virtual void PostRuntimeCreate() {} |
| 133 | |
Brian Carlstrom | a1ce1fe | 2014-02-24 23:23:58 -0800 | [diff] [blame] | 134 | static bool IsHost() { |
| 135 | return !kIsTargetBuild; |
| 136 | } |
| 137 | |
Igor Murashkin | 3774335 | 2014-11-13 14:38:00 -0800 | [diff] [blame] | 138 | // File location to core.art, e.g. $ANDROID_HOST_OUT/system/framework/core.art |
| 139 | static std::string GetCoreArtLocation(); |
| 140 | |
| 141 | // File location to core.oat, e.g. $ANDROID_HOST_OUT/system/framework/core.oat |
| 142 | static std::string GetCoreOatLocation(); |
| 143 | |
Richard Uhler | fbef44d | 2014-12-23 09:48:51 -0800 | [diff] [blame] | 144 | std::unique_ptr<const DexFile> LoadExpectSingleDexFile(const char* location); |
Andreas Gampe | 833a485 | 2014-05-21 18:46:59 -0700 | [diff] [blame] | 145 | |
Mathieu Chartier | f70fe3d | 2017-06-21 15:24:02 -0700 | [diff] [blame] | 146 | void ClearDirectory(const char* dirpath, bool recursive = true); |
Alex Light | a59dd80 | 2014-07-02 16:28:08 -0700 | [diff] [blame] | 147 | |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 148 | std::string GetTestAndroidRoot(); |
Brian Carlstrom | a1ce1fe | 2014-02-24 23:23:58 -0800 | [diff] [blame] | 149 | |
Mathieu Chartier | 496577f | 2016-09-20 15:33:31 -0700 | [diff] [blame] | 150 | std::vector<std::unique_ptr<const DexFile>> OpenTestDexFiles(const char* name); |
Andreas Gampe | 833a485 | 2014-05-21 18:46:59 -0700 | [diff] [blame] | 151 | |
Mathieu Chartier | db40eac | 2017-06-09 18:34:11 -0700 | [diff] [blame] | 152 | std::unique_ptr<const DexFile> OpenTestDexFile(const char* name); |
Brian Carlstrom | a1ce1fe | 2014-02-24 23:23:58 -0800 | [diff] [blame] | 153 | |
Calin Juravle | 7865ac7 | 2017-06-28 11:03:12 -0700 | [diff] [blame] | 154 | // Loads the test dex file identified by the given dex_name into a PathClassLoader. |
| 155 | // Returns the created class loader. |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 156 | jobject LoadDex(const char* dex_name) REQUIRES_SHARED(Locks::mutator_lock_); |
Calin Juravle | 7865ac7 | 2017-06-28 11:03:12 -0700 | [diff] [blame] | 157 | // Loads the test dex file identified by the given first_dex_name and second_dex_name |
| 158 | // into a PathClassLoader. Returns the created class loader. |
Nicolas Geoffray | d01f60c | 2016-10-28 14:45:48 +0100 | [diff] [blame] | 159 | jobject LoadMultiDex(const char* first_dex_name, const char* second_dex_name) |
| 160 | REQUIRES_SHARED(Locks::mutator_lock_); |
Brian Carlstrom | a1ce1fe | 2014-02-24 23:23:58 -0800 | [diff] [blame] | 161 | |
Calin Juravle | 7865ac7 | 2017-06-28 11:03:12 -0700 | [diff] [blame] | 162 | jobject LoadDexInPathClassLoader(const std::string& dex_name, jobject parent_loader); |
| 163 | jobject LoadDexInDelegateLastClassLoader(const std::string& dex_name, jobject parent_loader); |
| 164 | jobject LoadDexInWellKnownClassLoader(const std::string& dex_name, |
| 165 | jclass loader_class, |
| 166 | jobject parent_loader); |
| 167 | |
Brian Carlstrom | a1ce1fe | 2014-02-24 23:23:58 -0800 | [diff] [blame] | 168 | std::string android_data_; |
| 169 | std::string dalvik_cache_; |
Richard Uhler | fbef44d | 2014-12-23 09:48:51 -0800 | [diff] [blame] | 170 | |
Ian Rogers | 700a402 | 2014-05-19 16:49:03 -0700 | [diff] [blame] | 171 | std::unique_ptr<Runtime> runtime_; |
Richard Uhler | fbef44d | 2014-12-23 09:48:51 -0800 | [diff] [blame] | 172 | |
| 173 | // The class_linker_, java_lang_dex_file_, and boot_class_path_ are all |
| 174 | // owned by the runtime. |
Brian Carlstrom | a1ce1fe | 2014-02-24 23:23:58 -0800 | [diff] [blame] | 175 | ClassLinker* class_linker_; |
Richard Uhler | fbef44d | 2014-12-23 09:48:51 -0800 | [diff] [blame] | 176 | const DexFile* java_lang_dex_file_; |
| 177 | std::vector<const DexFile*> boot_class_path_; |
Brian Carlstrom | a1ce1fe | 2014-02-24 23:23:58 -0800 | [diff] [blame] | 178 | |
Calin Juravle | c79470d | 2017-07-12 17:37:42 -0700 | [diff] [blame] | 179 | // Get the dex files from a PathClassLoader or DelegateLastClassLoader. |
| 180 | // This only looks into the current class loader and does not recurse into the parents. |
Andreas Gampe | 81c6f8d | 2015-03-25 17:19:53 -0700 | [diff] [blame] | 181 | std::vector<const DexFile*> GetDexFiles(jobject jclass_loader); |
Calin Juravle | c79470d | 2017-07-12 17:37:42 -0700 | [diff] [blame] | 182 | std::vector<const DexFile*> GetDexFiles(ScopedObjectAccess& soa, |
| 183 | Handle<mirror::ClassLoader> class_loader) |
| 184 | REQUIRES_SHARED(Locks::mutator_lock_); |
Andreas Gampe | 81c6f8d | 2015-03-25 17:19:53 -0700 | [diff] [blame] | 185 | |
| 186 | // Get the first dex file from a PathClassLoader. Will abort if it is null. |
| 187 | const DexFile* GetFirstDexFile(jobject jclass_loader); |
| 188 | |
Andreas Gampe | bb9c6b1 | 2015-03-29 13:56:36 -0700 | [diff] [blame] | 189 | std::unique_ptr<CompilerCallbacks> callbacks_; |
| 190 | |
Przemyslaw Szczepaniak | a794c26 | 2016-07-25 17:31:06 +0100 | [diff] [blame] | 191 | virtual void SetUp(); |
Mathieu Chartier | 91c9116 | 2016-01-15 09:48:15 -0800 | [diff] [blame] | 192 | |
Przemyslaw Szczepaniak | a794c26 | 2016-07-25 17:31:06 +0100 | [diff] [blame] | 193 | virtual void TearDown(); |
Mathieu Chartier | 91c9116 | 2016-01-15 09:48:15 -0800 | [diff] [blame] | 194 | |
Przemyslaw Szczepaniak | a794c26 | 2016-07-25 17:31:06 +0100 | [diff] [blame] | 195 | // Called to finish up runtime creation and filling test fields. By default runs root |
| 196 | // initializers, initialize well-known classes, and creates the heap thread pool. |
| 197 | virtual void FinalizeSetup(); |
Mathieu Chartier | 91c9116 | 2016-01-15 09:48:15 -0800 | [diff] [blame] | 198 | |
Calin Juravle | c79470d | 2017-07-12 17:37:42 -0700 | [diff] [blame] | 199 | // Creates the class path string for the given dex files (the list of dex file locations |
| 200 | // separated by ':'). |
| 201 | std::string CreateClassPath( |
| 202 | const std::vector<std::unique_ptr<const DexFile>>& dex_files); |
| 203 | // Same as CreateClassPath but add the dex file checksum after each location. The separator |
| 204 | // is '*'. |
| 205 | std::string CreateClassPathWithChecksums( |
| 206 | const std::vector<std::unique_ptr<const DexFile>>& dex_files); |
| 207 | |
Brian Carlstrom | a1ce1fe | 2014-02-24 23:23:58 -0800 | [diff] [blame] | 208 | private: |
Igor Murashkin | 3774335 | 2014-11-13 14:38:00 -0800 | [diff] [blame] | 209 | static std::string GetCoreFileLocation(const char* suffix); |
| 210 | |
Richard Uhler | fbef44d | 2014-12-23 09:48:51 -0800 | [diff] [blame] | 211 | std::vector<std::unique_ptr<const DexFile>> loaded_dex_files_; |
Brian Carlstrom | a1ce1fe | 2014-02-24 23:23:58 -0800 | [diff] [blame] | 212 | }; |
| 213 | |
Mathieu Chartier | 91c9116 | 2016-01-15 09:48:15 -0800 | [diff] [blame] | 214 | template <typename TestType> |
| 215 | class CommonRuntimeTestBase : public TestType, public CommonRuntimeTestImpl { |
| 216 | public: |
| 217 | CommonRuntimeTestBase() {} |
| 218 | virtual ~CommonRuntimeTestBase() {} |
| 219 | |
| 220 | protected: |
Przemyslaw Szczepaniak | a794c26 | 2016-07-25 17:31:06 +0100 | [diff] [blame] | 221 | virtual void SetUp() OVERRIDE { |
Mathieu Chartier | 91c9116 | 2016-01-15 09:48:15 -0800 | [diff] [blame] | 222 | CommonRuntimeTestImpl::SetUp(); |
| 223 | } |
| 224 | |
Przemyslaw Szczepaniak | a794c26 | 2016-07-25 17:31:06 +0100 | [diff] [blame] | 225 | virtual void TearDown() OVERRIDE { |
Mathieu Chartier | 91c9116 | 2016-01-15 09:48:15 -0800 | [diff] [blame] | 226 | CommonRuntimeTestImpl::TearDown(); |
| 227 | } |
Mathieu Chartier | 91c9116 | 2016-01-15 09:48:15 -0800 | [diff] [blame] | 228 | }; |
| 229 | |
| 230 | using CommonRuntimeTest = CommonRuntimeTestBase<testing::Test>; |
| 231 | |
| 232 | template <typename Param> |
| 233 | using CommonRuntimeTestWithParam = CommonRuntimeTestBase<testing::TestWithParam<Param>>; |
| 234 | |
Brian Carlstrom | a1ce1fe | 2014-02-24 23:23:58 -0800 | [diff] [blame] | 235 | // Sets a CheckJni abort hook to catch failures. Note that this will cause CheckJNI to carry on |
| 236 | // rather than aborting, so be careful! |
| 237 | class CheckJniAbortCatcher { |
| 238 | public: |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 239 | CheckJniAbortCatcher(); |
Brian Carlstrom | a1ce1fe | 2014-02-24 23:23:58 -0800 | [diff] [blame] | 240 | |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 241 | ~CheckJniAbortCatcher(); |
Brian Carlstrom | a1ce1fe | 2014-02-24 23:23:58 -0800 | [diff] [blame] | 242 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 243 | void Check(const std::string& expected_text); |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 244 | void Check(const char* expected_text); |
Brian Carlstrom | a1ce1fe | 2014-02-24 23:23:58 -0800 | [diff] [blame] | 245 | |
| 246 | private: |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 247 | static void Hook(void* data, const std::string& reason); |
Brian Carlstrom | a1ce1fe | 2014-02-24 23:23:58 -0800 | [diff] [blame] | 248 | |
Ian Rogers | 68d8b42 | 2014-07-17 11:09:10 -0700 | [diff] [blame] | 249 | JavaVMExt* const vm_; |
Brian Carlstrom | a1ce1fe | 2014-02-24 23:23:58 -0800 | [diff] [blame] | 250 | std::string actual_; |
| 251 | |
| 252 | DISALLOW_COPY_AND_ASSIGN(CheckJniAbortCatcher); |
| 253 | }; |
| 254 | |
Jeff Hao | 0f7eaeb | 2016-08-31 17:56:13 -0700 | [diff] [blame] | 255 | #define TEST_DISABLED_FOR_TARGET() \ |
| 256 | if (kIsTargetBuild) { \ |
| 257 | printf("WARNING: TEST DISABLED FOR TARGET\n"); \ |
| 258 | return; \ |
| 259 | } |
| 260 | |
Nicolas Geoffray | 54accbc | 2014-08-13 03:40:45 +0100 | [diff] [blame] | 261 | #define TEST_DISABLED_FOR_MIPS() \ |
Vladimir Marko | 33bff25 | 2017-11-01 14:35:42 +0000 | [diff] [blame] | 262 | if (kRuntimeISA == InstructionSet::kMips) { \ |
Nicolas Geoffray | 54accbc | 2014-08-13 03:40:45 +0100 | [diff] [blame] | 263 | printf("WARNING: TEST DISABLED FOR MIPS\n"); \ |
| 264 | return; \ |
| 265 | } |
| 266 | |
Roland Levillain | 19772bf | 2017-02-16 11:28:10 +0000 | [diff] [blame] | 267 | #define TEST_DISABLED_FOR_X86() \ |
Vladimir Marko | 33bff25 | 2017-11-01 14:35:42 +0000 | [diff] [blame] | 268 | if (kRuntimeISA == InstructionSet::kX86) { \ |
Roland Levillain | 19772bf | 2017-02-16 11:28:10 +0000 | [diff] [blame] | 269 | printf("WARNING: TEST DISABLED FOR X86\n"); \ |
Vladimir Marko | 57070da | 2017-02-14 16:16:30 +0000 | [diff] [blame] | 270 | return; \ |
| 271 | } |
| 272 | |
jessicahandojo | 3aaa37b | 2016-07-29 14:46:37 -0700 | [diff] [blame] | 273 | #define TEST_DISABLED_FOR_STRING_COMPRESSION() \ |
| 274 | if (mirror::kUseStringCompression) { \ |
| 275 | printf("WARNING: TEST DISABLED FOR STRING COMPRESSION\n"); \ |
| 276 | return; \ |
| 277 | } |
| 278 | |
Roland Levillain | 6d729a7 | 2017-06-30 18:34:01 +0100 | [diff] [blame] | 279 | #define TEST_DISABLED_WITHOUT_BAKER_READ_BARRIERS() \ |
| 280 | if (!kEmitCompilerReadBarrier || !kUseBakerReadBarrier) { \ |
| 281 | printf("WARNING: TEST DISABLED FOR GC WITHOUT BAKER READ BARRIER\n"); \ |
| 282 | return; \ |
| 283 | } |
| 284 | |
Roland Levillain | 04147ef | 2016-09-06 11:09:41 +0100 | [diff] [blame] | 285 | #define TEST_DISABLED_FOR_NON_STATIC_HOST_BUILDS() \ |
| 286 | if (!kHostStaticBuildEnabled) { \ |
| 287 | printf("WARNING: TEST DISABLED FOR NON-STATIC HOST BUILDS\n"); \ |
| 288 | return; \ |
| 289 | } |
| 290 | |
Mathieu Chartier | 68dda8f | 2017-04-24 10:06:15 -0700 | [diff] [blame] | 291 | #define TEST_DISABLED_FOR_MEMORY_TOOL() \ |
| 292 | if (RUNNING_ON_MEMORY_TOOL > 0) { \ |
| 293 | printf("WARNING: TEST DISABLED FOR MEMORY TOOL\n"); \ |
| 294 | return; \ |
| 295 | } |
| 296 | |
Roland Levillain | 68db225 | 2017-08-14 12:48:47 +0100 | [diff] [blame] | 297 | #define TEST_DISABLED_FOR_MEMORY_TOOL_VALGRIND() \ |
| 298 | if (RUNNING_ON_MEMORY_TOOL > 0 && kMemoryToolIsValgrind) { \ |
| 299 | printf("WARNING: TEST DISABLED FOR MEMORY TOOL VALGRIND\n"); \ |
| 300 | return; \ |
| 301 | } |
| 302 | |
Andreas Gampe | f4a67fd | 2017-05-04 09:55:36 -0700 | [diff] [blame] | 303 | #define TEST_DISABLED_FOR_MEMORY_TOOL_ASAN() \ |
| 304 | if (RUNNING_ON_MEMORY_TOOL > 0 && !kMemoryToolIsValgrind) { \ |
| 305 | printf("WARNING: TEST DISABLED FOR MEMORY TOOL ASAN\n"); \ |
| 306 | return; \ |
| 307 | } |
| 308 | |
Mathieu Chartier | 2c4b084 | 2017-12-13 11:49:51 -0800 | [diff] [blame^] | 309 | #define TEST_DISABLED_FOR_COMPACT_DEX() \ |
| 310 | if (kDefaultCompactDexLevel != CompactDexLevel::kCompactDexLevelNone) { \ |
| 311 | printf("WARNING: TEST DISABLED FOR COMPACT DEX\n"); \ |
| 312 | return; \ |
| 313 | } |
Brian Carlstrom | a1ce1fe | 2014-02-24 23:23:58 -0800 | [diff] [blame] | 314 | } // namespace art |
| 315 | |
Brian Carlstrom | a1ce1fe | 2014-02-24 23:23:58 -0800 | [diff] [blame] | 316 | #endif // ART_RUNTIME_COMMON_RUNTIME_TEST_H_ |