| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // This file contains unit tests for PEImage. | 5 // This file contains unit tests for PEImage. |
| 6 | 6 |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "base/win/pe_image.h" | 8 #include "base/win/pe_image.h" |
| 9 #include "base/win/windows_version.h" | 9 #include "base/win/windows_version.h" |
| 10 | 10 |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 ExpectationSet expected_set = GetExpectationSet(os); | 182 ExpectationSet expected_set = GetExpectationSet(os); |
| 183 if (expected_set >= arraysize(expected)) { | 183 if (expected_set >= arraysize(expected)) { |
| 184 // This should never happen. Log a failure if it does. | 184 // This should never happen. Log a failure if it does. |
| 185 EXPECT_NE(UNSUPPORTED_SET, expected_set); | 185 EXPECT_NE(UNSUPPORTED_SET, expected_set); |
| 186 expected_set = WIN_2K_SET; | 186 expected_set = WIN_2K_SET; |
| 187 } | 187 } |
| 188 | 188 |
| 189 return expected[value][expected_set]; | 189 return expected[value][expected_set]; |
| 190 } | 190 } |
| 191 | 191 |
| 192 |
| 193 // TODO(jschuh): crbug.com/167707 Need to fix test on Win64 bots |
| 194 #if defined(OS_WIN) && defined(ARCH_CPU_X86_64) |
| 195 #define MAYBE_EnumeratesPE DISABLED_EnumeratesPE |
| 196 #else |
| 197 #define MAYBE_EnumeratesPE EnumeratesPE |
| 198 #endif |
| 199 |
| 192 // Tests that we are able to enumerate stuff from a PE file, and that | 200 // Tests that we are able to enumerate stuff from a PE file, and that |
| 193 // the actual number of items found is within the expected range. | 201 // the actual number of items found is within the expected range. |
| 194 TEST(PEImageTest, EnumeratesPE) { | 202 TEST(PEImageTest, MAYBE_EnumeratesPE) { |
| 195 HMODULE module = LoadLibrary(L"advapi32.dll"); | 203 HMODULE module = LoadLibrary(L"advapi32.dll"); |
| 196 ASSERT_TRUE(NULL != module); | 204 ASSERT_TRUE(NULL != module); |
| 197 | 205 |
| 198 PEImage pe(module); | 206 PEImage pe(module); |
| 199 int count = 0; | 207 int count = 0; |
| 200 EXPECT_TRUE(pe.VerifyMagic()); | 208 EXPECT_TRUE(pe.VerifyMagic()); |
| 201 | 209 |
| 202 DWORD os = pe.GetNTHeaders()->OptionalHeader.MajorOperatingSystemVersion; | 210 DWORD os = pe.GetNTHeaders()->OptionalHeader.MajorOperatingSystemVersion; |
| 203 os = os * 10 + pe.GetNTHeaders()->OptionalHeader.MinorOperatingSystemVersion; | 211 os = os * 10 + pe.GetNTHeaders()->OptionalHeader.MinorOperatingSystemVersion; |
| 204 | 212 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 FARPROC address2 = pe.GetProcAddress(reinterpret_cast<char*>(ordinal)); | 262 FARPROC address2 = pe.GetProcAddress(reinterpret_cast<char*>(ordinal)); |
| 255 EXPECT_TRUE(address1 != NULL); | 263 EXPECT_TRUE(address1 != NULL); |
| 256 EXPECT_TRUE(address2 != NULL); | 264 EXPECT_TRUE(address2 != NULL); |
| 257 EXPECT_TRUE(address1 == address2); | 265 EXPECT_TRUE(address1 == address2); |
| 258 | 266 |
| 259 FreeLibrary(module); | 267 FreeLibrary(module); |
| 260 } | 268 } |
| 261 | 269 |
| 262 } // namespace win | 270 } // namespace win |
| 263 } // namespace base | 271 } // namespace base |
| OLD | NEW |