Skip to content

Commit

Permalink
add build ltp workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
wintron04 committed Jan 23, 2025
1 parent bbefaab commit 54dd196
Show file tree
Hide file tree
Showing 2 changed files with 129 additions and 11 deletions.
104 changes: 104 additions & 0 deletions .github/workflows/build-ltp.yml
Original file line number Diff line number Diff line change
@@ -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 }}
36 changes: 25 additions & 11 deletions libkirk/ebclqemu.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
"""
.. module:: ebclqemu
:platform: Linux
:synopsis: module containing qemu SUT implementation
.. moduleauthor:: Andre Barthel <[email protected]>
"""
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")
Expand All @@ -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")
Expand All @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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}")

Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 54dd196

Please sign in to comment.