Skip to content

Commit

Permalink
Add build-scx-selftests action
Browse files Browse the repository at this point in the history
  • Loading branch information
theihor committed Oct 18, 2024
1 parent f605c62 commit 5d8a423
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 0 deletions.
1 change: 1 addition & 0 deletions build-linux/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ cat_kernel_config() {
cat ${GITHUB_WORKSPACE}/tools/testing/selftests/bpf/config \
${GITHUB_WORKSPACE}/tools/testing/selftests/bpf/config.vm \
${GITHUB_WORKSPACE}/tools/testing/selftests/bpf/config.${TARGET_ARCH} \
${GITHUB_WORKSPACE}/tools/testing/selftests/sched_ext/config \
${GITHUB_WORKSPACE}/ci/vmtest/configs/config \
${GITHUB_WORKSPACE}/ci/vmtest/configs/config.${TARGET_ARCH} 2> /dev/null > "${1}"
}
Expand Down
20 changes: 20 additions & 0 deletions build-scx-selftests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Build selftests/sched_ext

This action builds selftests/sched_ext given a kernel build
output. Kernel build configuration is supposed to include necessary
flags (i.e. `tools/testing/selftests/sched_ext/config`).

The action is expected to be executed by a workflow with access to the
Linux kernel repository.

## Required inputs

* `kbuild-output` - Path to the kernel build output.
* `repo-root` - Path to the root of the Linux kernel repository.
* `arch` - Kernel build architecture.
* `toolchain` - Toolchain name: `gcc` (default) or `llvm`.

## Optional inputs
* `llvm-version` - LLVM version, used when `toolchain` is `llvm`. Default: `16`.
* `max-make-jobs` - Maximum number of jobs to use when running make (e.g argument to -j). Default: 4*nproc.

34 changes: 34 additions & 0 deletions build-scx-selftests/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: 'Build selftests/sched_ext'
inputs:
kbuild-output:
description: 'Path to the kernel build output'
required: true
repo-root:
description: "Path to the root of the kernel repository"
required: true
arch:
description: 'arch'
required: true
toolchain:
description: 'gcc or llvm'
default: 'gcc'
required: true
llvm-version:
description: 'llvm version'
required: false
default: '16'
max-make-jobs:
description: 'Maximum number of jobs to use when running make (e.g argument to -j). Default: 4*nproc'
default: ''

runs:
using: "composite"
steps:
- name: Build selftests/sched_ext
env:
KBUILD_OUTPUT: ${{ inputs.kbuild-output }}
MAX_MAKE_JOBS: ${{ inputs.max-make-jobs }}
REPO_ROOT: ${{ inputs.repo-root || github.workspace }}
shell: bash
run:
${GITHUB_ACTION_PATH}/build.sh "${{ inputs.arch }}" "${{ inputs.toolchain }}" "${{ inputs.llvm-version }}"
45 changes: 45 additions & 0 deletions build-scx-selftests/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash

set -euo pipefail

source "${GITHUB_ACTION_PATH}/../helpers.sh"

TARGET_ARCH=$1
TOOLCHAIN=$2
LLVM_VERSION=$3

ARCH="$(platform_to_kernel_arch ${TARGET_ARCH})"
CROSS_COMPILE=""

if [[ "${TARGET_ARCH}" != "$(uname -m)" ]]
then
CROSS_COMPILE="${TARGET_ARCH}-linux-gnu-"
fi

if [[ $TOOLCHAIN = "llvm" ]]; then
export LLVM="-$LLVM_VERSION"
TOOLCHAIN="llvm-$LLVM_VERSION"
fi

foldable start build_selftests "Building selftests/sched_ext with $TOOLCHAIN"

MAKE_OPTS=$(cat <<EOF
ARCH=${ARCH}
CROSS_COMPILE=${CROSS_COMPILE}
CLANG=clang-${LLVM_VERSION}
LLC=llc-${LLVM_VERSION}
LLVM_STRIP=llvm-strip-${LLVM_VERSION}
VMLINUX_BTF=${KBUILD_OUTPUT}/vmlinux
EOF
)
SELF_OPTS=$(cat <<EOF
-C ${REPO_ROOT}/tools/testing/selftests/sched_ext
EOF
)

cd ${REPO_ROOT}
make ${MAKE_OPTS} ${SELF_OPTS} clean
make ${MAKE_OPTS} ${SELF_OPTS} -j $(kernel_build_make_jobs)

foldable end build_selftests

0 comments on commit 5d8a423

Please sign in to comment.