Debian Codegraph @

tests/linux_kernel/helpers/test_ioport.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 re
6
7 from drgn.helpers.linux.ioport import for_each_resource
8 from tests.linux_kernel import LinuxKernelTestCase
9
10
11 class TestIoport(LinuxKernelTestCase):
12 def test_for_each_resource(self):
13 resources = for_each_resource(self.prog["ioport_resource"].address_of_())
14 next(resources) # Skip the root.
15 self.assertEqual(
16 [resource.name.string_() for resource in resources],
17 re.findall(b"[^:]* : (.*)", Path("/proc/ioports").read_bytes()),
18 )