summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authormukesh agrawal <quiche@google.com>2016-06-22 15:46:11 -0700
committerMukesh Agrawal <quiche@google.com>2016-06-28 23:42:31 +0000
commite1db4e04054d8cc302fb96c4f78370845650504e (patch)
tree3a133cfa9f88f558ad5705f085f9ab2661606807 /tests
parent450fee26a21eb56d536df147d3e88d3549f807c0 (diff)
downloadandroid_frameworks_opt_net_wifi-e1db4e04054d8cc302fb96c4f78370845650504e.tar.gz
android_frameworks_opt_net_wifi-e1db4e04054d8cc302fb96c4f78370845650504e.tar.bz2
android_frameworks_opt_net_wifi-e1db4e04054d8cc302fb96c4f78370845650504e.zip
WifiLogger: use R for ring buffer sizing
Use Resources to determine ring-buffer sizing. This is to support board-specific ring-buffer sizes. BUG=29225988 TEST=unit tests TEST=manual Manual test (bullhead): Added some Log.e() statements, and verified that RING_BUFFER_BYTE_LIMIT_SMALL and RING_BUFFER_BYTE_LIMIT_LARGE were 32KB and 1024KB, respectively. Change-Id: I25ee7d871609c4ebe186424bfdd324a8283f43e3 (cherry picked from commit eacd212af097fada70bdb49da3ed06e8d172237b)
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiLoggerTest.java37
1 files changed, 26 insertions, 11 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiLoggerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiLoggerTest.java
index 55dc683c7..81c6274e8 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiLoggerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiLoggerTest.java
@@ -16,7 +16,9 @@
package com.android.server.wifi;
+import android.content.Context;
import android.test.suitebuilder.annotation.SmallTest;
+import com.android.internal.R;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
@@ -52,11 +54,15 @@ public class WifiLoggerTest {
@Mock WifiStateMachine mWsm;
@Mock WifiNative mWifiNative;
@Mock BuildProperties mBuildProperties;
+ @Mock Context mContext;
WifiLogger mWifiLogger;
private static final String FAKE_RING_BUFFER_NAME = "fake-ring-buffer";
- private WifiNative.RingBufferStatus mFakeRbs;
+ private static final int SMALL_RING_BUFFER_SIZE_KB = 32;
+ private static final int LARGE_RING_BUFFER_SIZE_KB = 1024;
+ private static final int BYTES_PER_KBYTE = 1024;
+ private WifiNative.RingBufferStatus mFakeRbs;
/**
* Returns the data that we would dump in a bug report, for our ring buffer.
* @return a 2-D byte array, where the first dimension is the record number, and the second
@@ -85,7 +91,14 @@ public class WifiLoggerTest {
when(mBuildProperties.isUserdebugBuild()).thenReturn(false);
when(mBuildProperties.isUserBuild()).thenReturn(true);
- mWifiLogger = new WifiLogger(mWsm, mWifiNative, mBuildProperties);
+ MockResources resources = new MockResources();
+ resources.setInteger(R.integer.config_wifi_logger_ring_buffer_default_size_limit_kb,
+ SMALL_RING_BUFFER_SIZE_KB);
+ resources.setInteger(R.integer.config_wifi_logger_ring_buffer_verbose_size_limit_kb,
+ LARGE_RING_BUFFER_SIZE_KB);
+ when(mContext.getResources()).thenReturn(resources);
+
+ mWifiLogger = new WifiLogger(mContext, mWsm, mWifiNative, mBuildProperties);
mWifiNative.enableVerboseLogging(0);
}
@@ -197,7 +210,7 @@ public class WifiLoggerTest {
final boolean verbosityToggle = false;
mWifiLogger.startLogging(verbosityToggle);
- final byte[] data = new byte[WifiLogger.RING_BUFFER_BYTE_LIMIT_SMALL];
+ final byte[] data = new byte[SMALL_RING_BUFFER_SIZE_KB * BYTES_PER_KBYTE];
mWifiLogger.onRingBufferData(mFakeRbs, data);
mWifiLogger.captureBugReportData(WifiLogger.REPORT_REASON_NONE);
@@ -214,7 +227,7 @@ public class WifiLoggerTest {
final boolean verbosityToggle = false;
mWifiLogger.startLogging(verbosityToggle);
- final byte[] data1 = new byte[WifiLogger.RING_BUFFER_BYTE_LIMIT_SMALL];
+ final byte[] data1 = new byte[SMALL_RING_BUFFER_SIZE_KB * BYTES_PER_KBYTE];
final byte[] data2 = {1, 2, 3};
mWifiLogger.onRingBufferData(mFakeRbs, data1);
mWifiLogger.onRingBufferData(mFakeRbs, data2);
@@ -526,7 +539,7 @@ public class WifiLoggerTest {
final boolean verbosityToggle = false;
mWifiLogger.startLogging(verbosityToggle);
mWifiLogger.onRingBufferData(
- mFakeRbs, new byte[WifiLogger.RING_BUFFER_BYTE_LIMIT_SMALL + 1]);
+ mFakeRbs, new byte[SMALL_RING_BUFFER_SIZE_KB * BYTES_PER_KBYTE + 1]);
mWifiLogger.captureBugReportData(WifiLogger.REPORT_REASON_NONE);
assertEquals(0, getLoggerRingBufferData().length);
}
@@ -540,7 +553,7 @@ public class WifiLoggerTest {
when(mBuildProperties.isUserBuild()).thenReturn(false);
mWifiLogger.startLogging(verbosityToggle);
mWifiLogger.onRingBufferData(
- mFakeRbs, new byte[WifiLogger.RING_BUFFER_BYTE_LIMIT_SMALL + 1]);
+ mFakeRbs, new byte[SMALL_RING_BUFFER_SIZE_KB * BYTES_PER_KBYTE + 1]);
mWifiLogger.captureBugReportData(WifiLogger.REPORT_REASON_NONE);
assertEquals(0, getLoggerRingBufferData().length);
}
@@ -554,7 +567,7 @@ public class WifiLoggerTest {
when(mBuildProperties.isUserBuild()).thenReturn(false);
mWifiLogger.startLogging(verbosityToggle);
mWifiLogger.onRingBufferData(
- mFakeRbs, new byte[WifiLogger.RING_BUFFER_BYTE_LIMIT_SMALL + 1]);
+ mFakeRbs, new byte[SMALL_RING_BUFFER_SIZE_KB * BYTES_PER_KBYTE + 1]);
mWifiLogger.captureBugReportData(WifiLogger.REPORT_REASON_NONE);
assertEquals(0, getLoggerRingBufferData().length);
}
@@ -564,7 +577,8 @@ public class WifiLoggerTest {
public void ringBufferSizeIsLargeInVerboseMode() throws Exception {
final boolean verbosityToggle = true;
mWifiLogger.startLogging(verbosityToggle);
- mWifiLogger.onRingBufferData(mFakeRbs, new byte[WifiLogger.RING_BUFFER_BYTE_LIMIT_LARGE]);
+ mWifiLogger.onRingBufferData(
+ mFakeRbs, new byte[LARGE_RING_BUFFER_SIZE_KB * BYTES_PER_KBYTE]);
mWifiLogger.captureBugReportData(WifiLogger.REPORT_REASON_NONE);
assertEquals(1, getLoggerRingBufferData().length);
}
@@ -574,7 +588,8 @@ public class WifiLoggerTest {
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.onRingBufferData(
+ mFakeRbs, new byte[LARGE_RING_BUFFER_SIZE_KB * BYTES_PER_KBYTE]);
mWifiLogger.captureBugReportData(WifiLogger.REPORT_REASON_NONE);
assertEquals(1, getLoggerRingBufferData().length);
}
@@ -584,7 +599,7 @@ public class WifiLoggerTest {
public void startLoggingShrinksRingBuffersIfNeeded() throws Exception {
mWifiLogger.startLogging(true /* verbose enabled */);
mWifiLogger.onRingBufferData(
- mFakeRbs, new byte[WifiLogger.RING_BUFFER_BYTE_LIMIT_SMALL + 1]);
+ mFakeRbs, new byte[SMALL_RING_BUFFER_SIZE_KB * BYTES_PER_KBYTE + 1]);
// Existing data is nuked (too large).
mWifiLogger.startLogging(false /* verbose disabled */);
@@ -593,7 +608,7 @@ public class WifiLoggerTest {
// New data must obey limit as well.
mWifiLogger.onRingBufferData(
- mFakeRbs, new byte[WifiLogger.RING_BUFFER_BYTE_LIMIT_SMALL + 1]);
+ mFakeRbs, new byte[SMALL_RING_BUFFER_SIZE_KB * BYTES_PER_KBYTE + 1]);
mWifiLogger.captureBugReportData(WifiLogger.REPORT_REASON_NONE);
assertEquals(0, getLoggerRingBufferData().length);
}