diff options
| -rw-r--r-- | tests/Kassignable | 34 | ||||
| -rw-r--r-- | testsuite.py | 44 |
2 files changed, 66 insertions, 12 deletions
diff --git a/tests/Kassignable b/tests/Kassignable index e600a39..fe88abe 100644 --- a/tests/Kassignable +++ b/tests/Kassignable @@ -167,3 +167,37 @@ config M_IMP_M_VIS_TRI config M_IMP_N_VIS_TRI tristate "m-imp n-vis tri" if n + + +# Symbols in y-mode choice + +choice Y_CHOICE + bool "y-mode choice" + +config Y_CHOICE_BOOL + bool "y-mode choice bool" + +config Y_CHOICE_TRISTATE + tristate "y-mode choice tristate" + +config Y_CHOICE_N_VIS_TRISTATE + tristate "y-mode choice tristate invisible" if n + +endchoice + + +# Symbols in m/y-mode choice + +choice MY_CHOICE + tristate "m/y-mode choice" + +config MY_CHOICE_BOOL + bool "m/y-mode choice bool" + +config MY_CHOICE_TRISTATE + tristate "m/y-mode choice tristate" + +config MY_CHOICE_N_VIS_TRISTATE + tristate "m/y-mode choice tristate invisible" if n + +endchoice diff --git a/testsuite.py b/testsuite.py index bd62c91..dd0fe7c 100644 --- a/testsuite.py +++ b/testsuite.py @@ -859,25 +859,28 @@ g c = Kconfig("Kconfiglib/tests/Kassignable") - def verify_assignable_imp(item, assignable): + def verify_assignable_imp(item, assignable, test_assign): verify(item.assignable == assignable, "Incorrect assignable values for {}. " "Should be {}, was {}." .format(item.name, assignable, item.assignable)) - # Verify that the values can actually be assigned too - for val in item.assignable: - item.set_value(val) - verify(item.tri_value == val, - "Unable to set {} to {}, even though " - "it was in .assignable" - .format(item.name, val)) + # Verify that the values can actually be assigned too, except for + # choices in y mode, where setting the user value to n doesn't change + # the value + if test_assign: + for val in item.assignable: + item.set_value(val) + verify(item.tri_value == val, + "Unable to set {} to {}, even though " + "it was in .assignable" + .format(item.name, val)) - def verify_assignable(sym_name, assignable): - verify_assignable_imp(c.syms[sym_name], assignable) + def verify_assignable(sym_name, assignable, test_assign=True): + verify_assignable_imp(c.syms[sym_name], assignable, test_assign) def verify_const_unassignable(sym_name): - verify_assignable_imp(c.const_syms[sym_name], ()) + verify_assignable_imp(c.const_syms[sym_name], (), False) # Test with modules enabled first c.modules.set_value(2) @@ -915,7 +918,7 @@ g verify_assignable("M_SEL_M_VIS_BOOL", ( 2,)) # Visibility/value promoted verify_assignable("M_SEL_N_VIS_BOOL", ( )) verify_assignable("M_SEL_Y_VIS_TRI", (1, 2 )) - verify_assignable("M_SEL_M_VIS_TRI", (1 ,)) + verify_assignable("M_SEL_M_VIS_TRI", (1, )) verify_assignable("M_SEL_N_VIS_TRI", ( )) # Symbols implied to y @@ -934,6 +937,23 @@ g verify_assignable("M_IMP_M_VIS_TRI", (0, 1 )) verify_assignable("M_IMP_N_VIS_TRI", ( )) + # Symbols in y-mode choice + verify_assignable("Y_CHOICE_BOOL", (0, 2), test_assign=False) + verify_assignable("Y_CHOICE_TRISTATE", (0, 2), test_assign=False) + verify_assignable("Y_CHOICE_N_VIS_TRISTATE", ( )) + + # Symbols in m/y-mode choice, starting out in m mode + verify_assignable("MY_CHOICE_BOOL", ( )) + verify_assignable("MY_CHOICE_TRISTATE", (0, 1)) + verify_assignable("MY_CHOICE_N_VIS_TRISTATE", ( )) + + c.named_choices["MY_CHOICE"].set_value(2) + + # Symbols in m/y-mode choice, now in y mode + verify_assignable("MY_CHOICE_BOOL", (0, 2), test_assign=False) + verify_assignable("MY_CHOICE_TRISTATE", (0, 2), test_assign=False) + verify_assignable("MY_CHOICE_N_VIS_TRISTATE", ( )) + print("Testing object relations") |
