summaryrefslogtreecommitdiff
path: root/compiler/utils/assembler_test_base.h
diff options
context:
space:
mode:
author Yi Kong <yikong@google.com> 2021-09-09 15:41:10 +0800
committer Yi Kong <yikong@google.com> 2021-09-10 04:21:51 +0000
commitfde4c2731123b01b12c1b2aee0ae747276fc6e17 (patch)
tree6ddd3b30cb18695435fa45d000b3c5cbc81ffafd /compiler/utils/assembler_test_base.h
parent75e50892c0702edcfcc0ddfc8fe4e01386b3ce65 (diff)
Adapt ART tests for the new llvm-objdump output format
llvm-objdump now emit comments where it sees helpful, breaking many test expectations. Since these comments are subject to frequent format changes, trim them from the output in ART tests. Test: m test-art-host-gtest Bug: 197230471 Change-Id: I27f33e28f993f3826b3a1da75afa9a79ad9c360d
Diffstat (limited to 'compiler/utils/assembler_test_base.h')
-rw-r--r--compiler/utils/assembler_test_base.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/utils/assembler_test_base.h b/compiler/utils/assembler_test_base.h
index b4c0d0c447..73318639c2 100644
--- a/compiler/utils/assembler_test_base.h
+++ b/compiler/utils/assembler_test_base.h
@@ -22,6 +22,7 @@
#include <cstdlib>
#include <fstream>
#include <iterator>
+#include <regex>
#include "android-base/strings.h"
@@ -110,9 +111,11 @@ class AssemblerTestBase : public testing::Test {
std::string art_disassembly;
ASSERT_TRUE(Disassemble(art_obj_file, &art_disassembly));
art_disassembly = Replace(art_disassembly, art_obj_file, test_path("<extension-redacted>"));
+ art_disassembly = StripComments(art_disassembly);
std::string ref_disassembly;
ASSERT_TRUE(Disassemble(ref_obj_file, &ref_disassembly));
ref_disassembly = Replace(ref_disassembly, ref_obj_file, test_path("<extension-redacted>"));
+ ref_disassembly = StripComments(ref_disassembly);
ASSERT_EQ(art_disassembly, ref_disassembly) << "Outputs (and disassembly) not identical.";
// ART produced different (but valid) code than the reference assembler, report it.
@@ -247,6 +250,11 @@ class AssemblerTestBase : public testing::Test {
return output;
}
+ // Remove comments emitted by objdump.
+ std::string StripComments(const std::string& str) {
+ return std::regex_replace(str, std::regex(" +#.*"), "");
+ }
+
std::optional<ScratchDir> scratch_dir_;
std::string android_data_;
DISALLOW_COPY_AND_ASSIGN(AssemblerTestBase);