DeviceInfoSettingsTest: test parsing llvm kernel
Adds unit test for DeviceInfoUtils.formatKernelVersion to see if it can
parse a /proc/version string from a kernel compiled with Clang/LLVM.
Bug: 32455817
Change-Id: I25123bf44f67e038e01d8c76d6eab18d5616c7c2
diff --git a/tests/unit/src/com/android/settings/DeviceInfoSettingsTest.java b/tests/robotests/src/com/android/settings/DeviceInfoSettingsTest.java
similarity index 79%
rename from tests/unit/src/com/android/settings/DeviceInfoSettingsTest.java
rename to tests/robotests/src/com/android/settings/DeviceInfoSettingsTest.java
index cec3f74..c66c2b4 100644
--- a/tests/unit/src/com/android/settings/DeviceInfoSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/DeviceInfoSettingsTest.java
@@ -18,19 +18,23 @@
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;
-
import com.android.settingslib.DeviceInfoUtils;
+import org.junit.runner.RunWith;
+import org.junit.Test;
+import org.robolectric.annotation.Config;
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public class DeviceInfoSettingsTest extends AndroidTestCase {
- @SmallTest
+ @Test
public void testGetFormattedKernelVersion() throws Exception {
if ("Unavailable".equals(DeviceInfoUtils.getFormattedKernelVersion())) {
fail("formatKernelVersion can't cope with this device's /proc/version");
}
}
- @SmallTest
+ @Test
public void testFormatKernelVersion() throws Exception {
assertEquals("Unavailable", DeviceInfoUtils.formatKernelVersion(""));
assertEquals("2.6.38.8-gg784\n" +
@@ -53,5 +57,12 @@
DeviceInfoUtils.formatKernelVersion("Linux version " +
"2.6.38.8-a-b-jellybean+ (x@y) " +
"(gcc version 4.4.3 (GCC) ) #1 PREEMPT Tue Aug 28 22:10:46 CDT 2012"));
+ assertEquals("3.18.31-g3ce5faa-dirty\n" +
+ "x@y #5\n" +
+ "Fri Oct 28 14:38:13 PDT 2016",
+ DeviceInfoUtils.formatKernelVersion("Linux version " +
+ "3.18.31-g3ce5faa-dirty (x@y) (Android clang " +
+ "version 3.8.275480 (based on LLVM 3.8.275480)) " +
+ "#5 SMP PREEMPT Fri Oct 28 14:38:13 PDT 2016"));
}
}