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

Side by Side Diff: chrome_elf/elf_imports_unittest.cc

Issue 2242323002: Revert of [chrome_elf] Big cleanup and removing dependencies that recently crept in. Part 1. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 | « chrome_elf/crash/crash_helper.cc ('k') | chrome_elf/hook_util/hook_util.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <stdint.h> 5 #include <stdint.h>
6 #include <windows.h> 6 #include <windows.h>
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 } 104 }
105 } 105 }
106 TEST_F(ELFImportsTest, ChromeElfLoadSanityTest) { 106 TEST_F(ELFImportsTest, ChromeElfLoadSanityTest) {
107 base::FilePath dll; 107 base::FilePath dll;
108 ASSERT_TRUE(PathService::Get(base::DIR_EXE, &dll)); 108 ASSERT_TRUE(PathService::Get(base::DIR_EXE, &dll));
109 dll = dll.Append(L"chrome_elf.dll"); 109 dll = dll.Append(L"chrome_elf.dll");
110 110
111 // We don't expect user32 to be loaded in chrome_elf_unittests. If this test 111 // We don't expect user32 to be loaded in chrome_elf_unittests. If this test
112 // case fails, then it means that a dependency on user32 has crept into the 112 // case fails, then it means that a dependency on user32 has crept into the
113 // chrome_elf_unittests executable, which needs to be removed. 113 // chrome_elf_unittests executable, which needs to be removed.
114 // NOTE: it may be a secondary dependency of another system DLL. If so, 114 EXPECT_EQ(nullptr, ::GetModuleHandle(L"user32.dll"));
115 // try adding a "/DELAYLOAD:<blah>.dll" to the build.gn file.
116 ASSERT_EQ(nullptr, ::GetModuleHandle(L"user32.dll"));
117 115
118 HMODULE chrome_elf_module_handle = ::LoadLibrary(dll.value().c_str()); 116 HMODULE chrome_elf_module_handle = ::LoadLibrary(dll.value().c_str());
119 EXPECT_TRUE(chrome_elf_module_handle != nullptr); 117 EXPECT_TRUE(chrome_elf_module_handle != nullptr);
120 // Loading chrome_elf.dll should not load user32.dll 118 // Loading chrome_elf.dll should not load user32.dll
121 EXPECT_EQ(nullptr, ::GetModuleHandle(L"user32.dll")); 119 EXPECT_EQ(nullptr, ::GetModuleHandle(L"user32.dll"));
122 EXPECT_TRUE(!!::FreeLibrary(chrome_elf_module_handle)); 120 EXPECT_TRUE(!!::FreeLibrary(chrome_elf_module_handle));
123 } 121 }
124 #endif // NDEBUG 122 #endif // NDEBUG
125 123
126 TEST_F(ELFImportsTest, ChromeExeSanityCheck) { 124 TEST_F(ELFImportsTest, ChromeExeSanityCheck) {
127 std::vector<std::string> exe_imports; 125 std::vector<std::string> exe_imports;
128 126
129 base::FilePath exe; 127 base::FilePath exe;
130 ASSERT_TRUE(PathService::Get(base::DIR_EXE, &exe)); 128 ASSERT_TRUE(PathService::Get(base::DIR_EXE, &exe));
131 exe = exe.Append(L"chrome.exe"); 129 exe = exe.Append(L"chrome.exe");
132 GetImports(exe, &exe_imports); 130 GetImports(exe, &exe_imports);
133 131
134 // Check that chrome.exe has imports. 132 // Check that chrome.exe has imports.
135 ASSERT_LT(0u, exe_imports.size()) << "Ensure the chrome_elf_unittests " 133 ASSERT_LT(0u, exe_imports.size()) << "Ensure the chrome_elf_unittests "
136 "target was built, instead of chrome_elf_unittests.exe"; 134 "target was built, instead of chrome_elf_unittests.exe";
137 135
138 // Chrome.exe's first import must be ELF. 136 // Chrome.exe's first import must be ELF.
139 EXPECT_EQ("chrome_elf.dll", exe_imports[0]) << 137 EXPECT_EQ("chrome_elf.dll", exe_imports[0]) <<
140 "Illegal import order in chrome.exe (ensure the chrome_elf_unittest " 138 "Illegal import order in chrome.exe (ensure the chrome_elf_unittest "
141 "target was built, instead of just chrome_elf_unittests.exe)"; 139 "target was built, instead of just chrome_elf_unittests.exe)";
142 } 140 }
143 141
144 } // namespace 142 } // namespace
OLDNEW
« no previous file with comments | « chrome_elf/crash/crash_helper.cc ('k') | chrome_elf/hook_util/hook_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698