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

Side by Side Diff: chrome_elf/blacklist/test/blacklist_test.cc

Issue 140763008: Add a UMA stat to track if the Browser blacklist is Set on the Renderer (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Add to test Created 6 years, 10 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
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 "base/environment.h" 5 #include "base/environment.h"
6 #include "base/files/file_path.h" 6 #include "base/files/file_path.h"
7 #include "base/files/scoped_temp_dir.h" 7 #include "base/files/scoped_temp_dir.h"
8 #include "base/i18n/case_conversion.h" 8 #include "base/i18n/case_conversion.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/scoped_native_library.h" 10 #include "base/scoped_native_library.h"
(...skipping 14 matching lines...) Expand all
25 const wchar_t kDll2Beacon[] = L"{F70A0100-2889-4629-9B44-610FE5C73231}"; 25 const wchar_t kDll2Beacon[] = L"{F70A0100-2889-4629-9B44-610FE5C73231}";
26 const wchar_t kDll3Beacon[] = L"{9E056AEC-169E-400c-B2D0-5A07E3ACE2EB}"; 26 const wchar_t kDll3Beacon[] = L"{9E056AEC-169E-400c-B2D0-5A07E3ACE2EB}";
27 27
28 extern const wchar_t* kEnvVars[]; 28 extern const wchar_t* kEnvVars[];
29 29
30 extern "C" { 30 extern "C" {
31 // When modifying the blacklist in the test process, use the exported test dll 31 // When modifying the blacklist in the test process, use the exported test dll
32 // functions on the test blacklist dll, not the ones linked into the test 32 // functions on the test blacklist dll, not the ones linked into the test
33 // executable itself. 33 // executable itself.
34 __declspec(dllimport) bool TestDll_AddDllToBlacklist(const wchar_t* dll_name); 34 __declspec(dllimport) bool TestDll_AddDllToBlacklist(const wchar_t* dll_name);
35 __declspec(dllimport) bool TestDLL_IsBlacklistInitialized();
35 __declspec(dllimport) bool TestDll_RemoveDllFromBlacklist( 36 __declspec(dllimport) bool TestDll_RemoveDllFromBlacklist(
36 const wchar_t* dll_name); 37 const wchar_t* dll_name);
37 } 38 }
38 39
39 class BlacklistTest : public testing::Test { 40 class BlacklistTest : public testing::Test {
40 virtual void SetUp() { 41 virtual void SetUp() {
41 // Force an import from blacklist_test_main_dll. 42 // Force an import from blacklist_test_main_dll.
42 InitBlacklistTestDll(); 43 InitBlacklistTestDll();
43 } 44 }
44 45
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 EXPECT_FALSE(blacklist::RemoveDllFromBlacklist( 116 EXPECT_FALSE(blacklist::RemoveDllFromBlacklist(
116 added_dlls[empty_spaces - 1].c_str())); 117 added_dlls[empty_spaces - 1].c_str()));
117 } 118 }
118 119
119 TEST_F(BlacklistTest, LoadBlacklistedLibrary) { 120 TEST_F(BlacklistTest, LoadBlacklistedLibrary) {
120 // TODO(robertshield): Add 64-bit support. 121 // TODO(robertshield): Add 64-bit support.
121 #if !defined(_WIN64) 122 #if !defined(_WIN64)
122 base::FilePath current_dir; 123 base::FilePath current_dir;
123 ASSERT_TRUE(PathService::Get(base::DIR_EXE, &current_dir)); 124 ASSERT_TRUE(PathService::Get(base::DIR_EXE, &current_dir));
124 125
126 // Ensure that the blacklist is loaded.
127 ASSERT_TRUE(TestDLL_IsBlacklistInitialized());
128
125 // Test that an un-blacklisted DLL can load correctly. 129 // Test that an un-blacklisted DLL can load correctly.
126 base::ScopedNativeLibrary dll1(current_dir.Append(kTestDllName1)); 130 base::ScopedNativeLibrary dll1(current_dir.Append(kTestDllName1));
127 EXPECT_TRUE(dll1.is_valid()); 131 EXPECT_TRUE(dll1.is_valid());
128 dll1.Reset(NULL); 132 dll1.Reset(NULL);
129 133
130 struct TestData { 134 struct TestData {
131 const wchar_t* dll_name; 135 const wchar_t* dll_name;
132 const wchar_t* dll_beacon; 136 const wchar_t* dll_beacon;
133 } test_data[] = { 137 } test_data[] = {
134 { kTestDllName2, kDll2Beacon }, 138 { kTestDllName2, kDll2Beacon },
(...skipping 27 matching lines...) Expand all
162 base::ScopedNativeLibrary dll_blacklisted_different_case( 166 base::ScopedNativeLibrary dll_blacklisted_different_case(
163 current_dir.Append(test_data[i].dll_name)); 167 current_dir.Append(test_data[i].dll_name));
164 EXPECT_FALSE(dll_blacklisted_different_case.is_valid()); 168 EXPECT_FALSE(dll_blacklisted_different_case.is_valid());
165 EXPECT_EQ(0u, ::GetEnvironmentVariable(test_data[i].dll_beacon, NULL, 0)); 169 EXPECT_EQ(0u, ::GetEnvironmentVariable(test_data[i].dll_beacon, NULL, 0));
166 dll_blacklisted_different_case.Reset(NULL); 170 dll_blacklisted_different_case.Reset(NULL);
167 171
168 EXPECT_TRUE(TestDll_RemoveDllFromBlacklist(uppercase_name.c_str())); 172 EXPECT_TRUE(TestDll_RemoveDllFromBlacklist(uppercase_name.c_str()));
169 } 173 }
170 #endif 174 #endif
171 } 175 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698