[2/3] CI: Add make world test case

Message ID 20250512083238.2089774-3-amikan@ilbers.de
State Under Review
Headers show
Series Add 'make world' test case | expand

Commit Message

Anton Mikanovich May 12, 2025, 8:32 a.m. UTC
Add test case which builds all available targets.

Single bitbake usage (directly from mc.conf):
$ avocado run testsuite/citest.py -t world

Multiple bitbakes usage (from generated yaml file):
$ avocado run testsuite/citest.py -t world -m testsuite/data/targets.yml

Or the same with ci_build.sh:

There is also a script to regenerate yaml from mc.conf:
$ ./testsuite/utils/targets_gen.py

This test case requires avocado-framework-plugin-varianter-yaml-to-mux.

Signed-off-by: Anton Mikanovich <amikan@ilbers.de>
---
 .gitignore                 |   2 +-
 scripts/ci_build.sh        |   8 ++-
 testsuite/citest.py        |  33 ++++++++++
 testsuite/data/targets.yml | 132 +++++++++++++++++++++++++++++++++++++
 testsuite/targets_gen.py   |  13 ++++
 testsuite/utils.py         |  35 +++++++++-
 6 files changed, 220 insertions(+), 3 deletions(-)
 create mode 100644 testsuite/data/targets.yml
 create mode 100755 testsuite/targets_gen.py

Patch

diff --git a/.gitignore b/.gitignore
index 81c09fc1..fff155f1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,4 +3,4 @@ 
 __pycache__
 .config.yaml*
 .kas_shell_history
-build/
+build*
diff --git a/scripts/ci_build.sh b/scripts/ci_build.sh
index 338557ad..690dadd4 100755
--- a/scripts/ci_build.sh
+++ b/scripts/ci_build.sh
@@ -23,6 +23,7 @@  if ! command -v avocado > /dev/null; then
     # shellcheck source=/dev/null
     source /tmp/avocado_venv/bin/activate
     pip install avocado-framework==103.0
+    pip install avocado-framework-plugin-varianter-yaml-to-mux==103.0
 fi
 
 # Get Avocado build tests path
@@ -49,6 +50,7 @@  show_help() {
     echo "    -b, --base BASE_DIR      set path to base directory. If not set,"
     echo "                             the tests will be started in current path."
     echo "    -d, --debug              enable debug bitbake output."
+    echo "    -m, --muxfile            input file for yaml-to-mux plugin."
     echo "    -T, --tags               specify basic avocado tags."
     echo "    --help                   display this message and exit."
     echo
@@ -94,6 +96,10 @@  do
         NORUN="1"
         echo "warning: deprecated parameter '$key', consider using '-T <TAG>,-startvm' instead"
         ;;
+    -m|--muxfile)
+        MUXFILE="-m $2"
+        shift
+        ;;
     -t|--timeout)
         TIMEOUT="-p time_to_wait=$2"
         shift
@@ -149,7 +155,7 @@  set -x
 
 avocado ${VERBOSE} run "${TESTSUITE_DIR}/citest.py" \
     -t "${TAGS}" --max-parallel-tasks=1 --disable-sysinfo \
-    ${SSTATE} ${TIMEOUT} \
+    ${SSTATE} ${MUXFILE} ${TIMEOUT} \
     || ret=$?
 
 python3 ${TESTSUITE_DIR}/cleanup.py
diff --git a/testsuite/citest.py b/testsuite/citest.py
index 9f18a51f..501dbf37 100755
--- a/testsuite/citest.py
+++ b/testsuite/citest.py
@@ -1,4 +1,10 @@ 
 #!/usr/bin/env python3
+#
+# This software is a part of ISAR.
+# Copyright (C) 2022-2025 ilbers GmbH
+# Copyright (C) 2022-2025 Siemens AG
+#
+# SPDX-License-Identifier: MIT
 
 from avocado import skipUnless
 from avocado.core import exceptions
@@ -734,3 +740,30 @@  class VmBootTestFull(CIBaseTest):
         self.init()
         self.vm_start('amd64-iso', 'bookworm', image='isar-image-ci',
                       script='test_system_running.sh 30')
