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>LinuxPerfSchedParser 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 testSchedSwitchRE() { 21 var re = tracing._LinuxPerfSchedParserTestExports.schedSwitchRE; 22 var x = re.exec('prev_comm=swapper prev_pid=0 prev_prio=120 prev_state=R ' + 23 '==> next_comm=SurfaceFlinger next_pid=178 next_prio=112'); 24 assertNotNull(x); 25 assertEquals('swapper', x[1]); 26 assertEquals('0', x[2]); 27 assertEquals('120', x[3]); 28 assertEquals('R', x[4]); 29 assertEquals('SurfaceFlinger', x[5]); 30 assertEquals('178', x[6]); 31 assertEquals('112', x[7]); 32 33 var x = re.exec('prev_comm=.android.chrome prev_pid=1562 prev_prio=120 ' + 34 'prev_state=R ==> next_comm=Binder Thread # next_pid=195 next_prio=120'); 35 assertNotNull(x); 36 assertEquals('.android.chrome', x[1]); 37 assertEquals('Binder Thread #', x[5]); 38 39 var x = re.exec('prev_comm=Binder Thread # prev_pid=1562 prev_prio=120 ' + 40 'prev_state=R ==> next_comm=.android.chrome next_pid=195 next_prio=120'); 41 assertNotNull(x); 42 assertEquals('Binder Thread #', x[1]); 43 assertEquals('.android.chrome', x[5]); 44 45 // explict test for prev_state of D|W 46 var x = re.exec('prev_comm=.android.chrome prev_pid=1562 prev_prio=120 ' + 47 'prev_state=D|W ==> next_comm=Binder Thread # next_pid=195 ' + 48 'next_prio=120'); 49 assertNotNull(x); 50 assertEquals('D|W', x[4]); 51 } 52 53 function testSchedWakeupRE() { 54 var re = tracing._LinuxPerfSchedParserTestExports.schedWakeupRE; 55 var x = re.exec( 56 'comm=SensorService pid=207 prio=112 success=1 target_cpu=000'); 57 assertNotNull(x); 58 assertEquals('SensorService', x[1]); 59 assertEquals('207', x[2]); 60 assertEquals('112', x[3]); 61 assertEquals('1', x[4]); 62 assertEquals('000', x[5]); 63 } 64 65 function testImportOneSequenceWithSchedWakeUp() { 66 // TODO(nduca): write test for this. 67 } 68 69 </script> 70 </body> 71 </html> 72