OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/image_info.h" | 5 #include "courgette/image_info.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 scoped_ptr<courgette::PEInfo> info(new courgette::PEInfo()); | 57 scoped_ptr<courgette::PEInfo> info(new courgette::PEInfo()); |
58 info->Init(reinterpret_cast<const uint8*>(file1.c_str()), file1.length()); | 58 info->Init(reinterpret_cast<const uint8*>(file1.c_str()), file1.length()); |
59 | 59 |
60 bool can_parse_header = info->ParseHeader(); | 60 bool can_parse_header = info->ParseHeader(); |
61 EXPECT_TRUE(can_parse_header); | 61 EXPECT_TRUE(can_parse_header); |
62 | 62 |
63 // The executable is the whole file, not 'embedded' with the file | 63 // The executable is the whole file, not 'embedded' with the file |
64 EXPECT_EQ(file1.length(), info->length()); | 64 EXPECT_EQ(file1.length(), info->length()); |
65 | 65 |
66 ExpectExecutable(info.get()); | 66 ExpectExecutable(info.get()); |
67 EXPECT_EQ(449536, info->size_of_code()); | 67 EXPECT_EQ(449536U, info->size_of_code()); |
68 EXPECT_EQ(SectionName(info->RVAToSection(0x00401234 - 0x00400000)), | 68 EXPECT_EQ(SectionName(info->RVAToSection(0x00401234 - 0x00400000)), |
69 std::string(".text")); | 69 std::string(".text")); |
70 | 70 |
71 EXPECT_EQ(0, info->RVAToFileOffset(0)); | 71 EXPECT_EQ(0, info->RVAToFileOffset(0)); |
72 EXPECT_EQ(1024, info->RVAToFileOffset(4096)); | 72 EXPECT_EQ(1024, info->RVAToFileOffset(4096)); |
73 EXPECT_EQ(46928, info->RVAToFileOffset(50000)); | 73 EXPECT_EQ(46928, info->RVAToFileOffset(50000)); |
74 | 74 |
75 std::vector<courgette::RVA> relocs; | 75 std::vector<courgette::RVA> relocs; |
76 bool can_parse_relocs = info->ParseRelocs(&relocs); | 76 bool can_parse_relocs = info->ParseRelocs(&relocs); |
77 EXPECT_TRUE(can_parse_relocs); | 77 EXPECT_TRUE(can_parse_relocs); |
(...skipping 12 matching lines...) Expand all Loading... |
90 info->Init(reinterpret_cast<const uint8*>(file1.c_str()), file1.length()); | 90 info->Init(reinterpret_cast<const uint8*>(file1.c_str()), file1.length()); |
91 | 91 |
92 bool can_parse_header = info->ParseHeader(); | 92 bool can_parse_header = info->ParseHeader(); |
93 EXPECT_TRUE(can_parse_header); | 93 EXPECT_TRUE(can_parse_header); |
94 | 94 |
95 // The executable is the whole file, not 'embedded' with the file | 95 // The executable is the whole file, not 'embedded' with the file |
96 EXPECT_EQ(file1.length(), info->length()); | 96 EXPECT_EQ(file1.length(), info->length()); |
97 | 97 |
98 EXPECT_TRUE(info->ok()); | 98 EXPECT_TRUE(info->ok()); |
99 EXPECT_FALSE(info->has_text_section()); | 99 EXPECT_FALSE(info->has_text_section()); |
100 EXPECT_EQ(0u, info->size_of_code()); | 100 EXPECT_EQ(0U, info->size_of_code()); |
101 } | 101 } |
102 | 102 |
103 TEST_F(ImageInfoTest, All) { | 103 TEST_F(ImageInfoTest, All) { |
104 TestExe(); | 104 TestExe(); |
105 TestResourceDll(); | 105 TestResourceDll(); |
106 } | 106 } |
OLD | NEW |