~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/kunit/kunit_config.py

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /tools/testing/kunit/kunit_config.py (Version linux-6.12-rc7) and /tools/testing/kunit/kunit_config.py (Version policy-sample)


  1 # SPDX-License-Identifier: GPL-2.0                
  2 #                                                 
  3 # Builds a .config from a kunitconfig.            
  4 #                                                 
  5 # Copyright (C) 2019, Google LLC.                 
  6 # Author: Felix Guo <felixguoxiuping@gmail.com>    
  7 # Author: Brendan Higgins <brendanhiggins@googl    
  8                                                   
  9 from dataclasses import dataclass                 
 10 import re                                         
 11 from typing import Any, Dict, Iterable, List,     
 12                                                   
 13 CONFIG_IS_NOT_SET_PATTERN = r'^# CONFIG_(\w+)     
 14 CONFIG_PATTERN = r'^CONFIG_(\w+)=(\S+|".*")$'     
 15                                                   
 16 @dataclass(frozen=True)                           
 17 class KconfigEntry:                               
 18         name: str                                 
 19         value: str                                
 20                                                   
 21         def __str__(self) -> str:                 
 22                 if self.value == 'n':             
 23                         return f'# CONFIG_{sel    
 24                 return f'CONFIG_{self.name}={s    
 25                                                   
 26                                                   
 27 class KconfigParseError(Exception):               
 28         """Error parsing Kconfig defconfig or     
 29                                                   
 30                                                   
 31 class Kconfig:                                    
 32         """Represents defconfig or .config spe    
 33                                                   
 34         def __init__(self) -> None:               
 35                 self._entries = {}  # type: Di    
 36                                                   
 37         def __eq__(self, other: Any) -> bool:     
 38                 if not isinstance(other, self.    
 39                         return False              
 40                 return self._entries == other.    
 41                                                   
 42         def __repr__(self) -> str:                
 43                 return ','.join(str(e) for e i    
 44                                                   
 45         def as_entries(self) -> Iterable[Kconf    
 46                 for name, value in self._entri    
 47                         yield KconfigEntry(nam    
 48                                                   
 49         def add_entry(self, name: str, value:     
 50                 self._entries[name] = value       
 51                                                   
 52         def is_subset_of(self, other: 'Kconfig    
 53                 for name, value in self._entri    
 54                         b = other._entries.get    
 55                         if b is None:             
 56                                 if value == 'n    
 57                                         contin    
 58                                 return False      
 59                         if value != b:            
 60                                 return False      
 61                 return True                       
 62                                                   
 63         def conflicting_options(self, other: '    
 64                 diff = []  # type: List[Tuple[    
 65                 for name, value in self._entri    
 66                         b = other._entries.get    
 67                         if b and value != b:      
 68                                 pair = (Kconfi    
 69                                 diff.append(pa    
 70                 return diff                       
 71                                                   
 72         def merge_in_entries(self, other: 'Kco    
 73                 for name, value in other._entr    
 74                         self._entries[name] =     
 75                                                   
 76         def write_to_file(self, path: str) ->     
 77                 with open(path, 'a+') as f:       
 78                         for e in self.as_entri    
 79                                 f.write(str(e)    
 80                                                   
 81 def parse_file(path: str) -> Kconfig:             
 82         with open(path, 'r') as f:                
 83                 return parse_from_string(f.rea    
 84                                                   
 85 def parse_from_string(blob: str) -> Kconfig:      
 86         """Parses a string containing Kconfig     
 87         kconfig = Kconfig()                       
 88         is_not_set_matcher = re.compile(CONFIG    
 89         config_matcher = re.compile(CONFIG_PAT    
 90         for line in blob.split('\n'):             
 91                 line = line.strip()               
 92                 if not line:                      
 93                         continue                  
 94                                                   
 95                 match = config_matcher.match(l    
 96                 if match:                         
 97                         kconfig.add_entry(matc    
 98                         continue                  
 99                                                   
100                 empty_match = is_not_set_match    
101                 if empty_match:                   
102                         kconfig.add_entry(empt    
103                         continue                  
104                                                   
105                 if line[0] == '#':                
106                         continue                  
107                 raise KconfigParseError('Faile    
108         return kconfig                            
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php