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

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: GN. Created 4 years, 7 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 (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"
(...skipping 30 matching lines...) Expand all
41 EXPECT_EQ(magic_error, ::GetLastError()); 41 EXPECT_EQ(magic_error, ::GetLastError());
42 42
43 // Create a new handle and then set LastError again. 43 // Create a new handle and then set LastError again.
44 handle = ::CreateMutex(nullptr, false, nullptr); 44 handle = ::CreateMutex(nullptr, false, nullptr);
45 base::win::ScopedHandle handle_source(handle); 45 base::win::ScopedHandle handle_source(handle);
46 ::SetLastError(magic_error); 46 ::SetLastError(magic_error);
47 handle_holder = std::move(handle_source); 47 handle_holder = std::move(handle_source);
48 EXPECT_EQ(magic_error, ::GetLastError()); 48 EXPECT_EQ(magic_error, ::GetLastError());
49 } 49 }
50 50
51 #if BUILDFLAG(ENABLE_HANDLE_VERIFIER)
51 TEST(ScopedHandleTest, ActiveVerifierTrackedHasBeenClosed) { 52 TEST(ScopedHandleTest, ActiveVerifierTrackedHasBeenClosed) {
52 HANDLE handle = ::CreateMutex(nullptr, false, nullptr); 53 HANDLE handle = ::CreateMutex(nullptr, false, nullptr);
53 ASSERT_NE(HANDLE(nullptr), handle); 54 ASSERT_NE(HANDLE(nullptr), handle);
54 typedef NTSTATUS(WINAPI * NtCloseFunc)(HANDLE); 55 typedef NTSTATUS(WINAPI * NtCloseFunc)(HANDLE);
55 NtCloseFunc ntclose = reinterpret_cast<NtCloseFunc>( 56 NtCloseFunc ntclose = reinterpret_cast<NtCloseFunc>(
56 GetProcAddress(GetModuleHandle(L"ntdll.dll"), "NtClose")); 57 GetProcAddress(GetModuleHandle(L"ntdll.dll"), "NtClose"));
57 ASSERT_NE(nullptr, ntclose); 58 ASSERT_NE(nullptr, ntclose);
58 59
59 ASSERT_DEATH({ 60 ASSERT_DEATH({
60 base::win::ScopedHandle handle_holder(handle); 61 base::win::ScopedHandle handle_holder(handle);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 return 1; 123 return 1;
123 auto run_test_function = reinterpret_cast<decltype(&testing::RunTest)>( 124 auto run_test_function = reinterpret_cast<decltype(&testing::RunTest)>(
124 module.GetFunctionPointer("RunTest")); 125 module.GetFunctionPointer("RunTest"));
125 if (!run_test_function) 126 if (!run_test_function)
126 return 1; 127 return 1;
127 if (!run_test_function()) 128 if (!run_test_function())
128 return 1; 129 return 1;
129 130
130 return 0; 131 return 0;
131 } 132 }
133 #endif
132 134
133 } // namespace win 135 } // namespace win
134 } // namespace base 136 } // namespace base
OLDNEW
« base/win/BUILD.gn ('K') | « 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