diff options
| -rw-r--r-- | tests/Kmisc | 27 | ||||
| -rw-r--r-- | testsuite.py | 67 |
2 files changed, 89 insertions, 5 deletions
diff --git a/tests/Kmisc b/tests/Kmisc index de44b38..725f661 100644 --- a/tests/Kmisc +++ b/tests/Kmisc @@ -17,12 +17,26 @@ config C tristate "C" config D tristate "D" +# Quirky symbols - not proper choice symbol + +config Q1 + tristate "Q1" + depends on D + +config Q2 + tristate "Q2" + depends on Q1 + +config Q3 + tristate "Q3" + depends on D + endchoice # get_user_value() config BOOL - bool "bool" + bool "bool" if NOT_DEFINED_1 config TRISTATE tristate # Visibility should not affect user value @@ -35,7 +49,18 @@ config INT config HEX hex "hex" + depends on NOT_DEFINED_2 comment "comment" menu "menu" + depends on NOT_DEFINED_3 || NOT_DEFINED_2 + depends on !NOT_DEFINED_4 endmenu + +config FROM_ENV + string + option env="ENV_VAR" + +config FROM_ENV_MISSING + string + option env="MISSING_ENV_VAR" diff --git a/testsuite.py b/testsuite.py index 917bfe8..b364ff4 100644 --- a/testsuite.py +++ b/testsuite.py @@ -923,7 +923,9 @@ def run_selftests(): # Misc. minor APIs # - c = kconfiglib.Config("Kconfiglib/tests/Kmisc") + os.environ["ENV_VAR"] = "foo" + # Contains reference to undefined environment variable, so disable warnings + c = kconfiglib.Config("Kconfiglib/tests/Kmisc", print_warnings = False) print "Testing is_optional()..." @@ -973,6 +975,63 @@ def run_selftests(): "{0} should not have a user value after being reset". format(s.get_name())) + print "Testing is_defined()..." + + for sym_name in ("n", "m", "y", "A", "B", "C", "D", "BOOL", "TRISTATE", + "STRING", "INT", "HEX"): + sym = c[sym_name] + verify(sym.is_defined(), + "{0} should be defined".format(sym_name)) + + for sym_name in ("NOT_DEFINED_1", "NOT_DEFINED_2", "NOT_DEFINED_3", + "NOT_DEFINED_4"): + sym = c[sym_name] + verify(not sym.is_defined(), + "{0} should not be defined".format(sym_name)) + + print "Testing is_special()..." + + for sym_name in ("n", "m", "y", "FROM_ENV", "FROM_ENV_MISSING"): + sym = c[sym_name] + verify(sym.is_special(), + "{0} should be special".format(sym_name)) + + for sym_name in ("A", "B", "C", "D", "BOOL", "TRISTATE", "STRING", + "INT", "HEX", "NOT_DEFINED_1", "NOT_DEFINED_2", + "NOT_DEFINED_3", "NOT_DEFINED_4"): + sym = c[sym_name] + verify(not sym.is_special(), + "{0} should not be special".format(sym_name)) + + print "Testing is_from_environment()..." + + for sym_name in ("FROM_ENV", "FROM_ENV_MISSING"): + sym = c[sym_name] + verify(sym.is_from_environment(), + "{0} should be from the environment".format(sym_name)) + + for sym_name in ("n", "m", "y", "A", "B", "C", "D", "BOOL", "TRISTATE", + "STRING", "INT", "HEX", "NOT_DEFINED_1", "NOT_DEFINED_2", + "NOT_DEFINED_3", "NOT_DEFINED_4"): + sym = c[sym_name] + verify(not sym.is_from_environment(), + "{0} should not be from the environment".format(sym_name)) + + print "Testing is_choice_symbol()..." + + for sym_name in ("A", "B", "C", "D"): + sym = c[sym_name] + verify(sym.is_choice_symbol(), + "{0} should be a choice symbol".format(sym_name)) + + for sym_name in ("n", "m", "y", "Q1", "Q2", "Q3", "BOOL", "TRISTATE", + "STRING", "INT", "HEX", "FROM_ENV", "FROM_ENV_MISSING", + "NOT_DEFINED_1", "NOT_DEFINED_2", "NOT_DEFINED_3", + "NOT_DEFINED_4"): + sym = c[sym_name] + verify(not sym.is_choice_symbol(), + "{0} should not be a choice symbol".format(sym_name)) + # # .config reading and writing # @@ -1048,8 +1107,8 @@ def run_selftests(): print "Testing get_config()..." - c1 = kconfiglib.Config("Kconfiglib/tests/Kmisc") - c2 = kconfiglib.Config("Kconfiglib/tests/Kmisc") + c1 = kconfiglib.Config("Kconfiglib/tests/Kmisc", print_warnings = False) + c2 = kconfiglib.Config("Kconfiglib/tests/Kmisc", print_warnings = False) c1_bool, c1_choice, c1_menu, c1_comment = c1["BOOL"], \ c1.get_choices()[0], c1.get_menus()[0], c1.get_comments()[0] @@ -1071,7 +1130,7 @@ def run_selftests(): os.environ["ARCH"] = "ARCH value" os.environ["SRCARCH"] = "SRCARCH value" os.environ["srctree"] = "srctree value" - c = kconfiglib.Config("Kconfiglib/tests/Kmisc") + c = kconfiglib.Config("Kconfiglib/tests/Kmisc", print_warnings = False) c.load_config("Kconfiglib/tests/empty") arch = c.get_arch() |
