Add CommonArtTest
Add a test framework that does not start up a Runtime object.
Bug: 78651010
Test: make -j 40 test-art-host
Change-Id: I6c8af384af5fe1289c6cf137635e94934ac3795d
diff --git a/runtime/common_runtime_test.h b/runtime/common_runtime_test.h
index 186b1cd..892abb4 100644
--- a/runtime/common_runtime_test.h
+++ b/runtime/common_runtime_test.h
@@ -25,6 +25,7 @@
#include <android-base/logging.h>
#include "arch/instruction_set.h"
+#include "base/common_art_test.h"
#include "base/globals.h"
#include "base/mutex.h"
#include "base/os.h"
@@ -55,64 +56,13 @@
class Thread;
class VariableSizedHandleScope;
-class ScratchFile {
- public:
- ScratchFile();
-
- explicit ScratchFile(const std::string& filename);
-
- ScratchFile(const ScratchFile& other, const char* suffix);
-
- ScratchFile(ScratchFile&& other);
-
- ScratchFile& operator=(ScratchFile&& other);
-
- explicit ScratchFile(File* file);
-
- ~ScratchFile();
-
- const std::string& GetFilename() const {
- return filename_;
- }
-
- File* GetFile() const {
- return file_.get();
- }
-
- int GetFd() const;
-
- void Close();
- void Unlink();
-
- private:
- std::string filename_;
- std::unique_ptr<File> file_;
-};
-
-class CommonRuntimeTestImpl {
+class CommonRuntimeTestImpl : public CommonArtTestImpl {
public:
CommonRuntimeTestImpl();
virtual ~CommonRuntimeTestImpl();
- static void SetUpAndroidRoot();
- // Note: setting up ANDROID_DATA may create a temporary directory. If this is used in a
- // non-derived class, be sure to also call the corresponding tear-down below.
- static void SetUpAndroidData(std::string& android_data);
-
- static void TearDownAndroidData(const std::string& android_data, bool fail_on_error);
-
- // Gets the paths of the libcore dex files.
- static std::vector<std::string> GetLibCoreDexFileNames();
-
- // Returns bin directory which contains host's prebuild tools.
- static std::string GetAndroidHostToolsDir();
-
- // Returns bin directory which contains target's prebuild tools.
static std::string GetAndroidTargetToolsDir(InstructionSet isa);
- // Retuerns the filename for a test dex (i.e. XandY or ManyMethods).
- std::string GetTestDexFileName(const char* name) const;
-
// A helper function to fill the heap.
static void FillHeap(Thread* self,
ClassLinker* class_linker,
@@ -157,26 +107,6 @@
// Called after the runtime is created.
virtual void PostRuntimeCreate() {}
- static bool IsHost() {
- return !kIsTargetBuild;
- }
-
- // File location to core.art, e.g. $ANDROID_HOST_OUT/system/framework/core.art
- static std::string GetCoreArtLocation();
-
- // File location to core.oat, e.g. $ANDROID_HOST_OUT/system/framework/core.oat
- static std::string GetCoreOatLocation();
-
- std::unique_ptr<const DexFile> LoadExpectSingleDexFile(const char* location);
-
- void ClearDirectory(const char* dirpath, bool recursive = true);
-
- std::string GetTestAndroidRoot();
-
- std::vector<std::unique_ptr<const DexFile>> OpenTestDexFiles(const char* name);
-
- std::unique_ptr<const DexFile> OpenTestDexFile(const char* name);
-
// Loads the test dex file identified by the given dex_name into a PathClassLoader.
// Returns the created class loader.
jobject LoadDex(const char* dex_name) REQUIRES_SHARED(Locks::mutator_lock_);
@@ -191,9 +121,6 @@
jclass loader_class,
jobject parent_loader);
- std::string android_data_;
- std::string dalvik_cache_;
-
std::unique_ptr<Runtime> runtime_;
// The class_linker_, java_lang_dex_file_, and boot_class_path_ are all
@@ -221,20 +148,6 @@
// 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.
virtual void FinalizeSetup();
-
- // Creates the class path string for the given dex files (the list of dex file locations
- // separated by ':').
- std::string CreateClassPath(
- const std::vector<std::unique_ptr<const DexFile>>& dex_files);
- // Same as CreateClassPath but add the dex file checksum after each location. The separator
- // is '*'.
- std::string CreateClassPathWithChecksums(
- const std::vector<std::unique_ptr<const DexFile>>& dex_files);
-
- private:
- static std::string GetCoreFileLocation(const char* suffix);
-
- std::vector<std::unique_ptr<const DexFile>> loaded_dex_files_;
};
template <typename TestType>
@@ -278,12 +191,6 @@
DISALLOW_COPY_AND_ASSIGN(CheckJniAbortCatcher);
};
-#define TEST_DISABLED_FOR_TARGET() \
- if (kIsTargetBuild) { \
- printf("WARNING: TEST DISABLED FOR TARGET\n"); \
- return; \
- }
-
#define TEST_DISABLED_FOR_MIPS() \
if (kRuntimeISA == InstructionSet::kMips) { \
printf("WARNING: TEST DISABLED FOR MIPS\n"); \
@@ -308,30 +215,6 @@
return; \
}
-#define TEST_DISABLED_FOR_NON_STATIC_HOST_BUILDS() \
- if (!kHostStaticBuildEnabled) { \
- printf("WARNING: TEST DISABLED FOR NON-STATIC HOST BUILDS\n"); \
- return; \
- }
-
-#define TEST_DISABLED_FOR_MEMORY_TOOL() \
- if (RUNNING_ON_MEMORY_TOOL > 0) { \
- printf("WARNING: TEST DISABLED FOR MEMORY TOOL\n"); \
- return; \
- }
-
-#define TEST_DISABLED_FOR_MEMORY_TOOL_VALGRIND() \
- if (RUNNING_ON_MEMORY_TOOL > 0 && kMemoryToolIsValgrind) { \
- printf("WARNING: TEST DISABLED FOR MEMORY TOOL VALGRIND\n"); \
- return; \
- }
-
-#define TEST_DISABLED_FOR_MEMORY_TOOL_ASAN() \
- if (RUNNING_ON_MEMORY_TOOL > 0 && !kMemoryToolIsValgrind) { \
- printf("WARNING: TEST DISABLED FOR MEMORY TOOL ASAN\n"); \
- return; \
- }
-
#define TEST_DISABLED_FOR_HEAP_POISONING() \
if (kPoisonHeapReferences) { \
printf("WARNING: TEST DISABLED FOR HEAP POISONING\n"); \