From fde4c2731123b01b12c1b2aee0ae747276fc6e17 Mon Sep 17 00:00:00 2001 From: Yi Kong Date: Thu, 9 Sep 2021 15:41:10 +0800 Subject: 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 --- compiler/utils/assembler_test_base.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'compiler/utils/assembler_test_base.h') 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 #include #include +#include #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("")); + 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("")); + 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 scratch_dir_; std::string android_data_; DISALLOW_COPY_AND_ASSIGN(AssemblerTestBase); -- cgit v1.2.3-59-g8ed1b