From: Nick Desaulniers Date: Sun, 30 Oct 2016 21:48:08 +0000 (-0700) Subject: DeviceInfoSettingsTest: test parsing llvm kernel X-Git-Tag: android-x86-9.0-r1~89^2^2~3^2~27^2~46^2^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=4021eb5229e9e5f087b4e026ef057f140d61127c;p=android-x86%2Fpackages-apps-Settings.git 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 cec3f74544..c66c2b42a9 100644 --- a/tests/unit/src/com/android/settings/DeviceInfoSettingsTest.java +++ b/tests/robotests/src/com/android/settings/DeviceInfoSettingsTest.java @@ -18,19 +18,23 @@ package com.android.settings; 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 @@ public class DeviceInfoSettingsTest extends AndroidTestCase { 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")); } }