Skip to content

Commit 35c3e44

Browse files
committed
Add smoke test ensuring we can attach to /proc/vmcore
Signed-off-by: Kevin Svetlitski <[email protected]>
1 parent a2d2648 commit 35c3e44

File tree

4 files changed

+22
-13
lines changed

4 files changed

+22
-13
lines changed

setup.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,11 @@ def _run_vm(self, kernel_dir):
196196
else
197197
DRGN_RUN_LINUX_HELPER_TESTS=1 "$PYTHON" -Bm \
198198
unittest discover -t . -s tests/helpers/linux {"-v" if self.verbose else ""}
199-
"$PYTHON" vmtest/enter_kdump.py
200-
# We should crash and not reach this.
201-
exit 1
199+
if "$BUSYBOX" [ -n "$crashkernel" ]; then
200+
"$PYTHON" vmtest/enter_kdump.py
201+
# We should crash and not reach this.
202+
exit 1
203+
fi
202204
fi
203205
"""
204206
try:

tests/linux_kernel/vmcore/test_dummy.py

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from pathlib import Path
2+
import unittest
3+
4+
from drgn import Program
5+
6+
VMCORE_PATH = Path("/proc/vmcore")
7+
8+
9+
@unittest.skipUnless(VMCORE_PATH.exists(), "not running in kdump")
10+
class TestAttachToVMCore(unittest.TestCase):
11+
def test_attach_to_vmcore(self):
12+
prog = Program()
13+
prog.set_core_dump("/proc/vmcore")
14+
prog.load_debug_info("", default=True, main=True)

vmtest/enter_kdump.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
with open("/proc/cmdline", "rb") as f:
2020
cmdline = f.read().rstrip(b"\n")
2121
cmdline = re.sub(rb"(^|\s)crashkernel=\S+", b"", cmdline)
22+
# `nosmp` is required to avoid QEMU sporadically failing an internal assertion
23+
# `nokaslr` is required to avoid sporadically failing to reserve space for the
24+
# capture kernel
2225
cmdline += b" nosmp nokaslr"
2326

2427
with open(f"/lib/modules/{os.uname().release}/vmlinuz", "rb") as kernel:

0 commit comments

Comments
 (0)