Rewrite assembler_test_base.h
Simplify the code in preparation of move to LLVM prebuilt tools.
Bug: 147817558
Test: m test-art-host-gtest
Change-Id: Iba277235255fd7d7f0965749b0b2d4a9567ced1f
diff --git a/compiler/utils/assembler_test.h b/compiler/utils/assembler_test.h
index 9e23d11..9fffda5 100644
--- a/compiler/utils/assembler_test.h
+++ b/compiler/utils/assembler_test.h
@@ -53,7 +53,7 @@
typename FPReg,
typename Imm,
typename VecReg = NoVectorRegs>
-class AssemblerTest : public testing::Test {
+class AssemblerTest : public AssemblerTestBase {
public:
Ass* GetAssembler() {
return assembler_.get();
@@ -683,11 +683,6 @@
bias);
}
- // This is intended to be run as a test.
- bool CheckTools() {
- return test_helper_->CheckTools();
- }
-
// The following functions are public so that TestFn can use them...
// Returns a vector of address used by any of the repeat methods
@@ -738,23 +733,14 @@
AssemblerTest() {}
void SetUp() override {
+ AssemblerTestBase::SetUp();
allocator_.reset(new ArenaAllocator(&pool_));
assembler_.reset(CreateAssembler(allocator_.get()));
- test_helper_.reset(
- new AssemblerTestInfrastructure(GetArchitectureString(),
- GetAssemblerCmdName(),
- GetAssemblerParameters(),
- GetObjdumpCmdName(),
- GetObjdumpParameters(),
- GetDisassembleCmdName(),
- GetDisassembleParameters(),
- GetAssemblyHeader()));
-
SetUpHelpers();
}
void TearDown() override {
- test_helper_.reset(); // Clean up the helper.
+ AssemblerTestBase::TearDown();
assembler_.reset();
allocator_.reset();
}
@@ -767,38 +753,6 @@
// Override this to set up any architecture-specific things, e.g., register vectors.
virtual void SetUpHelpers() {}
- // Get the typically used name for this architecture, e.g., aarch64, x86_64, ...
- virtual std::string GetArchitectureString() = 0;
-
- // Get the name of the assembler, e.g., "as" by default.
- virtual std::string GetAssemblerCmdName() {
- return "as";
- }
-
- // Switches to the assembler command. Default none.
- virtual std::string GetAssemblerParameters() {
- return "";
- }
-
- // Get the name of the objdump, e.g., "objdump" by default.
- virtual std::string GetObjdumpCmdName() {
- return "objdump";
- }
-
- // Switches to the objdump command. Default is " -h".
- virtual std::string GetObjdumpParameters() {
- return " -h";
- }
-
- // Get the name of the objdump, e.g., "objdump" by default.
- virtual std::string GetDisassembleCmdName() {
- return "objdump";
- }
-
- // Switches to the objdump command. As it's a binary, one needs to push the architecture and
- // such to objdump, so it's architecture-specific and there is no default.
- virtual std::string GetDisassembleParameters() = 0;
-
// Create a couple of immediate values up to the number of bytes given.
virtual std::vector<int64_t> CreateImmediateValues(size_t imm_bytes, bool as_uint = false) {
std::vector<int64_t> res;
@@ -1529,11 +1483,6 @@
return sreg.str();
}
- // If the assembly file needs a header, return it in a sub-class.
- virtual const char* GetAssemblyHeader() {
- return nullptr;
- }
-
void WarnOnCombinations(size_t count) {
if (count > kWarnManyCombinationsThreshold) {
GTEST_LOG_(WARNING) << "Many combinations (" << count << "), test generation might be slow.";
@@ -1602,7 +1551,7 @@
MemoryRegion code(&(*data)[0], data->size());
assembler_->FinalizeInstructions(code);
Pad(*data);
- test_helper_->Driver(*data, assembly_text, test_name);
+ Driver(*data, assembly_text, test_name);
}
static constexpr size_t kWarnManyCombinationsThreshold = 500;
@@ -1610,7 +1559,6 @@
MallocArenaPool pool_;
std::unique_ptr<ArenaAllocator> allocator_;
std::unique_ptr<Ass> assembler_;
- std::unique_ptr<AssemblerTestInfrastructure> test_helper_;
DISALLOW_COPY_AND_ASSIGN(AssemblerTest);
};