| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |