Tests: refactor test framework to eliminate py.test
[deliverable/lttng-analyses.git] / tests / test_cputop.py
1 # The MIT License (MIT)
2 #
3 # Copyright (C) 2016 - Julien Desfossez <jdesfossez@efficios.com>
4 # Antoine Busque <abusque@efficios.com>
5 #
6 # Permission is hereby granted, free of charge, to any person obtaining a copy
7 # of this software and associated documentation files (the "Software"), to deal
8 # in the Software without restriction, including without limitation the rights
9 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 # copies of the Software, and to permit persons to whom the Software is
11 # furnished to do so, subject to the following conditions:
12 #
13 # The above copyright notice and this permission notice shall be included in
14 # all copies or substantial portions of the Software.
15 #
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 # SOFTWARE.
23
24 from .analysis_test import AnalysisTest
25
26
27 class CpuTest(AnalysisTest):
28 def write_trace(self):
29 # runs the whole time: 100%
30 self.trace_writer.write_sched_switch(1000, 5, 'swapper/5',
31 0, 'prog100pc-cpu5', 42)
32 # runs for 2s alternating with swapper out every 100ms
33 self.trace_writer.sched_switch_50pc(1100, 5000, 0, 100, 'swapper/0',
34 0, 'prog20pc-cpu0', 30664)
35 # runs for 2.5s alternating with swapper out every 100ms
36 self.trace_writer.sched_switch_50pc(5100, 10000, 1, 100, 'swapper/1',
37 0, 'prog25pc-cpu1', 30665)
38 # switch out prog100pc-cpu5
39 self.trace_writer.write_sched_switch(11000, 5, 'prog100pc-cpu5',
40 42, 'swapper/5', 0)
41 self.trace_writer.flush()
42
43 def test_cputop(self):
44 expected = self.get_expected_output('cputop.txt')
45 result = self.get_cmd_output('lttng-cputop')
46
47 self.assertMultiLineEqual(result, expected)
This page took 0.031929 seconds and 6 git commands to generate.