From 958a1ae750f1b1e814bcf434585c7c901473f116 Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Mon, 30 Oct 2017 16:17:16 +0100 Subject: Merge user_str/tri_value into user_value user_str_value isn't justified any more with the other API improvements. user_value now stores 0, 1, 2 for bool/tristate symbols, and a string for other symbol types. Much simpler and more intuitive. Also avoid printing quotes around tristate values in __repr__(). This was inconsistent too as it was only done for the value and user value. Should be getting close to final API. --- testsuite.py | 56 +++++++++++++++++++++----------------------------------- 1 file changed, 21 insertions(+), 35 deletions(-) (limited to 'testsuite.py') diff --git a/testsuite.py b/testsuite.py index adde8f3..fa10a39 100644 --- a/testsuite.py +++ b/testsuite.py @@ -207,30 +207,18 @@ def run_selftests(): assign_and_verify_value(sym_name, user_val, user_val) def assign_and_verify_user_value(sym_name, val, user_val): - """Assigns a user value to the symbol and verifies the new user value. - Also checks consistency of user_str_value and user_tri_value.""" + """ + Assigns a user value to the symbol and verifies the new user value. + """ sym = c.syms[sym_name] + sym_old_user_val = sym.user_value - if sym.type in (BOOL, TRISTATE): - user_val = TRI_TO_STR[user_val] - - sym_old_user_val = sym.user_str_value sym.set_value(val) - verify(sym.user_str_value == user_val, - "{} should have the user value '{}' after being assigned " - "the user value '{}'. Instead, the new user value was '{}'. " - "The old user value was '{}'." - .format(sym_name, user_val, user_val, sym.user_str_value, - sym_old_user_val)) - - if sym.type in (BOOL, TRISTATE): - verify(sym.user_tri_value == STR_TO_TRI[sym.user_str_value], - "{} has an inconsistent user value ('{}' vs '{}')" - .format(sym_name, sym.user_tri_value, sym.user_str_value)) - else: - verify(sym.user_tri_value == 0, - "{} is non-bool/tristate and has the non-zero " - "user_tri_value {}".format(sym_name, sym.user_tri_value)) + verify(sym.user_value == user_val, + "the assigned user value '{}' wasn't reflected in user_value " + "on the symbol {}. Instead, the new user_value was '{}'. The " + "old user value was '{}'." + .format(user_val, sym.name, sym.user_value, sym_old_user_val)) # # Selftests @@ -614,15 +602,15 @@ choice c = Kconfig("Kconfiglib/tests/Krepr", warn=False) verify_repr(c.n, """ - + """) verify_repr(c.m, """ - + """) verify_repr(c.y, """ - + """) verify_repr(c.syms["UNDEFINED"], """ @@ -630,17 +618,17 @@ choice """) verify_repr(c.syms["BASIC"], """ - + """) verify_repr(c.syms["VISIBLE"], """ - + """) c.syms["VISIBLE"].set_value(2) verify_repr(c.syms["VISIBLE"], """ - + """) verify_repr(c.syms["DIR_DEP_N"], """ @@ -656,11 +644,11 @@ choice """) verify_repr(c.syms["CHOICE_1"], """ - + """) verify_repr(c.modules, """ - + """) @@ -1267,7 +1255,7 @@ g ("BOOL", "TRISTATE", "STRING", "INT", "HEX")] for sym in syms: - verify(sym.user_str_value is None and sym.user_tri_value is None, + verify(sym.user_value is None, "{} should not have a user value to begin with") # Assign valid values for the types @@ -1297,7 +1285,7 @@ g for s in syms: s.unset_value() - verify(s.user_str_value is None and s.user_tri_value is None, + verify(s.user_value is None, "{} should not have a user value after being reset". format(s.name)) @@ -1953,8 +1941,7 @@ def test_sanity(conf, arch): sym.tri_value sym.type sym.unset_value() - sym.user_str_value - sym.user_tri_value + sym.user_value sym.visibility for sym in conf.defined_syms: @@ -2009,8 +1996,7 @@ def test_sanity(conf, arch): choice.__repr__() choice.str_value choice.tri_value - choice.user_str_value - choice.user_tri_value + choice.user_value choice.assignable choice.selection choice.default_selection -- cgit v1.2.3