tests: add a new unit test to verify the arch override
authorAndrea Righi <andrea.righi@canonical.com>
Tue, 12 Dec 2023 16:03:52 +0000 (17:03 +0100)
committerAndrea Righi <andrea.righi@canonical.com>
Tue, 12 Dec 2023 16:03:52 +0000 (17:03 +0100)
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
tests/data/annotations.override.1 [new file with mode: 0644]
tests/data/annotations.override.1.result [new file with mode: 0644]
tests/data/annotations.override.2 [new file with mode: 0644]
tests/test_override.py [new file with mode: 0644]

diff --git a/tests/data/annotations.override.1 b/tests/data/annotations.override.1
new file mode 100644 (file)
index 0000000..47f0964
--- /dev/null
@@ -0,0 +1,9 @@
+# Menu: HEADER
+# FORMAT: 4
+# ARCH: arm64 armhf
+# FLAVOUR: arm64-raspi armhf-raspi
+# FLAVOUR_DEP: {'arm64-raspi': 'arm64-generic', 'armhf-raspi': 'armhf-generic-lpae'}
+
+include "annotations.override.2"
+
+CONFIG_SND_TRIDENT                              policy<{'arm64': '-', 'armhf': '-'}> note<'Pi specific (not availble on Pi)'>
diff --git a/tests/data/annotations.override.1.result b/tests/data/annotations.override.1.result
new file mode 100644 (file)
index 0000000..b25e305
--- /dev/null
@@ -0,0 +1,28 @@
+{
+  "arch": [
+    "arm64",
+    "armhf"
+  ],
+  "flavour": [
+    "arm64-raspi",
+    "armhf-raspi"
+  ],
+  "flavour_dep": {
+    "arm64-raspi": "arm64-generic",
+    "armhf-raspi": "armhf-generic-lpae"
+  },
+  "include": [
+    "annotations.override.2"
+  ],
+  "config": {
+    "CONFIG_SND_TRIDENT": {
+      "policy": {
+        "amd64": "m",
+        "i386": "m",
+        "arm64": "-",
+        "armhf": "-"
+      },
+      "note": "'Pi specific (not availble on Pi)'"
+    }
+  }
+}
diff --git a/tests/data/annotations.override.2 b/tests/data/annotations.override.2
new file mode 100644 (file)
index 0000000..dfdf2cb
--- /dev/null
@@ -0,0 +1,6 @@
+# Menu: HEADER
+# FORMAT: 4
+# ARCH: amd64 arm64 armhf i386 ppc64el s390x
+# FLAVOUR: amd64-generic amd64-lowlatency arm64-generic armhf-generic armhf-generic-lpae i386-generic i386-lowlatency ppc64el-generic s390x-generic
+
+CONFIG_SND_TRIDENT                              policy<{'amd64': 'm', 'armhf-generic-lpae': 'm', 'i386': 'm'}>
diff --git a/tests/test_override.py b/tests/test_override.py
new file mode 100644 (file)
index 0000000..3ec180e
--- /dev/null
@@ -0,0 +1,15 @@
+import unittest
+
+from tests import utils
+
+from kconfig.annotations import Annotation
+
+
+class TestLoadAnnotations(unittest.TestCase):
+    def test_load(self):
+        for d in ("annotations.override.1",):
+            f = "tests/data/" + d
+            a = Annotation(f)
+            print(utils.to_dict(a))
+            r = utils.load_json(f + ".result")
+            self.assertEqual(utils.to_dict(a), r)