From 54dd196a70d0d300a86ce2d64b3acffa2b72f7e3 Mon Sep 17 00:00:00 2001 From: Andre Barthel Date: Thu, 23 Jan 2025 14:23:14 +0000 Subject: [PATCH] add build ltp workflow --- .github/workflows/build-ltp.yml | 104 ++++++++++++++++++++++++++++++++ libkirk/ebclqemu.py | 36 +++++++---- 2 files changed, 129 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/build-ltp.yml diff --git a/.github/workflows/build-ltp.yml b/.github/workflows/build-ltp.yml new file mode 100644 index 0000000..9c0cc45 --- /dev/null +++ b/.github/workflows/build-ltp.yml @@ -0,0 +1,104 @@ +name: "Compile LTP Tests" +on: + schedule: + - cron: "0 0 1 * *" + workflow_dispatch: + +permissions: + contents: write # to create release + +jobs: + job: + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + include: + - container: "ghcr.io/elektrobit/ebcl_dev_container:v1.4.10" + env: + RELEASE: amd + CC: gcc + TREE: out + MAKE_INSTALL: 1 + DIR: /etc + + - container: "ghcr.io/elektrobit/ebcl_dev_container:v1.4.10" + env: + RELEASE: arm + ARCH: arm64 + CC: aarch64-linux-gnu-gcc + MAKE_INSTALL: 1 + TREE: out + VARIANT: cross-compile + DIR: /etc + + container: + image: ${{ matrix.container }} + env: ${{ matrix.env }} + options: --privileged -v/boot:/boot + + steps: + - name: Show OS + run: cat /etc/os-release + + - name: Git checkout + uses: actions/checkout@v4 + with: + repository: linux-test-project/ltp + + # INSTALL="debian", because ubuntu is a symlink to debian anyway, but for cross-compiling ther is no symling for ubuntu-cross-compile.sh to debian.. + - name: Install additional packages + run: | + INSTALL="debian" + ACTION="$VARIANT" ./ci/$INSTALL.sh + if [ "$VARIANT" ]; then ./ci/$INSTALL.$VARIANT.sh; fi + + - name: Compiler version + run: $CC --version + + - name: Autotools + run: ./build.sh -r autotools -p $DIR + + - name: Configure + run: | + if [ "$METADATA" = "asciidoc-pdf" ]; then CONFIGURE_OPT_EXTRA="--with-metadata-generator=asciidoc --enable-metadata-pdf"; fi + if [ "$METADATA" = "asciidoctor" ]; then CONFIGURE_OPT_EXTRA="--with-metadata-generator=asciidoctor"; fi + if [ "$METADATA" = "asciidoctor-pdf" ]; then CONFIGURE_OPT_EXTRA="--with-metadata-generator=asciidoctor --enable-metadata-pdf"; fi + case "$VARIANT" in cross-compile*) BUILD="cross";; i386) BUILD="32";; *) BUILD="native";; esac + CONFIGURE_OPT_EXTRA="$CONFIGURE_OPT_EXTRA" ./build.sh -r configure -o ${TREE:-in} -t $BUILD -c $CC -p $DIR + + - name: Compile + run: ./build.sh -r build -o ${TREE:-in} -p $DIR + + - name: Test C API + run: | + case "$VARIANT" in cross-compile*) BUILD="cross";; i386) BUILD="32";; *) BUILD="native";; esac + ./build.sh -r test-c -o ${TREE:-in} -t $BUILD + + - name: Test shell API + run: | + case "$VARIANT" in cross-compile*) BUILD="cross";; i386) BUILD="32";; *) BUILD="native";; esac + ./build.sh -r test-shell -o ${TREE:-in} -t $BUILD + + - name: Test shell loader + run: | + case "$VARIANT" in cross-compile*) BUILD="cross";; i386) BUILD="32";; *) BUILD="native";; esac + ./build.sh -r test-shell-loader -o ${TREE:-in} -t $BUILD + + - name: Install + run: | + if [ "$MAKE_INSTALL" = 1 ]; then INSTALL_OPT="-i"; fi + ./build.sh -r install -o ${TREE:-in} -p $DIR $INSTALL_OPT + + - name: Compress + run: | + tar -czvf ltp-${{ matrix.env.release }}.tar.gz /etc/opt/ltp + + - name: Release + uses: softprops/action-gh-release@v2 + with: + files: ./ltp.tar.gz + make_latest: false + tag_name: ${{ matrix.env.release }}-${{ env.release_version }} + name: LTP Compiled Binares for ${{ matrix.env.release }} \ No newline at end of file diff --git a/libkirk/ebclqemu.py b/libkirk/ebclqemu.py index 023d867..9ca3b4b 100644 --- a/libkirk/ebclqemu.py +++ b/libkirk/ebclqemu.py @@ -1,12 +1,24 @@ +""" +.. module:: ebclqemu + :platform: Linux + :synopsis: module containing qemu SUT implementation + +.. moduleauthor:: Andre Barthel +""" import os +from logging import getLogger from libkirk.sut import IOBuffer # from typing import override (Not working for SDK [Python 3.10 < 3.12]) from libkirk.qemu import QemuSUT from libkirk.sut import SUTError -from logging import getLogger class EbclQemuSUT(QemuSUT): - + """ + EbclQemu SUT spawn a new VM using qemu and execute commands inside it. + This SUT implementation can be used to run commands inside + a protected, virtualized environment. Implements further QEMU + customization. + """ def __init__(self): super().__init__() self._logger = getLogger("kirk.ebclqemu") @@ -15,7 +27,7 @@ def __init__(self): self._machine = None self._system = None self._cpu = None - + def setup(self, **kwargs): super().setup(**kwargs) self._user = kwargs.get("user", "root") @@ -26,12 +38,13 @@ def setup(self, **kwargs): self._machine = kwargs.get("machine", "") self._system = kwargs.get("system", "") self._cpu = kwargs.get("cpu", "") - + if self._system == "aarch64": if not self._cpu or not self._machine: raise SUTError( - f"For aarch64 machine (\"{self._machine}\") and cpu (\"{self._cpu}\") parameters must be set!") - + f"For aarch64 machine (\"{self._machine}\") \ + and cpu (\"{self._cpu}\") parameters must be set!") + # @override # Reason: Fit the QEMU commands better to our needs and enable arguments for kernel_append @property @@ -54,7 +67,7 @@ def config_help(self) -> dict: "format": "Image format (default: 'raw')", "options": "user defined options", } - + # @override # Reason: Fit the QEMU commands better to our needs and enable arguments for kernel_append def _get_command(self) -> str: @@ -95,7 +108,7 @@ def _get_command(self) -> str: if self._system == "aarch64" and self._cpu and self._machine: params.append(f"-machine {self._machine} -cpu {self._cpu}") - + if self._image: params.append(f"-drive if=virtio,cache=unsafe,file={self._image},format={self._format}") @@ -123,12 +136,13 @@ def _get_command(self) -> str: def name(self) -> str: return "ebclqemu" -# @override -# Reason: SDK Setup inserts copy/paste support ANSI characters, remove them from super's return set +# @override +# Reason: SDK Setup inserts copy/paste support ANSI characters, +# remove them from super's return set async def _exec(self, command: str, iobuffer: IOBuffer) -> set: """ Execute a command and return set(stdout, retcode, exec_time) without ANSI escape sequences. - """ + """ stdout, retcode, exec_time = await super()._exec(command, iobuffer) # Strip ANSI escape sequences from the stdout if stdout is not None: