summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authoroshima <oshima@chromium.org>2016-01-25 14:11:47 -0800
committerCommit bot <commit-bot@chromium.org>2016-01-25 22:14:10 +0000
commitd22a80067f3e4afe64a4e638579b8030d4c95248 (patch)
tree2a8a1a55693c0c306b7dedbd52e6c9b597fa5f91 /base
parent3c0aa77c46d827484a01662cc0eb383e7de6d93f (diff)
downloadchromium_src-d22a80067f3e4afe64a4e638579b8030d4c95248.zip
chromium_src-d22a80067f3e4afe64a4e638579b8030d4c95248.tar.gz
chromium_src-d22a80067f3e4afe64a4e638579b8030d4c95248.tar.bz2
Revert of Enable handle verifier for tests and add some tests. (patchset #7 id:120001 of https://codereview.chromium.org/1580873003/ )
Reason for revert: A lot of test are crashing on DrMemory x64 bot, so I'm reverting this speculatively. I'll reland this if it didn't help. Original issue's description: > Enable handle verifier for tests and add some tests. > > BUG=571304 > > Committed: https://crrev.com/ff6cc3d794e1285c68f74ec9ae6d59dc3e523d5b > Cr-Commit-Position: refs/heads/master@{#371075} TBR=cpu@chromium.org,wfh@chromium.org # Not skipping CQ checks because original CL landed more than 1 days ago. BUG=571304,580795 Review URL: https://codereview.chromium.org/1633623003 Cr-Commit-Position: refs/heads/master@{#371330}
Diffstat (limited to 'base')
-rw-r--r--base/test/test_suite.cc13
-rw-r--r--base/win/scoped_handle.cc10
-rw-r--r--base/win/scoped_handle.h3
-rw-r--r--base/win/scoped_handle_unittest.cc76
4 files changed, 6 insertions, 96 deletions
diff --git a/base/test/test_suite.cc b/base/test/test_suite.cc
index 34e8e11..82510a2 100644
--- a/base/test/test_suite.cc
+++ b/base/test/test_suite.cc
@@ -40,10 +40,7 @@
#endif // OS_IOS
#endif // OS_MACOSX
-#if defined(OS_WIN)
-#include "base/debug/close_handle_hook_win.h"
-#include "base/win/windows_version.h"
-#else
+#if !defined(OS_WIN)
#include "base/i18n/rtl.h"
#if !defined(OS_IOS)
#include "base/strings/string_util.h"
@@ -320,14 +317,6 @@ void TestSuite::Initialize() {
CHECK(debug::EnableInProcessStackDumping());
#if defined(OS_WIN)
-#if defined(_DEBUG)
- // Handle hooks cause shutdown asserts in Debug on Windows 7. crbug.com/571304
- if (base::win::GetVersion() >= base::win::VERSION_WIN8)
- base::debug::InstallHandleHooks();
-#else
- base::debug::InstallHandleHooks();
-#endif
-
RouteStdioToConsole(true);
// Make sure we run with high resolution timer to minimize differences
// between production code and test code.
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 0407351..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,72 +30,3 @@ TEST(ScopedHandleTest, ScopedHandle) {
handle_holder = handle_source.Pass();
EXPECT_EQ(magic_error, ::GetLastError());
}
-
-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.");
-}
-
-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