+
+
+class World(CIBaseTest):
+
+    """
+    All targets build test
+
+    :avocado: tags=world
+    """
+
+    def test_world(self):
+        name = self.params.get('name')
+        image = self.params.get('image', default='isar-image-ci')
+        targets = []
+
+        if name is None:
+            self.init()
+            for target in CIUtils.get_targets():
+                for image in CIUtils.get_test_images():
+                    targets.append(f'mc:{target}:{image}')
+        else:
+            targets.append(f'mc:{name}:{image}')
+            self.init(f'build-{name}')
+
+        self.perform_build_test(
+            targets, container=name and name.startswith('container')
+        )
diff --git a/testsuite/data/targets.yml b/testsuite/data/targets.yml
new file mode 100644
index 00000000..5c9b5196
--- /dev/null
+++ b/testsuite/data/targets.yml
@@ -0,0 +1,132 @@ 
+a: !mux
+  qemuarm-buster:
+    name: qemuarm-buster
+  qemuarm-bullseye:
+    name: qemuarm-bullseye
+  qemuarm-bookworm:
+    name: qemuarm-bookworm
+  qemuarm-trixie:
+    name: qemuarm-trixie
+  qemuarm64-buster:
+    name: qemuarm64-buster
+  qemuarm64-bullseye:
+    name: qemuarm64-bullseye
+  qemuarm64-bookworm:
+    name: qemuarm64-bookworm
+  qemuarm64-trixie:
+    name: qemuarm64-trixie
+  qemui386-buster:
+    name: qemui386-buster
+  qemui386-bullseye:
+    name: qemui386-bullseye
+  qemui386-bookworm:
+    name: qemui386-bookworm
+  qemuamd64-buster:
+    name: qemuamd64-buster
+  qemuamd64-bullseye:
+    name: qemuamd64-bullseye
+  qemuamd64-sb-bullseye:
+    name: qemuamd64-sb-bullseye
+  qemuamd64-bookworm:
+    name: qemuamd64-bookworm
+  qemuamd64-cip-bookworm:
+    name: qemuamd64-cip-bookworm
+  qemuamd64-iso-bookworm:
+    name: qemuamd64-iso-bookworm
+  qemuamd64-trixie:
+    name: qemuamd64-trixie
+  container-amd64-buster:
+    name: container-amd64-buster
+  container-amd64-bullseye:
+    name: container-amd64-bullseye
+  container-amd64-bookworm:
+    name: container-amd64-bookworm
+  qemumipsel-bullseye:
+    name: qemumipsel-bullseye
+  qemumipsel-bookworm:
+    name: qemumipsel-bookworm
+  qemuriscv64-trixie:
+    name: qemuriscv64-trixie
+  bananapi-buster:
+    name: bananapi-buster
+  bananapi-bullseye:
+    name: bananapi-bullseye
+  bananapi-bookworm:
+    name: bananapi-bookworm
+  beagleplay-bookworm:
+    name: beagleplay-bookworm
+  de0-nano-soc-buster:
+    name: de0-nano-soc-buster
+  de0-nano-soc-bullseye:
+    name: de0-nano-soc-bullseye
+  de0-nano-soc-bookworm:
+    name: de0-nano-soc-bookworm
+  hikey-bullseye:
+    name: hikey-bullseye
+  hikey-bookworm:
+    name: hikey-bookworm
+  imx6-sabrelite-buster:
+    name: imx6-sabrelite-buster
+  imx6-sabrelite-bullseye:
+    name: imx6-sabrelite-bullseye
+  phyboard-mira-bullseye:
+    name: phyboard-mira-bullseye
+  phyboard-mira-bookworm:
+    name: phyboard-mira-bookworm
+  nanopi-neo-buster:
+    name: nanopi-neo-buster
+  nanopi-neo-bullseye:
+    name: nanopi-neo-bullseye
+  nanopi-neo-bookworm:
+    name: nanopi-neo-bookworm
+  nanopi-neo-efi-bookworm:
+    name: nanopi-neo-efi-bookworm
+  stm32mp15x-bullseye:
+    name: stm32mp15x-bullseye
+  virtualbox-bullseye:
+    name: virtualbox-bullseye
+  virtualbox-bookworm:
+    name: virtualbox-bookworm
+  x86-pc-bookworm:
+    name: x86-pc-bookworm
+  rpi-arm-bullseye:
+    name: rpi-arm-bullseye
+  rpi-arm-bookworm:
+    name: rpi-arm-bookworm
+  rpi-arm-v7-bullseye:
+    name: rpi-arm-v7-bullseye
+  rpi-arm-v7-bookworm:
+    name: rpi-arm-v7-bookworm
+  rpi-arm-v7l-bullseye:
+    name: rpi-arm-v7l-bullseye
+  rpi-arm-v7l-bookworm:
+    name: rpi-arm-v7l-bookworm
+  rpi-arm64-v8-bullseye:
+    name: rpi-arm64-v8-bullseye
+  rpi-arm64-v8-bookworm:
+    name: rpi-arm64-v8-bookworm
+  sifive-fu540-trixie:
+    name: sifive-fu540-trixie
+  starfive-visionfive2-trixie:
+    name: starfive-visionfive2-trixie
+  qemuarm64-focal:
+    name: qemuarm64-focal
+  qemuarm64-jammy:
+    name: qemuarm64-jammy
+  qemuarm64-noble:
+    name: qemuarm64-noble
+  qemuamd64-focal:
+    name: qemuamd64-focal
+  qemuamd64-jammy:
+    name: qemuamd64-jammy
+  qemuamd64-noble:
+    name: qemuamd64-noble
+  qemuamd64-sid:
+    name: qemuamd64-sid
+  qemuarm64-sid:
+    name: qemuarm64-sid
+b: !mux
+  base:
+    image: isar-image-base
+  ci:
+    image: isar-image-ci
diff --git a/testsuite/targets_gen.py b/testsuite/targets_gen.py
new file mode 100755
index 00000000..41b4d644
--- /dev/null
+++ b/testsuite/targets_gen.py
@@ -0,0 +1,13 @@ 
+#!/usr/bin/env python3
+
+"""
+# This software is a part of Isar.
+# Copyright (C) 2025 ilbers GmbH
+
+# targets_gen.py: Generates yaml for yaml-to-mux Avocado varianter plugin.
+"""
+
+from utils import CIUtils
+
+if __name__ == "__main__":
+    CIUtils.gen_targets_yaml()
diff --git a/testsuite/utils.py b/testsuite/utils.py
index ffcb5cc7..9b18999b 100755
--- a/testsuite/utils.py
+++ b/testsuite/utils.py
@@ -1,4 +1,9 @@ 
 #!/usr/bin/env python3
