diff options
author | Isaac Chiou <isaacchiou@google.com> | 2019-04-12 12:03:45 +0800 |
---|---|---|
committer | Isaac Chiou <isaacchiou@google.com> | 2019-04-22 10:11:01 +0800 |
commit | e1ebbceea0832f2b6e4e30e84ec4ea1ff84762e4 (patch) | |
tree | 65eec426f18d1aa06d48f28ea6c278aa859c2d32 /tests | |
parent | be70cc2e5eb921f4c49ad2ca118211335df8a5dd (diff) |
WifiDiagnostics: Collect logs when detecting fatal firmware alert
When detecting fatal firmware alert, flushing HAL ring buffer to files
Bug: 114766171
Test: Manual test
Test: ./frameworks/opt/net/wifi/tests/wifitests/runtests.sh
Change-Id: I687efca90c25d8d9de224b6b2e426294cae1f0f1
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/MockResources.java | 15 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java | 26 |
2 files changed, 41 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/MockResources.java b/tests/wifitests/src/com/android/server/wifi/MockResources.java index 1a061e22a..dd4413228 100644 --- a/tests/wifitests/src/com/android/server/wifi/MockResources.java +++ b/tests/wifitests/src/com/android/server/wifi/MockResources.java @@ -24,12 +24,14 @@ public class MockResources extends android.test.mock.MockResources { private HashMap<Integer, Integer> mIntegerValues; private HashMap<Integer, String> mStringValues; private HashMap<Integer, CharSequence> mTextValues; + private HashMap<Integer, int[]> mIntArrayValues; public MockResources() { mBooleanValues = new HashMap<Integer, Boolean>(); mIntegerValues = new HashMap<Integer, Integer>(); mStringValues = new HashMap<Integer, String>(); mTextValues = new HashMap<Integer, CharSequence>(); + mIntArrayValues = new HashMap<Integer, int[]>(); } @Override @@ -68,6 +70,15 @@ public class MockResources extends android.test.mock.MockResources { } } + @Override + public int[] getIntArray(int id) { + if (mIntArrayValues.containsKey(id)) { + return mIntArrayValues.get(id); + } else { + return null; + } + } + public void setBoolean(int id, boolean value) { mBooleanValues.put(id, value); } @@ -83,4 +94,8 @@ public class MockResources extends android.test.mock.MockResources { public void setText(int id, CharSequence value) { mTextValues.put(id, value); } + + public void setIntArray(int id, int[] value) { + mIntArrayValues.put(id, value); + } } diff --git a/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java index 1c33d3920..6b63137a2 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java @@ -79,6 +79,10 @@ public class WifiDiagnosticsTest { private static final int BYTES_PER_KBYTE = 1024; private static final int ALERT_REASON_CODE = 1; private static final byte[] ALERT_DATA = {0 , 4, 5}; + /** Mock resource for fatal firmware alert list */ + private static final int[] FATAL_FW_ALART_LIST = {256, 257, 258}; + /** Mock a non fatal firmware alert */ + private static final int NON_FATAL_FW_ALART = 0; private WifiNative.RingBufferStatus mFakeRbs; /** @@ -117,6 +121,8 @@ public class WifiDiagnosticsTest { SMALL_RING_BUFFER_SIZE_KB); resources.setInteger(R.integer.config_wifi_logger_ring_buffer_verbose_size_limit_kb, LARGE_RING_BUFFER_SIZE_KB); + resources.setIntArray(R.array.config_wifi_fatal_firmware_alert_error_code_list, + FATAL_FW_ALART_LIST); when(mContext.getResources()).thenReturn(resources); when(mWifiInjector.makeLog(anyString())).thenReturn(mLog); when(mWifiInjector.getJavaRuntime()).thenReturn(mJavaRuntime); @@ -864,4 +870,24 @@ public class WifiDiagnosticsTest { mWifiDiagnostics.captureBugReportData(WifiDiagnostics.REPORT_REASON_NONE); verify(mWifiNative).flushRingBufferData(); } + + /** Verifies that we flush HAL ringbuffer when detecting fatal firmware alert. */ + @Test + public void captureAlertFlushRingBufferData() { + when(mBuildProperties.isUserBuild()).thenReturn(false); + when(mWifiNative.flushRingBufferData()).thenReturn(true); + /** captureAlertData with mock fatal firmware alert*/ + mWifiDiagnostics.captureAlertData(FATAL_FW_ALART_LIST[0], ALERT_DATA); + verify(mWifiNative).flushRingBufferData(); + } + + /** Verifies that we don't flush HAL ringbuffer when detecting non fatal firmware alert. */ + @Test + public void captureNonAlertFlushRingBufferData() { + when(mBuildProperties.isUserBuild()).thenReturn(false); + when(mWifiNative.flushRingBufferData()).thenReturn(true); + /** captureAlertData with mock non fatal firmware alert*/ + mWifiDiagnostics.captureAlertData(NON_FATAL_FW_ALART, ALERT_DATA); + verify(mWifiNative, never()).flushRingBufferData(); + } } |