diff options
author | David Hu <hud@google.com> | 2012-05-12 17:01:39 -0700 |
---|---|---|
committer | David Hu <hud@google.com> | 2012-05-14 18:13:19 -0700 |
commit | 71a0d06fd8f0cae4d3f38f1f34ceebbfd6d61db6 (patch) | |
tree | c564f6cba917866b4b1096a4499cc78ea86c7c36 /core/tests | |
parent | dfed49a2852e9336e212f6934dcddec7dd743c26 (diff) | |
download | frameworks_base-71a0d06fd8f0cae4d3f38f1f34ceebbfd6d61db6.zip frameworks_base-71a0d06fd8f0cae4d3f38f1f34ceebbfd6d61db6.tar.gz frameworks_base-71a0d06fd8f0cae4d3f38f1f34ceebbfd6d61db6.tar.bz2 |
Allow tests to run when bandwidth profiling fails
When bandwidth profiling fails due to lack of kernel module
the test should still be able to run.
Change-Id: Ib111989d2892b05c147889e562e77035fab05140
Diffstat (limited to 'core/tests')
-rw-r--r-- | core/tests/utillib/src/android/test/BandwidthTestCase.java | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/core/tests/utillib/src/android/test/BandwidthTestCase.java b/core/tests/utillib/src/android/test/BandwidthTestCase.java index 4f95f77..c03d9b3 100644 --- a/core/tests/utillib/src/android/test/BandwidthTestCase.java +++ b/core/tests/utillib/src/android/test/BandwidthTestCase.java @@ -18,6 +18,7 @@ package android.test; import android.net.NetworkStats; import android.net.TrafficStats; import android.os.Bundle; +import android.util.Log; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -29,6 +30,7 @@ import java.lang.reflect.Modifier; * as an {@link InstrumentationTestCase} */ public class BandwidthTestCase extends InstrumentationTestCase { + private static final String TAG = "BandwidthTestCase"; private static final String REPORT_KEY_PACKETS_SENT = "txPackets"; private static final String REPORT_KEY_PACKETS_RECEIVED = "rxPackets"; private static final String REPORT_KEY_BYTES_SENT = "txBytes"; @@ -86,11 +88,26 @@ public class BandwidthTestCase extends InstrumentationTestCase { } } else if (method.isAnnotationPresent(BandwidthTest.class) || testClass.isAnnotationPresent(BandwidthTest.class)) { - TrafficStats.startDataProfiling(null); + /** + * If bandwidth profiling fails for whatever reason the test + * should be allow to execute to its completion. + * Typically bandwidth profiling would fail when a lower level + * component is missing, such as the kernel module, for a newly + * introduced hardware. + */ + try{ + TrafficStats.startDataProfiling(null); + } catch(IllegalStateException isx){ + Log.w(TAG, "Failed to start bandwidth profiling"); + } runMethod(method, 1, false); - NetworkStats stats = TrafficStats.stopDataProfiling(null); - NetworkStats.Entry entry = stats.getTotal(null); - getInstrumentation().sendStatus(2, getBandwidthStats(entry)); + try{ + NetworkStats stats = TrafficStats.stopDataProfiling(null); + NetworkStats.Entry entry = stats.getTotal(null); + getInstrumentation().sendStatus(2, getBandwidthStats(entry)); + } catch (IllegalStateException isx){ + Log.w(TAG, "Failed to collect bandwidth stats"); + } } else { runMethod(method, runCount, isRepetitive); } |