xref: /aosp_15_r20/external/bcc/tests/python/test_tools_smoke.py (revision 387f9dfdfa2baef462e92476d413c7bc2470293e)
1*387f9dfdSAndroid Build Coastguard Worker#!/usr/bin/env python3
2*387f9dfdSAndroid Build Coastguard Worker# Copyright (c) Sasha Goldshtein, 2017
3*387f9dfdSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License")
4*387f9dfdSAndroid Build Coastguard Worker
5*387f9dfdSAndroid Build Coastguard Workerimport subprocess
6*387f9dfdSAndroid Build Coastguard Workerimport os
7*387f9dfdSAndroid Build Coastguard Workerimport re
8*387f9dfdSAndroid Build Coastguard Workerfrom unittest import main, skipUnless, TestCase
9*387f9dfdSAndroid Build Coastguard Workerfrom utils import mayFail, kernel_version_ge
10*387f9dfdSAndroid Build Coastguard Worker
11*387f9dfdSAndroid Build Coastguard WorkerTOOLS_DIR = "/bcc/tools/"
12*387f9dfdSAndroid Build Coastguard Worker
13*387f9dfdSAndroid Build Coastguard Workerdef _helpful_rc_msg(rc, allow_early, kill):
14*387f9dfdSAndroid Build Coastguard Worker    s = "rc was %d\n" % rc
15*387f9dfdSAndroid Build Coastguard Worker    if rc == 0:
16*387f9dfdSAndroid Build Coastguard Worker        s += "\tMeaning: command returned successfully before test timeout\n"
17*387f9dfdSAndroid Build Coastguard Worker    elif rc == 124:
18*387f9dfdSAndroid Build Coastguard Worker        s += "\tMeaning: command was killed by INT signal\n"
19*387f9dfdSAndroid Build Coastguard Worker    elif rc == 137:
20*387f9dfdSAndroid Build Coastguard Worker        s += "\tMeaning: command was killed by KILL signal\n"
21*387f9dfdSAndroid Build Coastguard Worker
22*387f9dfdSAndroid Build Coastguard Worker    s += "Command was expected to do one of:\n"
23*387f9dfdSAndroid Build Coastguard Worker    s += "\tBe killed by SIGINT\n"
24*387f9dfdSAndroid Build Coastguard Worker    if kill:
25*387f9dfdSAndroid Build Coastguard Worker        s += "\tBe killed by SIGKILL\n"
26*387f9dfdSAndroid Build Coastguard Worker    if allow_early:
27*387f9dfdSAndroid Build Coastguard Worker        s += "\tSuccessfully return before being killed\n"
28*387f9dfdSAndroid Build Coastguard Worker
29*387f9dfdSAndroid Build Coastguard Worker    return s
30*387f9dfdSAndroid Build Coastguard Worker
31*387f9dfdSAndroid Build Coastguard Worker@skipUnless(kernel_version_ge(4,1), "requires kernel >= 4.1")
32*387f9dfdSAndroid Build Coastguard Workerclass SmokeTests(TestCase):
33*387f9dfdSAndroid Build Coastguard Worker    # Use this for commands that have a built-in timeout, so they only need
34*387f9dfdSAndroid Build Coastguard Worker    # to be killed in case of a hard hang.
35*387f9dfdSAndroid Build Coastguard Worker    def run_with_duration(self, command, timeout=10):
36*387f9dfdSAndroid Build Coastguard Worker        full_command = TOOLS_DIR + command
37*387f9dfdSAndroid Build Coastguard Worker        self.assertEqual(0,     # clean exit
38*387f9dfdSAndroid Build Coastguard Worker                subprocess.call("timeout -s KILL %ds %s > /dev/null" %
39*387f9dfdSAndroid Build Coastguard Worker                                (timeout, full_command), shell=True))
40*387f9dfdSAndroid Build Coastguard Worker
41*387f9dfdSAndroid Build Coastguard Worker    # Use this for commands that don't have a built-in timeout, so we have
42*387f9dfdSAndroid Build Coastguard Worker    # to Ctrl-C out of them by sending SIGINT. If that still doesn't stop
43*387f9dfdSAndroid Build Coastguard Worker    # them, send a kill signal 5 seconds later.
44*387f9dfdSAndroid Build Coastguard Worker    def run_with_int(self, command, timeout=5, kill_timeout=5,
45*387f9dfdSAndroid Build Coastguard Worker                     allow_early=False, kill=False):
46*387f9dfdSAndroid Build Coastguard Worker        full_command = TOOLS_DIR + command
47*387f9dfdSAndroid Build Coastguard Worker        signal = "KILL" if kill else "INT"
48*387f9dfdSAndroid Build Coastguard Worker        rc = subprocess.call("timeout -s %s -k %ds %ds %s > /dev/null" %
49*387f9dfdSAndroid Build Coastguard Worker                (signal, kill_timeout, timeout, full_command), shell=True)
50*387f9dfdSAndroid Build Coastguard Worker        # timeout returns 124 if the program did not terminate prematurely,
51*387f9dfdSAndroid Build Coastguard Worker        # and returns 137 if we used KILL instead of INT. So there are three
52*387f9dfdSAndroid Build Coastguard Worker        # sensible scenarios:
53*387f9dfdSAndroid Build Coastguard Worker        #   1. The script is allowed to return early, and it did, with a
54*387f9dfdSAndroid Build Coastguard Worker        #      success return code.
55*387f9dfdSAndroid Build Coastguard Worker        #   2. The script timed out and was killed by the SIGINT signal.
56*387f9dfdSAndroid Build Coastguard Worker        #   3. The script timed out and was killed by the SIGKILL signal, and
57*387f9dfdSAndroid Build Coastguard Worker        #      this was what we asked for using kill=True.
58*387f9dfdSAndroid Build Coastguard Worker        self.assertTrue((rc == 0 and allow_early) or rc == 124
59*387f9dfdSAndroid Build Coastguard Worker                        or (rc == 137 and kill), _helpful_rc_msg(rc,
60*387f9dfdSAndroid Build Coastguard Worker                        allow_early, kill))
61*387f9dfdSAndroid Build Coastguard Worker
62*387f9dfdSAndroid Build Coastguard Worker    def kmod_loaded(self, mod):
63*387f9dfdSAndroid Build Coastguard Worker        with open("/proc/modules", "r") as mods:
64*387f9dfdSAndroid Build Coastguard Worker            reg = re.compile("^%s\s" % mod)
65*387f9dfdSAndroid Build Coastguard Worker            for line in mods:
66*387f9dfdSAndroid Build Coastguard Worker                if reg.match(line):
67*387f9dfdSAndroid Build Coastguard Worker                    return 1
68*387f9dfdSAndroid Build Coastguard Worker                return 0
69*387f9dfdSAndroid Build Coastguard Worker
70*387f9dfdSAndroid Build Coastguard Worker    def setUp(self):
71*387f9dfdSAndroid Build Coastguard Worker        pass
72*387f9dfdSAndroid Build Coastguard Worker
73*387f9dfdSAndroid Build Coastguard Worker    def tearDown(self):
74*387f9dfdSAndroid Build Coastguard Worker        pass
75*387f9dfdSAndroid Build Coastguard Worker
76*387f9dfdSAndroid Build Coastguard Worker    @mayFail("This fails on github actions environment, and needs to be fixed")
77*387f9dfdSAndroid Build Coastguard Worker    def test_argdist(self):
78*387f9dfdSAndroid Build Coastguard Worker        self.run_with_duration("argdist.py -v -C 'p::do_sys_open()' -n 1 -i 1")
79*387f9dfdSAndroid Build Coastguard Worker
80*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,4), "requires kernel >= 4.4")
81*387f9dfdSAndroid Build Coastguard Worker    def test_bashreadline(self):
82*387f9dfdSAndroid Build Coastguard Worker        self.run_with_int("bashreadline.py")
83*387f9dfdSAndroid Build Coastguard Worker
84*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,4), "requires kernel >= 4.4")
85*387f9dfdSAndroid Build Coastguard Worker    def test_bindsnoop(self):
86*387f9dfdSAndroid Build Coastguard Worker        self.run_with_int("bindsnoop.py")
87*387f9dfdSAndroid Build Coastguard Worker
88*387f9dfdSAndroid Build Coastguard Worker    def test_biolatency(self):
89*387f9dfdSAndroid Build Coastguard Worker        self.run_with_duration("biolatency.py 1 1")
90*387f9dfdSAndroid Build Coastguard Worker
91*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,4), "requires kernel >= 4.4")
92*387f9dfdSAndroid Build Coastguard Worker    def test_biosnoop(self):
93*387f9dfdSAndroid Build Coastguard Worker        self.run_with_int("biosnoop.py")
94*387f9dfdSAndroid Build Coastguard Worker
95*387f9dfdSAndroid Build Coastguard Worker    def test_biotop(self):
96*387f9dfdSAndroid Build Coastguard Worker        self.run_with_duration("biotop.py 1 1")
97*387f9dfdSAndroid Build Coastguard Worker
98*387f9dfdSAndroid Build Coastguard Worker    def test_bitesize(self):
99*387f9dfdSAndroid Build Coastguard Worker        self.run_with_int("biotop.py")
100*387f9dfdSAndroid Build Coastguard Worker
101*387f9dfdSAndroid Build Coastguard Worker    def test_bpflist(self):
102*387f9dfdSAndroid Build Coastguard Worker        self.run_with_duration("bpflist.py")
103*387f9dfdSAndroid Build Coastguard Worker
104*387f9dfdSAndroid Build Coastguard Worker    def test_btrfsdist(self):
105*387f9dfdSAndroid Build Coastguard Worker        # Will attempt to do anything meaningful only when btrfs is installed.
106*387f9dfdSAndroid Build Coastguard Worker        self.run_with_duration("btrfsdist.py 1 1")
107*387f9dfdSAndroid Build Coastguard Worker
108*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,4), "requires kernel >= 4.4")
109*387f9dfdSAndroid Build Coastguard Worker    def test_btrfsslower(self):
110*387f9dfdSAndroid Build Coastguard Worker        # Will attempt to do anything meaningful only when btrfs is installed.
111*387f9dfdSAndroid Build Coastguard Worker        self.run_with_int("btrfsslower.py", allow_early=True)
112*387f9dfdSAndroid Build Coastguard Worker
113*387f9dfdSAndroid Build Coastguard Worker    def test_cachestat(self):
114*387f9dfdSAndroid Build Coastguard Worker        self.run_with_duration("cachestat.py 1 1")
115*387f9dfdSAndroid Build Coastguard Worker
116*387f9dfdSAndroid Build Coastguard Worker    def test_cachetop(self):
117*387f9dfdSAndroid Build Coastguard Worker        # TODO cachetop doesn't like to run without a terminal, disabled
118*387f9dfdSAndroid Build Coastguard Worker        # for now.
119*387f9dfdSAndroid Build Coastguard Worker        # self.run_with_int("cachetop.py 1")
120*387f9dfdSAndroid Build Coastguard Worker        pass
121*387f9dfdSAndroid Build Coastguard Worker
122*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,4), "requires kernel >= 4.4")
123*387f9dfdSAndroid Build Coastguard Worker    def test_capable(self):
124*387f9dfdSAndroid Build Coastguard Worker        self.run_with_int("capable.py")
125*387f9dfdSAndroid Build Coastguard Worker
126*387f9dfdSAndroid Build Coastguard Worker    def test_cpudist(self):
127*387f9dfdSAndroid Build Coastguard Worker        self.run_with_duration("cpudist.py 1 1")
128*387f9dfdSAndroid Build Coastguard Worker
129*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,9), "requires kernel >= 4.9")
130*387f9dfdSAndroid Build Coastguard Worker    def test_cpuunclaimed(self):
131*387f9dfdSAndroid Build Coastguard Worker        self.run_with_duration("cpuunclaimed.py 1 1")
132*387f9dfdSAndroid Build Coastguard Worker
133*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,17), "requires kernel >= 4.17")
134*387f9dfdSAndroid Build Coastguard Worker    def test_compactsnoop(self):
135*387f9dfdSAndroid Build Coastguard Worker        self.run_with_int("compactsnoop.py")
136*387f9dfdSAndroid Build Coastguard Worker
137*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,4), "requires kernel >= 4.4")
138*387f9dfdSAndroid Build Coastguard Worker    def test_dbslower(self):
139*387f9dfdSAndroid Build Coastguard Worker        # Deliberately left empty -- dbslower requires an instance of either
140*387f9dfdSAndroid Build Coastguard Worker        # MySQL or PostgreSQL to be running, or it fails to attach.
141*387f9dfdSAndroid Build Coastguard Worker        pass
142*387f9dfdSAndroid Build Coastguard Worker
143*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,3), "requires kernel >= 4.3")
144*387f9dfdSAndroid Build Coastguard Worker    def test_dbstat(self):
145*387f9dfdSAndroid Build Coastguard Worker        # Deliberately left empty -- dbstat requires an instance of either
146*387f9dfdSAndroid Build Coastguard Worker        # MySQL or PostgreSQL to be running, or it fails to attach.
147*387f9dfdSAndroid Build Coastguard Worker        pass
148*387f9dfdSAndroid Build Coastguard Worker
149*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,4), "requires kernel >= 4.4")
150*387f9dfdSAndroid Build Coastguard Worker    def test_dcsnoop(self):
151*387f9dfdSAndroid Build Coastguard Worker        self.run_with_int("dcsnoop.py")
152*387f9dfdSAndroid Build Coastguard Worker
153*387f9dfdSAndroid Build Coastguard Worker    def test_dcstat(self):
154*387f9dfdSAndroid Build Coastguard Worker        self.run_with_duration("dcstat.py 1 1")
155*387f9dfdSAndroid Build Coastguard Worker
156*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,6), "requires kernel >= 4.6")
157*387f9dfdSAndroid Build Coastguard Worker    def test_deadlock(self):
158*387f9dfdSAndroid Build Coastguard Worker        # TODO This tool requires a massive BPF stack traces table allocation,
159*387f9dfdSAndroid Build Coastguard Worker        # which might fail the run or even trigger the oomkiller to kill some
160*387f9dfdSAndroid Build Coastguard Worker        # other processes. Disabling for now.
161*387f9dfdSAndroid Build Coastguard Worker        # self.run_with_int("deadlock.py $(pgrep -n bash)", timeout=10)
162*387f9dfdSAndroid Build Coastguard Worker        pass
163*387f9dfdSAndroid Build Coastguard Worker
164*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,7), "requires kernel >= 4.7")
165*387f9dfdSAndroid Build Coastguard Worker    def test_drsnoop(self):
166*387f9dfdSAndroid Build Coastguard Worker        self.run_with_int("drsnoop.py")
167*387f9dfdSAndroid Build Coastguard Worker
168*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,8), "requires kernel >= 4.8")
169*387f9dfdSAndroid Build Coastguard Worker    def test_execsnoop(self):
170*387f9dfdSAndroid Build Coastguard Worker        self.run_with_int("execsnoop.py")
171*387f9dfdSAndroid Build Coastguard Worker
172*387f9dfdSAndroid Build Coastguard Worker    def test_ext4dist(self):
173*387f9dfdSAndroid Build Coastguard Worker        self.run_with_duration("ext4dist.py 1 1")
174*387f9dfdSAndroid Build Coastguard Worker
175*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,4), "requires kernel >= 4.4")
176*387f9dfdSAndroid Build Coastguard Worker    def test_ext4slower(self):
177*387f9dfdSAndroid Build Coastguard Worker        self.run_with_int("ext4slower.py")
178*387f9dfdSAndroid Build Coastguard Worker
179*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,4), "requires kernel >= 4.4")
180*387f9dfdSAndroid Build Coastguard Worker    def test_filelife(self):
181*387f9dfdSAndroid Build Coastguard Worker        self.run_with_int("filelife.py")
182*387f9dfdSAndroid Build Coastguard Worker
183*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,4), "requires kernel >= 4.4")
184*387f9dfdSAndroid Build Coastguard Worker    def test_fileslower(self):
185*387f9dfdSAndroid Build Coastguard Worker        self.run_with_int("fileslower.py")
186*387f9dfdSAndroid Build Coastguard Worker
187*387f9dfdSAndroid Build Coastguard Worker    def test_filetop(self):
188*387f9dfdSAndroid Build Coastguard Worker        self.run_with_duration("filetop.py 1 1")
189*387f9dfdSAndroid Build Coastguard Worker
190*387f9dfdSAndroid Build Coastguard Worker    def test_funccount(self):
191*387f9dfdSAndroid Build Coastguard Worker        self.run_with_int("funccount.py __kmalloc -i 1")
192*387f9dfdSAndroid Build Coastguard Worker
193*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,4), "requires kernel >= 4.4")
194*387f9dfdSAndroid Build Coastguard Worker    def test_funclatency(self):
195*387f9dfdSAndroid Build Coastguard Worker        self.run_with_int("funclatency.py __kmalloc -i 1")
196*387f9dfdSAndroid Build Coastguard Worker
197*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,4), "requires kernel >= 4.4")
198*387f9dfdSAndroid Build Coastguard Worker    def test_funcslower(self):
199*387f9dfdSAndroid Build Coastguard Worker        self.run_with_int("funcslower.py __kmalloc")
200*387f9dfdSAndroid Build Coastguard Worker
201*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,4), "requires kernel >= 4.4")
202*387f9dfdSAndroid Build Coastguard Worker    def test_gethostlatency(self):
203*387f9dfdSAndroid Build Coastguard Worker        self.run_with_int("gethostlatency.py")
204*387f9dfdSAndroid Build Coastguard Worker
205*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,7), "requires kernel >= 4.7")
206*387f9dfdSAndroid Build Coastguard Worker    def test_hardirqs(self):
207*387f9dfdSAndroid Build Coastguard Worker        self.run_with_duration("hardirqs.py 1 1")
208*387f9dfdSAndroid Build Coastguard Worker
209*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,4), "requires kernel >= 4.4")
210*387f9dfdSAndroid Build Coastguard Worker    def test_killsnoop(self):
211*387f9dfdSAndroid Build Coastguard Worker        # Because killsnoop intercepts signals, if we send it a SIGINT we we
212*387f9dfdSAndroid Build Coastguard Worker        # we likely catch it while it is handling the data packet from the
213*387f9dfdSAndroid Build Coastguard Worker        # BPF program, and the exception from the SIGINT will be swallowed by
214*387f9dfdSAndroid Build Coastguard Worker        # ctypes. Therefore, we use SIGKILL.
215*387f9dfdSAndroid Build Coastguard Worker        # To reproduce the above issue, run killsnoop and in another shell run
216*387f9dfdSAndroid Build Coastguard Worker        # `kill -s SIGINT $(pidof python)`. As a result, killsnoop will print
217*387f9dfdSAndroid Build Coastguard Worker        # a traceback but will not exit.
218*387f9dfdSAndroid Build Coastguard Worker        self.run_with_int("killsnoop.py", kill=True)
219*387f9dfdSAndroid Build Coastguard Worker
220*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,18), "requires kernel >= 4.18")
221*387f9dfdSAndroid Build Coastguard Worker    def test_klockstat(self):
222*387f9dfdSAndroid Build Coastguard Worker        self.run_with_int("klockstat.py")
223*387f9dfdSAndroid Build Coastguard Worker
224*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,9), "requires kernel >= 4.9")
225*387f9dfdSAndroid Build Coastguard Worker    def test_llcstat(self):
226*387f9dfdSAndroid Build Coastguard Worker        # Requires PMU, which is not available in virtual machines.
227*387f9dfdSAndroid Build Coastguard Worker        pass
228*387f9dfdSAndroid Build Coastguard Worker
229*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,4), "requires kernel >= 4.4")
230*387f9dfdSAndroid Build Coastguard Worker    def test_mdflush(self):
231*387f9dfdSAndroid Build Coastguard Worker        self.run_with_int("mdflush.py")
232*387f9dfdSAndroid Build Coastguard Worker
233*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,6), "requires kernel >= 4.6")
234*387f9dfdSAndroid Build Coastguard Worker    def test_memleak(self):
235*387f9dfdSAndroid Build Coastguard Worker        self.run_with_duration("memleak.py 1 1")
236*387f9dfdSAndroid Build Coastguard Worker
237*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,8), "requires kernel >= 4.8")
238*387f9dfdSAndroid Build Coastguard Worker    def test_mountsnoop(self):
239*387f9dfdSAndroid Build Coastguard Worker        self.run_with_int("mountsnoop.py")
240*387f9dfdSAndroid Build Coastguard Worker
241*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,3), "requires kernel >= 4.3")
242*387f9dfdSAndroid Build Coastguard Worker    def test_mysqld_qslower(self):
243*387f9dfdSAndroid Build Coastguard Worker        # Deliberately left empty -- mysqld_qslower requires an instance of
244*387f9dfdSAndroid Build Coastguard Worker        # MySQL to be running, or it fails to attach.
245*387f9dfdSAndroid Build Coastguard Worker        pass
246*387f9dfdSAndroid Build Coastguard Worker
247*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,4), "requires kernel >= 4.4")
248*387f9dfdSAndroid Build Coastguard Worker    def test_nfsslower(self):
249*387f9dfdSAndroid Build Coastguard Worker        if(self.kmod_loaded("nfs")):
250*387f9dfdSAndroid Build Coastguard Worker            self.run_with_int("nfsslower.py")
251*387f9dfdSAndroid Build Coastguard Worker        else:
252*387f9dfdSAndroid Build Coastguard Worker            pass
253*387f9dfdSAndroid Build Coastguard Worker
254*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,4), "requires kernel >= 4.4")
255*387f9dfdSAndroid Build Coastguard Worker    def test_nfsdist(self):
256*387f9dfdSAndroid Build Coastguard Worker        if(self.kmod_loaded("nfs")):
257*387f9dfdSAndroid Build Coastguard Worker            self.run_with_duration("nfsdist.py 1 1")
258*387f9dfdSAndroid Build Coastguard Worker        else:
259*387f9dfdSAndroid Build Coastguard Worker            pass
260*387f9dfdSAndroid Build Coastguard Worker
261*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,6), "requires kernel >= 4.6")
262*387f9dfdSAndroid Build Coastguard Worker    @mayFail("This fails on github actions environment, and needs to be fixed")
263*387f9dfdSAndroid Build Coastguard Worker    def test_offcputime(self):
264*387f9dfdSAndroid Build Coastguard Worker        self.run_with_duration("offcputime.py 1")
265*387f9dfdSAndroid Build Coastguard Worker
266*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,6), "requires kernel >= 4.6")
267*387f9dfdSAndroid Build Coastguard Worker    def test_offwaketime(self):
268*387f9dfdSAndroid Build Coastguard Worker        self.run_with_duration("offwaketime.py 1")
269*387f9dfdSAndroid Build Coastguard Worker
270*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,9), "requires kernel >= 4.9")
271*387f9dfdSAndroid Build Coastguard Worker    def test_oomkill(self):
272*387f9dfdSAndroid Build Coastguard Worker        self.run_with_int("oomkill.py")
273*387f9dfdSAndroid Build Coastguard Worker
274*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,4), "requires kernel >= 4.4")
275*387f9dfdSAndroid Build Coastguard Worker    def test_opensnoop(self):
276*387f9dfdSAndroid Build Coastguard Worker        self.run_with_int("opensnoop.py")
277*387f9dfdSAndroid Build Coastguard Worker
278*387f9dfdSAndroid Build Coastguard Worker    def test_pidpersec(self):
279*387f9dfdSAndroid Build Coastguard Worker        self.run_with_int("pidpersec.py")
280*387f9dfdSAndroid Build Coastguard Worker
281*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,17), "requires kernel >= 4.17")
282*387f9dfdSAndroid Build Coastguard Worker    @mayFail("This fails on github actions environment, and needs to be fixed")
283*387f9dfdSAndroid Build Coastguard Worker    def test_syscount(self):
284*387f9dfdSAndroid Build Coastguard Worker        self.run_with_int("ppchcalls.py -i 1")
285*387f9dfdSAndroid Build Coastguard Worker
286*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,9), "requires kernel >= 4.9")
287*387f9dfdSAndroid Build Coastguard Worker    def test_profile(self):
288*387f9dfdSAndroid Build Coastguard Worker        self.run_with_duration("profile.py 1")
289*387f9dfdSAndroid Build Coastguard Worker
290*387f9dfdSAndroid Build Coastguard Worker    def test_runqlat(self):
291*387f9dfdSAndroid Build Coastguard Worker        self.run_with_duration("runqlat.py 1 1")
292*387f9dfdSAndroid Build Coastguard Worker
293*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,9), "requires kernel >= 4.9")
294*387f9dfdSAndroid Build Coastguard Worker    def test_runqlen(self):
295*387f9dfdSAndroid Build Coastguard Worker        self.run_with_duration("runqlen.py 1 1")
296*387f9dfdSAndroid Build Coastguard Worker
297*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,8), "requires kernel >= 4.8")
298*387f9dfdSAndroid Build Coastguard Worker    def test_shmsnoop(self):
299*387f9dfdSAndroid Build Coastguard Worker        self.run_with_int("shmsnoop.py")
300*387f9dfdSAndroid Build Coastguard Worker
301*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,8), "requires kernel >= 4.8")
302*387f9dfdSAndroid Build Coastguard Worker    def test_sofdsnoop(self):
303*387f9dfdSAndroid Build Coastguard Worker        self.run_with_int("sofdsnoop.py")
304*387f9dfdSAndroid Build Coastguard Worker
305*387f9dfdSAndroid Build Coastguard Worker    def test_slabratetop(self):
306*387f9dfdSAndroid Build Coastguard Worker        self.run_with_duration("slabratetop.py 1 1")
307*387f9dfdSAndroid Build Coastguard Worker
308*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,7), "requires kernel >= 4.7")
309*387f9dfdSAndroid Build Coastguard Worker    def test_softirqs(self):
310*387f9dfdSAndroid Build Coastguard Worker        self.run_with_duration("softirqs.py 1 1")
311*387f9dfdSAndroid Build Coastguard Worker        pass
312*387f9dfdSAndroid Build Coastguard Worker
313*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,4), "requires kernel >= 4.4")
314*387f9dfdSAndroid Build Coastguard Worker    def test_solisten(self):
315*387f9dfdSAndroid Build Coastguard Worker        self.run_with_int("solisten.py")
316*387f9dfdSAndroid Build Coastguard Worker
317*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,4), "requires kernel >= 4.4")
318*387f9dfdSAndroid Build Coastguard Worker    @mayFail("This fails on github actions environment, and needs to be fixed")
319*387f9dfdSAndroid Build Coastguard Worker    def test_sslsniff(self):
320*387f9dfdSAndroid Build Coastguard Worker        self.run_with_int("sslsniff.py")
321*387f9dfdSAndroid Build Coastguard Worker
322*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,6), "requires kernel >= 4.6")
323*387f9dfdSAndroid Build Coastguard Worker    def test_stackcount(self):
324*387f9dfdSAndroid Build Coastguard Worker        self.run_with_int("stackcount.py __kmalloc -i 1")
325*387f9dfdSAndroid Build Coastguard Worker
326*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,4), "requires kernel >= 4.4")
327*387f9dfdSAndroid Build Coastguard Worker    def test_statsnoop(self):
328*387f9dfdSAndroid Build Coastguard Worker        self.run_with_int("statsnoop.py")
329*387f9dfdSAndroid Build Coastguard Worker
330*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,4), "requires kernel >= 4.4")
331*387f9dfdSAndroid Build Coastguard Worker    def test_syncsnoop(self):
332*387f9dfdSAndroid Build Coastguard Worker        self.run_with_int("syncsnoop.py")
333*387f9dfdSAndroid Build Coastguard Worker
334*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,7), "requires kernel >= 4.7")
335*387f9dfdSAndroid Build Coastguard Worker    def test_syscount(self):
336*387f9dfdSAndroid Build Coastguard Worker        self.run_with_int("syscount.py -i 1")
337*387f9dfdSAndroid Build Coastguard Worker
338*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,4), "requires kernel >= 4.4")
339*387f9dfdSAndroid Build Coastguard Worker    def test_tcpaccept(self):
340*387f9dfdSAndroid Build Coastguard Worker        self.run_with_int("tcpaccept.py")
341*387f9dfdSAndroid Build Coastguard Worker
342*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,4), "requires kernel >= 4.4")
343*387f9dfdSAndroid Build Coastguard Worker    def test_tcpconnect(self):
344*387f9dfdSAndroid Build Coastguard Worker        self.run_with_int("tcpconnect.py")
345*387f9dfdSAndroid Build Coastguard Worker
346*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,4), "requires kernel >= 4.4")
347*387f9dfdSAndroid Build Coastguard Worker    def test_tcpconnlat(self):
348*387f9dfdSAndroid Build Coastguard Worker        self.run_with_int("tcpconnlat.py")
349*387f9dfdSAndroid Build Coastguard Worker
350*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,4), "requires kernel >= 4.4")
351*387f9dfdSAndroid Build Coastguard Worker    def test_tcplife(self):
352*387f9dfdSAndroid Build Coastguard Worker        self.run_with_int("tcplife.py")
353*387f9dfdSAndroid Build Coastguard Worker
354*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,4), "requires kernel >= 4.4")
355*387f9dfdSAndroid Build Coastguard Worker    def test_tcpretrans(self):
356*387f9dfdSAndroid Build Coastguard Worker        self.run_with_int("tcpretrans.py")
357*387f9dfdSAndroid Build Coastguard Worker
358*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4, 7), "requires kernel >= 4.7")
359*387f9dfdSAndroid Build Coastguard Worker    @mayFail("This fails on github actions environment, and needs to be fixed")
360*387f9dfdSAndroid Build Coastguard Worker    def test_tcpdrop(self):
361*387f9dfdSAndroid Build Coastguard Worker        self.run_with_int("tcpdrop.py")
362*387f9dfdSAndroid Build Coastguard Worker
363*387f9dfdSAndroid Build Coastguard Worker    def test_tcptop(self):
364*387f9dfdSAndroid Build Coastguard Worker        self.run_with_duration("tcptop.py 1 1")
365*387f9dfdSAndroid Build Coastguard Worker
366*387f9dfdSAndroid Build Coastguard Worker    def test_tcpcong(self):
367*387f9dfdSAndroid Build Coastguard Worker        self.run_with_duration("tcpcong.py 1 1")
368*387f9dfdSAndroid Build Coastguard Worker
369*387f9dfdSAndroid Build Coastguard Worker    def test_tplist(self):
370*387f9dfdSAndroid Build Coastguard Worker        self.run_with_duration("tplist.py -p %d" % os.getpid())
371*387f9dfdSAndroid Build Coastguard Worker
372*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,4), "requires kernel >= 4.4")
373*387f9dfdSAndroid Build Coastguard Worker    def test_trace(self):
374*387f9dfdSAndroid Build Coastguard Worker        self.run_with_int("trace.py do_sys_open")
375*387f9dfdSAndroid Build Coastguard Worker
376*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,4), "requires kernel >= 4.4")
377*387f9dfdSAndroid Build Coastguard Worker    @mayFail("This fails on github actions environment, and needs to be fixed")
378*387f9dfdSAndroid Build Coastguard Worker    def test_ttysnoop(self):
379*387f9dfdSAndroid Build Coastguard Worker        self.run_with_int("ttysnoop.py /dev/console")
380*387f9dfdSAndroid Build Coastguard Worker
381*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,7), "requires kernel >= 4.7")
382*387f9dfdSAndroid Build Coastguard Worker    def test_ucalls(self):
383*387f9dfdSAndroid Build Coastguard Worker        self.run_with_int("lib/ucalls.py -l none -S %d" % os.getpid())
384*387f9dfdSAndroid Build Coastguard Worker
385*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,4), "requires kernel >= 4.4")
386*387f9dfdSAndroid Build Coastguard Worker    def test_uflow(self):
387*387f9dfdSAndroid Build Coastguard Worker        # The Python installed on the Ubuntu buildbot doesn't have USDT
388*387f9dfdSAndroid Build Coastguard Worker        # probes, so we can't run uflow.
389*387f9dfdSAndroid Build Coastguard Worker        # self.run_with_int("pythonflow.py %d" % os.getpid())
390*387f9dfdSAndroid Build Coastguard Worker        pass
391*387f9dfdSAndroid Build Coastguard Worker
392*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,4), "requires kernel >= 4.4")
393*387f9dfdSAndroid Build Coastguard Worker    def test_ugc(self):
394*387f9dfdSAndroid Build Coastguard Worker        # This requires a runtime that has GC probes to be installed.
395*387f9dfdSAndroid Build Coastguard Worker        # Python has them, but only in very recent versions. Skip.
396*387f9dfdSAndroid Build Coastguard Worker        pass
397*387f9dfdSAndroid Build Coastguard Worker
398*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,4), "requires kernel >= 4.4")
399*387f9dfdSAndroid Build Coastguard Worker    def test_uobjnew(self):
400*387f9dfdSAndroid Build Coastguard Worker        self.run_with_int("cobjnew.sh %d" % os.getpid())
401*387f9dfdSAndroid Build Coastguard Worker
402*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,4), "requires kernel >= 4.4")
403*387f9dfdSAndroid Build Coastguard Worker    def test_ustat(self):
404*387f9dfdSAndroid Build Coastguard Worker        self.run_with_duration("lib/ustat.py 1 1")
405*387f9dfdSAndroid Build Coastguard Worker
406*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,4), "requires kernel >= 4.4")
407*387f9dfdSAndroid Build Coastguard Worker    def test_uthreads(self):
408*387f9dfdSAndroid Build Coastguard Worker        self.run_with_int("lib/uthreads.py %d" % os.getpid())
409*387f9dfdSAndroid Build Coastguard Worker
410*387f9dfdSAndroid Build Coastguard Worker    def test_vfscount(self):
411*387f9dfdSAndroid Build Coastguard Worker        self.run_with_int("vfscount.py", timeout=15, kill_timeout=15)
412*387f9dfdSAndroid Build Coastguard Worker
413*387f9dfdSAndroid Build Coastguard Worker    def test_vfsstat(self):
414*387f9dfdSAndroid Build Coastguard Worker        self.run_with_duration("vfsstat.py 1 1")
415*387f9dfdSAndroid Build Coastguard Worker
416*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,6), "requires kernel >= 4.6")
417*387f9dfdSAndroid Build Coastguard Worker    def test_wakeuptime(self):
418*387f9dfdSAndroid Build Coastguard Worker        self.run_with_duration("wakeuptime.py 1")
419*387f9dfdSAndroid Build Coastguard Worker
420*387f9dfdSAndroid Build Coastguard Worker    def test_xfsdist(self):
421*387f9dfdSAndroid Build Coastguard Worker        # Doesn't work on build bot because xfs functions not present in the
422*387f9dfdSAndroid Build Coastguard Worker        # kernel image.
423*387f9dfdSAndroid Build Coastguard Worker        # self.run_with_duration("xfsdist.py 1 1")
424*387f9dfdSAndroid Build Coastguard Worker        pass
425*387f9dfdSAndroid Build Coastguard Worker
426*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,4), "requires kernel >= 4.4")
427*387f9dfdSAndroid Build Coastguard Worker    def test_xfsslower(self):
428*387f9dfdSAndroid Build Coastguard Worker        # Doesn't work on build bot because xfs functions not present in the
429*387f9dfdSAndroid Build Coastguard Worker        # kernel image.
430*387f9dfdSAndroid Build Coastguard Worker        # self.run_with_int("xfsslower.py")
431*387f9dfdSAndroid Build Coastguard Worker        pass
432*387f9dfdSAndroid Build Coastguard Worker
433*387f9dfdSAndroid Build Coastguard Worker    def test_zfsdist(self):
434*387f9dfdSAndroid Build Coastguard Worker        # Fails to attach the probe if zfs is not installed.
435*387f9dfdSAndroid Build Coastguard Worker        pass
436*387f9dfdSAndroid Build Coastguard Worker
437*387f9dfdSAndroid Build Coastguard Worker    @skipUnless(kernel_version_ge(4,4), "requires kernel >= 4.4")
438*387f9dfdSAndroid Build Coastguard Worker    def test_zfsslower(self):
439*387f9dfdSAndroid Build Coastguard Worker        # Fails to attach the probe if zfs is not installed.
440*387f9dfdSAndroid Build Coastguard Worker        pass
441*387f9dfdSAndroid Build Coastguard Worker
442*387f9dfdSAndroid Build Coastguard Workerif __name__ == "__main__":
443*387f9dfdSAndroid Build Coastguard Worker    main()
444