summaryrefslogtreecommitdiff
path: root/testsuite.py
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2017-09-24 09:49:20 +0200
committerUlf Magnusson <ulfalizer@gmail.com>2017-09-24 11:37:42 +0200
commit799e6d4e1a4e4a4f59e58298bbb9c01d286159dc (patch)
tree90b4a013bda3026db46057fecded5cdf10ab812b /testsuite.py
parent27fe993b0e36b0598b0dc16c1b7ae417389562f8 (diff)
Fix get_defconfig_filename() $srctree search order
Previously, $srctree/path/to/defconfig would be looked up before /path/to/defconfig, and the code wouldn't check if /path/to/defconfig was an absolute path ($srctree is ignored otherwise). Sloppy old oversights. The behavior now fully matches the C implementation. Also fix some related things: - An 'if m' suffices to select a defconfig. We previously required 'y'. - Make the code less hacky and possibly more Windows-friendly by using os.path.relpath() to de-absolutize paths, and stop using os.path.normpath() as it could change the meaning of paths that contain symbolic links. - Explain what happens if 'option defconfig_list' is set on multiple symbols and print a warning in that case. - Fix get_srctree(). It would previously return "." instead of None if $srctree was unset at parse time. Somehow forgot to to test this. The code is now much more straightforward.
Diffstat (limited to 'testsuite.py')
-rw-r--r--testsuite.py32
1 files changed, 28 insertions, 4 deletions
diff --git a/testsuite.py b/testsuite.py
index f582fb0..b2f306a 100644
--- a/testsuite.py
+++ b/testsuite.py
@@ -539,8 +539,7 @@ def run_selftests():
Base directory : .
Value of $ARCH at creation time : (not set)
Value of $SRCARCH at creation time : (not set)
- Source tree (derived from $srctree;
- defaults to '.' if $srctree isn't set) : .
+ Value of $srctree at creation time : (not set)
Most recently loaded .config : (no .config loaded)
Print warnings : true
Print assignments to undefined symbols : false""")
@@ -560,8 +559,7 @@ def run_selftests():
Base directory : foobar
Value of $ARCH at creation time : foo
Value of $SRCARCH at creation time : bar
- Source tree (derived from $srctree;
- defaults to '.' if $srctree isn't set) : baz
+ Value of $srctree at creation time : baz
Most recently loaded .config : Kconfiglib/tests/empty
Print warnings : false
Print assignments to undefined symbols : true""")
@@ -1465,6 +1463,20 @@ def run_selftests():
"get_defconfig_filename() should return the existent file "
"Kconfiglib/tests/defconfig_2")
+ # Should also look relative to $srctree if the defconfig is an absolute
+ # path and not found
+
+ del os.environ["srctree"]
+ c = kconfiglib.Config("Kconfiglib/tests/Kdefconfig_srctree")
+ verify(c.get_defconfig_filename() == "Kconfiglib/tests/defconfig_2",
+ "get_defconfig_filename() returned wrong file with $srctree unset")
+
+ os.environ["srctree"] = "Kconfiglib/tests"
+ c = kconfiglib.Config("Kconfiglib/tests/Kdefconfig_srctree")
+ verify(c.get_defconfig_filename() ==
+ "Kconfiglib/tests/sub/defconfig_in_sub",
+ "get_defconfig_filename() returned wrong file with $srctree set")
+
#
# get_mainmenu_text()
#
@@ -1758,6 +1770,18 @@ def run_selftests():
# get_arch/srcarch/srctree/kconfig_filename()
#
+ del os.environ["ARCH"]
+ del os.environ["SRCARCH"]
+ del os.environ["srctree"]
+
+ c = kconfiglib.Config("Kconfiglib/tests/Kmisc", print_warnings = False)
+ arch = c.get_arch()
+ verify(arch is None, "Expected None arch, got '{}'".format(arch))
+ srcarch = c.get_srcarch()
+ verify(srcarch is None, "Expected None srcarch, got '{}'".format(srcarch))
+ srctree = c.get_srctree()
+ verify(srctree is None, "Expected None srctree, got '{}'".format(srctree))
+
os.environ["ARCH"] = "ARCH value"
os.environ["SRCARCH"] = "SRCARCH value"
os.environ["srctree"] = "srctree value"