Refactor utils from linuxautomaton/common into the common package
[deliverable/lttng-analyses.git] / tests / test_io.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 IoTest(AnalysisTest):
28 def write_trace(self):
29 # app (99) is known at statedump
30 self.trace_writer.write_lttng_statedump_process_state(
31 1000, 0, 99, 99, 99, 99, 98, 98, 'app', 0, 5, 0, 5, 0)
32 # app2 (100) unknown at statedump has testfile, FD 3 defined at
33 # statedump
34 self.trace_writer.write_lttng_statedump_file_descriptor(
35 1001, 0, 100, 3, 0, 0, 'testfile')
36 # app write 10 bytes to FD 4
37 self.trace_writer.write_sched_switch(1002, 0, 'swapper/0', 0, 'app',
38 99)
39 self.trace_writer.write_syscall_write(1004, 0, 1, 4, 0xabcd, 10, 10)
40 # app2 reads 100 bytes in FD 3
41 self.trace_writer.write_sched_switch(1006, 0, 'app', 99, 'app2', 100)
42 self.trace_writer.write_syscall_read(1008, 0, 1, 3, 0xcafe, 100, 100)
43 # app3 and its FD 3 are completely unknown at statedump, tries to read
44 # 100 bytes from FD 3 but only gets 42
45 self.trace_writer.write_sched_switch(1010, 0, 'app2', 100, 'app3', 101)
46 self.trace_writer.write_syscall_read(1012, 0, 1, 3, 0xcafe, 100, 42)
47 # block write
48 self.trace_writer.write_block_rq_issue(1015, 0, 264241152, 33, 10, 40,
49 99, 0, 0, '', 'app')
50 self.trace_writer.write_block_rq_complete(1016, 0, 264241152, 33, 10,
51 0, 0, 0, '')
52 # block read
53 self.trace_writer.write_block_rq_issue(1017, 0, 8388608, 33, 20, 90,
54 101, 1, 0, '', 'app3')
55 self.trace_writer.write_block_rq_complete(1018, 0, 8388608, 33, 20, 0,
56 1, 0, '')
57 # net xmit
58 self.trace_writer.write_net_dev_xmit(1020, 2, 0xff, 32, 100, 'wlan0')
59 # net receive
60 self.trace_writer.write_netif_receive_skb(1021, 1, 0xff, 100, 'wlan1')
61 self.trace_writer.write_netif_receive_skb(1022, 1, 0xff, 200, 'wlan0')
62 # syscall open
63 self.trace_writer.write_syscall_open(1023, 0, 1, 'test/open/file', 0,
64 0, 42)
65 self.trace_writer.flush()
66
67 def test_iousagetop(self):
68 test_name = 'iousagetop'
69 expected = self.get_expected_output(test_name)
70 result = self.get_cmd_output('lttng-iousagetop')
71
72 self._assertMultiLineEqual(result, expected, test_name)
73
74 def test_iolatencytop(self):
75 test_name = 'iolatencytop'
76 expected = self.get_expected_output(test_name)
77 result = self.get_cmd_output('lttng-iolatencytop')
78
79 self._assertMultiLineEqual(result, expected, test_name)
This page took 0.033017 seconds and 5 git commands to generate.