Skip to content

Commit

Permalink
tests: Add test for vmcoreinfo special object
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Brennan <[email protected]>
  • Loading branch information
brenns10 committed Aug 17, 2023
1 parent e18acb2 commit d623263
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 19 deletions.
43 changes: 43 additions & 0 deletions tests/linux_kernel/test_special_objects.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# SPDX-License-Identifier: LGPL-2.1-or-later

import os

import drgn
from tests.linux_kernel import LinuxKernelTestCase


class TestUts(LinuxKernelTestCase):
def test_uts_release(self):
self.assertEqual(
self.prog["UTS_RELEASE"].string_().decode(), os.uname().release
)

def test_uts_release_no_debug_info(self):
prog = drgn.Program()
prog.set_kernel()
self.assertEqual(prog["UTS_RELEASE"].string_().decode(), os.uname().release)


class TestVmcoreinfo(LinuxKernelTestCase):
def test_vmcoreinfo(self):
vmcoreinfo_data = dict(
line.split("=", 1)
for line in self.prog["VMCOREINFO"].string_().decode().strip().split("\n")
)
self.assertEqual(
int(vmcoreinfo_data["SYMBOL(init_uts_ns)"], 16),
self.prog.symbol("init_uts_ns").address,
)

def test_vmcoreinfo_no_debug_info(self):
prog = drgn.Program()
prog.set_kernel()
vmcoreinfo_data = dict(
line.split("=", 1)
for line in prog["VMCOREINFO"].string_().decode().strip().split("\n")
)
self.assertEqual(
vmcoreinfo_data["OSRELEASE"],
os.uname().release,
)
19 changes: 0 additions & 19 deletions tests/linux_kernel/test_uts.py

This file was deleted.

0 comments on commit d623263

Please sign in to comment.