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

Unified Diff: courgette/rel32_finder_x86_unittest.cc

Issue 2008253004: Refactor rel32 searching process for x64 to make it more similar to x86. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
Index: courgette/rel32_finder_x86_unittest.cc
diff --git a/courgette/rel32_finder_win32_x86_unittest.cc b/courgette/rel32_finder_x86_unittest.cc
similarity index 84%
rename from courgette/rel32_finder_win32_x86_unittest.cc
rename to courgette/rel32_finder_x86_unittest.cc
index 496f0b94bb249bb837bad08f0ca3bcbc9e4a8272..6c025825bf82dc8ec640929823754996104c8ca9 100644
--- a/courgette/rel32_finder_win32_x86_unittest.cc
+++ b/courgette/rel32_finder_x86_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "courgette/rel32_finder_win32_x86.h"
+#include "courgette/rel32_finder_x86.h"
#include <stddef.h>
#include <stdint.h>
@@ -20,10 +20,10 @@ namespace courgette {
namespace {
-// Helper class to load and execute a Rel32FinderWin32X86 test case.
-class Rel32FinderWin32X86TestCase {
+// Helper class to load and execute a Rel32FinderX86 test case.
+class Rel32FinderX86TestCase {
public:
- Rel32FinderWin32X86TestCase(const std::string& test_data)
+ Rel32FinderX86TestCase(const std::string& test_data)
: text_start_rva_(0),
text_end_rva_(0),
relocs_start_rva_(0),
@@ -33,10 +33,11 @@ class Rel32FinderWin32X86TestCase {
}
void RunTestBasic(std::string name) {
- Rel32FinderWin32X86_Basic finder(relocs_start_rva_, relocs_end_rva_);
+ Rel32FinderX86 finder(relocs_start_rva_, relocs_end_rva_);
ASSERT_FALSE(text_data_.empty());
finder.Find(&text_data_[0], &text_data_[0] + text_data_.size(),
- text_start_rva_, text_end_rva_, abs32_locations_);
+ text_start_rva_, text_end_rva_, image_end_rva_,
+ abs32_locations_);
std::vector<RVA> rel32_locations;
finder.SwapRel32Locations(&rel32_locations);
EXPECT_EQ(expected_rel32_locations_, rel32_locations)
@@ -83,7 +84,7 @@ class Rel32FinderWin32X86TestCase {
}
// Initializes the test case by parsing the multi-line string |test_data|
- // to extract Rel32FinderWin32X86 parameters, and read expected values.
+ // to extract Rel32FinderX86 parameters, and read expected values.
void LoadTestFromString(const std::string& test_data) {
// The first lines (ignoring empty ones) specify RVA bounds.
std::istringstream iss(test_data);
@@ -107,7 +108,7 @@ class Rel32FinderWin32X86TestCase {
std::string toks = line.substr(kBytesBegin, kBytesEnd);
uint32_t vals[6];
int num_read = sscanf(toks.c_str(), "%X %X %X %X %X %X", &vals[0],
- &vals[1], &vals[2], &vals[3], &vals[4], &vals[5]);
+ &vals[1], &vals[2], &vals[3], &vals[4], &vals[5]);
for (int i = 0; i < num_read; ++i)
text_data_.push_back(static_cast<uint8_t>(vals[i] & 0xFF));
}
@@ -131,19 +132,19 @@ class Rel32FinderWin32X86TestCase {
}
};
-class Rel32FinderWin32X86Test : public BaseTest {
+class Rel32FinderX86Test : public BaseTest {
public:
void RunTest(const char* test_case_file) {
- Rel32FinderWin32X86TestCase test_case(FileContents(test_case_file));
+ Rel32FinderX86TestCase test_case(FileContents(test_case_file));
test_case.RunTestBasic(test_case_file);
}
};
-TEST_F(Rel32FinderWin32X86Test, TestBasic) {
- RunTest("rel32_win32_x86_01.txt");
- RunTest("rel32_win32_x86_02.txt");
- RunTest("rel32_win32_x86_03.txt");
- RunTest("rel32_win32_x86_04.txt");
+TEST_F(Rel32FinderX86Test, TestBasic) {
+ RunTest("rel32_x86_01.txt");
+ RunTest("rel32_x86_02.txt");
+ RunTest("rel32_x86_03.txt");
+ RunTest("rel32_x86_04.txt");
}
} // namespace

Powered by Google App Engine
This is Rietveld 408576698