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

Side by Side Diff: base/win/scoped_handle_unittest.cc

Issue 1977833003: Add a buildflag to use the handle verifier in a per module mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a flag to use the HV in a single module mode. 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 unified diff | Download patch
« no previous file with comments | « base/win/scoped_handle_test_dll.cc ('k') | build/common.gypi » ('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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <windows.h> 5 #include <windows.h>
6 #include <winternl.h> 6 #include <winternl.h>
7 7
8 #include "base/base_switches.h" 8 #include "base/base_switches.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/scoped_native_library.h" 11 #include "base/scoped_native_library.h"
12 #include "base/test/multiprocess_test.h" 12 #include "base/test/multiprocess_test.h"
13 #include "base/test/test_timeouts.h" 13 #include "base/test/test_timeouts.h"
14 #include "base/win/base_features.h"
14 #include "base/win/scoped_handle.h" 15 #include "base/win/scoped_handle.h"
15 16
16 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
17 #include "testing/multiprocess_func_list.h" 18 #include "testing/multiprocess_func_list.h"
18 19
19 namespace base { 20 namespace base {
20 namespace win { 21 namespace win {
21 22
22 namespace testing { 23 namespace testing {
23 extern "C" bool __declspec(dllexport) RunTest(); 24 extern "C" bool __declspec(dllexport) RunTest();
(...skipping 17 matching lines...) Expand all
41 EXPECT_EQ(magic_error, ::GetLastError()); 42 EXPECT_EQ(magic_error, ::GetLastError());
42 43
43 // Create a new handle and then set LastError again. 44 // Create a new handle and then set LastError again.
44 handle = ::CreateMutex(nullptr, false, nullptr); 45 handle = ::CreateMutex(nullptr, false, nullptr);
45 base::win::ScopedHandle handle_source(handle); 46 base::win::ScopedHandle handle_source(handle);
46 ::SetLastError(magic_error); 47 ::SetLastError(magic_error);
47 handle_holder = std::move(handle_source); 48 handle_holder = std::move(handle_source);
48 EXPECT_EQ(magic_error, ::GetLastError()); 49 EXPECT_EQ(magic_error, ::GetLastError());
49 } 50 }
50 51
52 #if BUILDFLAG(SINGLE_MODULE_MODE_HANDLE_VERIFIER)
Will Harris 2016/06/01 16:46:40 why do these tests now depend on this, they didn't
Sébastien Marchand 2016/06/01 19:18:47 Hum, I thought that there was a #ifdef COMPONENT_B
51 TEST(ScopedHandleTest, ActiveVerifierTrackedHasBeenClosed) { 53 TEST(ScopedHandleTest, ActiveVerifierTrackedHasBeenClosed) {
52 HANDLE handle = ::CreateMutex(nullptr, false, nullptr); 54 HANDLE handle = ::CreateMutex(nullptr, false, nullptr);
53 ASSERT_NE(HANDLE(nullptr), handle); 55 ASSERT_NE(HANDLE(nullptr), handle);
54 typedef NTSTATUS(WINAPI * NtCloseFunc)(HANDLE); 56 typedef NTSTATUS(WINAPI * NtCloseFunc)(HANDLE);
55 NtCloseFunc ntclose = reinterpret_cast<NtCloseFunc>( 57 NtCloseFunc ntclose = reinterpret_cast<NtCloseFunc>(
56 GetProcAddress(GetModuleHandle(L"ntdll.dll"), "NtClose")); 58 GetProcAddress(GetModuleHandle(L"ntdll.dll"), "NtClose"));
57 ASSERT_NE(nullptr, ntclose); 59 ASSERT_NE(nullptr, ntclose);
58 60
59 ASSERT_DEATH({ 61 ASSERT_DEATH({
60 base::win::ScopedHandle handle_holder(handle); 62 base::win::ScopedHandle handle_holder(handle);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 return 1; 124 return 1;
123 auto run_test_function = reinterpret_cast<decltype(&testing::RunTest)>( 125 auto run_test_function = reinterpret_cast<decltype(&testing::RunTest)>(
124 module.GetFunctionPointer("RunTest")); 126 module.GetFunctionPointer("RunTest"));
125 if (!run_test_function) 127 if (!run_test_function)
126 return 1; 128 return 1;
127 if (!run_test_function()) 129 if (!run_test_function())
128 return 1; 130 return 1;
129 131
130 return 0; 132 return 0;
131 } 133 }
134 #endif
132 135
133 } // namespace win 136 } // namespace win
134 } // namespace base 137 } // namespace base
OLDNEW
« no previous file with comments | « base/win/scoped_handle_test_dll.cc ('k') | build/common.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698