diff options
| -rw-r--r-- | kconfiglib.py | 44 | ||||
| -rw-r--r-- | tests/Kstr | 49 | ||||
| -rw-r--r-- | testsuite.py | 18 |
3 files changed, 108 insertions, 3 deletions
diff --git a/kconfiglib.py b/kconfiglib.py index acf365c..8e6d206 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -4026,6 +4026,12 @@ class Symbol(object): than plain integers. Undefined symbols get their name as their string value, so this works out. The C tools work the same way. + orig_defaults: + orig_selects: + orig_implies: + orig_ranges: + See the corresponding attributes on the MenuNode class. + rev_dep: Reverse dependency expression from other symbols selecting this symbol. Multiple selections get ORed together. A condition on a select is ANDed @@ -4515,6 +4521,34 @@ class Symbol(object): """ return {item for node in self.nodes for item in node.referenced} + @property + def orig_defaults(self): + """ + See the class documentation. + """ + return [d for node in self.nodes for d in node.orig_defaults] + + @property + def orig_selects(self): + """ + See the class documentation. + """ + return [s for node in self.nodes for s in node.orig_selects] + + @property + def orig_implies(self): + """ + See the class documentation. + """ + return [i for node in self.nodes for i in node.orig_implies] + + @property + def orig_ranges(self): + """ + See the class documentation. + """ + return [r for node in self.nodes for r in node.orig_ranges] + def __repr__(self): """ Returns a string with information about the symbol (including its name, @@ -4939,6 +4973,9 @@ class Choice(object): Note that 'depends on' and parent dependencies are propagated to 'default' conditions. + orig_defaults: + See the corresponding attribute on the MenuNode class. + direct_dep: See Symbol.direct_dep. @@ -5102,6 +5139,13 @@ class Choice(object): """ return {item for node in self.nodes for item in node.referenced} + @property + def orig_defaults(self): + """ + See the class documentation. + """ + return [d for node in self.nodes for d in node.orig_defaults] + def __repr__(self): """ Returns a string with information about the choice when it is evaluated @@ -242,3 +242,52 @@ endmenu # Only prompt, no type config PROMPT_ONLY prompt "prompt only" + +# {Symbol,Choice}.orig_* + +if BASE_DEP + +config BOOL_SYM_ORIG + bool + default D1 if DEP + default D2 + select S1 + select S2 if DEP + imply I1 + imply I1 + +config BOOL_SYM_ORIG + default D3 + select S3 + imply I3 if DEP + +config INT_SYM_ORIG + int + range 1 2 if DEP + range 3 4 + +config INT_SYM_ORIG + range 5 6 if DEP + +choice CHOICE_ORIG + bool "choice orig" + default A + default B if DEP + +config A + bool + +config B + bool + +endchoice + +choice CHOICE_ORIG + default C if DEP + +config C + bool + +endchoice + +endif diff --git a/testsuite.py b/testsuite.py index 4bb1991..d5f9726 100644 --- a/testsuite.py +++ b/testsuite.py @@ -782,10 +782,10 @@ comment "advanced comment" """) - print("Testing MenuNode.orig_*") + print("Testing {MenuNode,Symbol,Choice}.orig_*") - # Just test some corner cases here. These are already tested above. Use - # MenuNode.__str__() as a proxy. + # Just test some corner cases here re. MenuNode.orig_*. They are already + # indirectly tested above. Use MenuNode.__str__() as a proxy. verify_str(c.syms["DEP_REM_CORNER_CASES"], """ config DEP_REM_CORNER_CASES @@ -823,6 +823,18 @@ config DEP_REM_CORNER_CASES depends on BAZ && QAZ """) + # Test {Symbol,Choice}.orig_* + + def verify_deps(elms, dep_index, expected): + verify_equal(" ".join(expr_str(elm[dep_index]) for elm in elms), + expected) + + verify_deps(c.syms["BOOL_SYM_ORIG"].orig_defaults, 1, "DEP y y") + verify_deps(c.syms["BOOL_SYM_ORIG"].orig_selects, 1, "y DEP y") + verify_deps(c.syms["BOOL_SYM_ORIG"].orig_implies, 1, "y y DEP") + verify_deps(c.syms["INT_SYM_ORIG"].orig_ranges, 2, "DEP y DEP") + verify_deps(c.named_choices["CHOICE_ORIG"].orig_defaults, 1, "y DEP DEP") + print("Testing Symbol.__repr__()") |
