| 1 |
# Copyright (c) Meta Platforms, Inc. and affiliates. |
| 2 |
# SPDX-License-Identifier: LGPL-2.1-or-later |
| 3 |
|
| 4 |
import gzip |
| 5 |
import re |
| 6 |
|
| 7 |
from drgn.helpers.linux.kconfig import get_kconfig |
| 8 |
from tests.linux_kernel import LinuxKernelTestCase |
| 9 |
|
| 10 |
|
| 11 |
class TestKconfig(LinuxKernelTestCase): |
| 12 |
def test_get_kconfig(self): |
| 13 |
expected = {} |
| 14 |
try: |
| 15 |
with gzip.open("/proc/config.gz", "rt") as f: |
| 16 |
for line in f: |
| 17 |
match = re.match(r"(\w+)=(.*)", line) |
| 18 |
if match: |
| 19 |
expected[match.group(1)] = match.group(2) |
| 20 |
except FileNotFoundError: |
| 21 |
self.skipTest("kernel not built with CONFIG_IKCONFIG_PROC") |
| 22 |
self.assertEqual(get_kconfig(self.prog), expected) |