diff options
author | Roshan Pius <rpius@google.com> | 2020-05-29 15:47:43 -0700 |
---|---|---|
committer | Roshan Pius <rpius@google.com> | 2020-06-10 20:06:13 -0700 |
commit | a4fc5402d0a52aff7092160b7e73d071a53ef4a4 (patch) | |
tree | 575438bf04bde06a86fbe7249bfa081e38a86df6 /tests | |
parent | 6b61b75021ae98eab575dbcf9ccd244d0a821a1e (diff) |
WifiDiagnostics: Remove blocking call to readLine()
Changes in the CL:
a) Add a check for isReady() before invoking blocking readLine().
b) Add a timeout in the loop to ensure we're not looping forever.
Note: Even with this, there is a theoretical chance that we will get
stuck in readLine() since isReady() will indicate some bytes available,
but not necessarily EOL. But, the logcat daemon outputs a line of data
at a time.
Bug: 157062041
Test: Manual verification of wifi dumpsys after a connection failure.
Change-Id: I6bbdf5f2fe7ed6afc9dd65d95fcb9e938366fdad
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java index 6b235b9f7..c89fe675a 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java @@ -26,6 +26,7 @@ import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.contains; import static org.mockito.Mockito.anyInt; import static org.mockito.Mockito.anyObject; +import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.eq; import static org.mockito.Mockito.never; @@ -72,6 +73,7 @@ public class WifiDiagnosticsTest extends WifiBaseTest { @Mock WifiMetrics mWifiMetrics; @Mock Clock mClock; @Mock BugreportManager mBugreportManager; + private long mBootTimeMs = 0L; MockResources mResources; WifiDiagnostics mWifiDiagnostics; @@ -135,6 +137,13 @@ public class WifiDiagnosticsTest extends WifiBaseTest { when(mWifiInjector.getWifiMetrics()).thenReturn(mWifiMetrics); when(mWifiInjector.getDeviceConfigFacade()).thenReturn(mDeviceConfigFacade); when(mDeviceConfigFacade.getBugReportMinWindowMs()).thenReturn(BUG_REPORT_MIN_WINDOW_MS); + // needed to for the loop in WifiDiagnostics.readLogcatStreamLinesWithTimeout(). + doAnswer(new AnswerWithArguments() { + public long answer() throws Exception { + mBootTimeMs += WifiDiagnostics.LOGCAT_READ_TIMEOUT_MILLIS / 2; + return mBootTimeMs; + } + }).when(mClock).getElapsedSinceBootMillis(); mWifiDiagnostics = new WifiDiagnostics( mContext, mWifiInjector, mWifiNative, mBuildProperties, mLastMileLogger, mClock); mWifiNative.enableVerboseLogging(0); |