summaryrefslogtreecommitdiff
path: root/testsuite.py
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2017-11-03 06:13:23 +0100
committerUlf Magnusson <ulfalizer@gmail.com>2017-11-03 06:14:43 +0100
commitd1ea825a1d9d8bfc9496926b6a800ad58581b09a (patch)
treef605a507aabd4686f4dfdd59729ac1914dd283cf /testsuite.py
parent882d5d671c2c0fcec914fd8ec66cf15122cb1fb6 (diff)
Add .assignable selftests for choice symbols
Diffstat (limited to 'testsuite.py')
-rw-r--r--testsuite.py44
1 files changed, 32 insertions, 12 deletions
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")