Fix TSan issues for data_fetcher_shared_memory_base_unittest.cc.

This patch moves the test for valid handle to a more appropriate place. Currently the expectation itself in the test can cause a race condition because it implicitly looks up a shared mem pointer from a different thread.

BUG=284959
NOTRY=true

Review URL: https://chromiumcodereview.appspot.com/23986002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221444 0039d316-1c4b-4281-b951-d872f2087c98
parent 2022894f
...@@ -130,10 +130,6 @@ class FakeNonPollingDataFetcher : public FakeDataFetcher { ...@@ -130,10 +130,6 @@ class FakeNonPollingDataFetcher : public FakeDataFetcher {
virtual ~FakeNonPollingDataFetcher() { } virtual ~FakeNonPollingDataFetcher() { }
virtual bool Start(ConsumerType consumer_type, void* buffer) OVERRIDE { virtual bool Start(ConsumerType consumer_type, void* buffer) OVERRIDE {
base::SharedMemoryHandle handle = GetSharedMemoryHandleForProcess(
consumer_type, base::GetCurrentProcessHandle());
EXPECT_TRUE(base::SharedMemory::IsHandleValid(handle));
Init(consumer_type, buffer); Init(consumer_type, buffer);
switch (consumer_type) { switch (consumer_type) {
case CONSUMER_TYPE_MOTION: case CONSUMER_TYPE_MOTION:
...@@ -185,9 +181,6 @@ class FakePollingDataFetcher : public FakeDataFetcher { ...@@ -185,9 +181,6 @@ class FakePollingDataFetcher : public FakeDataFetcher {
virtual bool Start(ConsumerType consumer_type, void* buffer) OVERRIDE { virtual bool Start(ConsumerType consumer_type, void* buffer) OVERRIDE {
EXPECT_TRUE(base::MessageLoop::current() == GetPollingMessageLoop()); EXPECT_TRUE(base::MessageLoop::current() == GetPollingMessageLoop());
base::SharedMemoryHandle handle = GetSharedMemoryHandleForProcess(
consumer_type, base::GetCurrentProcessHandle());
EXPECT_TRUE(base::SharedMemory::IsHandleValid(handle));
Init(consumer_type, buffer); Init(consumer_type, buffer);
switch (consumer_type) { switch (consumer_type) {
...@@ -304,8 +297,18 @@ TEST(DataFetcherSharedMemoryBaseTest, DoesPollMotionAndOrientation) { ...@@ -304,8 +297,18 @@ TEST(DataFetcherSharedMemoryBaseTest, DoesPollMotionAndOrientation) {
EXPECT_TRUE(fake_data_fetcher.StartFetchingDeviceData( EXPECT_TRUE(fake_data_fetcher.StartFetchingDeviceData(
CONSUMER_TYPE_ORIENTATION)); CONSUMER_TYPE_ORIENTATION));
base::SharedMemoryHandle handle_orientation =
fake_data_fetcher.GetSharedMemoryHandleForProcess(
CONSUMER_TYPE_ORIENTATION, base::GetCurrentProcessHandle());
EXPECT_TRUE(base::SharedMemory::IsHandleValid(handle_orientation));
EXPECT_TRUE(fake_data_fetcher.StartFetchingDeviceData( EXPECT_TRUE(fake_data_fetcher.StartFetchingDeviceData(
CONSUMER_TYPE_MOTION)); CONSUMER_TYPE_MOTION));
base::SharedMemoryHandle handle_motion =
fake_data_fetcher.GetSharedMemoryHandleForProcess(
CONSUMER_TYPE_MOTION, base::GetCurrentProcessHandle());
EXPECT_TRUE(base::SharedMemory::IsHandleValid(handle_motion));
fake_data_fetcher.WaitForStart(CONSUMER_TYPE_ORIENTATION); fake_data_fetcher.WaitForStart(CONSUMER_TYPE_ORIENTATION);
fake_data_fetcher.WaitForStart(CONSUMER_TYPE_MOTION); fake_data_fetcher.WaitForStart(CONSUMER_TYPE_MOTION);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment