diff options
author | Qijiang Fan <fqj@chromium.org> | 2019-11-19 20:33:43 +0900 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-11-24 19:49:49 +0000 |
commit | 6955bcc4ffe4cc9d62a88186b9a7e75d095a7897 (patch) | |
tree | cc0eca7e4a21e07ae76f05735696a1dda37cb35d /common/subprocess_unittest.cc | |
parent | 1f6bcab058b94446e25d9a55356d0398bee9aa60 (diff) |
update_engine: Get rid of WatchFileDescriptor.
The API is removed in the next libchrome uprev to r576297.
This CL replaces the use by new API base::FileDescriptorWatcher.
BUG=chromium:909719
TEST=Build locally. Ran cros_run_unit_tests.
Change-Id: I318b35b2d00742955f6877c4e36624e4c672827b
Reviewed-on: https://chromium-review.googlesource.com/c/aosp/platform/system/update_engine/+/1924097
Tested-by: Qijiang Fan <fqj@google.com>
Reviewed-by: Amin Hassani <ahassani@chromium.org>
Commit-Queue: Qijiang Fan <fqj@google.com>
Diffstat (limited to 'common/subprocess_unittest.cc')
-rw-r--r-- | common/subprocess_unittest.cc | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/common/subprocess_unittest.cc b/common/subprocess_unittest.cc index 8dbaa0b2..19b24f45 100644 --- a/common/subprocess_unittest.cc +++ b/common/subprocess_unittest.cc @@ -45,6 +45,7 @@ using base::TimeDelta; using brillo::MessageLoop; using std::string; +using std::unique_ptr; using std::vector; namespace { @@ -73,6 +74,7 @@ class SubprocessTest : public ::testing::Test { brillo::BaseMessageLoop loop_{&base_loop_}; brillo::AsynchronousSignalHandler async_signal_handler_; Subprocess subprocess_; + unique_ptr<base::FileDescriptorWatcher::Controller> watcher_; }; namespace { @@ -256,21 +258,23 @@ TEST_F(SubprocessTest, CancelTest) { int fifo_fd = HANDLE_EINTR(open(fifo_path.c_str(), O_RDONLY)); EXPECT_GE(fifo_fd, 0); - loop_.WatchFileDescriptor(FROM_HERE, - fifo_fd, - MessageLoop::WatchMode::kWatchRead, - false, - base::Bind( - [](int fifo_fd, uint32_t tag) { - char c; - EXPECT_EQ(1, - HANDLE_EINTR(read(fifo_fd, &c, 1))); - EXPECT_EQ('X', c); - LOG(INFO) << "Killing tag " << tag; - Subprocess::Get().KillExec(tag); - }, - fifo_fd, - tag)); + watcher_ = base::FileDescriptorWatcher::WatchReadable( + fifo_fd, + base::Bind( + [](unique_ptr<base::FileDescriptorWatcher::Controller>* watcher, + int fifo_fd, + uint32_t tag) { + char c; + EXPECT_EQ(1, HANDLE_EINTR(read(fifo_fd, &c, 1))); + EXPECT_EQ('X', c); + LOG(INFO) << "Killing tag " << tag; + Subprocess::Get().KillExec(tag); + *watcher = nullptr; + }, + // watcher_ is no longer used outside the clousure. + base::Unretained(&watcher_), + fifo_fd, + tag)); // This test would leak a callback that runs when the child process exits // unless we wait for it to run. |