summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authormukesh agrawal <quiche@google.com>2016-04-06 14:07:41 -0700
committermukesh agrawal <quiche@google.com>2016-04-07 17:44:04 -0700
commitd604bbd63d620244ef43408de10f65ead01d5026 (patch)
tree45a2d08d277375d0df2e0de58634ea15c418d92d /tests
parentca0bac5826ab430d1b765b201a609f7bc38401ee (diff)
wifi service: use large ringbuffers in verbose mode
When the user has chosen to enable wi-fi verbose logging, we'd like to use larger ring buffers. Make it so. BUG=27578082 TEST=unit tests Change-Id: I1e2447df2beda455cea37072e91fa0aac338bb3f
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiLoggerTest.java57
1 files changed, 53 insertions, 4 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiLoggerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiLoggerTest.java
index 749f383fb..1ea7e21fc 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiLoggerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiLoggerTest.java
@@ -45,7 +45,6 @@ import java.io.StringWriter;
@SmallTest
public class WifiLoggerTest {
public static final String TAG = "WifiLoggerTest";
- private static final int MAX_RING_BUFFER_SIZE_BYTES = 1024;
@Mock WifiStateMachine mWsm;
@Mock WifiNative mWifiNative;
@@ -79,7 +78,7 @@ public class WifiLoggerTest {
when(mWifiNative.getRingBufferStatus()).thenReturn(ringBufferStatuses);
when(mWifiNative.readKernelLog()).thenReturn("");
- mWifiLogger = new WifiLogger(mWsm, mWifiNative, MAX_RING_BUFFER_SIZE_BYTES);
+ mWifiLogger = new WifiLogger(mWsm, mWifiNative);
}
/**
@@ -109,7 +108,7 @@ public class WifiLoggerTest {
final boolean verbosityToggle = false;
mWifiLogger.startLogging(verbosityToggle);
- final byte[] data = new byte[MAX_RING_BUFFER_SIZE_BYTES];
+ final byte[] data = new byte[WifiLogger.RING_BUFFER_BYTE_LIMIT_SMALL];
mWifiLogger.onRingBufferData(mFakeRbs, data);
mWifiLogger.captureBugReportData(WifiLogger.REPORT_REASON_NONE);
@@ -126,7 +125,7 @@ public class WifiLoggerTest {
final boolean verbosityToggle = false;
mWifiLogger.startLogging(verbosityToggle);
- final byte[] data1 = new byte[MAX_RING_BUFFER_SIZE_BYTES];
+ final byte[] data1 = new byte[WifiLogger.RING_BUFFER_BYTE_LIMIT_SMALL];
final byte[] data2 = {1, 2, 3};
mWifiLogger.onRingBufferData(mFakeRbs, data1);
mWifiLogger.onRingBufferData(mFakeRbs, data2);
@@ -352,4 +351,54 @@ public class WifiLoggerTest {
assertTrue(fateDumpString.contains(
"Frame number: 4\nFrame direction: RX\nFrame timestamp: 3\n"));
}
+
+ /** Verifies that the default size of our ring buffers is small. */
+ @Test
+ public void ringBufferSizeIsSmallByDefault() throws Exception {
+ final boolean verbosityToggle = false;
+ mWifiLogger.startLogging(verbosityToggle);
+ mWifiLogger.onRingBufferData(
+ mFakeRbs, new byte[WifiLogger.RING_BUFFER_BYTE_LIMIT_SMALL + 1]);
+ mWifiLogger.captureBugReportData(WifiLogger.REPORT_REASON_NONE);
+ assertEquals(0, getLoggerRingBufferData().length);
+ }
+
+ /** Verifies that we use large ring buffers when initially started in verbose mode. */
+ @Test
+ public void ringBufferSizeIsLargeInVerboseMode() throws Exception {
+ final boolean verbosityToggle = true;
+ mWifiLogger.startLogging(verbosityToggle);
+ mWifiLogger.onRingBufferData(mFakeRbs, new byte[WifiLogger.RING_BUFFER_BYTE_LIMIT_LARGE]);
+ mWifiLogger.captureBugReportData(WifiLogger.REPORT_REASON_NONE);
+ assertEquals(1, getLoggerRingBufferData().length);
+ }
+
+ /** Verifies that we use large ring buffers when switched from normal to verbose mode. */
+ @Test
+ public void startLoggingGrowsRingBuffersIfNeeded() throws Exception {
+ mWifiLogger.startLogging(false /* verbose disabled */);
+ mWifiLogger.startLogging(true /* verbose enabled */);
+ mWifiLogger.onRingBufferData(mFakeRbs, new byte[WifiLogger.RING_BUFFER_BYTE_LIMIT_LARGE]);
+ mWifiLogger.captureBugReportData(WifiLogger.REPORT_REASON_NONE);
+ assertEquals(1, getLoggerRingBufferData().length);
+ }
+
+ /** Verifies that we use small ring buffers when switched from verbose to normal mode. */
+ @Test
+ public void startLoggingShrinksRingBuffersIfNeeded() throws Exception {
+ mWifiLogger.startLogging(true /* verbose enabled */);
+ mWifiLogger.onRingBufferData(
+ mFakeRbs, new byte[WifiLogger.RING_BUFFER_BYTE_LIMIT_SMALL + 1]);
+
+ // Existing data is nuked (too large).
+ mWifiLogger.startLogging(false /* verbose disabled */);
+ mWifiLogger.captureBugReportData(WifiLogger.REPORT_REASON_NONE);
+ assertEquals(0, getLoggerRingBufferData().length);
+
+ // New data must obey limit as well.
+ mWifiLogger.onRingBufferData(
+ mFakeRbs, new byte[WifiLogger.RING_BUFFER_BYTE_LIMIT_SMALL + 1]);
+ mWifiLogger.captureBugReportData(WifiLogger.REPORT_REASON_NONE);
+ assertEquals(0, getLoggerRingBufferData().length);
+ }
}