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

Unified Diff: chrome_elf/elf_imports_unittest.cc

Issue 2078913005: Add a chrome_elf_unittest ChromeElfLoadSanityTest which validates that loading chrome_elf does not … (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove braces Created 4 years, 6 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
« no previous file with comments | « chrome_elf/chrome_elf.gyp ('k') | chrome_elf/run_all_unittests.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome_elf/elf_imports_unittest.cc
diff --git a/chrome_elf/elf_imports_unittest.cc b/chrome_elf/elf_imports_unittest.cc
index 3aa03ad06fea0f26fd829c6830a3cda12cf19591..016398965ddb10a404efe5668d3e464a24c725e2 100644
--- a/chrome_elf/elf_imports_unittest.cc
+++ b/chrome_elf/elf_imports_unittest.cc
@@ -107,6 +107,22 @@ TEST_F(ELFImportsTest, ChromeElfSanityCheck) {
ASSERT_TRUE(match) << "Illegal import in chrome_elf.dll: " << import;
}
}
+TEST_F(ELFImportsTest, ChromeElfLoadSanityTest) {
+ base::FilePath dll;
+ ASSERT_TRUE(PathService::Get(base::DIR_EXE, &dll));
+ dll = dll.Append(L"chrome_elf.dll");
+
+ // We don't expect user32 to be loaded in chrome_elf_unittests. If this test
+ // case fails, then it means that a dependency on user32 has crept into the
+ // chrome_elf_unittests executable, which needs to be removed.
+ EXPECT_EQ(nullptr, ::GetModuleHandle(L"user32.dll"));
+
+ HMODULE chrome_elf_module_handle = ::LoadLibrary(dll.value().c_str());
+ EXPECT_TRUE(chrome_elf_module_handle != nullptr);
+ // Loading chrome_elf.dll should not load user32.dll
+ EXPECT_EQ(nullptr, ::GetModuleHandle(L"user32.dll"));
+ EXPECT_TRUE(!!::FreeLibrary(chrome_elf_module_handle));
+}
#endif // NDEBUG
TEST_F(ELFImportsTest, ChromeExeSanityCheck) {
« no previous file with comments | « chrome_elf/chrome_elf.gyp ('k') | chrome_elf/run_all_unittests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698