Commit 29ad850a authored by Ilya Leoshkevich's avatar Ilya Leoshkevich Committed by Andrii Nakryiko

selfetests/bpf: Adapt vmtest.sh to s390 libbpf CI changes

[1] added s390 support to libbpf CI and added an ${ARCH} prefix to a
number of paths and identifiers in libbpf GitHub repo, which vmtest.sh
relies upon. Update these and make use of the new s390 support.

[1] https://github.com/libbpf/libbpf/pull/204Co-developed-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Signed-off-by: default avatarIlya Leoshkevich <iii@linux.ibm.com>
Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20211118115225.1349726-1-iii@linux.ibm.com
parent dd7f091f
...@@ -4,17 +4,34 @@ ...@@ -4,17 +4,34 @@
set -u set -u
set -e set -e
# This script currently only works for x86_64, as # This script currently only works for x86_64 and s390x, as
# it is based on the VM image used by the BPF CI which is # it is based on the VM image used by the BPF CI, which is
# x86_64. # available only for these architectures.
QEMU_BINARY="${QEMU_BINARY:="qemu-system-x86_64"}" ARCH="$(uname -m)"
X86_BZIMAGE="arch/x86/boot/bzImage" case "${ARCH}" in
s390x)
QEMU_BINARY=qemu-system-s390x
QEMU_CONSOLE="ttyS1"
QEMU_FLAGS=(-smp 2)
BZIMAGE="arch/s390/boot/compressed/vmlinux"
;;
x86_64)
QEMU_BINARY=qemu-system-x86_64
QEMU_CONSOLE="ttyS0,115200"
QEMU_FLAGS=(-cpu host -smp 8)
BZIMAGE="arch/x86/boot/bzImage"
;;
*)
echo "Unsupported architecture"
exit 1
;;
esac
DEFAULT_COMMAND="./test_progs" DEFAULT_COMMAND="./test_progs"
MOUNT_DIR="mnt" MOUNT_DIR="mnt"
ROOTFS_IMAGE="root.img" ROOTFS_IMAGE="root.img"
OUTPUT_DIR="$HOME/.bpf_selftests" OUTPUT_DIR="$HOME/.bpf_selftests"
KCONFIG_URL="https://raw.githubusercontent.com/libbpf/libbpf/master/travis-ci/vmtest/configs/latest.config" KCONFIG_URL="https://raw.githubusercontent.com/libbpf/libbpf/master/travis-ci/vmtest/configs/config-latest.${ARCH}"
KCONFIG_API_URL="https://api.github.com/repos/libbpf/libbpf/contents/travis-ci/vmtest/configs/latest.config" KCONFIG_API_URL="https://api.github.com/repos/libbpf/libbpf/contents/travis-ci/vmtest/configs/config-latest.${ARCH}"
INDEX_URL="https://raw.githubusercontent.com/libbpf/libbpf/master/travis-ci/vmtest/configs/INDEX" INDEX_URL="https://raw.githubusercontent.com/libbpf/libbpf/master/travis-ci/vmtest/configs/INDEX"
NUM_COMPILE_JOBS="$(nproc)" NUM_COMPILE_JOBS="$(nproc)"
LOG_FILE_BASE="$(date +"bpf_selftests.%Y-%m-%d_%H-%M-%S")" LOG_FILE_BASE="$(date +"bpf_selftests.%Y-%m-%d_%H-%M-%S")"
...@@ -85,7 +102,7 @@ newest_rootfs_version() ...@@ -85,7 +102,7 @@ newest_rootfs_version()
{ {
{ {
for file in "${!URLS[@]}"; do for file in "${!URLS[@]}"; do
if [[ $file =~ ^libbpf-vmtest-rootfs-(.*)\.tar\.zst$ ]]; then if [[ $file =~ ^"${ARCH}"/libbpf-vmtest-rootfs-(.*)\.tar\.zst$ ]]; then
echo "${BASH_REMATCH[1]}" echo "${BASH_REMATCH[1]}"
fi fi
done done
...@@ -102,7 +119,7 @@ download_rootfs() ...@@ -102,7 +119,7 @@ download_rootfs()
exit 1 exit 1
fi fi
download "libbpf-vmtest-rootfs-$rootfsversion.tar.zst" | download "${ARCH}/libbpf-vmtest-rootfs-$rootfsversion.tar.zst" |
zstd -d | sudo tar -C "$dir" -x zstd -d | sudo tar -C "$dir" -x
} }
...@@ -224,13 +241,12 @@ EOF ...@@ -224,13 +241,12 @@ EOF
-nodefaults \ -nodefaults \
-display none \ -display none \
-serial mon:stdio \ -serial mon:stdio \
-cpu host \ "${qemu_flags[@]}" \
-enable-kvm \ -enable-kvm \
-smp 8 \
-m 4G \ -m 4G \
-drive file="${rootfs_img}",format=raw,index=1,media=disk,if=virtio,cache=none \ -drive file="${rootfs_img}",format=raw,index=1,media=disk,if=virtio,cache=none \
-kernel "${kernel_bzimage}" \ -kernel "${kernel_bzimage}" \
-append "root=/dev/vda rw console=ttyS0,115200" -append "root=/dev/vda rw console=${QEMU_CONSOLE}"
} }
copy_logs() copy_logs()
...@@ -282,7 +298,7 @@ main() ...@@ -282,7 +298,7 @@ main()
local kernel_checkout=$(realpath "${script_dir}"/../../../../) local kernel_checkout=$(realpath "${script_dir}"/../../../../)
# By default the script searches for the kernel in the checkout directory but # By default the script searches for the kernel in the checkout directory but
# it also obeys environment variables O= and KBUILD_OUTPUT= # it also obeys environment variables O= and KBUILD_OUTPUT=
local kernel_bzimage="${kernel_checkout}/${X86_BZIMAGE}" local kernel_bzimage="${kernel_checkout}/${BZIMAGE}"
local command="${DEFAULT_COMMAND}" local command="${DEFAULT_COMMAND}"
local update_image="no" local update_image="no"
local exit_command="poweroff -f" local exit_command="poweroff -f"
...@@ -337,13 +353,13 @@ main() ...@@ -337,13 +353,13 @@ main()
if is_rel_path "${O}"; then if is_rel_path "${O}"; then
O="$(realpath "${PWD}/${O}")" O="$(realpath "${PWD}/${O}")"
fi fi
kernel_bzimage="${O}/${X86_BZIMAGE}" kernel_bzimage="${O}/${BZIMAGE}"
make_command="${make_command} O=${O}" make_command="${make_command} O=${O}"
elif [[ "${KBUILD_OUTPUT:=""}" != "" ]]; then elif [[ "${KBUILD_OUTPUT:=""}" != "" ]]; then
if is_rel_path "${KBUILD_OUTPUT}"; then if is_rel_path "${KBUILD_OUTPUT}"; then
KBUILD_OUTPUT="$(realpath "${PWD}/${KBUILD_OUTPUT}")" KBUILD_OUTPUT="$(realpath "${PWD}/${KBUILD_OUTPUT}")"
fi fi
kernel_bzimage="${KBUILD_OUTPUT}/${X86_BZIMAGE}" kernel_bzimage="${KBUILD_OUTPUT}/${BZIMAGE}"
make_command="${make_command} KBUILD_OUTPUT=${KBUILD_OUTPUT}" make_command="${make_command} KBUILD_OUTPUT=${KBUILD_OUTPUT}"
fi fi
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment