summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2012-12-08 22:49:41 +0100
committerUlf Magnusson <ulfalizer@gmail.com>2012-12-08 22:50:11 +0100
commite3583375d0b2a061768cdfa885ca61b03aff0696 (patch)
tree14bb101fd804b3e0a1c3f8e8a99706330b5b0259
parent979f427e2c33ae296653d784809649b86af3fc30 (diff)
Add selftests for internal object dependencies.
-rw-r--r--kconfigtest.py31
-rw-r--r--tests/Kdep101
2 files changed, 132 insertions, 0 deletions
diff --git a/kconfigtest.py b/kconfigtest.py
index cdebc4d..d05cd71 100644
--- a/kconfigtest.py
+++ b/kconfigtest.py
@@ -274,6 +274,37 @@ def run_selftests():
assert_true(menu_2.get_symbols(True) == [F, G, H],
"Wrong recursive symbols in second menu")
+ #
+ # Object dependencies
+ #
+
+ print "Testing object dependencies..."
+
+ c = kconfiglib.Config("Kconfiglib/tests/Kdep")
+ def assert_dependent(sym_name, deps_names):
+ sym = c[sym_name]
+ deps = [c[dep] for dep in deps_names]
+ sym_deps = sym._get_dependent()
+ assert_true(len(sym_deps) == len(deps),
+ "Wrong number of dependent symbols for {0}".\
+ format(sym.get_name()))
+ assert_true(len(sym_deps) == len(set(sym_deps)),
+ "{0}'s dependencies contains duplicates".\
+ format(sym.get_name()))
+ for dep in deps:
+ assert_true(dep in sym_deps,
+ "{0} should depend on {1}".\
+ format(dep.get_name(), sym.get_name()))
+ # Test twice to cover dependency caching
+ for i in range(0, 2):
+ n_deps = 14
+ assert_dependent("D", ["D{0}".format(i) for i in range(1, n_deps + 1)])
+ # Choices
+ assert_dependent("A", ["B", "C"])
+ assert_dependent("B", ["A", "C"])
+ assert_dependent("C", ["A", "B"])
+ assert_dependent("S", ["A", "B", "C"])
+
print
def run_compatibility_tests():
diff --git a/tests/Kdep b/tests/Kdep
new file mode 100644
index 0000000..fe99283
--- /dev/null
+++ b/tests/Kdep
@@ -0,0 +1,101 @@
+config D
+ bool "D"
+
+# The symbols below depend on D in different ways
+
+config D1
+ def_bool D
+
+config D2
+ int "D2" if D
+
+config D3
+ int "D3"
+ depends on D
+
+config D4
+ bool "D4"
+ default D
+
+config D5
+ bool
+ default y if D
+
+config D6
+ int
+ range 0 1 if D
+
+config D7
+ int
+ range D 1
+
+config D8
+ int
+ range 0 D
+
+if D
+
+# Has no prompt and hence does not depend on D even though it's within the
+# 'if D' block
+config NO_DEPEND
+ bool
+
+config D9
+ bool "D9"
+
+endif
+
+menu "m"
+ depends on D
+
+config D10
+ bool "D10"
+
+menu "nested"
+
+config D11
+ bool "D11"
+
+endmenu
+endmenu
+
+# Indirect dependency
+config D12
+ def_tristate D11
+
+menu "m"
+ depends on D
+if D
+# Depends on D in lots of different ways
+config D13
+ int "D13" if D
+ depends on D && D12
+ default D if D
+ range D D if D
+endif
+endmenu
+
+# Complicated expression
+config D14
+ bool "D14" if n || (y && n || (m || D))
+
+#
+# Choices
+#
+
+choice
+ tristate "choice" if S
+
+config A
+ bool "A"
+
+config B
+ bool "B"
+
+config C
+ bool "C"
+
+endchoice
+
+config S
+ bool "S"