1 /* 2 * Copyright 2018 Google Inc. 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 * https://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 trebuchet.importers.ftrace 18 19 import trebuchet.importers.ftrace.events.* 20 import kotlin.test.Test 21 import kotlin.test.assertEquals 22 import kotlin.test.assertSame 23 24 class TracingMarkerEventTest { testBeginnull25 @Test fun testBegin() { 26 val begin = detailsFor<BeginSliceEvent>("tracing_mark_write: B|5000|hello world") 27 assertEquals(5000, begin.tgid) 28 assertEquals("hello world", begin.title) 29 } 30 testEndnull31 @Test fun testEnd() { 32 detailsFor<EndSliceEvent>("tracing_mark_write: E") 33 } 34 testCounternull35 @Test fun testCounter() { 36 val counter = detailsFor<CounterSliceEvent>("tracing_mark_write: C|42|myCounter|9001") 37 assertEquals(42, counter.tgid) 38 assertEquals("myCounter", counter.name) 39 assertEquals(9001, counter.value) 40 } 41 testParentTSnull42 @Test fun testParentTS() { 43 val parentTS = detailsFor<ParentTSEvent>( 44 "tracing_mark_write: trace_event_clock_sync: parent_ts=4492.069824") 45 assertEquals(4492.069824, parentTS.parentTimestamp) 46 } 47 testRealtimeTSnull48 @Test fun testRealtimeTS() { 49 val realtimeTS = detailsFor<RealtimeTSEvent>( 50 "tracing_mark_write: trace_event_clock_sync: realtime_ts=1491850748338") 51 assertEquals(1491850748338, realtimeTS.realtimeTimestamp) 52 } 53 testUnknownnull54 @Test fun testUnknown() { 55 val details = detailsFor<FtraceEventDetails>("tracing_mark_write: this is unknown") 56 assertSame(NoDetails, details) 57 } 58 testStartAsyncnull59 @Test fun testStartAsync() { 60 val start = detailsFor<StartAsyncSliceEvent>("tracing_mark_write: S|1150|launching: com.google.android.calculator|0") 61 assertEquals(1150, start.tgid) 62 assertEquals("launching: com.google.android.calculator", start.name) 63 assertEquals(0, start.cookie) 64 } 65 testFinishAsyncnull66 @Test fun testFinishAsync() { 67 val finish = detailsFor<FinishAsyncSliceEvent>("tracing_mark_write: F|1150|launching: com.google.android.calculator|0") 68 assertEquals(1150, finish.tgid) 69 assertEquals("launching: com.google.android.calculator", finish.name) 70 assertEquals(0, finish.cookie) 71 } 72 }