From 2cd87dcf083f16177a984cad2ecff4710bde05d0 Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Thu, 6 Dec 2012 19:26:50 +0100 Subject: Add tests for is_modifiable(). Introduce selftests with specific configurations provided by us. --- kconfigtest.py | 34 ++++++++++++++++++++++++++++++++++ tests/Kmodifiable | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 tests/Kmodifiable diff --git a/kconfigtest.py b/kconfigtest.py index edb14d4..adf2ce8 100644 --- a/kconfigtest.py +++ b/kconfigtest.py @@ -33,6 +33,40 @@ os.environ.pop("KCONFIG_ALLCONFIG", None) nconfigs = 0 def run_tests(): + run_selftests() + run_compatibility_tests() + +def run_selftests(): + """Runs tests on specific configurations provided by us.""" + + print "Running selftests...\n" + + print "Testing is_modifiable()..." + c = kconfiglib.Config("Kconfiglib/tests/Kmodifiable") + for s in (c["VISIBLE"], + c["TRISTATE_SELECTED_TO_M"], + c["VISIBLE_STRING"], + c["VISIBLE_INT"], + c["VISIBLE_HEX"]): + if not s.is_modifiable(): + fail("{0} should be modifiable".format(s.get_name())) + for s in (c["NOT_VISIBLE"], + c["SELECTED_TO_Y"], + c["BOOL_SELECTED_TO_M"], + c["NOT_VISIBLE_STRING"], + c["NOT_VISIBLE_INT"], + c["NOT_VISIBLE_HEX"]): + if s.is_modifiable(): + fail("{0} should not be modifiable".format(s.get_name())) + + print + +def run_compatibility_tests(): + """Runs tests on configurations from the kernel. Tests compability with the + C implementation by comparing outputs.""" + + print "Running compatibility tests...\n" + # The set of tests that want to run for all architectures in the kernel # tree -- currently, all tests. The boolean flag indicates whether .config # (generated by the C implementation) should be compared to ._config diff --git a/tests/Kmodifiable b/tests/Kmodifiable new file mode 100644 index 0000000..d4d695c --- /dev/null +++ b/tests/Kmodifiable @@ -0,0 +1,45 @@ +config MODULES + def_bool y + +config VISIBLE + tristate "bool visible" + +config NOT_VISIBLE + tristate + +config Y_SELECTOR + def_tristate y + select SELECTED_TO_Y + +config SELECTED_TO_Y + tristate "selected to y" + +config M_SELECTOR + def_tristate m + select TRISTATE_SELECTED_TO_M + select BOOL_SELECTED_TO_M + +config TRISTATE_SELECTED_TO_M + tristate "tristate selected to m" + +# The "m" will get promoted to a "y", so this should still not be modifiable +config BOOL_SELECTED_TO_M + bool "bool selected to m" + +config VISIBLE_STRING + string "visible string" + +config VISIBLE_INT + int "visible int" + +config VISIBLE_HEX + hex "visible hex" + +config NOT_VISIBLE_STRING + string + +config NOT_VISIBLE_INT + int "not visible int" if n + +config NOT_VISIBLE_HEX + hex -- cgit v1.2.3