diff options
Diffstat (limited to 'testsuite.py')
| -rw-r--r-- | testsuite.py | 73 |
1 files changed, 31 insertions, 42 deletions
diff --git a/testsuite.py b/testsuite.py index dad38d8..9438863 100644 --- a/testsuite.py +++ b/testsuite.py @@ -117,9 +117,8 @@ def run_selftests(): # def verify_value(sym_name, val): - """ - Verifies that a symbol has a particular value. - """ + # Verifies that a symbol has a particular value. + if isinstance(val, int): val = TRI_TO_STR[val] @@ -129,11 +128,10 @@ def run_selftests(): .format(sym_name, val, sym.str_value)) def assign_and_verify_value(sym_name, val, new_val): - """ - Assigns 'val' to a symbol and verifies that its value becomes - 'new_val'. Assumes (and tests) that 'val' is valid for the - symbol type. - """ + # Assigns 'val' to a symbol and verifies that its value becomes + # 'new_val'. Assumes (and tests) that 'val' is valid for the + # symbol type. + if isinstance(new_val, int): new_val = TRI_TO_STR[new_val] @@ -149,18 +147,16 @@ def run_selftests(): .format(sym_name, new_val, val, sym.str_value, old_val)) def assign_and_verify(sym_name, user_val): - """ - Like assign_and_verify_value(), with the expected value being the - value just set. - """ + # Like assign_and_verify_value(), with the expected value being the + # value just set. + assign_and_verify_value(sym_name, user_val, user_val) def assign_and_verify_user_value(sym_name, val, user_val, valid): - """ - Assigns a user value to the symbol and verifies the new user value. If - valid is True, the user value is valid for the type, otherwise not. - This is used to test the set_value() return value. - """ + # Assigns a user value to the symbol and verifies the new user value. + # If valid is True, the user value is valid for the type, otherwise + # not. This is used to test the set_value() return value. + sym = c.syms[sym_name] sym_old_user_val = sym.user_value @@ -183,10 +179,9 @@ def run_selftests(): c = Kconfig("Kconfiglib/tests/empty") def verify_string_lex(s, expected): - """ - Verifies that a constant symbol with the name 'res' is produced from - lexing 's' - """ + # Verifies that a constant symbol with the name 'res' is produced from + # lexing 's' + res = c._tokenize("if " + s)[1].name verify(res == expected, "expected <{}> to produced the constant symbol <{}>, " @@ -221,11 +216,10 @@ def run_selftests(): verify_string_lex(r""" '\a\\"\b\c\'"d' """, "a\\\"bc'\"d") def verify_string_bad(s): - """ - Verifies that tokenizing 's' throws a KconfigError. Strips the first - and last characters from 's' so we can use readable raw strings as - input. - """ + # Verifies that tokenizing 's' throws a KconfigError. Strips the first + # and last characters from 's' so we can use readable raw strings as + # input. + try: c.eval_string(s) except KconfigError: @@ -1435,9 +1429,8 @@ tests/Krecursive2:1 c = Kconfig("Kconfiglib/tests/Kassignable") def verify_assignable_imp(item, assignable_no_modules, assignable_modules): - """ - Verifies the assignable values for 'item', with and without modules. - """ + # Verifies the assignable values for 'item', with and without modules. + for modules_val, assignable in (0, assignable_no_modules), \ (2, assignable_modules): @@ -1629,11 +1622,10 @@ tests/Krecursive2:1 c.disable_warnings() def verify_range(sym_name, low, high, default): - """ - Tests that the values in the range 'low'-'high' can be assigned, and - that assigning values outside this range reverts the value back to - 'default' (None if it should revert back to ""). - """ + # Verifies that all values in the range 'low'-'high' can be assigned, + # and that assigning values outside the range reverts the value back to + # 'default' (None if it should revert back to ""). + is_hex = (c.syms[sym_name].type == HEX) for i in range(low, high + 1): @@ -2639,10 +2631,8 @@ menu "menu" def run_compatibility_tests(): - """ - Runs tests on configurations from the kernel. Tests compability with the - C implementation by comparing outputs. - """ + # Runs tests on configurations from the kernel. Tests compability with the + # C implementation by comparing outputs. # Referenced inside the kernel Kconfig files. # @@ -3055,10 +3045,9 @@ def defconfig_files(srcarch): def rm_configs(): - """ - Delete any old ".config" (generated by the C implementation) and - "._config" (generated by us), if present. - """ + # Delete any old ".config" (generated by the C implementation) and + # "._config" (generated by us), if present. + def rm_if_exists(f): if os.path.exists(f): os.remove(f) |
