// OBJ pointer helpers to avoid needing .Decode everywhere. #define EXPECT_OBJ_PTR_EQ(a, b) EXPECT_EQ(MakeObjPtr(a).Ptr(), MakeObjPtr(b).Ptr()) #define ASSERT_OBJ_PTR_EQ(a, b) ASSERT_EQ(MakeObjPtr(a).Ptr(), MakeObjPtr(b).Ptr()) #define EXPECT_OBJ_PTR_NE(a, b) EXPECT_NE(MakeObjPtr(a).Ptr(), MakeObjPtr(b).Ptr()) #define ASSERT_OBJ_PTR_NE(a, b) ASSERT_NE(MakeObjPtr(a).Ptr(), MakeObjPtr(b).Ptr())
class ClassLinker; class CompilerCallbacks; class DexFile; class JavaVMExt; class Runtime; using RuntimeOptions = std::vector<std::pair<std::string, constvoid*>>; class Thread; class VariableSizedHandleScope;
class CommonRuntimeTestImpl : public CommonArtTestImpl { public:
CommonRuntimeTestImpl(); virtual ~CommonRuntimeTestImpl();
// A helper function to fill the heap. staticvoid FillHeap(Thread* self,
ClassLinker* class_linker,
VariableSizedHandleScope* handle_scope)
REQUIRES_SHARED(Locks::mutator_lock_); // A helper to set up a small heap (4M) to make FillHeap faster. staticvoid SetUpRuntimeOptionsForFillHeap(RuntimeOptions *options);
protected: // Create a `Runtime`. This is usually done during `SetUp()`. void CreateRuntime();
// Allow subclases such as CommonCompilerTest to add extra options. virtualvoid SetUpRuntimeOptions([[maybe_unused]] RuntimeOptions* options) {}
// Called before the runtime is created. virtualvoid PreRuntimeCreate() {}
// Called after the runtime is created. virtualvoid PostRuntimeCreate() {}
// Loads the test dex file identified by the given dex_name into a PathClassLoader. // Returns the created class loader.
jobject LoadDex(constchar* dex_name) REQUIRES_SHARED(Locks::mutator_lock_); // Loads the test dex file identified by the given first_dex_name and second_dex_name // into a PathClassLoader. Returns the created class loader.
jobject LoadMultiDex(constchar* first_dex_name, constchar* second_dex_name)
REQUIRES_SHARED(Locks::mutator_lock_);
// The class_linker_, java_lang_dex_file_, and boot_class_path_ are all // owned by the runtime.
ClassLinker* class_linker_; const DexFile* java_lang_dex_file_;
std::vector<const DexFile*> boot_class_path_;
// Get the dex files from a PathClassLoader or DelegateLastClassLoader. // This only looks into the current class loader and does not recurse into the parents.
std::vector<const DexFile*> GetDexFiles(jobject jclass_loader);
std::vector<const DexFile*> GetDexFiles(Thread* self, Handle<mirror::ClassLoader> class_loader)
REQUIRES_SHARED(Locks::mutator_lock_);
// Get the first dex file from a PathClassLoader. Will abort if it is null. const DexFile* GetFirstDexFile(jobject jclass_loader);
std::unique_ptr<CompilerCallbacks> callbacks_;
bool use_boot_image_;
virtualvoid SetUp();
virtualvoid TearDown();
// Called to finish up runtime creation and filling test fields. By default runs root // initializers, initialize well-known classes, and creates the heap thread pool. virtualvoid FinalizeSetup();
// Returns the directory where the pre-compiled boot.art can be found. static std::string GetImageLocation(); static std::string GetSystemImageFile();
};
template <typename TestType> class CommonRuntimeTestBase : public TestType, public CommonRuntimeTestImpl { public:
CommonRuntimeTestBase() {} virtual ~CommonRuntimeTestBase() {}
using CommonRuntimeTest = CommonRuntimeTestBase<::testing::Test>;
template <typename Param> using CommonRuntimeTestWithParam = CommonRuntimeTestBase<::testing::TestWithParam<Param>>;
// Sets a CheckJni abort hook to catch failures. Note that this will cause CheckJNI to carry on // rather than aborting, so be careful! class CheckJniAbortCatcher { public:
CheckJniAbortCatcher();
#define TEST_DISABLED() GTEST_SKIP() << "WARNING: TEST DISABLED";
#define TEST_DISABLED_FOR_ARM() \ if (kRuntimeISA == InstructionSet::kArm || kRuntimeISA == InstructionSet::kThumb2) { \
GTEST_SKIP() << "WARNING: TEST DISABLED FOR ARM"; \
}
#define TEST_DISABLED_FOR_ARM64() \ if (kRuntimeISA == InstructionSet::kArm64) { \
GTEST_SKIP() << "WARNING: TEST DISABLED FOR ARM64"; \
}
#define TEST_DISABLED_FOR_RISCV64() \ if (kRuntimeISA == InstructionSet::kRiscv64) { \
GTEST_SKIP() << "WARNING: TEST DISABLED FOR RISCV64"; \
}
#define TEST_DISABLED_FOR_X86() \ if (kRuntimeISA == InstructionSet::kX86) { \
GTEST_SKIP() << "WARNING: TEST DISABLED FOR X86"; \
}
#define TEST_DISABLED_FOR_X86_64() \ if (kRuntimeISA == InstructionSet::kX86_64) { \
GTEST_SKIP() << "WARNING: TEST DISABLED FOR X86_64"; \
}
#define TEST_DISABLED_WITHOUT_BAKER_READ_BARRIERS() \ if (!gUseReadBarrier || !kUseBakerReadBarrier) { \
GTEST_SKIP() << "WARNING: TEST DISABLED FOR GC WITHOUT BAKER READ BARRIER"; \
}
#define TEST_DISABLED_FOR_MEMORY_TOOL_WITH_HEAP_POISONING_WITHOUT_READ_BARRIERS() \ if (kRunningOnMemoryTool && kPoisonHeapReferences && !gUseReadBarrier) { \
GTEST_SKIP() \
<< "WARNING: TEST DISABLED FOR MEMORY TOOL WITH HEAP POISONING WITHOUT READ BARRIERS"; \
}
#define TEST_DISABLED_FOR_KERNELS_WITH_CACHE_SEGFAULT() \ if (CacheOperationsMaySegFault()) { \
GTEST_SKIP() << "WARNING: TEST DISABLED ON KERNEL THAT SEGFAULT ON CACHE OPERATIONS"; \
}
#define TEST_DISABLED_ON_VM() \ if (RunningOnVM()) { \
GTEST_SKIP(); \
}
#define TEST_DISABLED_ON_SBC() \ if (RunningOnSBC()) { \
GTEST_SKIP(); \
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.