summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authormukesh agrawal <quiche@google.com>2017-04-14 14:24:40 -0700
committermukesh agrawal <quiche@google.com>2017-04-18 14:56:15 -0700
commitd9b2ef1b267206c2ef353aa352bdffdedefdd532 (patch)
tree916da0a212fbc95648bb86ee2db69960092d9875 /tests
parent13612152ae5278262065ef00dce6df31d8f0a127 (diff)
tests: don't crash on Log.wtf() in eng builds
We'd like to be able to run the unit tests on eng builds, and get meaningful results. Unfortunately, at the moment, any test that excerises a call to Log.wtf() will cause the tests to abort (not fail -- abort). The abort happens because Log.wtf() aborts on eng builds (by design). While that likely makes sense for normal code, it gets in the way of testing. Resolve this, by installing a custom TerribleFailureHandler before running our tests. Note that this does mean that our code behaves differently under eng-test than eng-normal. I think we're okay with that, since the eng-test behavior now more closely reflects the user-normal and userdebug-normal behavior. Bug: 36981745 Test: tests/wifitests/runtests.sh (on aosp_bullhead-eng) Change-Id: Ieb3a3a98eacdf7131efd1efc6a966f68724e701b
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/AndroidManifest.xml2
-rwxr-xr-xtests/wifitests/runtests.sh2
-rw-r--r--tests/wifitests/src/com/android/server/wifi/CustomTestRunner.java33
3 files changed, 35 insertions, 2 deletions
diff --git a/tests/wifitests/AndroidManifest.xml b/tests/wifitests/AndroidManifest.xml
index 63b9542d9..dcb61c740 100644
--- a/tests/wifitests/AndroidManifest.xml
+++ b/tests/wifitests/AndroidManifest.xml
@@ -30,7 +30,7 @@
</activity>
</application>
- <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
+ <instrumentation android:name="com.android.server.wifi.CustomTestRunner"
android:targetPackage="com.android.server.wifi.test"
android:label="Frameworks Wifi Tests">
</instrumentation>
diff --git a/tests/wifitests/runtests.sh b/tests/wifitests/runtests.sh
index 529a535e6..7a34bf7dc 100755
--- a/tests/wifitests/runtests.sh
+++ b/tests/wifitests/runtests.sh
@@ -42,4 +42,4 @@ adb install -r -g "$OUT/data/app/FrameworksWifiTests/FrameworksWifiTests.apk"
adb shell am instrument -w "$@" \
-e notAnnotation com.android.server.wifi.DisabledForUpdateToAnyMatcher \
- 'com.android.server.wifi.test/android.support.test.runner.AndroidJUnitRunner'
+ 'com.android.server.wifi.test/com.android.server.wifi.CustomTestRunner'
diff --git a/tests/wifitests/src/com/android/server/wifi/CustomTestRunner.java b/tests/wifitests/src/com/android/server/wifi/CustomTestRunner.java
new file mode 100644
index 000000000..d51f16e36
--- /dev/null
+++ b/tests/wifitests/src/com/android/server/wifi/CustomTestRunner.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.server.wifi;
+
+import android.os.Bundle;
+import android.support.test.runner.AndroidJUnitRunner;
+import android.util.Log;
+
+import static org.mockito.Mockito.mock;
+
+public class CustomTestRunner extends AndroidJUnitRunner {
+ @Override
+ public void onCreate(Bundle arguments) {
+ // Override the default TerribleFailureHandler, as that handler might terminate
+ // the process (if we're on an eng build).
+ Log.setWtfHandler(mock(Log.TerribleFailureHandler.class));
+ super.onCreate(arguments);
+ }
+}