Skip to content

Commit ce99ee7

Browse files
gigilibala2Commit Bot
authored and
Commit Bot
committed
update_engine: Fix failing unittests on ARM
A few of the unittests fail when running on ARM. Android has already fixed those problems and protected them with __ANDROID__. We can just start using them in Chrome OS too. BUG=b:165005216 TEST=FEATURES=test emerge-gale update_engine Change-Id: I7f8820c2ba81f23144257d78aa6c0c599f645e6a Reviewed-on: https://chromium-review.googlesource.com/c/aosp/platform/system/update_engine/+/2460235 Tested-by: Amin Hassani <[email protected]> Reviewed-by: Jae Hoon Kim <[email protected]> Commit-Queue: Amin Hassani <[email protected]>
1 parent e331f5a commit ce99ee7

File tree

2 files changed

+7
-21
lines changed

2 files changed

+7
-21
lines changed

libcurl_http_fetcher.cc

+4-5
Original file line numberDiff line numberDiff line change
@@ -458,10 +458,10 @@ void LibcurlHttpFetcher::CurlPerformOnce() {
458458
// There's either more work to do or we are paused, so we just keep the
459459
// file descriptors to watch up to date and exit, until we are done with the
460460
// work and we are not paused.
461-
#ifdef __ANDROID__
462-
// When there's no base::SingleThreadTaskRunner on current thread, it's not
463-
// possible to watch file descriptors. Just poll it later. This usually
464-
// happens if brillo::FakeMessageLoop is used.
461+
//
462+
// When there's no |base::SingleThreadTaskRunner| on current thread, it's
463+
// not possible to watch file descriptors. Just poll it later. This usually
464+
// happens if |brillo::FakeMessageLoop| is used.
465465
if (!base::ThreadTaskRunnerHandle::IsSet()) {
466466
MessageLoop::current()->PostDelayedTask(
467467
FROM_HERE,
@@ -470,7 +470,6 @@ void LibcurlHttpFetcher::CurlPerformOnce() {
470470
TimeDelta::FromSeconds(1));
471471
return;
472472
}
473-
#endif
474473
SetupMessageLoopSources();
475474
return;
476475
}

libcurl_http_fetcher_unittest.cc

+3-16
Original file line numberDiff line numberDiff line change
@@ -100,18 +100,14 @@ TEST_F(LibcurlHttpFetcherTest, CouldNotResolveHostTest) {
100100

101101
libcurl_fetcher_.BeginTransfer("https://An-uNres0lvable-uRl.invalid");
102102

103-
#ifdef __ANDROID__
104103
// It's slower on Android that libcurl handle may not finish within 1 cycle.
105104
// Will need to wait for more cycles until it finishes. Original test didn't
106105
// correctly handle when we need to re-watch libcurl fds.
107106
while (loop_.PendingTasks() &&
108107
libcurl_fetcher_.GetAuxiliaryErrorCode() == ErrorCode::kSuccess) {
109108
loop_.RunOnce(true);
110109
}
111-
#else
112-
// The first time it can't resolve.
113-
loop_.RunOnce(true);
114-
#endif
110+
115111
EXPECT_EQ(libcurl_fetcher_.GetAuxiliaryErrorCode(),
116112
ErrorCode::kUnresolvedHostError);
117113

@@ -141,18 +137,14 @@ TEST_F(LibcurlHttpFetcherTest, HostResolvedTest) {
141137
// easier to mock the part that depends on internet connectivity.
142138
libcurl_fetcher_.BeginTransfer("https://An-uNres0lvable-uRl.invalid");
143139

144-
#ifdef __ANDROID__
145140
// It's slower on Android that libcurl handle may not finish within 1 cycle.
146141
// Will need to wait for more cycles until it finishes. Original test didn't
147142
// correctly handle when we need to re-watch libcurl fds.
148143
while (loop_.PendingTasks() &&
149144
libcurl_fetcher_.GetAuxiliaryErrorCode() == ErrorCode::kSuccess) {
150145
loop_.RunOnce(true);
151146
}
152-
#else
153-
// The first time it can't resolve.
154-
loop_.RunOnce(true);
155-
#endif
147+
156148
EXPECT_EQ(libcurl_fetcher_.GetAuxiliaryErrorCode(),
157149
ErrorCode::kUnresolvedHostError);
158150

@@ -165,19 +157,14 @@ TEST_F(LibcurlHttpFetcherTest, HostResolvedTest) {
165157
[this]() { libcurl_fetcher_.http_response_code_ = 0; }));
166158
libcurl_fetcher_.transfer_size_ = 10;
167159

168-
#ifdef __ANDROID__
169160
// It's slower on Android that libcurl handle may not finish within 1 cycle.
170161
// Will need to wait for more cycles until it finishes. Original test didn't
171162
// correctly handle when we need to re-watch libcurl fds.
172163
while (loop_.PendingTasks() && libcurl_fetcher_.GetAuxiliaryErrorCode() ==
173164
ErrorCode::kUnresolvedHostError) {
174165
loop_.RunOnce(true);
175166
}
176-
#else
177-
// This time the host is resolved. But after that again we can't resolve
178-
// anymore (See above).
179-
loop_.RunOnce(true);
180-
#endif
167+
181168
EXPECT_EQ(libcurl_fetcher_.GetAuxiliaryErrorCode(),
182169
ErrorCode::kUnresolvedHostRecovered);
183170

0 commit comments

Comments
 (0)