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

Side by Side Diff: courgette/disassembler_win32_x64_unittest.cc

Issue 1676683002: [Courgette] Clean up Disassembler; fix ELF Memory leaks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Wrap #include <iostream> under #if COURGETTE_HISTOGRAM_TARGETS. Created 4 years, 9 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 unified diff | Download patch
« no previous file with comments | « courgette/disassembler_win32_x64.cc ('k') | courgette/disassembler_win32_x86.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "courgette/disassembler_win32_x64.h" 5 #include "courgette/disassembler_win32_x64.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <string>
10 #include <vector>
11
9 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
10 #include "base/stl_util.h" 13 #include "base/stl_util.h"
11 #include "courgette/base_test_unittest.h" 14 #include "courgette/base_test_unittest.h"
12 15
13 class DisassemblerWin32X64Test : public BaseTest { 16 class DisassemblerWin32X64Test : public BaseTest {
14 public: 17 public:
15 void TestExe() const; 18 void TestExe() const;
16 void TestExe32() const; 19 void TestExe32() const;
17 void TestResourceDll() const; 20 void TestResourceDll() const;
18 }; 21 };
(...skipping 11 matching lines...) Expand all
30 EXPECT_EQ(file1.length(), disassembler->length()); 33 EXPECT_EQ(file1.length(), disassembler->length());
31 34
32 EXPECT_TRUE(disassembler->ok()); 35 EXPECT_TRUE(disassembler->ok());
33 EXPECT_TRUE(disassembler->has_text_section()); 36 EXPECT_TRUE(disassembler->has_text_section());
34 EXPECT_EQ(488448U, disassembler->size_of_code()); 37 EXPECT_EQ(488448U, disassembler->size_of_code());
35 EXPECT_FALSE(disassembler->is_32bit()); 38 EXPECT_FALSE(disassembler->is_32bit());
36 EXPECT_EQ(courgette::DisassemblerWin32X64::SectionName( 39 EXPECT_EQ(courgette::DisassemblerWin32X64::SectionName(
37 disassembler->RVAToSection(0x00401234 - 0x00400000)), 40 disassembler->RVAToSection(0x00401234 - 0x00400000)),
38 std::string(".text")); 41 std::string(".text"));
39 42
40 EXPECT_EQ(0, disassembler->RVAToFileOffset(0)); 43 EXPECT_EQ(0U, disassembler->RVAToFileOffset(0));
41 EXPECT_EQ(1024, disassembler->RVAToFileOffset(4096)); 44 EXPECT_EQ(1024U, disassembler->RVAToFileOffset(4096));
42 EXPECT_EQ(46928, disassembler->RVAToFileOffset(50000)); 45 EXPECT_EQ(46928U, disassembler->RVAToFileOffset(50000));
43 46
44 std::vector<courgette::RVA> relocs; 47 std::vector<courgette::RVA> relocs;
45 bool can_parse_relocs = disassembler->ParseRelocs(&relocs); 48 bool can_parse_relocs = disassembler->ParseRelocs(&relocs);
46 EXPECT_TRUE(can_parse_relocs); 49 EXPECT_TRUE(can_parse_relocs);
47 EXPECT_TRUE(base::STLIsSorted(relocs)); 50 EXPECT_TRUE(base::STLIsSorted(relocs));
48 51
49 const uint8_t* offset_p = disassembler->OffsetToPointer(0); 52 const uint8_t* offset_p = disassembler->FileOffsetToPointer(0);
50 EXPECT_EQ(reinterpret_cast<const void*>(file1.c_str()), 53 EXPECT_EQ(reinterpret_cast<const void*>(file1.c_str()),
51 reinterpret_cast<const void*>(offset_p)); 54 reinterpret_cast<const void*>(offset_p));
52 EXPECT_EQ('M', offset_p[0]); 55 EXPECT_EQ('M', offset_p[0]);
53 EXPECT_EQ('Z', offset_p[1]); 56 EXPECT_EQ('Z', offset_p[1]);
54 57
55 const uint8_t* rva_p = disassembler->RVAToPointer(0); 58 const uint8_t* rva_p = disassembler->RVAToPointer(0);
56 EXPECT_EQ(reinterpret_cast<const void*>(file1.c_str()), 59 EXPECT_EQ(reinterpret_cast<const void*>(file1.c_str()),
57 reinterpret_cast<const void*>(rva_p)); 60 reinterpret_cast<const void*>(rva_p));
58 EXPECT_EQ('M', rva_p[0]); 61 EXPECT_EQ('M', rva_p[0]);
59 EXPECT_EQ('Z', rva_p[1]); 62 EXPECT_EQ('Z', rva_p[1]);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 EXPECT_FALSE(disassembler->has_text_section()); 96 EXPECT_FALSE(disassembler->has_text_section());
94 EXPECT_EQ(0U, disassembler->size_of_code()); 97 EXPECT_EQ(0U, disassembler->size_of_code());
95 EXPECT_FALSE(disassembler->is_32bit()); 98 EXPECT_FALSE(disassembler->is_32bit());
96 } 99 }
97 100
98 TEST_F(DisassemblerWin32X64Test, All) { 101 TEST_F(DisassemblerWin32X64Test, All) {
99 TestExe(); 102 TestExe();
100 TestExe32(); 103 TestExe32();
101 TestResourceDll(); 104 TestResourceDll();
102 } 105 }
OLDNEW
« no previous file with comments | « courgette/disassembler_win32_x64.cc ('k') | courgette/disassembler_win32_x86.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698