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 16from python.generators.diff_tests.testing import Path, DataPath, Metric, Systrace 17from python.generators.diff_tests.testing import Csv, Json, TextProto, BinaryProto 18from python.generators.diff_tests.testing import DiffTestBlueprint 19from python.generators.diff_tests.testing import TestSuite 20from python.generators.diff_tests.testing import PrintProfileProto 21 22 23class LinuxTests(TestSuite): 24 25 def test_kernel_threads(self): 26 return DiffTestBlueprint( 27 trace=DataPath('android_postboot_unlock.pftrace'), 28 query=""" 29 INCLUDE PERFETTO MODULE linux.threads; 30 31 SELECT pid, tid, process_name, thread_name 32 FROM linux_kernel_threads 33 ORDER by tid LIMIT 10; 34 """, 35 out=Csv(""" 36 "pid","tid","process_name","thread_name" 37 2,2,"kthreadd","kthreadd" 38 5,5,"kworker/0:0H","kworker/0:0H" 39 6,6,"kworker/u16:0","kworker/u16:0" 40 8,8,"kworker/u16:1","kworker/u16:1" 41 11,11,"ksoftirqd/0","ksoftirqd/0" 42 12,12,"rcu_preempt","rcu_preempt" 43 13,13,"rcuog/0","rcuog/0" 44 14,14,"rcuop/0","rcuop/0" 45 15,15,"rcub/0","rcub/0" 46 17,17,"rcu_exp_gp_kthr","rcu_exp_gp_kthr" 47 """)) 48 49 # Tests that DSU devfreq counters are working properly 50 def test_dsu_devfreq(self): 51 return DiffTestBlueprint( 52 trace=DataPath('wattson_tk4_pcmark.pb'), 53 query=(""" 54 INCLUDE PERFETTO MODULE linux.devfreq; 55 SELECT id, ts, dur, dsu_freq FROM linux_devfreq_dsu_counter 56 LIMIT 20 57 """), 58 out=Csv(""" 59 "id","ts","dur","dsu_freq" 60 61,4106584783742,11482788,610000 61 166,4106596266530,8108602,1197000 62 212,4106604375132,21453410,610000 63 487,4106625828542,39427368,820000 64 1130,4106665255910,3264242,610000 65 1173,4106668520152,16966105,820000 66 1391,4106685486257,10596883,970000 67 1584,4106696083140,10051636,610000 68 1868,4106706134776,14058960,820000 69 2136,4106720193736,116719238,610000 70 4388,4106836912974,8285848,1197000 71 4583,4106845198822,16518433,820000 72 5006,4106861717255,9357503,1328000 73 5238,4106871074758,27228760,1197000 74 5963,4106898303518,16581706,820000 75 6498,4106914885224,9954142,1197000 76 6763,4106924839366,9024780,970000 77 7061,4106933864146,26264160,820000 78 7637,4106960128306,11008505,970000 79 7880,4106971136811,9282511,1197000 80 """)) 81 82 def test_active_block_io_operations_by_device(self): 83 return DiffTestBlueprint( 84 trace=DataPath('linux_block_io_trace.pb'), 85 query=""" 86 INCLUDE PERFETTO MODULE linux.block_io; 87 88 SELECT 89 ts, 90 ops_in_queue_or_device, 91 dev, 92 linux_device_major_id(dev) as major, 93 linux_device_minor_id(dev) as minor 94 FROM linux_active_block_io_operations_by_device 95 ORDER by ts 96 LIMIT 20; 97 """, 98 out=Csv(""" 99 "ts","ops_in_queue_or_device","dev","major","minor" 100 241211905210838,1,45824,179,0 101 241211909452069,0,45824,179,0 102 241211909585838,1,45824,179,0 103 241211909845222,0,45824,179,0 104 241211910299145,1,1795,7,3 105 241211910636838,0,1795,7,3 106 241211912818299,1,45824,179,0 107 241211913170838,0,45824,179,0 108 241211916130530,1,45824,179,0 109 241211916325222,0,45824,179,0 110 241211916472453,1,45824,179,0 111 241211916809376,0,45824,179,0 112 241211917486915,1,45824,179,0 113 241211917815761,0,45824,179,0 114 241211918424838,1,45824,179,0 115 241211918650915,0,45824,179,0 116 241211918760222,1,45824,179,0 117 241211918973684,0,45824,179,0 118 241211919810453,1,45824,179,0 119 241211920094761,0,45824,179,0 120 """)) 121