Skip to content

Commit

Permalink
build-selftests: v2 of the action inputs
Browse files Browse the repository at this point in the history
Changes in action inputs:
  * kernel-root is now a required input
  * kernel, kbuild-output and max-make-jobs are removed

kernel-root input is required, because to build selftests
one must to clone a kernel source tree first.

The build script behavior can be directed more granularly with env
variables:
  * KBUILD_OUTPUT now defaults to the kernel-root
  * VMLINUX_BTF now can be set externally
  * MAX_MAKE_JOBS can be set as env variable if desired

Preparation script logic is removed: the rationale is that the caller
is responsible for setting up required environment before building.

Signed-off-by: Ihor Solodrai <ihor.solodrai@pm.me>
  • Loading branch information
theihor committed Nov 13, 2024
1 parent e67a7e4 commit 0af20a5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 30 deletions.
33 changes: 13 additions & 20 deletions build-selftests/action.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,27 @@
name: 'build selftests'
description: 'Build BPF selftests'
inputs:
kernel:
description: 'kernel version'
default: 'LATEST'
toolchain:
description: 'what toolchain to use'
default: 'gcc'
kbuild-output:
description: 'relative or absolute path to use for storing build artifacts'
arch:
description: 'arch'
required: true
kernel-root:
description: 'Path to the root of the kernel source tree'
required: true
max-make-jobs:
description: 'Maximum number of jobs to use when running make (e.g argument to -j). Default: 4*nproc'
default: ''
llvm-version:
description: 'llvm version'
required: false
default: '16'
arch:
description: 'arch'
required: true
default: '18'
toolchain:
description: 'gcc or llvm'
default: 'gcc'

runs:
using: "composite"
steps:
- name: build selftests
shell: bash
run: |
kbuild_output="$(realpath ${{ inputs.kbuild-output }})"
export LLVM_VERSION=${{ inputs.llvm-version }}
${GITHUB_ACTION_PATH}/build_selftests.sh "${{ inputs.arch }}" "${{ inputs.kernel }}" "${{ inputs.toolchain }}" "${kbuild_output}"
env:
MAX_MAKE_JOBS: ${{ inputs.max-make-jobs }}
LLVM_VERSION: ${{ inputs.llvm-version }}
run: |
${GITHUB_ACTION_PATH}/build_selftests.sh "${{ inputs.arch }}" "${{ inputs.toolchain }}" "${{ inputs.kernel-root }}"
17 changes: 7 additions & 10 deletions build-selftests/build_selftests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ set -euo pipefail
source "${GITHUB_ACTION_PATH}/../helpers.sh"

TARGET_ARCH="$1"
KERNEL="$2"
TOOLCHAIN="$3"
export KBUILD_OUTPUT="$4"
VMLINUX_H=${VMLINUX_H:-}
TOOLCHAIN="$2"
KERNEL_ROOT="$(realpath $3)"

export KBUILD_OUTPUT="${KBUILD_OUTPUT:-${KERNEL_ROOT}}"
export VMLINUX_BTF="${VMLINUX_BTF:-${KBUILD_OUTPUT}/vmlinux}"
export VMLINUX_H="${VMLINUX_H:-}"

ARCH="$(platform_to_kernel_arch ${TARGET_ARCH})"
CROSS_COMPILE=""
Expand All @@ -25,18 +27,13 @@ fi

foldable start build_selftests "Building selftests with $TOOLCHAIN"

PREPARE_SELFTESTS_SCRIPT=$(find $GITHUB_WORKSPACE -name prepare_selftests-${KERNEL}.sh)
if [ -f "${PREPARE_SELFTESTS_SCRIPT}" ]; then
(cd "${KERNEL_ROOT}/tools/testing/selftests/bpf" && ${PREPARE_SELFTESTS_SCRIPT})
fi

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
VMLINUX_BTF=${VMLINUX_BTF}
VMLINUX_H=${VMLINUX_H}
EOF
)
Expand Down

0 comments on commit 0af20a5

Please sign in to comment.