Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5121)

Unified Diff: base/message_pump_libevent_unittest.cc

Issue 10698112: Fix failed apk unit test case MessagePumpLibeventTest.* on Android. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: refine the patch Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | build/android/gtest_filter/base_unittests_disabled » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/message_pump_libevent_unittest.cc
diff --git a/base/message_pump_libevent_unittest.cc b/base/message_pump_libevent_unittest.cc
index acc33c077296c5667bf58af59d5eb8499b7687d1..a5380b7aa2fafa204c7917d863bcf0e2970b8ccb 100644
--- a/base/message_pump_libevent_unittest.cc
+++ b/base/message_pump_libevent_unittest.cc
@@ -6,6 +6,7 @@
#include <unistd.h>
+#include "base/eintr_wrapper.h"
#include "base/message_loop.h"
#include "base/threading/thread.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -101,15 +102,23 @@ class DeleteWatcher : public MessagePumpLibevent::Watcher {
};
TEST_F(MessagePumpLibeventTest, DeleteWatcher) {
+ int pipefds[2];
+ int err = pipe(pipefds);
+ ASSERT_EQ(0, err);
+ int fd = pipefds[1];
scoped_refptr<MessagePumpLibevent> pump(new MessagePumpLibevent);
MessagePumpLibevent::FileDescriptorWatcher* watcher =
new MessagePumpLibevent::FileDescriptorWatcher;
DeleteWatcher delegate(watcher);
pump->WatchFileDescriptor(
- 0, false, MessagePumpLibevent::WATCH_READ_WRITE, watcher, &delegate);
+ fd, false, MessagePumpLibevent::WATCH_READ_WRITE, watcher, &delegate);
// Spoof a libevent notification.
OnLibeventNotification(pump, watcher);
+ if (HANDLE_EINTR(close(pipefds[0])) < 0)
+ PLOG(ERROR) << "close";
+ if (HANDLE_EINTR(close(pipefds[1])) < 0)
+ PLOG(ERROR) << "close";
}
class StopWatcher : public MessagePumpLibevent::Watcher {
@@ -134,14 +143,22 @@ class StopWatcher : public MessagePumpLibevent::Watcher {
};
TEST_F(MessagePumpLibeventTest, StopWatcher) {
+ int pipefds[2];
+ int err = pipe(pipefds);
+ ASSERT_EQ(0, err);
+ int fd = pipefds[1];
jar (doing other things) 2012/07/09 21:12:23 I hate seeing growth of replicated code... WDYT
Shouqun Liu 2012/07/10 05:42:41 Yes, agree with you. I have made the following ch
scoped_refptr<MessagePumpLibevent> pump(new MessagePumpLibevent);
MessagePumpLibevent::FileDescriptorWatcher watcher;
StopWatcher delegate(&watcher);
pump->WatchFileDescriptor(
- 0, false, MessagePumpLibevent::WATCH_READ_WRITE, &watcher, &delegate);
+ fd, false, MessagePumpLibevent::WATCH_READ_WRITE, &watcher, &delegate);
// Spoof a libevent notification.
OnLibeventNotification(pump, &watcher);
+ if (HANDLE_EINTR(close(pipefds[0])) < 0)
+ PLOG(ERROR) << "close";
+ if (HANDLE_EINTR(close(pipefds[1])) < 0)
+ PLOG(ERROR) << "close";
}
} // namespace
« no previous file with comments | « no previous file | build/android/gtest_filter/base_unittests_disabled » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698