From f7cc4fbcc769b23dad05ad0b8d21ec650ac01037 Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Tue, 11 Dec 2012 11:42:07 +0100 Subject: Add selftests for get_defconfig_filename(). --- kconfigtest.py | 23 +++++++++++++++++++++++ tests/Kdefconfig_existent | 12 ++++++++++++ tests/Kdefconfig_none | 1 + tests/Kdefconfig_nonexistent | 5 +++++ tests/defconfig_1 | 0 tests/defconfig_2 | 0 6 files changed, 41 insertions(+) create mode 100644 tests/Kdefconfig_existent create mode 100644 tests/Kdefconfig_none create mode 100644 tests/Kdefconfig_nonexistent create mode 100644 tests/defconfig_1 create mode 100644 tests/defconfig_2 diff --git a/kconfigtest.py b/kconfigtest.py index 2d2e217..fc4bc94 100644 --- a/kconfigtest.py +++ b/kconfigtest.py @@ -474,6 +474,29 @@ def run_selftests(): verify_selects("NO_REF", []) verify_selects("MANY_REF", ["I", "N"]) + # + # get_defconfig_filename() + # + + print "Testing get_defconfig_filename()..." + + c = kconfiglib.Config("Kconfiglib/tests/Kdefconfig_none") + verify(c.get_defconfig_filename() is None, + "get_defconfig_filename() should be None with no defconfig_list " + "symbol") + + c = kconfiglib.Config("Kconfiglib/tests/Kdefconfig_nonexistent") + verify(c.get_defconfig_filename() is None, + "get_defconfig_filename() should be None when none of the files " + "in the defconfig_list symbol exist") + + # Referenced in Kdefconfig_existent + os.environ["BAR"] = "defconfig_2" + c = kconfiglib.Config("Kconfiglib/tests/Kdefconfig_existent") + verify(c.get_defconfig_filename() == "Kconfiglib/tests/defconfig_2", + "get_defconfig_filename() should return the existent file " + "Kconfiglib/tests/defconfig_2") + # # Object dependencies # diff --git a/tests/Kdefconfig_existent b/tests/Kdefconfig_existent new file mode 100644 index 0000000..895c218 --- /dev/null +++ b/tests/Kdefconfig_existent @@ -0,0 +1,12 @@ +# $FOO is "defconfig_2" +# Should produce "Kconfiglib/tests/defconfig_2" + +config FOO + option env="BAR" + +config A + string + option defconfig_list + default "Kconfiglib/tests/defconfig_1" if y && !n && n + default "Kconfiglib/tests/$FOO" + default "Kconfiglib/tests/defconfig_1" diff --git a/tests/Kdefconfig_none b/tests/Kdefconfig_none new file mode 100644 index 0000000..7259b21 --- /dev/null +++ b/tests/Kdefconfig_none @@ -0,0 +1 @@ +# No symbol with "option defconfig_list" defined here diff --git a/tests/Kdefconfig_nonexistent b/tests/Kdefconfig_nonexistent new file mode 100644 index 0000000..5b7230f --- /dev/null +++ b/tests/Kdefconfig_nonexistent @@ -0,0 +1,5 @@ +config A + string + option defconfig_list + default "Kconfiglib/tests/non_existent_1" + default "Kconfiglib/tests/non_existent_2" diff --git a/tests/defconfig_1 b/tests/defconfig_1 new file mode 100644 index 0000000..e69de29 diff --git a/tests/defconfig_2 b/tests/defconfig_2 new file mode 100644 index 0000000..e69de29 -- cgit v1.2.3