Debian Codegraph @

tests/linux_kernel/crash_commands/test_whatis.py

raw
1 # Copyright (c) 2025 Oracle and/or its affiliates
2 # SPDX-License-Identifier: LGPL-2.1-or-later
3
4 from tests.linux_kernel.crash_commands import CrashCommandTestCase
5
6
7 class TestWhatis(CrashCommandTestCase):
8 def test_struct_explicit(self):
9 cmd = self.run_crash_command("whatis 'struct list_head'")
10 self.assertIn("struct list_head {", cmd.stdout)
11 self.assertRegex(cmd.stdout, r"(?m)^SIZE: [0-9]+$")
12
13 def test_struct_implicit(self):
14 cmd = self.run_crash_command("whatis list_head")
15 self.assertIn("struct list_head {", cmd.stdout)
16 self.assertRegex(cmd.stdout, r"(?m)^SIZE: [0-9]+$")
17
18 def test_typedef(self):
19 cmd = self.run_crash_command("whatis atomic_t")
20 self.assertIn("atomic_t", cmd.stdout)
21 self.assertRegex(cmd.stdout, r"(?m)^SIZE: [0-9]+$")
22
23 def test_enum(self):
24 cmd = self.run_crash_command("whatis pid_type")
25 self.assertIn("enum pid_type", cmd.stdout)
26 self.assertRegex(cmd.stdout, r"(?m)^SIZE: [0-9]+$")
27
28 def test_function_symbol(self):
29 cmd = self.run_crash_command("whatis schedule")
30 self.assertRegex(cmd.stdout, r"(?m)\bschedule\s*\(.*\);")
31
32 def test_data_symbol(self):
33 cmd = self.run_crash_command("whatis init_task")
34 self.assertIn("init_task;", cmd.stdout)
35 self.assertIn("struct task_struct", cmd.stdout)