summaryrefslogtreecommitdiffstats
path: root/base/win
diff options
context:
space:
mode:
authorwfh <wfh@chromium.org>2016-02-05 17:29:11 -0800
committerCommit bot <commit-bot@chromium.org>2016-02-06 01:30:36 +0000
commit3d5ae6880f89c31701feda4e367ad0b0cad6e0a7 (patch)
treea80261caf0a39804a27f7cbf44332c1c4d770748 /base/win
parent0b6ccf5a8df850b5ada971820f1376cb3c268023 (diff)
downloadchromium_src-3d5ae6880f89c31701feda4e367ad0b0cad6e0a7.zip
chromium_src-3d5ae6880f89c31701feda4e367ad0b0cad6e0a7.tar.gz
chromium_src-3d5ae6880f89c31701feda4e367ad0b0cad6e0a7.tar.bz2
Revert of Enable handle verifier for tests and add some tests. (patchset #11 id:220001 of https://codereview.chromium.org/1580873003/ )
Reason for revert: This breaks on win7 component builds, and also win10. Original issue's description: > Enable handle verifier for tests and add some tests. > > Disable handle verifier hooks if running under drmemory. > > BUG=571304 > CQ_INCLUDE_TRYBOTS=tryserver.chromium.win:win_chromium_dbg_ng > > Committed: https://crrev.com/5556e56290c41891b0830af9b6b9153b745dd226 > Cr-Commit-Position: refs/heads/master@{#372877} TBR=cpu@chromium.org,scottmg@chromium.org # Not skipping CQ checks because original CL landed more than 1 days ago. BUG=571304,583676,584741 Review URL: https://codereview.chromium.org/1678553002 Cr-Commit-Position: refs/heads/master@{#373983}
Diffstat (limited to 'base/win')
-rw-r--r--base/win/scoped_handle.cc10
-rw-r--r--base/win/scoped_handle.h3
-rw-r--r--base/win/scoped_handle_unittest.cc79
3 files changed, 5 insertions, 87 deletions
diff --git a/base/win/scoped_handle.cc b/base/win/scoped_handle.cc
index debe223..9c21603 100644
--- a/base/win/scoped_handle.cc
+++ b/base/win/scoped_handle.cc
@@ -44,7 +44,7 @@ base::LazyInstance<NativeLock>::Leaky g_lock = LAZY_INSTANCE_INITIALIZER;
bool CloseHandleWrapper(HANDLE handle) {
if (!::CloseHandle(handle))
- LOG(FATAL) << "CloseHandle failed.";
+ CHECK(false);
return true;
}
@@ -166,7 +166,7 @@ void ActiveVerifier::StartTracking(HANDLE handle, const void* owner,
if (!result.second) {
Info other = result.first->second;
base::debug::Alias(&other);
- LOG(FATAL) << "Attempt to start tracking already tracked handle.";
+ CHECK(false);
}
}
@@ -178,12 +178,12 @@ void ActiveVerifier::StopTracking(HANDLE handle, const void* owner,
AutoNativeLock lock(*lock_);
HandleMap::iterator i = map_.find(handle);
if (i == map_.end())
- LOG(FATAL) << "Attempting to close an untracked handle.";
+ CHECK(false);
Info other = i->second;
if (other.owner != owner) {
base::debug::Alias(&other);
- LOG(FATAL) << "Attempting to close a handle not owned by opener.";
+ CHECK(false);
}
map_.erase(i);
@@ -207,7 +207,7 @@ void ActiveVerifier::OnHandleBeingClosed(HANDLE handle) {
Info other = i->second;
base::debug::Alias(&other);
- LOG(FATAL) << "CloseHandle called on tracked handle.";
+ CHECK(false);
}
} // namespace
diff --git a/base/win/scoped_handle.h b/base/win/scoped_handle.h
index ac01485..404ab66 100644
--- a/base/win/scoped_handle.h
+++ b/base/win/scoped_handle.h
@@ -8,7 +8,6 @@
#include <windows.h>
#include "base/base_export.h"
-#include "base/gtest_prod_util.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/macros.h"
@@ -109,8 +108,6 @@ class GenericScopedHandle {
}
private:
- FRIEND_TEST_ALL_PREFIXES(ScopedHandleTest, ActiveVerifierWrongOwner);
- FRIEND_TEST_ALL_PREFIXES(ScopedHandleTest, ActiveVerifierUntrackedHandle);
Handle handle_;
};
diff --git a/base/win/scoped_handle_unittest.cc b/base/win/scoped_handle_unittest.cc
index b9663ef..b573b66 100644
--- a/base/win/scoped_handle_unittest.cc
+++ b/base/win/scoped_handle_unittest.cc
@@ -2,17 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <windows.h>
-#include <winternl.h>
-
#include "base/win/scoped_handle.h"
-#include "base/win/windows_version.h"
#include "testing/gtest/include/gtest/gtest.h"
-namespace base {
-namespace win {
-
TEST(ScopedHandleTest, ScopedHandle) {
// Any illegal error code will do. We just need to test that it is preserved
// by ScopedHandle to avoid bug 528394.
@@ -37,75 +30,3 @@ TEST(ScopedHandleTest, ScopedHandle) {
handle_holder = handle_source.Pass();
EXPECT_EQ(magic_error, ::GetLastError());
}
-
-// This test requires that the CloseHandle hook be in place.
-#if !defined(DISABLE_HANDLE_VERIFIER_HOOKS)
-TEST(ScopedHandleTest, ActiveVerifierCloseTracked) {
-#if defined(_DEBUG)
- // Handle hooks cause shutdown asserts in Debug on Windows 7. crbug.com/571304
- if (base::win::GetVersion() < base::win::VERSION_WIN8)
- return;
-#endif
- HANDLE handle = ::CreateMutex(nullptr, FALSE, nullptr);
- ASSERT_NE(HANDLE(NULL), handle);
- ASSERT_DEATH({
- base::win::ScopedHandle handle_holder(handle);
- // Calling CloseHandle on a tracked handle should crash.
- ::CloseHandle(handle);
- }, "CloseHandle called on tracked handle.");
-}
-#endif
-
-TEST(ScopedHandleTest, ActiveVerifierTrackedHasBeenClosed) {
- HANDLE handle = ::CreateMutex(nullptr, FALSE, nullptr);
- ASSERT_NE(HANDLE(NULL), handle);
- typedef NTSTATUS(WINAPI * NtCloseFunc)(HANDLE);
- NtCloseFunc ntclose = reinterpret_cast<NtCloseFunc>(
- GetProcAddress(GetModuleHandle(L"ntdll.dll"), "NtClose"));
- ASSERT_NE(nullptr, ntclose);
-
- ASSERT_DEATH({
- base::win::ScopedHandle handle_holder(handle);
- ntclose(handle);
- // Destructing a ScopedHandle with an illegally closed handle should fail.
- }, "CloseHandle failed.");
-}
-
-TEST(ScopedHandleTest, ActiveVerifierDoubleTracking) {
- HANDLE handle = ::CreateMutex(nullptr, FALSE, nullptr);
- ASSERT_NE(HANDLE(NULL), handle);
-
- base::win::ScopedHandle handle_holder(handle);
-
- ASSERT_DEATH({
- base::win::ScopedHandle handle_holder2(handle);
- }, "Attempt to start tracking already tracked handle.");
-}
-
-TEST(ScopedHandleTest, ActiveVerifierWrongOwner) {
- HANDLE handle = ::CreateMutex(nullptr, FALSE, nullptr);
- ASSERT_NE(HANDLE(NULL), handle);
-
- base::win::ScopedHandle handle_holder(handle);
- ASSERT_DEATH({
- base::win::ScopedHandle handle_holder2;
- handle_holder2.handle_ = handle;
- }, "Attempting to close a handle not owned by opener.");
- ASSERT_TRUE(handle_holder.IsValid());
- handle_holder.Close();
-}
-
-TEST(ScopedHandleTest, ActiveVerifierUntrackedHandle) {
- HANDLE handle = ::CreateMutex(nullptr, FALSE, nullptr);
- ASSERT_NE(HANDLE(NULL), handle);
-
- ASSERT_DEATH({
- base::win::ScopedHandle handle_holder;
- handle_holder.handle_ = handle;
- }, "Attempting to close an untracked handle.");
-
- ASSERT_TRUE(::CloseHandle(handle));
-}
-
-} // namespace win
-} // namespace base