summaryrefslogtreecommitdiffstats
path: root/tests/wifitests/src/com/android/server/wifi/CustomTestRunner.java
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/wifitests/src/com/android/server/wifi/CustomTestRunner.java
parent13612152ae5278262065ef00dce6df31d8f0a127 (diff)
downloadandroid_frameworks_opt_net_wifi-d9b2ef1b267206c2ef353aa352bdffdedefdd532.tar.gz
android_frameworks_opt_net_wifi-d9b2ef1b267206c2ef353aa352bdffdedefdd532.tar.bz2
android_frameworks_opt_net_wifi-d9b2ef1b267206c2ef353aa352bdffdedefdd532.zip
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/wifitests/src/com/android/server/wifi/CustomTestRunner.java')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/CustomTestRunner.java33
1 files changed, 33 insertions, 0 deletions
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);
+ }
+}