brintos

brintos / linux-shallow public Read only

0
0
Text · 1.4 KiB · 1ace583 Raw
50 lines · python
1# SPDX-License-Identifier: GPL-2.02 3import sys4from pathlib import Path5from .consts import KSRC, KSFT_DIR6from .ksft import ksft_pr, ktap_result7 8# Resolve paths9try:10    if (KSFT_DIR / "kselftest-list.txt").exists():11        # Running in "installed" selftests12        tools_full_path = KSFT_DIR13        SPEC_PATH = KSFT_DIR / "net/lib/specs"14 15        sys.path.append(tools_full_path.as_posix())16        from net.lib.ynl.lib import YnlFamily, NlError17    else:18        # Running in tree19        tools_full_path = KSRC / "tools"20        SPEC_PATH = KSRC / "Documentation/netlink/specs"21 22        sys.path.append(tools_full_path.as_posix())23        from net.ynl.lib import YnlFamily, NlError24except ModuleNotFoundError as e:25    ksft_pr("Failed importing `ynl` library from kernel sources")26    ksft_pr(str(e))27    ktap_result(True, comment="SKIP")28    sys.exit(4)29 30#31# Wrapper classes, loading the right specs32# Set schema='' to avoid jsonschema validation, it's slow33#34class EthtoolFamily(YnlFamily):35    def __init__(self):36        super().__init__((SPEC_PATH / Path('ethtool.yaml')).as_posix(),37                         schema='')38 39 40class RtnlFamily(YnlFamily):41    def __init__(self):42        super().__init__((SPEC_PATH / Path('rt_link.yaml')).as_posix(),43                         schema='')44 45 46class NetdevFamily(YnlFamily):47    def __init__(self):48        super().__init__((SPEC_PATH / Path('netdev.yaml')).as_posix(),49                         schema='')50