summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2012-12-06 20:25:09 +0100
committerUlf Magnusson <ulfalizer@gmail.com>2012-12-06 20:25:29 +0100
commita764086b6200d5bb482da2dd9a623c703bab1428 (patch)
tree32189fb35c55d7b4859ab92cf666874886f3da16
parent8142cc4d86823830e09a0a987696e24bdf6aa4a1 (diff)
Add selftests for get_lower/upper_bound().
-rw-r--r--kconfigtest.py23
-rw-r--r--tests/Kbounds49
2 files changed, 72 insertions, 0 deletions
diff --git a/kconfigtest.py b/kconfigtest.py
index 02c80b4..58cf450 100644
--- a/kconfigtest.py
+++ b/kconfigtest.py
@@ -59,6 +59,29 @@ def run_selftests():
assert_false(s.is_modifiable(),
"{0} should not be modifiable".format(s.get_name()))
+ print "Testing get_lower/upper_bound()..."
+ c = kconfiglib.Config("Kconfiglib/tests/Kbounds")
+ def assert_bounds(sym, lower, upper):
+ sym = c[sym]
+ low = sym.get_lower_bound()
+ high = sym.get_upper_bound()
+ assert_true(low == lower and high == upper,
+ "Incorrectly calculated bounds for {0}: {1}-{2}. "
+ "Expected {3}-{4}.".format(sym.get_name(),
+ low, high, lower, upper))
+ assert_bounds("Y_VISIBLE_BOOL", "n", "y")
+ assert_bounds("Y_VISIBLE_TRISTATE", "n", "y")
+ assert_bounds("M_VISIBLE_BOOL", "n", "y")
+ assert_bounds("M_VISIBLE_TRISTATE", "n", "m")
+ assert_bounds("Y_SELECTED_BOOL", None, None)
+ assert_bounds("M_SELECTED_BOOL", None, None)
+ assert_bounds("Y_SELECTED_TRISTATE", None, None)
+ assert_bounds("M_SELECTED_TRISTATE", "m", "y")
+ assert_bounds("M_SELECTED_M_VISIBLE_TRISTATE", None, None)
+ assert_bounds("STRING", None, None)
+ assert_bounds("INT", None, None)
+ assert_bounds("HEX", None, None)
+
print
def run_compatibility_tests():
diff --git a/tests/Kbounds b/tests/Kbounds
new file mode 100644
index 0000000..9713474
--- /dev/null
+++ b/tests/Kbounds
@@ -0,0 +1,49 @@
+config MODULES
+ def_bool y
+
+config Y_VISIBLE_BOOL
+ bool "y-visible bool"
+
+config Y_VISIBLE_TRISTATE
+ tristate "y-visible tristate"
+
+config M_VISIBLE_BOOL
+ bool "m-visible bool" if m
+
+config M_VISIBLE_TRISTATE
+ tristate "m-visible tristate" if m
+
+config Y_SELECTOR
+ def_tristate y
+ select Y_SELECTED_BOOL
+ select Y_SELECTED_TRISTATE
+
+config M_SELECTOR
+ def_tristate m
+ select M_SELECTED_BOOL
+ select M_SELECTED_TRISTATE
+ select M_SELECTED_M_VISIBLE_TRISTATE
+
+config Y_SELECTED_BOOL
+ bool "y-selected bool"
+
+config Y_SELECTED_TRISTATE
+ tristate "y-selected tristate"
+
+config M_SELECTED_BOOL
+ bool "m-selected bool"
+
+config M_SELECTED_TRISTATE
+ tristate "m-selected tristate"
+
+config M_SELECTED_M_VISIBLE_TRISTATE
+ tristate "m-selected m-visible tristate" if m
+
+config STRING
+ string "string"
+
+config INT
+ int "int"
+
+config HEX
+ hex "hex"