|
| 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