1 <!DOCTYPE html> 2 <html> 3 <!-- 4 Copyright (c) 2012 The Chromium Authors. All rights reserved. 5 Use of this source code is governed by a BSD-style license that can be 6 found in the LICENSE file. 7 --> 8 <head> 9 <title>LinuxPerfAndroidParser tests</title> 10 <script src="base.js"></script> 11 </head> 12 <body> 13 <script> 14 'use strict'; 15 16 base.require('unittest'); 17 base.require('test_utils'); 18 base.require('linux_perf_importer'); 19 20 function testAndroidUserlandImport() { 21 var lines = [ 22 'SurfaceFlinger-4831 [001] ...1 80909.598554: tracing_mark_write: B|4829|onMessageReceived', 23 'SurfaceFlinger-4831 [001] ...1 80909.598572: tracing_mark_write: B|4829|handleMessageInvalidate', 24 'SurfaceFlinger-4831 [001] ...1 80909.598590: tracing_mark_write: B|4829|latchBuffer', 25 'SurfaceFlinger-4831 [001] ...1 80909.598604: tracing_mark_write: E', 26 'SurfaceFlinger-4831 [001] ...1 80909.598627: tracing_mark_write: B|4829|latchBuffer', 27 'SurfaceFlinger-4831 [001] ...1 80909.598651: tracing_mark_write: B|4829|updateTexImage', 28 'SurfaceFlinger-4831 [001] ...1 80909.598675: tracing_mark_write: B|4829|acquireBuffer', 29 'SurfaceFlinger-4831 [001] ...1 80909.598695: tracing_mark_write: B|4829|' + 30 'com.android.launcher/com.android.launcher2.Launcher: 0', 31 'SurfaceFlinger-4831 [001] ...1 80909.598709: tracing_mark_write: E', 32 'SurfaceFlinger-4831 [001] ...1 80909.598733: tracing_mark_write: C|4829|' + 33 'com.android.launcher/com.android.launcher2.Launcher|0', 34 'SurfaceFlinger-4831 [001] ...1 80909.598746: tracing_mark_write: E', 35 'SurfaceFlinger-4831 [001] ...1 80909.598844: tracing_mark_write: B|4829|releaseBuffer', 36 'SurfaceFlinger-4831 [001] ...1 80909.598862: tracing_mark_write: B|4829|' + 37 'com.android.launcher/com.android.launcher2.Launcher: 2', 38 'SurfaceFlinger-4831 [001] ...1 80909.598876: tracing_mark_write: E', 39 'SurfaceFlinger-4831 [001] ...1 80909.598892: tracing_mark_write: E', 40 'SurfaceFlinger-4831 [001] ...1 80909.598925: tracing_mark_write: E', 41 'SurfaceFlinger-4831 [001] ...1 80909.598955: tracing_mark_write: E', 42 'SurfaceFlinger-4831 [001] ...1 80909.598988: tracing_mark_write: B|4829|latchBuffer', 43 'SurfaceFlinger-4831 [001] ...1 80909.599001: tracing_mark_write: E', 44 'SurfaceFlinger-4831 [001] ...1 80909.599021: tracing_mark_write: B|4829|latchBuffer', 45 'SurfaceFlinger-4831 [001] ...1 80909.599036: tracing_mark_write: E', 46 'SurfaceFlinger-4831 [001] ...1 80909.599068: tracing_mark_write: E', 47 'SurfaceFlinger-4831 [001] ...1 80909.599087: tracing_mark_write: E', 48 'SurfaceFlinger-4831 [001] ...1 80909.599104: tracing_mark_write: E' 49 ]; 50 var m = new tracing.TimelineModel(lines.join('\n'), false); 51 assertEquals(0, m.importErrors.length); 52 53 var threads = m.getAllThreads(); 54 assertEquals(1, threads.length); 55 56 var thread = threads[0]; 57 assertEquals(4829, thread.pid); 58 assertEquals(4831, thread.tid); 59 assertEquals('SurfaceFlinger', thread.name); 60 assertEquals(11, thread.slices.length); 61 } 62 63 function testAndroidUserlandImportWithSpacesInThreadName() { 64 var lines = [ 65 'Surface Flinger -4831 [001] ...1 80909.598590: tracing_mark_write: B|4829|latchBuffer', 66 'Surface Flinger -4831 [001] ...1 80909.598604: tracing_mark_write: E', 67 ]; 68 var m = new tracing.TimelineModel(lines.join('\n'), false); 69 assertEquals(0, m.importErrors.length); 70 71 var threads = m.getAllThreads(); 72 assertEquals(1, threads.length); 73 74 var thread = threads[0]; 75 assertEquals(4829, thread.pid); 76 assertEquals(4831, thread.tid); 77 assertEquals('Surface Flinger ', thread.name); 78 assertEquals(1, thread.slices.length); 79 } 80 81 function testAndroidUserlandLegacyKernelImport() { 82 var lines = [ 83 'SurfaceFlinger-4831 [001] ...1 80909.598554: 0: B|4829|onMessageReceived', 84 'SurfaceFlinger-4831 [001] ...1 80909.598572: 0: B|4829|handleMessageInvalidate', 85 'SurfaceFlinger-4831 [001] ...1 80909.598590: 0: B|4829|latchBuffer', 86 'SurfaceFlinger-4831 [001] ...1 80909.598604: 0: E', 87 'SurfaceFlinger-4831 [001] ...1 80909.598627: 0: B|4829|latchBuffer', 88 'SurfaceFlinger-4831 [001] ...1 80909.598651: 0: B|4829|updateTexImage', 89 'SurfaceFlinger-4831 [001] ...1 80909.598675: 0: B|4829|acquireBuffer', 90 'SurfaceFlinger-4831 [001] ...1 80909.598695: 0: B|4829|' + 91 'com.android.launcher/com.android.launcher2.Launcher: 0', 92 'SurfaceFlinger-4831 [001] ...1 80909.598709: 0: E', 93 'SurfaceFlinger-4831 [001] ...1 80909.598733: 0: C|4829|' + 94 'com.android.launcher/com.android.launcher2.Launcher|0', 95 'SurfaceFlinger-4831 [001] ...1 80909.598746: 0: E', 96 'SurfaceFlinger-4831 [001] ...1 80909.598844: 0: B|4829|releaseBuffer', 97 'SurfaceFlinger-4831 [001] ...1 80909.598862: 0: B|4829|' + 98 'com.android.launcher/com.android.launcher2.Launcher: 2', 99 'SurfaceFlinger-4831 [001] ...1 80909.598876: 0: E', 100 'SurfaceFlinger-4831 [001] ...1 80909.598892: 0: E', 101 'SurfaceFlinger-4831 [001] ...1 80909.598925: 0: E', 102 'SurfaceFlinger-4831 [001] ...1 80909.598955: 0: E', 103 'SurfaceFlinger-4831 [001] ...1 80909.598988: 0: B|4829|latchBuffer', 104 'SurfaceFlinger-4831 [001] ...1 80909.599001: 0: E', 105 'SurfaceFlinger-4831 [001] ...1 80909.599021: 0: B|4829|latchBuffer', 106 'SurfaceFlinger-4831 [001] ...1 80909.599036: 0: E', 107 'SurfaceFlinger-4831 [001] ...1 80909.599068: 0: E', 108 'SurfaceFlinger-4831 [001] ...1 80909.599087: 0: E', 109 'SurfaceFlinger-4831 [001] ...1 80909.599104: 0: E' 110 ]; 111 var m = new tracing.TimelineModel(lines.join('\n'), false); 112 assertEquals(0, m.importErrors.length); 113 114 var threads = m.getAllThreads(); 115 assertEquals(1, threads.length); 116 117 var thread = threads[0]; 118 assertEquals(4829, thread.pid); 119 assertEquals(4831, thread.tid); 120 assertEquals('SurfaceFlinger', thread.name); 121 assertEquals(11, thread.slices.length); 122 } 123 124 </script> 125 </body> 126 </html> 127