Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / test / API / functionalities / postmortem / FreeBSDKernel / TestFreeBSDKernelLive.py
blob689f76959150f08e448ed0bbe809d49e6d8fbdf4
1 import os
2 import struct
3 import subprocess
5 import lldb
6 from lldbsuite.test.decorators import *
7 from lldbsuite.test.lldbtest import *
8 from lldbsuite.test import lldbutil
11 class FreeBSDKernelVMCoreTestCase(TestBase):
12 NO_DEBUG_INFO_TESTCASE = True
14 def test_mem(self):
15 kernel_exec = "/boot/kernel/kernel"
16 mem_device = "/dev/mem"
18 if not os.access(kernel_exec, os.R_OK):
19 self.skipTest("Kernel @ %s is not readable" % (kernel_exec,))
20 if not os.access(mem_device, os.R_OK):
21 self.skipTest("Memory @ %s is not readable" % (mem_device,))
23 target = self.dbg.CreateTarget(kernel_exec)
24 process = target.LoadCore(mem_device)
25 hz_value = int(subprocess.check_output(["sysctl", "-n", "kern.hz"]))
27 self.assertTrue(process, PROCESS_IS_VALID)
28 self.assertEqual(process.GetNumThreads(), 1)
29 self.assertEqual(process.GetProcessID(), 0)
31 # test memory reading
32 self.expect("expr -- *(int *) &hz", substrs=["(int) $0 = %d" % hz_value])
34 main_mod = target.GetModuleAtIndex(0)
35 hz_addr = main_mod.FindSymbols("hz")[0].symbol.addr.GetLoadAddress(target)
36 error = lldb.SBError()
37 self.assertEqual(
38 process.ReadMemory(hz_addr, 4, error), struct.pack("<I", hz_value)
41 self.dbg.DeleteTarget(target)