File: test_kconfig.py

package info (click to toggle)
drgn 0.0.33-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,892 kB
  • sloc: python: 59,081; ansic: 51,400; awk: 423; makefile: 339; sh: 113
file content (22 lines) | stat: -rw-r--r-- 741 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
# Copyright (c) Meta Platforms, Inc. and affiliates.
# SPDX-License-Identifier: LGPL-2.1-or-later

import gzip
import re

from drgn.helpers.linux.kconfig import get_kconfig
from tests.linux_kernel import LinuxKernelTestCase


class TestKconfig(LinuxKernelTestCase):
    def test_get_kconfig(self):
        expected = {}
        try:
            with gzip.open("/proc/config.gz", "rt") as f:
                for line in f:
                    match = re.match(r"(\w+)=(.*)", line)
                    if match:
                        expected[match.group(1)] = match.group(2)
        except FileNotFoundError:
            self.skipTest("kernel not built with CONFIG_IKCONFIG_PROC")
        self.assertEqual(get_kconfig(self.prog), expected)