Skip to content

Commit

Permalink
github/workflows: Run the selftests on multiple architectures
Browse files Browse the repository at this point in the history
We're already running the tests in QEMU, so it only takes a bit of surgery
to enable them to run on all the architectures we can pull the Fedora
kernels from.

Signed-off-by: Toke Høiland-Jørgensen <[email protected]>
  • Loading branch information
tohojo committed Feb 10, 2022
1 parent f17b087 commit 43ea91c
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 44 deletions.
40 changes: 20 additions & 20 deletions .github/scripts/prepare_test_kernel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@

set -e

if [[ "$KERNEL_VERSION" == "LATEST" ]]; then
git clone --depth 1 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git kernel
cd kernel
cp "$GITHUB_WORKSPACE"/.github/scripts/.config .config
make -j $(nproc) olddefconfig all
else
KERNEL_VERSION_COMPLETE="$KERNEL_VERSION"-"$KERNEL_PATCH_VERSION".x86_64
PACKAGES_URL=https://kojipkgs.fedoraproject.org/packages/kernel/
PACKAGES_URL+="$KERNEL_VERSION"/"$KERNEL_PATCH_VERSION"/x86_64
IFS=- read KERNEL_UPSTREAM_VERSION KERNEL_PATCH_VERSION <<< $KERNEL_VERSION

for package in core modules modules-extra devel; do
wget -nv "$PACKAGES_URL"/kernel-"$package"-"$KERNEL_VERSION_COMPLETE".rpm
rpm2cpio kernel-"$package"-"$KERNEL_VERSION_COMPLETE".rpm | cpio -di
done
find lib -name "*.xz" -exec xz -d {} \;
KERNEL_VERSION_COMPLETE="$KERNEL_UPSTREAM_VERSION"-"$KERNEL_PATCH_VERSION"."$KERNEL_ARCH"
PACKAGES_URL=https://kojipkgs.fedoraproject.org/packages/kernel/
PACKAGES_URL+="$KERNEL_UPSTREAM_VERSION"/"$KERNEL_PATCH_VERSION"/"$KERNEL_ARCH"

mv lib/modules/"$KERNEL_VERSION_COMPLETE" kernel
mkdir -p kernel/arch/x86/boot
cp kernel/vmlinuz kernel/arch/x86/boot/bzImage
cp kernel/config kernel/.config
rsync -a usr/src/kernels/"$KERNEL_VERSION_COMPLETE"/ kernel/
fi
for package in core modules modules-extra devel; do
wget -nv "$PACKAGES_URL"/kernel-"$package"-"$KERNEL_VERSION_COMPLETE".rpm
rpm2cpio kernel-"$package"-"$KERNEL_VERSION_COMPLETE".rpm | cpio -di
done
find lib -name "*.xz" -exec xz -d {} \;

KERNEL_ARCHDIR=x86
[[ "$KERNEL_ARCH" == "aarch64" ]] && KERNEL_ARCHDIR=arm64
[[ "$KERNEL_ARCH" == "ppc64le" ]] && KERNEL_ARCHDIR=ppc64le
[[ "$KERNEL_ARCH" == "s390x" ]] && KERNEL_ARCHDIR=s390

mv lib/modules/"$KERNEL_VERSION_COMPLETE" kernel
mkdir -p kernel/arch/$KERNEL_ARCHDIR/boot
cp kernel/vmlinuz kernel/arch/$KERNEL_ARCHDIR/boot/bzImage
cp kernel/config kernel/.config
rsync -a usr/src/kernels/"$KERNEL_VERSION_COMPLETE"/ kernel/
13 changes: 0 additions & 13 deletions .github/scripts/prepare_test_tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,3 @@ echo ::group::Install virtme
git clone https://github.com/amluto/virtme
sudo python3 -m pip install ./virtme
echo ::endgroup::


if [[ $KERNEL_VERSION == "LATEST" ]]; then
echo ::group::Install pahole
# In the repo there is only version 1.15 and we need newer.
git clone https://git.kernel.org/pub/scm/devel/pahole/pahole.git
mkdir pahole/build
cd pahole/build
cmake -D__LIB=lib ..
sudo make install
sudo ldconfig /usr/local/lib
echo ::endgroup::
fi
4 changes: 2 additions & 2 deletions .github/scripts/run_tests_in_vm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
touch TEST_OUTPUT
tail -f TEST_OUTPUT &

sudo virtme-run --kdir kernel --script-exec .github/scripts/run_tests.sh --pwd --rw --mods=auto --qemu-opts -cpu qemu64 -machine accel=tcg -m 2G
sudo virtme-run --arch $KERNEL_ARCH --kdir kernel --script-exec .github/scripts/run_tests.sh --pwd --rw --mods=auto --memory 2G

kill %1

exit "$(cat TEST_RESULT)"
exit "$(cat TEST_RESULT)"
20 changes: 11 additions & 9 deletions .github/workflows/selftests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,20 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- KERNEL_VERSION: 5.16.8
KERNEL_PATCH_VERSION: 200.fc35
- KERNEL_VERSION: 5.11.0
KERNEL_PATCH_VERSION: 156.fc34
- KERNEL_VERSION: 5.6.19
KERNEL_PATCH_VERSION: 300.fc32
KERNEL_VERSION:
- "5.16.8-200.fc35"
- "5.11.0-156.fc34"
- "5.6.19-300.fc32"
KERNEL_ARCH:
- aarch64
- ppc64le
- s390x
- x86_64
fail-fast: false

env:
KERNEL_VERSION: ${{ matrix.KERNEL_VERSION }}
KERNEL_PATCH_VERSION: ${{ matrix.KERNEL_PATCH_VERSION }}
KERNEL_ARCH: ${{ matrix.KERNEL_ARCH }}
CLANG: clang-10
LLC: llc-10

Expand All @@ -34,7 +36,7 @@ jobs:
- name: Prepare packages
run: |
sudo apt-get update
sudo apt-get install zstd binutils-dev elfutils libpcap-dev libelf-dev gcc-multilib pkg-config wireshark tshark bpfcc-tools python3 python3-pip python3-setuptools qemu-kvm rpm2cpio libdw-dev libdwarf-dev
sudo apt-get install zstd binutils-dev elfutils libpcap-dev libelf-dev gcc-multilib pkg-config wireshark tshark bpfcc-tools python3 python3-pip python3-setuptools qemu-kvm rpm2cpio libdw-dev libdwarf-dev qemu-system-arm qemu-system-ppc qemu-system-s390x
- name: Prepare Clang
run: |
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
Expand Down

0 comments on commit 43ea91c

Please sign in to comment.