| <!DOCTYPE html> |
| <!-- |
| Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| Use of this source code is governed by a BSD-style license that can be |
| found in the LICENSE file. |
| --> |
| |
| <link rel="import" href="/core/test_utils.html"> |
| <link rel="import" href="/extras/importer/linux_perf/ftrace_importer.html"> |
| |
| |
| <script> |
| 'use strict'; |
| |
| tr.b.unittest.testSuite(function() { |
| test('binderParserImport', function() { |
| var lines = [ |
| 'binderLibTest-10619 (10619) [001] ...1 25191.335749: binder_transaction' + |
| ': transaction=489053 dest_node=489048 dest_proc=10670 dest_thread=0 ' + |
| 'reply=0 flags=0x10 code=0xd', |
| 'binderLibTest-10670 (10670) [000] ...1 25191.335996:' + |
| ' binder_transaction_received: transaction=489053', |
| 'binderLibTest-10670 (10670) [000] ...1 25191.336167:' + |
| ' binder_transaction: transaction=489056 dest_node=161277 ' + |
| 'dest_proc=3454 dest_thread=0 reply=0 flags=0x10 code=0x2', |
| '/system/bin/servicemanager-3454 ( 3454) [000] ...1 25191.336199:' + |
| ' binder_transaction_received: transaction=489056', |
| '/system/bin/servicemanager-3454 ( 3454) [000] ...1 25191.336302:' + |
| ' binder_transaction: transaction=489057 dest_node=0 dest_proc=10670' + |
| ' dest_thread=10670 reply=1 flags=0x0 code=0x0', |
| 'binderLibTest-10670 (10670) [000] ...1 25191.336334:' + |
| ' binder_transaction_received: transaction=489057', |
| 'binderLibTest-10670 (10670) [000] ...1 25191.336655:' + |
| ' binder_transaction: transaction=489059 dest_node=488755' + |
| ' dest_proc=10622 dest_thread=0 reply=0 flags=0x10 code=0x1', |
| 'Binder_4-10645 (10622) [001] ...1 25191.336693:' + |
| ' binder_transaction_received: transaction=489059', |
| 'Binder_4-10645 (10622) [001] ...1 25191.336754: binder_transaction:' + |
| ' transaction=489060 dest_node=0 dest_proc=10670 dest_thread=10670' + |
| ' reply=1 flags=0x0 code=0x0', |
| 'binderLibTest-10670 (10670) [000] ...1 25191.337003:' + |
| ' binder_transaction_received: transaction=489060', |
| 'binderLibTest-10670 (10670) [000] ...1 25191.337052:' + |
| ' binder_transaction: transaction=489061 dest_node=0 dest_proc=10619' + |
| ' dest_thread=10619 reply=1 flags=0x8 code=0x0', |
| 'binderLibTest-10619 (10619) [001] ...1 25191.337085:' + |
| ' binder_transaction_received: transaction=489061', |
| 'atrace-10618 (10618) [000] ...1 25196.059954: tracing_mark_write:' + |
| ' trace_event_clock_sync: parent_ts=25196.050781' |
| ]; |
| |
| var m = new tr.Model(lines.join('\n'), false); |
| assert.isFalse(m.hasImportWarnings); |
| |
| var threads = m.getAllThreads(); |
| assert.equal(threads.length, 4); |
| |
| }); |
| |
| |
| test('binderRecursiveTest', function() { |
| |
| var lines = [ |
| 'binderLibTest-10619 (10619) [001] ...1 25191.335749: binder_transaction' + |
| ': transaction=489053 dest_node=489048 dest_proc=10670 dest_thread=0 ' + |
| 'reply=0 flags=0x10 code=0xd', |
| 'binderLibTest-10670 (10670) [000] ...1 25191.335996:' + |
| ' binder_transaction_received: transaction=489053', |
| 'binderLibTest-10670 (10670) [000] ...1 25191.336167:' + |
| ' binder_transaction: transaction=489056 dest_node=161277 ' + |
| 'dest_proc=3454 dest_thread=0 reply=0 flags=0x10 code=0x2', |
| '/system/bin/servicemanager-3454 ( 3454) [000] ...1 25191.336199:' + |
| ' binder_transaction_received: transaction=489056', |
| '/system/bin/servicemanager-3454 ( 3454) [000] ...1 25191.336302:' + |
| ' binder_transaction: transaction=489057 dest_node=0 dest_proc=10670' + |
| ' dest_thread=10670 reply=1 flags=0x0 code=0x0', |
| 'binderLibTest-10670 (10670) [000] ...1 25191.336334:' + |
| ' binder_transaction_received: transaction=489057', |
| 'binderLibTest-10670 (10670) [000] ...1 25191.336655:' + |
| ' binder_transaction: transaction=489059 dest_node=488755' + |
| ' dest_proc=10622 dest_thread=0 reply=0 flags=0x10 code=0x1', |
| 'Binder_4-10645 (10622) [001] ...1 25191.336693:' + |
| ' binder_transaction_received: transaction=489059', |
| 'Binder_4-10645 (10622) [001] ...1 25191.336754: binder_transaction:' + |
| ' transaction=489060 dest_node=0 dest_proc=10670 dest_thread=10670' + |
| ' reply=1 flags=0x0 code=0x0', |
| 'binderLibTest-10670 (10670) [000] ...1 25191.337003:' + |
| ' binder_transaction_received: transaction=489060', |
| 'binderLibTest-10670 (10670) [000] ...1 25191.337052:' + |
| ' binder_transaction: transaction=489061 dest_node=0 dest_proc=10619' + |
| ' dest_thread=10619 reply=1 flags=0x8 code=0x0', |
| 'binderLibTest-10619 (10619) [001] ...1 25191.337085:' + |
| ' binder_transaction_received: transaction=489061', |
| 'atrace-10618 (10618) [000] ...1 25196.059954: tracing_mark_write:' + |
| ' trace_event_clock_sync: parent_ts=25196.050781' |
| ]; |
| |
| var m = new tr.Model(lines.join('\n'), false); |
| var threads = m.getAllThreads(); |
| |
| var thread = threads[0]; |
| assert.equal(thread.parent.pid, 3454); |
| assert.equal(thread.tid, 3454); |
| assert.equal(thread.name, '/system/bin/servicemanager'); |
| /* one main slice and one 'internal slice' for the end flow event' */ |
| assert.equal(thread.sliceGroup.length, 2); |
| |
| /* check flow events for service manager */ |
| var main_slice = thread.sliceGroup.slices[0]; |
| assert.equal(main_slice.inFlowEvents.length, 1); |
| assert.equal(main_slice.outFlowEvents.length, 1); |
| var internal_slice = thread.sliceGroup.slices[1]; |
| assert.equal(internal_slice.outFlowEvents.length, 1); |
| |
| /* check name of slice */ |
| assert.equal(main_slice.title, 'binder reply'); |
| |
| |
| /* check binderLibTest */ |
| thread = threads[1]; |
| assert.equal(thread.parent.pid, 10619); |
| assert.equal(thread.tid, 10619); |
| assert.equal(thread.name, 'binderLibTest'); |
| |
| assert.equal(2, thread.sliceGroup.length); |
| |
| main_slice = thread.sliceGroup.slices[0]; |
| assert.equal(main_slice.inFlowEvents.length, 1); |
| assert.equal(main_slice.outFlowEvents.length, 1); |
| internal_slice = thread.sliceGroup.slices[1]; |
| assert.equal(internal_slice.inFlowEvents.length, 1); |
| |
| assert.equal(main_slice.title, 'binder transaction'); |
| |
| |
| /* check Binder_4 */ |
| thread = threads[2]; |
| assert.equal(thread.parent.pid, 10622); |
| assert.equal(thread.tid, 10645); |
| assert.equal(thread.name, 'Binder_4'); |
| assert.equal(2, thread.sliceGroup.length); |
| |
| main_slice = thread.sliceGroup.slices[0]; |
| assert.equal(main_slice.inFlowEvents.length, 1); |
| assert.equal(main_slice.outFlowEvents.length, 1); |
| internal_slice = thread.sliceGroup.slices[1]; |
| assert.equal(internal_slice.outFlowEvents.length, 1); |
| |
| assert.equal(main_slice.title, 'binder reply'); |
| |
| /* check last binderLibTest with recursive slices */ |
| thread = threads[3]; |
| assert.equal(thread.parent.pid, 10670); |
| assert.equal(thread.tid, 10670); |
| assert.equal(thread.name, 'binderLibTest'); |
| assert.equal(6, thread.sliceGroup.length); |
| |
| main_slice = thread.sliceGroup.slices[0]; |
| assert.equal(main_slice.inFlowEvents.length, 1); |
| assert.equal(main_slice.outFlowEvents.length, 1); |
| internal_slice = thread.sliceGroup.slices[5]; |
| assert.equal(internal_slice.outFlowEvents.length, 1); |
| |
| assert.equal(main_slice.title, 'binder reply'); |
| |
| console.log(thread.sliceGroup.slices); |
| var recursive = thread.sliceGroup.slices[1]; |
| var recursive_internal = thread.sliceGroup.slices[2]; |
| assert.equal(recursive.inFlowEvents.length, 1); |
| assert.equal(recursive.outFlowEvents.length, 1); |
| assert.equal(recursive_internal.inFlowEvents.length, 1); |
| |
| assert.equal(recursive.title, 'binder transaction'); |
| |
| /* check second recursive slice and internal */ |
| |
| var recursive = thread.sliceGroup.slices[3]; |
| var recursive_internal = thread.sliceGroup.slices[4]; |
| assert.equal(recursive.inFlowEvents.length, 1); |
| assert.equal(recursive.outFlowEvents.length, 1); |
| assert.equal(recursive_internal.inFlowEvents.length, 1); |
| |
| assert.equal(recursive.title, 'binder transaction'); |
| }); |
| |
| test('binderSimpleAsync', function() { |
| var lines = [ |
| '/system/bin/surfaceflinger-3462 ( 3462) [000] ...1 108286.109437:' + |
| ' binder_transaction: transaction=923419 dest_node=175950' + |
| ' dest_proc=4044 dest_thread=0 reply=0 flags=0x11 code=0x1', |
| 'Binder_5-12869 ( 4044) [000] ...1 108286.109835:' + |
| ' binder_transaction_received: transaction=923419' |
| ]; |
| |
| var m = new tr.Model(lines.join('\n'), false); |
| assert.isFalse(m.hasImportWarnings); |
| |
| var threads = m.getAllThreads(0); |
| assert.equal(threads.length, 2); |
| |
| var thread = threads[0]; |
| assert.equal(thread.tid, 3462); |
| assert.equal(thread.name, '/system/bin/surfaceflinger'); |
| assert.equal(thread.sliceGroup.length, 1); |
| |
| var slice = thread.sliceGroup.slices[0]; |
| assert.equal(slice.outFlowEvents.length, 1); |
| assert.equal(slice.inFlowEvents.length, 0); |
| assert.equal(slice.title, 'binder transaction async'); |
| |
| thread = threads[1]; |
| assert.equal(thread.tid, 12869); |
| assert.equal(thread.name, 'Binder_5'); |
| assert.equal(thread.sliceGroup.length, 1); |
| |
| slice = thread.sliceGroup.slices[0]; |
| assert.equal(slice.inFlowEvents.length, 1); |
| assert.equal(slice.outFlowEvents.length, 0); |
| assert.equal(slice.title, 'binder Async recv'); |
| |
| }); |
| }); |
| |
| </script> |
| |