--- /dev/null
+# Menu: HEADER
+# FORMAT: 4
+# ARCH: amd64 armhf
+# FLAVOUR: amd64-foo amd64-bar armhf-foo armhf-bar
+
+CONFIG_A_1 policy<{'amd64': '1', 'armhf': '1'}> note<Config A_1>
+CONFIG_B_2 policy<{'amd64': '2', 'armhf': '2'}> note<Config B_2>
--- /dev/null
+{
+ "arch": ["amd64", "armhf"],
+ "flavour": ["amd64-foo", "amd64-bar", "armhf-foo", "armhf-bar"],
+ "config": {
+ "CONFIG_A_1": {
+ "policy": {"amd64": "1", "armhf": "1"},
+ "note": "'Config A_1'"
+ },
+ "CONFIG_B_2": {
+ "policy": {"amd64": "2", "armhf": "2"},
+ "note": "'Config B_2'"
+ }
+ }
+}
--- /dev/null
+# Menu: HEADER
+# FORMAT: 4
+# ARCH: amd64 arm64
+# FLAVOUR: amd64-gcp arm64-gcp
+# FLAVOUR_DEP: {'amd64-gcp': 'amd64-generic', 'arm64-gcp': 'arm64-generic'}
+
+include "annotations.todo-note.main"
+
+CONFIG_ACCESSIBILITY policy<{'amd64': 'y', 'arm64': 'y'}>
--- /dev/null
+{
+ "arch": [
+ "amd64",
+ "arm64"
+ ],
+ "flavour": [
+ "amd64-gcp",
+ "arm64-gcp"
+ ],
+ "flavour_dep": {
+ "amd64-gcp": "amd64-generic",
+ "arm64-gcp": "arm64-generic"
+ },
+ "include": [
+ "annotations.todo-note.main"
+ ],
+ "config": {
+ "CONFIG_ACCESSIBILITY": {
+ "policy": {
+ "amd64": "y",
+ "arm64": "y",
+ "amd64-gcp": "n"
+ },
+ "note": "TODO: update note"
+ }
+ }
+}
--- /dev/null
+# Menu: HEADER
+# FORMAT: 4
+# ARCH: amd64 arm64 armhf ppc64el riscv64 s390x
+# FLAVOUR: amd64-generic arm64-generic arm64-generic-64k armhf-generic armhf-generic-lpae ppc64el-generic riscv64-generic s390x-generic
+
+CONFIG_ACCESSIBILITY policy<{'amd64': 'y', 'arm64': 'y'}>
+CONFIG_ACCESSIBILITY note<'this config must be enabled'>
--- /dev/null
+# CONFIG_ACCESSIBILITY is not set
--- /dev/null
+import unittest
+
+from tests import utils
+
+from kconfig.annotations import Annotation
+
+
+class TestLoadAnnotations(unittest.TestCase):
+ def test_load(self):
+ for d in ("annotations.load.1",):
+ f = "tests/data/" + d
+ a = Annotation(f)
+ r = utils.load_json(f + ".result")
+ self.assertEqual(utils.to_dict(a), r)
--- /dev/null
+import unittest
+import json
+
+from tests import utils
+
+from kconfig.annotations import Annotation, KConfig
+
+
+class TestTodoNote(unittest.TestCase):
+ def test_todo(self):
+ a = Annotation("tests/data/annotations.todo-note.1")
+ c = KConfig("tests/data/config.todo-note.1")
+ a.update(c, arch="amd64", flavour="gcp")
+ print(json.dumps(utils.to_dict(a)))
+ r = utils.load_json("tests/data/annotations.todo-note.1.result")
+ self.assertEqual(utils.to_dict(a), r)
--- /dev/null
+import json
+
+
+def to_dict(a):
+ """Return relevant data from an annotatios object as a dict"""
+ data = {}
+
+ if a.arch:
+ data["arch"] = a.arch
+ if a.flavour:
+ data["flavour"] = a.flavour
+ if a.flavour_dep:
+ data["flavour_dep"] = a.flavour_dep
+ if a.include:
+ data["include"] = a.include
+ if a.config:
+ config = dict(a.config)
+ for _, val in config.items():
+ # Weed out internal "oneline" keys
+ if "oneline" in val:
+ del val["oneline"]
+ data["config"] = config
+
+ return data
+
+
+def load_json(d):
+ """Return JSON file content"""
+ with open(d, encoding="utf-8") as fh:
+ return json.load(fh)