summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-16 16:45:36 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-16 16:45:36 +0000
commit76aac1e0281a0518734c4404e9fb0814ff3c7b20 (patch)
tree0e50063deed8b1f7daaac3ca92d0826412f0aca1
parent3bec623b6d7cd31d93bdb48e6ee6eb7fd0c79c31 (diff)
downloadchromium_src-76aac1e0281a0518734c4404e9fb0814ff3c7b20.zip
chromium_src-76aac1e0281a0518734c4404e9fb0814ff3c7b20.tar.gz
chromium_src-76aac1e0281a0518734c4404e9fb0814ff3c7b20.tar.bz2
Port visitedlink tests to Linux. Also make them pass on Linux, which
may fix the attached bug. The problem was that the debug check was in wrong place (too early, before every member was initialized), so it failed in the test. BUG=8710 Review URL: http://codereview.chromium.org/48005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11734 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/shared_memory.h3
-rw-r--r--base/shared_memory_posix.cc5
-rw-r--r--base/shared_memory_win.cc5
-rw-r--r--chrome/browser/visitedlink_master.cc17
-rw-r--r--chrome/browser/visitedlink_unittest.cc8
-rw-r--r--chrome/test/unit/unit_tests.scons1
6 files changed, 30 insertions, 9 deletions
diff --git a/base/shared_memory.h b/base/shared_memory.h
index 744b348..bd6770c 100644
--- a/base/shared_memory.h
+++ b/base/shared_memory.h
@@ -58,6 +58,9 @@ class SharedMemory {
// invalid value; NULL for a HANDLE and -1 for a file descriptor)
static bool IsHandleValid(const SharedMemoryHandle& handle);
+ // Return invalid handle (see comment above for exact definition).
+ static SharedMemoryHandle NULLHandle();
+
// Creates or opens a shared memory segment based on a name.
// If read_only is true, opens the memory as read-only.
// If open_existing is true, and the shared memory already exists,
diff --git a/base/shared_memory_posix.cc b/base/shared_memory_posix.cc
index c948e58..37f0c4e 100644
--- a/base/shared_memory_posix.cc
+++ b/base/shared_memory_posix.cc
@@ -65,6 +65,11 @@ bool SharedMemory::IsHandleValid(const SharedMemoryHandle& handle) {
return handle.fd >= 0;
}
+// static
+SharedMemoryHandle SharedMemory::NULLHandle() {
+ return SharedMemoryHandle();
+}
+
bool SharedMemory::Create(const std::wstring &name, bool read_only,
bool open_existing, size_t size) {
read_only_ = read_only;
diff --git a/base/shared_memory_win.cc b/base/shared_memory_win.cc
index 3822fc9..66f8fb6 100644
--- a/base/shared_memory_win.cc
+++ b/base/shared_memory_win.cc
@@ -50,6 +50,11 @@ bool SharedMemory::IsHandleValid(const SharedMemoryHandle& handle) {
return handle != NULL;
}
+// static
+SharedMemoryHandle SharedMemory::NULLHandle() {
+ return NULL;
+}
+
bool SharedMemory::Create(const std::wstring &name, bool read_only,
bool open_existing, size_t size) {
DCHECK(mapped_file_ == NULL);
diff --git a/chrome/browser/visitedlink_master.cc b/chrome/browser/visitedlink_master.cc
index e45c059..09a3bee 100644
--- a/chrome/browser/visitedlink_master.cc
+++ b/chrome/browser/visitedlink_master.cc
@@ -582,6 +582,10 @@ bool VisitedLinkMaster::InitFromFile() {
}
used_items_ = used_count;
+#ifndef NDEBUG
+ DebugValidate();
+#endif
+
file_ = file_closer.release();
return true;
}
@@ -597,6 +601,10 @@ bool VisitedLinkMaster::InitFromScratch(bool suppress_rebuild) {
if (!CreateURLTable(table_size, true))
return false;
+#ifndef NDEBUG
+ DebugValidate();
+#endif
+
if (suppress_rebuild) {
// When we disallow rebuilds (normally just unit tests), just use the
// current empty table.
@@ -713,10 +721,6 @@ bool VisitedLinkMaster::CreateURLTable(int32 num_entries, bool init_to_empty) {
hash_table_ = reinterpret_cast<Fingerprint*>(
static_cast<char*>(shared_memory_->memory()) + sizeof(SharedHeader));
-#ifndef NDEBUG
- DebugValidate();
-#endif
-
return true;
}
@@ -731,6 +735,11 @@ bool VisitedLinkMaster::BeginReplaceURLTable(int32 num_entries) {
table_length_ = old_table_length;
return false;
}
+
+#ifndef NDEBUG
+ DebugValidate();
+#endif
+
return true;
}
diff --git a/chrome/browser/visitedlink_unittest.cc b/chrome/browser/visitedlink_unittest.cc
index 8f59462..5c4ddce 100644
--- a/chrome/browser/visitedlink_unittest.cc
+++ b/chrome/browser/visitedlink_unittest.cc
@@ -36,7 +36,7 @@ void SynchronousBroadcastNewTableEvent(base::SharedMemory* table) {
if (table) {
for (std::vector<VisitedLinkSlave>::size_type i = 0;
i < g_slaves.size(); i++) {
- base::SharedMemoryHandle new_handle = NULL;
+ base::SharedMemoryHandle new_handle = base::SharedMemory::NULLHandle();
table->ShareToProcess(base::GetCurrentProcessHandle(), &new_handle);
g_slaves[i]->Init(new_handle);
}
@@ -103,7 +103,7 @@ class VisitedLinkTest : public testing::Test {
// Create a slave database.
VisitedLinkSlave slave;
- base::SharedMemoryHandle new_handle = NULL;
+ base::SharedMemoryHandle new_handle = base::SharedMemory::NULLHandle();
master_->ShareToProcess(base::GetCurrentProcessHandle(), &new_handle);
bool success = slave.Init(new_handle);
ASSERT_TRUE(success);
@@ -239,7 +239,7 @@ TEST_F(VisitedLinkTest, DeleteAll) {
{
VisitedLinkSlave slave;
- base::SharedMemoryHandle new_handle = NULL;
+ base::SharedMemoryHandle new_handle = base::SharedMemory::NULLHandle();
master_->ShareToProcess(base::GetCurrentProcessHandle(), &new_handle);
ASSERT_TRUE(slave.Init(new_handle));
g_slaves.push_back(&slave);
@@ -287,7 +287,7 @@ TEST_F(VisitedLinkTest, Resizing) {
// ...and a slave
VisitedLinkSlave slave;
- base::SharedMemoryHandle new_handle = NULL;
+ base::SharedMemoryHandle new_handle = base::SharedMemory::NULLHandle();
master_->ShareToProcess(base::GetCurrentProcessHandle(), &new_handle);
bool success = slave.Init(new_handle);
ASSERT_TRUE(success);
diff --git a/chrome/test/unit/unit_tests.scons b/chrome/test/unit/unit_tests.scons
index 450b500..c87e6dd 100644
--- a/chrome/test/unit/unit_tests.scons
+++ b/chrome/test/unit/unit_tests.scons
@@ -421,7 +421,6 @@ if not env.Bit('windows'):
'$CHROME_DIR/browser/tabs/tab_strip_model_unittest.cc',
'$CHROME_DIR/browser/views/bookmark_editor_view_unittest.cc',
'$CHROME_DIR/browser/views/keyword_editor_view_unittest.cc',
- '$CHROME_DIR/browser/visitedlink_unittest.cc',
'$CHROME_DIR/browser/webdata/web_database_unittest.cc',
'$CHROME_DIR/browser/window_sizer_unittest.cc',
'$CHROME_DIR/common/chrome_plugin_unittest.cc',