1 # SPDX-License-Identifier: GPL-2.0 2 3 import sys 4 from pathlib import Path 5 from .consts import KSRC, KSFT_DIR 6 from .ksft import ksft_pr, ktap_result 7 8 # Resolve paths 9 try: 10 if (KSFT_DIR / "kselftest-list.txt").exists(): 11 # Running in "installed" selftests 12 tools_full_path = KSFT_DIR 13 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, NlError 17 else: 18 # Running in tree 19 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, NlError 24 except 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 specs 32 # Set schema='' to avoid jsonschema validation, it's slow 33 # 34 class EthtoolFamily(YnlFamily): 35 def __init__(self): 36 super().__init__((SPEC_PATH / Path('ethtool.yaml')).as_posix(), 37 schema='') 38 39 40 class RtnlFamily(YnlFamily): 41 def __init__(self): 42 super().__init__((SPEC_PATH / Path('rt_link.yaml')).as_posix(), 43 schema='') 44 45 46 class NetdevFamily(YnlFamily): 47 def __init__(self): 48 super().__init__((SPEC_PATH / Path('netdev.yaml')).as_posix(), 49 schema='')
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.