Home | History | Annotate | Download | only in parser
      1 /*
      2  * Copyright (C) 2015 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 package com.android.loganalysis.parser;
     17 
     18 
     19 
     20 import com.android.loganalysis.item.InterruptItem;
     21 
     22 import junit.framework.TestCase;
     23 
     24 import java.util.Arrays;
     25 import java.util.List;
     26 
     27 /**
     28  * Unit tests for {@link InterruptParser}
     29  */
     30 public class InterruptParserTest extends TestCase {
     31 
     32     /**
     33      * Test that normal input is parsed.
     34      */
     35     public void testInterruptParser() {
     36         List<String> inputBlock = Arrays.asList(
     37                " Wakeup reason 200:qcom,smd-rpm:222:fc4: 11m 49s 332ms (0 times) realtime",
     38                " Wakeup reason 200:qcom,smd-rpm: 48s 45ms (0 times) realtime",
     39                " Wakeup reason 2:qcom,smd-rpm:2:f0.qm,mm:22:fc4mi: 3s 417ms (0 times) realtime",
     40                " Wakeup reason 188:qcom,smd-adsp:200:qcom,smd-rpm: 1s 656ms (0 times) realtime",
     41                " Wakeup reason 58:qcom,smsm-modem:2:qcom,smd-rpm: 6m 16s 1ms (5 times) realtime",
     42                " Wakeup reason 57:qcom,smd-modem:200:qcom,smd-rpm: 40s 995ms (0 times) realtime",
     43                " Wakeup reason unknown: 8s 455ms (0 times) realtime",
     44                " Wakeup reason 9:bcmsdh_sdmmc:2:qcomd-rpm:240:mso: 8m 5s 9ms (0 times) realtime");
     45 
     46         InterruptItem interrupt = new InterruptParser().parse(inputBlock);
     47 
     48         assertEquals(1, interrupt.getInterrupts(
     49                 InterruptItem.InterruptCategory.WIFI_INTERRUPT).size());
     50 
     51         assertEquals("9:bcmsdh_sdmmc:2:qcomd-rpm:240:mso", interrupt.getInterrupts(
     52                 InterruptItem.InterruptCategory.WIFI_INTERRUPT).get(0).getName());
     53 
     54         assertEquals(2, interrupt.getInterrupts(
     55                 InterruptItem.InterruptCategory.MODEM_INTERRUPT).size());
     56 
     57         assertEquals(5, interrupt.getInterrupts(InterruptItem.InterruptCategory.MODEM_INTERRUPT).
     58                 get(0).getInterruptCount());
     59 
     60     }
     61 }
     62 
     63