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 21 import com.android.settings.DeviceInfoSettings; 22 23 public class DeviceInfoSettingsTest extends AndroidTestCase { 24 25 public void testGetFormattedKernelVersion() throws Exception { 26 if ("Unavailable".equals(DeviceInfoSettings.getFormattedKernelVersion())) { 27 fail("formatKernelVersion can't cope with this device's /proc/version"); 28 } 29 } 30 31 public void testFormatKernelVersion() throws Exception { 32 assertEquals("Unavailable", DeviceInfoSettings.formatKernelVersion("")); 33 assertEquals("2.6.38.8-gg784\n" + 34 "root (at) hpao4.eem.corp.google.com #2\n" + 35 "Fri Feb 24 03:31:23 PST 2012", 36 DeviceInfoSettings.formatKernelVersion("Linux version 2.6.38.8-gg784 " + 37 "(root (at) hpao4.eem.corp.google.com) " + 38 "(gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) ) #2 SMP " + 39 "Fri Feb 24 03:31:23 PST 2012")); 40 assertEquals("3.0.31-g6fb96c9\n" + 41 "android-build (at) vpbs1.mtv.corp.google.com #1\n" + 42 "Thu Jun 28 11:02:39 PDT 2012", 43 DeviceInfoSettings.formatKernelVersion("Linux version 3.0.31-g6fb96c9 " + 44 "(android-build (at) vpbs1.mtv.corp.google.com) " + 45 "(gcc version 4.6.x-google 20120106 (prerelease) (GCC) ) #1 " + 46 "SMP PREEMPT Thu Jun 28 11:02:39 PDT 2012")); 47 assertEquals("2.6.38.8-a-b-jellybean+\n" + 48 "x@y #1\n" + 49 "Tue Aug 28 22:10:46 CDT 2012", 50 DeviceInfoSettings.formatKernelVersion("Linux version " + 51 "2.6.38.8-a-b-jellybean+ (x@y) " + 52 "(gcc version 4.4.3 (GCC) ) #1 PREEMPT Tue Aug 28 22:10:46 CDT 2012")); 53 } 54 } 55