From dd0e227216e247d2040cdd40bf7397702880cdc4 Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Mon, 9 Oct 2017 23:05:00 +0200 Subject: Kconfiglib 2 backup WIP --- tests/Kstr | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 tests/Kstr (limited to 'tests/Kstr') diff --git a/tests/Kstr b/tests/Kstr new file mode 100644 index 0000000..8d74017 --- /dev/null +++ b/tests/Kstr @@ -0,0 +1,76 @@ +if UNDEFINED +endif + +config NO_TYPE + +config BASIC_NO_PROMPT + bool + help + blah blah + + blah blah blah + + blah + +config BASIC_PROMPT + bool "basic" + +config ADVANCED + tristate "prompt" if DEP + default DEFAULT_1 + default DEFAULT_2 if DEP + select SELECTED_1 + select SELECTED_2 if DEP + imply IMPLIED_1 + imply IMPLIED_2 if DEP + help + first help text + +config ADVANCED + prompt "prompt 2" + +menuconfig ADVANCED + prompt "prompt 3" + depends on DEP2 + +config ADVANCED + help + second help text + +config STRING + string + default "foo" + default "bar" if DEP + default STRING2 + default STRING3 if DEP + +config INT + int + range 1 2 + range FOO BAR + range BAZ QAZ if DEP + +config MODULES + option modules + +config OPTIONS + option allnoconfig_y + option defconfig_list + option env="ENV" + +choice CHOICE + tristate "foo" + default CHOICE_1 + default CHOICE_2 if dep + +config CHOICE_1 + tristate "choice 1" + +config CHOICE_2 + tristate "choice 2" + +endchoice + +choice + tristate "no name" +endchoice -- cgit v1.2.3 From 7bbaf7e7cf131d83931bfda2d2e8e5d6ef1b235f Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Sat, 28 Oct 2017 05:46:25 +0200 Subject: Add uncommitted test files --- kconfiglib.py | 2 ++ tests/Khelp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ tests/Klocation | 2 ++ tests/Krepr | 2 +- tests/Kstr | 1 + tests/Kwtf | 8 ++++++++ 6 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 tests/Khelp create mode 100644 tests/Kwtf (limited to 'tests/Kstr') diff --git a/kconfiglib.py b/kconfiglib.py index 3262b43..1bf61a6 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -893,6 +893,8 @@ class Config(object): self._file = self._open(filename) except IOError as e: # Extend the error message a bit in this case + # TODO: broken for top-level Kconfig (because + # self._filename/_linenr isn't set) raise IOError( "{}:{}: {} Also note that e.g. $FOO in a 'source' " "statement does not refer to the environment " diff --git a/tests/Khelp b/tests/Khelp new file mode 100644 index 0000000..fdc81ed --- /dev/null +++ b/tests/Khelp @@ -0,0 +1,46 @@ +config TWO_HELP_STRINGS + help + first help string + + + + +config TWO_HELP_STRINGS + help + second help string + +config NO_BLANK_AFTER_HELP + help + help for + NO_BLANK_AFTER_HELP +choice CHOICE_HELP + help + help for + CHOICE_HELP +endchoice + +config HELP_TERMINATED_BY_COMMENT + bool + help + a + b + c +# + +config TRICKY_HELP + bool + help + + + a + b + c + + d + e + f + + + g + h + i diff --git a/tests/Klocation b/tests/Klocation index 498a372..737a221 100644 --- a/tests/Klocation +++ b/tests/Klocation @@ -28,3 +28,5 @@ config _INCLUDED # Expands to "tests/Klocation_included" source "$EXPANDED_FROM_ENV/Klocation$_INCLUDED" + +config MULTI_DEF diff --git a/tests/Krepr b/tests/Krepr index d886fe3..5a5b8b8 100644 --- a/tests/Krepr +++ b/tests/Krepr @@ -41,7 +41,7 @@ endchoice config CHOICE_HOOK choice - tristate "choice" if n + tristate "optional choice" if n optional endchoice diff --git a/tests/Kstr b/tests/Kstr index 8d74017..e591792 100644 --- a/tests/Kstr +++ b/tests/Kstr @@ -51,6 +51,7 @@ config INT range BAZ QAZ if DEP config MODULES + bool "MODULES" option modules config OPTIONS diff --git a/tests/Kwtf b/tests/Kwtf new file mode 100644 index 0000000..c71e328 --- /dev/null +++ b/tests/Kwtf @@ -0,0 +1,8 @@ +config A + bool + select n + select m + select y + imply n + imply m + imply y -- cgit v1.2.3 From e388f85764dcc6ab87b256e4088b4be918e02c1f Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Thu, 2 Nov 2017 19:46:11 +0100 Subject: Get rid of separate is_optional test The choice semantics tests already verify the behavior of optional choices. Just print an optional choice instead to get some coverage for querying it. Do minor cleanup elsewhere. --- tests/Kstr | 1 + testsuite.py | 30 +++++++----------------------- 2 files changed, 8 insertions(+), 23 deletions(-) (limited to 'tests/Kstr') diff --git a/tests/Kstr b/tests/Kstr index e591792..d792f08 100644 --- a/tests/Kstr +++ b/tests/Kstr @@ -74,4 +74,5 @@ endchoice choice tristate "no name" + optional endchoice diff --git a/testsuite.py b/testsuite.py index 4721349..b5c00ff 100644 --- a/testsuite.py +++ b/testsuite.py @@ -584,6 +584,7 @@ choice CHOICE choice tristate prompt "no name" + optional """) @@ -1052,7 +1053,6 @@ g verify_value("INACTIVE_RANGE", "2") verify_value("ACTIVE_RANGE", "1") - # TODO: test symbol references in some other way? # TODO: test selects in some other way? # TODO: test implies in some other way? @@ -1096,9 +1096,6 @@ g verify(c.defconfig_filename == "Kconfiglib/tests/sub/defconfig_in_sub", "defconfig_filename gave wrong file with $srctree set") - # - # mainmenu_text - # print("Testing mainmenu_text...") @@ -1112,29 +1109,18 @@ g verify(c.mainmenu_text == "---bar baz---", "Wrong mainmenu text") - # - # Misc. minor APIs - # - - os.environ["ENV_VAR"] = "foo" - # Contains reference to undefined environment variable, so disable warnings - c = Kconfig("Kconfiglib/tests/Kmisc", warn=False) - - print("Testing is_optional...") - - verify(not get_choices(c)[0].is_optional, - "First choice should not be optional") - verify(get_choices(c)[1].is_optional, - "Second choice should be optional") print("Testing user_value...") + # References undefined env. var. Disable warnings. + c = Kconfig("Kconfiglib/tests/Kmisc", warn=False) + # Avoid warnings from assigning invalid user values and assigning user # values to symbols without prompts c.disable_warnings() - syms = [c.syms[name] for name in \ - ("BOOL", "TRISTATE", "STRING", "INT", "HEX")] + syms = [c.syms[name] for name in + "BOOL", "TRISTATE", "STRING", "INT", "HEX"] for sym in syms: verify(sym.user_value is None, @@ -1183,6 +1169,7 @@ g verify(not c.syms[name].nodes, "{} should not be defined".format(name)) + print("Testing Symbol.choice...") for name in "A", "B", "C", "D": @@ -1211,9 +1198,6 @@ g ur.env_var == "", "UNAME_RELEASE has wrong fields") - # - # .config reading and writing - # print("Testing .config reading and writing...") -- cgit v1.2.3