Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Unified Diff: tools/relocation_packer/src/packer_unittest.cc

Issue 404553003: Create builds configured for ARM and AARCH64. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename DT tags to DT_ANDROID_REL_XXX Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/relocation_packer/src/packer.cc ('k') | tools/relocation_packer/src/run_length_encoder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/relocation_packer/src/packer_unittest.cc
diff --git a/tools/relocation_packer/src/packer_unittest.cc b/tools/relocation_packer/src/packer_unittest.cc
index c917a392c35e744c258922e1da701ddf827ad382..ac70caa360a1287ef7c0eb7569220857da7d3f33 100644
--- a/tools/relocation_packer/src/packer_unittest.cc
+++ b/tools/relocation_packer/src/packer_unittest.cc
@@ -6,17 +6,22 @@
#include <vector>
#include "elf.h"
+#include "elf_traits.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
-void AddRelocation(Elf32_Addr addr, std::vector<Elf32_Rel>* relocations) {
- Elf32_Rel relocation = {addr, R_ARM_RELATIVE};
+void AddRelocation(ELF::Addr addr, std::vector<ELF::Rel>* relocations) {
+ ELF::Rel relocation;
+ relocation.r_offset = addr;
+ relocation.r_info = ELF_R_INFO(0, ELF::kRelativeRelocationCode);
relocations->push_back(relocation);
}
-bool CheckRelocation(Elf32_Addr addr, const Elf32_Rel& relocation) {
- return relocation.r_offset == addr && relocation.r_info == R_ARM_RELATIVE;
+bool CheckRelocation(ELF::Addr addr, const ELF::Rel& relocation) {
+ return relocation.r_offset == addr &&
+ ELF_R_SYM(relocation.r_info) == 0 &&
+ ELF_R_TYPE(relocation.r_info) == ELF::kRelativeRelocationCode;
}
} // namespace
@@ -24,7 +29,7 @@ bool CheckRelocation(Elf32_Addr addr, const Elf32_Rel& relocation) {
namespace relocation_packer {
TEST(Packer, Pack) {
- std::vector<Elf32_Rel> relocations;
+ std::vector<ELF::Rel> relocations;
std::vector<uint8_t> packed;
RelocationPacker packer;
@@ -42,34 +47,34 @@ TEST(Packer, Pack) {
packed.clear();
packer.PackRelativeRelocations(relocations, &packed);
- EXPECT_EQ(16u, packed.size());
+ EXPECT_EQ(16, packed.size());
// Identifier.
EXPECT_EQ('A', packed[0]);
EXPECT_EQ('P', packed[1]);
EXPECT_EQ('R', packed[2]);
EXPECT_EQ('1', packed[3]);
// Count-delta pairs count.
- EXPECT_EQ(2u, packed[4]);
+ EXPECT_EQ(2, packed[4]);
// 0xd1ce0000
- EXPECT_EQ(128u, packed[5]);
- EXPECT_EQ(128u, packed[6]);
- EXPECT_EQ(184u, packed[7]);
- EXPECT_EQ(142u, packed[8]);
- EXPECT_EQ(13u, packed[9]);
+ EXPECT_EQ(128, packed[5]);
+ EXPECT_EQ(128, packed[6]);
+ EXPECT_EQ(184, packed[7]);
+ EXPECT_EQ(142, packed[8]);
+ EXPECT_EQ(13, packed[9]);
// Run of two relocations, 4 byte deltas.
- EXPECT_EQ(2u, packed[10]);
- EXPECT_EQ(4u, packed[11]);
+ EXPECT_EQ(2, packed[10]);
+ EXPECT_EQ(4, packed[11]);
// Run of three relocations, 8 byte deltas.
- EXPECT_EQ(3u, packed[12]);
- EXPECT_EQ(8u, packed[13]);
+ EXPECT_EQ(3, packed[12]);
+ EXPECT_EQ(8, packed[13]);
// Padding.
- EXPECT_EQ(0u, packed[14]);
- EXPECT_EQ(0u, packed[15]);
+ EXPECT_EQ(0, packed[14]);
+ EXPECT_EQ(0, packed[15]);
}
TEST(Packer, Unpack) {
std::vector<uint8_t> packed;
- std::vector<Elf32_Rel> relocations;
+ std::vector<ELF::Rel> relocations;
RelocationPacker packer;
@@ -79,27 +84,27 @@ TEST(Packer, Unpack) {
packed.push_back('R');
packed.push_back('1');
// Count-delta pairs count.
- packed.push_back(2u);
+ packed.push_back(2);
// 0xd1ce0000
- packed.push_back(128u);
- packed.push_back(128u);
- packed.push_back(184u);
- packed.push_back(142u);
- packed.push_back(13u);
+ packed.push_back(128);
+ packed.push_back(128);
+ packed.push_back(184);
+ packed.push_back(142);
+ packed.push_back(13);
// Run of two relocations, 4 byte deltas.
- packed.push_back(2u);
- packed.push_back(4u);
+ packed.push_back(2);
+ packed.push_back(4);
// Run of three relocations, 8 byte deltas.
- packed.push_back(3u);
- packed.push_back(8u);
+ packed.push_back(3);
+ packed.push_back(8);
// Padding.
- packed.push_back(0u);
- packed.push_back(0u);
+ packed.push_back(0);
+ packed.push_back(0);
relocations.clear();
packer.UnpackRelativeRelocations(packed, &relocations);
- EXPECT_EQ(6u, relocations.size());
+ EXPECT_EQ(6, relocations.size());
// Initial relocation.
EXPECT_TRUE(CheckRelocation(0xd1ce0000, relocations[0]));
// Two relocations, 4 byte deltas.
« no previous file with comments | « tools/relocation_packer/src/packer.cc ('k') | tools/relocation_packer/src/run_length_encoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698