+#
+# This software is a part of ISAR.
+# Copyright (C) 2024-2025 ilbers GmbH
+#
+# SPDX-License-Identifier: MIT
 
 import os
 import sys
@@ -10,8 +15,10 @@  sys.path.append(os.path.join(os.path.dirname(__file__), '../bitbake/lib'))
 import bb
 import bb.tinfoil
 
+isar_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
 
-class CIUtils():
+
+class CIUtils:
     @staticmethod
     def getVars(*vars, target=None):
         def fixStream(stream):
@@ -53,3 +60,29 @@  class CIUtils():
             return tar.getnames()
         except Exception:
             return []
+
+    @staticmethod
+    def get_test_images():
+        return ['isar-image-base', 'isar-image-ci']
+
+    @staticmethod
+    def get_targets():
+        d = bb.data.init()
+        d.setVar('BBPATH', os.path.join(isar_root, 'meta-isar'))
+        d = bb.cookerdata.parse_config_file('conf/mc.conf', d, False)
+        return d.getVar('BBMULTICONFIG').split()
+
+    @staticmethod
+    def gen_targets_yaml(fn='targets.yml'):
+        targetsfile = os.path.join(os.path.dirname(__file__), 'data', fn)
+        with open(targetsfile, 'w') as f:
+            f.write('a: !mux\n')
+            for target in CIUtils.get_targets():
+                f.write(f'  {target}:\n    name: {target}\n')
+            f.write('b: !mux\n')
+            prefix = 'isar-image-'
+            for image in CIUtils.get_test_images():
+                nodename = image
+                if image.startswith(prefix):
+                    nodename = image[len(prefix):]
+                f.write(f'  {nodename}:\n    image: {image}\n')