Browse Source

confserver: In protocol V2, a "load" should only send back changes not all items

Angus Gratton 7 years ago
parent
commit
ec4c75b692

+ 1 - 0
tools/kconfig_new/README.md

@@ -97,3 +97,4 @@ These error messages are intended to be human readable, not machine parseable.
 ### Protocol Version Changes
 
 * V2: Added the `visible` key to the response. Invisible items are no longer represented as having value null.
+* V2: `load` now sends changes compared to values before the load, not the whole list of config items.

+ 8 - 4
tools/kconfig_new/confserver.py

@@ -84,10 +84,14 @@ def run_server(kconfig, sdkconfig, default_version=MAX_PROTOCOL_VERSION):
         before_ranges = get_ranges(config)
         before_visible = get_visible(config)
 
-        if "load" in req:  # if we're loading a different sdkconfig, response should have all items in it
-            before = {}
-            before_ranges = {}
-            before_visible = {}
+        if "load" in req:  # load a new sdkconfig
+
+            if req.get("version", default_version) == 1:
+                # for V1 protocol, send all items when loading new sdkconfig.
+                # (V2+ will only send changes, same as when setting an item)
+                before = {}
+                before_ranges = {}
+                before_visible = {}
 
             # if no new filename is supplied, use existing sdkconfig path, otherwise update the path
             if req["load"] is None:

+ 7 - 5
tools/kconfig_new/test/test_confserver.py

@@ -64,11 +64,6 @@ def main():
 
         test_load_save(p, temp_sdkconfig_path)
 
-        p.send("%s\n" % json.dumps({"version": 2, "load": temp_sdkconfig_path}))
-        load_result = expect_json(p)
-        print("Load result: %s" % (json.dumps(load_result)))
-        assert len(load_result["values"]) > 0  # loading same file should return all config items
-        assert len(load_result["ranges"]) > 0
         print("Done. All passed.")
 
     finally:
@@ -133,6 +128,13 @@ def test_load_save(p, temp_sdkconfig_path):
     after = os.stat(temp_sdkconfig_path).st_mtime
     assert after > before  # something got written to disk
 
+    # Do a V2 load
+    load_result = send_request(p, {"version": 2, "load": temp_sdkconfig_path})
+    print("V2 Load result: %s" % (json.dumps(load_result)))
+    assert "error" not in load_result
+    assert len(load_result["values"]) == 0  # in V2, loading same file should return no config items
+    assert len(load_result["ranges"]) == 0
+
     # Do a V1 load
     load_result = send_request(p, {"version": 1, "load": temp_sdkconfig_path})
     print("V1 Load result: %s" % (json.dumps(load_result)))