summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kconfiglib.py6
-rw-r--r--tests/Korder35
-rw-r--r--testsuite.py33
3 files changed, 72 insertions, 2 deletions
diff --git a/kconfiglib.py b/kconfiglib.py
index a01df27..fd114ea 100644
--- a/kconfiglib.py
+++ b/kconfiglib.py
@@ -1020,7 +1020,8 @@ class Kconfig(object):
for sym in self._defined_syms_set:
sym._written = False
- for sym in self._defined_syms_set:
+ # Using 'defined_syms' gives us the same order as in .config files
+ for sym in self.defined_syms:
if not sym._written:
sym._written = True
# Note: _write_to_conf is determined when the value is
@@ -1151,7 +1152,8 @@ class Kconfig(object):
for sym in self._defined_syms_set:
sym._written = False
- for sym in self._defined_syms_set:
+ # Using 'defined_syms' gives us the same order as in .config files
+ for sym in self.defined_syms:
if not sym._written:
sym._written = True
diff --git a/tests/Korder b/tests/Korder
new file mode 100644
index 0000000..3a8dffa
--- /dev/null
+++ b/tests/Korder
@@ -0,0 +1,35 @@
+config O
+ int "O"
+ default 0
+
+config R
+ int "R"
+ default 1
+
+config D
+ int "D"
+ default 2
+
+config E
+ int "E"
+ default 3
+
+# Defined twice
+config R
+ int "R"
+
+config R2
+ int "R2"
+ default 4
+
+config I
+ int "I"
+ default 5
+
+config N
+ int "N"
+ default 6
+
+config G
+ int "G"
+ default 7
diff --git a/testsuite.py b/testsuite.py
index cddce68..d9923cf 100644
--- a/testsuite.py
+++ b/testsuite.py
@@ -1764,6 +1764,39 @@ g
c.load_config("Kconfiglib/tests/config_indented")
verify_value("IGNOREME", "y")
+ # Symbol order should match definition order in headers
+
+ c = Kconfig("Kconfiglib/tests/Korder")
+
+ c.write_config(config_test_file, header="")
+ verify_file_contents(config_test_file, """
+CONFIG_O=0
+CONFIG_R=1
+CONFIG_D=2
+CONFIG_E=3
+CONFIG_R2=4
+CONFIG_I=5
+CONFIG_N=6
+CONFIG_G=7
+"""[1:])
+
+ # Differs from defaults
+ c.syms["O"].set_value("-1")
+ c.syms["R"].set_value("-1")
+ c.syms["E"].set_value("-1")
+ c.syms["R2"].set_value("-1")
+ c.syms["N"].set_value("-1")
+ c.syms["G"].set_value("-1")
+ c.write_min_config(config_test_file, header="")
+ verify_file_contents(config_test_file, """
+CONFIG_O=-1
+CONFIG_R=-1
+CONFIG_E=-1
+CONFIG_R2=-1
+CONFIG_N=-1
+CONFIG_G=-1
+"""[1:])
+
print("Testing Kconfig fetching and separation")