File: test_special_objects.py

package info (click to toggle)
drgn 0.0.31-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 5,956 kB
  • sloc: ansic: 49,446; python: 45,054; awk: 423; makefile: 339; sh: 114
file content (55 lines) | stat: -rw-r--r-- 1,616 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# Copyright (c) Meta Platforms, Inc. and affiliates.
# SPDX-License-Identifier: LGPL-2.1-or-later

import os

from drgn import Object, Program
from tests.linux_kernel import LinuxKernelTestCase


class TestJiffies(LinuxKernelTestCase):
    def test_jiffies(self):
        self.assertIdentical(
            self.prog["jiffies"],
            Object(
                self.prog,
                "volatile unsigned long",
                address=self.prog.symbol("jiffies").address,
            ),
        )


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 = 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 = 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,
        )