Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d451f392 authored by Christopher Ferris's avatar Christopher Ferris Committed by Gerrit Code Review
Browse files

Merge "Avoid signed extension of chars for build ids."

parents ae7aaab9 ce34d623
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -320,7 +320,8 @@ std::string MapInfo::GetPrintableBuildID() {
  }
  }
  std::string printable_build_id;
  std::string printable_build_id;
  for (const char& c : raw_build_id) {
  for (const char& c : raw_build_id) {
    printable_build_id += android::base::StringPrintf("%02x", c);
    // Use %hhx to avoid sign extension on abis that have signed chars.
    printable_build_id += android::base::StringPrintf("%02hhx", c);
  }
  }
  return printable_build_id;
  return printable_build_id;
}
}
+11 −0
Original line number Original line Diff line number Diff line
@@ -78,6 +78,17 @@ TEST_F(MapInfoGetBuildIDTest, from_elf) {
  EXPECT_EQ("46414b455f4255494c445f4944", map_info_->GetPrintableBuildID());
  EXPECT_EQ("46414b455f4255494c445f4944", map_info_->GetPrintableBuildID());
}
}


TEST_F(MapInfoGetBuildIDTest, from_elf_no_sign_extension) {
  map_info_->elf.reset(elf_container_.release());

  std::string build_id = {static_cast<char>(0xfa), static_cast<char>(0xab), static_cast<char>(0x12),
                          static_cast<char>(0x02)};
  elf_interface_->FakeSetBuildID(build_id);

  EXPECT_EQ("\xFA\xAB\x12\x2", map_info_->GetBuildID());
  EXPECT_EQ("faab1202", map_info_->GetPrintableBuildID());
}

void MapInfoGetBuildIDTest::MultipleThreadTest(std::string expected_build_id) {
void MapInfoGetBuildIDTest::MultipleThreadTest(std::string expected_build_id) {
  static constexpr size_t kNumConcurrentThreads = 100;
  static constexpr size_t kNumConcurrentThreads = 100;