1 /* 2 * Copyright (C) 2012 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.settings; 18 19 import android.test.AndroidTestCase; 20 import android.test.suitebuilder.annotation.SmallTest; 21 22 import com.android.settingslib.DeviceInfoUtils; 23 24 public class DeviceInfoSettingsTest extends AndroidTestCase { 25 26 @SmallTest 27 public void testGetFormattedKernelVersion() throws Exception { 28 if ("Unavailable".equals(DeviceInfoUtils.getFormattedKernelVersion())) { 29 fail("formatKernelVersion can't cope with this device's /proc/version"); 30 } 31 } 32 33 @SmallTest 34 public void testFormatKernelVersion() throws Exception { 35 assertEquals("Unavailable", DeviceInfoUtils.formatKernelVersion("")); 36 assertEquals("2.6.38.8-gg784\n" + 37 "root (at) hpao4.eem.corp.google.com #2\n" + 38 "Fri Feb 24 03:31:23 PST 2012", 39 DeviceInfoUtils.formatKernelVersion("Linux version 2.6.38.8-gg784 " + 40 "(root (at) hpao4.eem.corp.google.com) " + 41 "(gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) ) #2 SMP " + 42 "Fri Feb 24 03:31:23 PST 2012")); 43 assertEquals("3.0.31-g6fb96c9\n" + 44 "android-build (at) vpbs1.mtv.corp.google.com #1\n" + 45 "Thu Jun 28 11:02:39 PDT 2012", 46 DeviceInfoUtils.formatKernelVersion("Linux version 3.0.31-g6fb96c9 " + 47 "(android-build (at) vpbs1.mtv.corp.google.com) " + 48 "(gcc version 4.6.x-google 20120106 (prerelease) (GCC) ) #1 " + 49 "SMP PREEMPT Thu Jun 28 11:02:39 PDT 2012")); 50 assertEquals("2.6.38.8-a-b-jellybean+\n" + 51 "x@y #1\n" + 52 "Tue Aug 28 22:10:46 CDT 2012", 53 DeviceInfoUtils.formatKernelVersion("Linux version " + 54 "2.6.38.8-a-b-jellybean+ (x@y) " + 55 "(gcc version 4.4.3 (GCC) ) #1 PREEMPT Tue Aug 28 22:10:46 CDT 2012")); 56 } 57 } 58