Debian Codegraph @

tests/linux_kernel/vmcore/__init__.py

raw
1 # Copyright (c) Meta Platforms, Inc. and affiliates.
2 # SPDX-License-Identifier: LGPL-2.1-or-later
3
4 from pathlib import Path
5 import unittest
6
7 import drgn
8 from tests import TestCase
9 from tests.linux_kernel import LinuxKernelTestCase
10 from tests.linux_kernel.crash_commands import CrashCommandTestCaseBase
11
12 VMCORE_PATH = Path("/proc/vmcore")
13
14
15 @unittest.skipUnless(VMCORE_PATH.exists(), "not running in kdump")
16 class LinuxVMCoreTestCase(TestCase):
17 prog = None
18
19 @classmethod
20 def setUpClass(cls):
21 super().setUpClass()
22 # We only want to create the Program once for all tests, so it's cached
23 # as a class variable (in the base class).
24 if LinuxVMCoreTestCase.prog is None:
25 prog = drgn.Program()
26 prog.set_core_dump(VMCORE_PATH)
27 LinuxKernelTestCase._load_debug_info(prog)
28 LinuxVMCoreTestCase.prog = prog
29
30
31 class LinuxVMCoreCrashCommandTestCase(CrashCommandTestCaseBase, LinuxVMCoreTestCase):
32 pass