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