Skip to content

Commit 2cb2b19

Browse files
Treehugger RobotGerrit Code Review
authored andcommitted
Merge "tp: Add a diff test for block_io_* tracepoints" into main
2 parents 809f015 + 975cee0 commit 2cb2b19

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

test/trace_processor/diff_tests/include_index.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
from diff_tests.parser.chrome.tests_v8 import ChromeV8Parser
6969
from diff_tests.parser.cros.tests import Cros
7070
from diff_tests.parser.fs.tests import Fs
71+
from diff_tests.parser.ftrace.block_io_tests import BlockIo
7172
from diff_tests.parser.ftrace.ftrace_crop_tests import FtraceCrop
7273
from diff_tests.parser.ftrace.kprobes_tests import Kprobes
7374
from diff_tests.parser.fuchsia.tests import Fuchsia
@@ -237,6 +238,7 @@ def fetch_all_diff_tests(index_path: str) -> List['testing.TestCase']:
237238
*ParsingSysStats(index_path, 'parser/parsing', 'ParsingSysStats').fetch(),
238239
*ParsingMemoryCounters(index_path, 'parser/parsing',
239240
'ParsingMemoryCounters').fetch(),
241+
*BlockIo(index_path, 'parser/ftrace', 'BlockIo').fetch(),
240242
*FtraceCrop(index_path, 'parser/ftrace', 'FtraceCrop').fetch(),
241243
*Kprobes(index_path, 'parser/ftrace', 'Kprobes').fetch(),
242244
*ParsingTracedStats(index_path, 'parser/parsing',
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/usr/bin/env python3
2+
# Copyright (C) 2024 The Android Open Source Project
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License a
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
from python.generators.diff_tests.testing import Csv, TextProto
17+
from python.generators.diff_tests.testing import DiffTestBlueprint
18+
from python.generators.diff_tests.testing import TestSuite
19+
20+
21+
class BlockIo(TestSuite):
22+
23+
def test_block_io_slice(self):
24+
return DiffTestBlueprint(
25+
trace=TextProto(r"""
26+
packet { ftrace_events {
27+
cpu: 1
28+
event {
29+
timestamp: 1000
30+
pid: 31918
31+
block_io_start {
32+
dev: 45824
33+
sector: 44920176
34+
nr_sector: 56
35+
bytes: 28672
36+
ioprio: 16386
37+
rwbs: "RA"
38+
comm: "oid.apps.chrome"
39+
cmd: ""
40+
}
41+
}
42+
event {
43+
timestamp: 2400
44+
pid: 0
45+
block_io_done {
46+
dev: 45824
47+
sector: 44920176
48+
nr_sector: 0
49+
bytes: 0
50+
ioprio: 16386
51+
rwbs: "RA"
52+
comm: "kworker/0:2H"
53+
cmd: ""
54+
}
55+
}
56+
}}
57+
"""),
58+
query="""
59+
SELECT
60+
slice.name as name,
61+
slice.ts as ts,
62+
slice.dur as dur,
63+
extract_arg(track.dimension_arg_set_id, 'block_device') as dev,
64+
extract_arg(slice.arg_set_id, 'sector') as sector
65+
FROM slice
66+
JOIN track ON slice.track_id = track.id AND track.classification = 'block_io'
67+
""",
68+
out=Csv("""
69+
"name","ts","dur","dev","sector"
70+
"block_io",1000,1400,45824,44920176
71+
"""))

0 commit comments

Comments
 (0)