From 0e6cd82908f5c649e15e6a63ad77a94f627449d2 Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Fri, 2 Nov 2018 02:35:49 +0100 Subject: Fix removal of multiple consecutive 'if' nodes Despite 'if' nodes being flattened before 'if' removal, consecutive 'if' nodes can still show up for code like the following: ... if X endif if X endif ... _remove_ifs() failed to remove the second 'if' node, leading to a crash e.g. when turning on show-all mode in the menuconfig in a menu with such code (due to the unexpected 'if' node). Stuff like the above could potentially result from 'osource's with no matches, though I just spotted the error while looking over the code. Fix the 'if' removal logic to properly handle consecutive 'if' nodes. --- testsuite.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'testsuite.py') diff --git a/testsuite.py b/testsuite.py index cca5dad..6f05b6a 100644 --- a/testsuite.py +++ b/testsuite.py @@ -2212,6 +2212,25 @@ CONFIG_G=-1 verify_is_normal_choice_symbol("WS9") + print("Testing 'if' node removal") + + c = Kconfig("Kconfiglib/tests/Kifremoval", warn=False) + + nodes = [node for node in c.node_iter()] + verify_equal(nodes[0].item.name, "A") + verify_equal(nodes[1].item.name, "B") + verify_equal(nodes[2].item.name, "C") + verify_equal(nodes[3].item.name, "D") + verify_equal(nodes[4].prompt[0], "E") + verify_equal(nodes[5].prompt[0], "F") + verify_equal(nodes[6].prompt[0], "G") + verify_equal(nodes[7].item.name, "H") + verify_equal(nodes[8].item.name, "I") + verify_equal(nodes[9].item.name, "J") + verify(len(nodes) == 10, + "Wrong number of nodes after 'if' removal") + + print("Testing multi.def. property copying") c = Kconfig("Kconfiglib/tests/Kdepcopy", warn=False) -- cgit v1.2.3