<!DOCTYPE html>
<html>
<!--
Copyright (c) 2012 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.
-->
<head>
<title>LinuxPerfSchedParser tests</title>
<script src="base.js"></script>
</head>
<body>
<script>
'use strict';
base.require('unittest');
base.require('test_utils');
base.require('linux_perf_importer');
function testSchedSwitchRE() {
var re = tracing._LinuxPerfSchedParserTestExports.schedSwitchRE;
var x = re.exec('prev_comm=swapper prev_pid=0 prev_prio=120 prev_state=R ' +
'==> next_comm=SurfaceFlinger next_pid=178 next_prio=112');
assertNotNull(x);
assertEquals('swapper', x[1]);
assertEquals('0', x[2]);
assertEquals('120', x[3]);
assertEquals('R', x[4]);
assertEquals('SurfaceFlinger', x[5]);
assertEquals('178', x[6]);
assertEquals('112', x[7]);
var x = re.exec('prev_comm=.android.chrome prev_pid=1562 prev_prio=120 ' +
'prev_state=R ==> next_comm=Binder Thread # next_pid=195 next_prio=120');
assertNotNull(x);
assertEquals('.android.chrome', x[1]);
assertEquals('Binder Thread #', x[5]);
var x = re.exec('prev_comm=Binder Thread # prev_pid=1562 prev_prio=120 ' +
'prev_state=R ==> next_comm=.android.chrome next_pid=195 next_prio=120');
assertNotNull(x);
assertEquals('Binder Thread #', x[1]);
assertEquals('.android.chrome', x[5]);
// explict test for prev_state of D|W
var x = re.exec('prev_comm=.android.chrome prev_pid=1562 prev_prio=120 ' +
'prev_state=D|W ==> next_comm=Binder Thread # next_pid=195 ' +
'next_prio=120');
assertNotNull(x);
assertEquals('D|W', x[4]);
}
function testSchedWakeupRE() {
var re = tracing._LinuxPerfSchedParserTestExports.schedWakeupRE;
var x = re.exec(
'comm=SensorService pid=207 prio=112 success=1 target_cpu=000');
assertNotNull(x);
assertEquals('SensorService', x[1]);
assertEquals('207', x[2]);
assertEquals('112', x[3]);
assertEquals('1', x[4]);
assertEquals('000', x[5]);
}
function testImportOneSequenceWithSchedWakeUp() {
// TODO(nduca): write test for this.
}
</script>
</body>
</html>