Skip to content

Commit 29ad850

Browse files
iii-ianakryiko
authored andcommitted
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] libbpf/libbpf#204 Co-developed-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20211118115225.1349726-1-iii@linux.ibm.com
1 parent dd7f091 commit 29ad850

File tree

1 file changed

+31
-15
lines changed

1 file changed

+31
-15
lines changed

tools/testing/selftests/bpf/vmtest.sh

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,34 @@
44
set -u
55
set -e
66

7-
# This script currently only works for x86_64, as
8-
# it is based on the VM image used by the BPF CI which is
9-
# x86_64.
10-
QEMU_BINARY="${QEMU_BINARY:="qemu-system-x86_64"}"
11-
X86_BZIMAGE="arch/x86/boot/bzImage"
7+
# This script currently only works for x86_64 and s390x, as
8+
# it is based on the VM image used by the BPF CI, which is
9+
# available only for these architectures.
10+
ARCH="$(uname -m)"
11+
case "${ARCH}" in
12+
s390x)
13+
QEMU_BINARY=qemu-system-s390x
14+
QEMU_CONSOLE="ttyS1"
15+
QEMU_FLAGS=(-smp 2)
16+
BZIMAGE="arch/s390/boot/compressed/vmlinux"
17+
;;
18+
x86_64)
19+
QEMU_BINARY=qemu-system-x86_64
20+
QEMU_CONSOLE="ttyS0,115200"
21+
QEMU_FLAGS=(-cpu host -smp 8)
22+
BZIMAGE="arch/x86/boot/bzImage"
23+
;;
24+
*)
25+
echo "Unsupported architecture"
26+
exit 1
27+
;;
28+
esac
1229
DEFAULT_COMMAND="./test_progs"
1330
MOUNT_DIR="mnt"
1431
ROOTFS_IMAGE="root.img"
1532
OUTPUT_DIR="$HOME/.bpf_selftests"
16-
KCONFIG_URL="https://raw.githubusercontent.com/libbpf/libbpf/master/travis-ci/vmtest/configs/latest.config"
17-
KCONFIG_API_URL="https://api.github.com/repos/libbpf/libbpf/contents/travis-ci/vmtest/configs/latest.config"
33+
KCONFIG_URL="https://raw.githubusercontent.com/libbpf/libbpf/master/travis-ci/vmtest/configs/config-latest.${ARCH}"
34+
KCONFIG_API_URL="https://api.github.com/repos/libbpf/libbpf/contents/travis-ci/vmtest/configs/config-latest.${ARCH}"
1835
INDEX_URL="https://raw.githubusercontent.com/libbpf/libbpf/master/travis-ci/vmtest/configs/INDEX"
1936
NUM_COMPILE_JOBS="$(nproc)"
2037
LOG_FILE_BASE="$(date +"bpf_selftests.%Y-%m-%d_%H-%M-%S")"
@@ -85,7 +102,7 @@ newest_rootfs_version()
85102
{
86103
{
87104
for file in "${!URLS[@]}"; do
88-
if [[ $file =~ ^libbpf-vmtest-rootfs-(.*)\.tar\.zst$ ]]; then
105+
if [[ $file =~ ^"${ARCH}"/libbpf-vmtest-rootfs-(.*)\.tar\.zst$ ]]; then
89106
echo "${BASH_REMATCH[1]}"
90107
fi
91108
done
@@ -102,7 +119,7 @@ download_rootfs()
102119
exit 1
103120
fi
104121

105-
download "libbpf-vmtest-rootfs-$rootfsversion.tar.zst" |
122+
download "${ARCH}/libbpf-vmtest-rootfs-$rootfsversion.tar.zst" |
106123
zstd -d | sudo tar -C "$dir" -x
107124
}
108125

@@ -224,13 +241,12 @@ EOF
224241
-nodefaults \
225242
-display none \
226243
-serial mon:stdio \
227-
-cpu host \
244+
"${qemu_flags[@]}" \
228245
-enable-kvm \
229-
-smp 8 \
230246
-m 4G \
231247
-drive file="${rootfs_img}",format=raw,index=1,media=disk,if=virtio,cache=none \
232248
-kernel "${kernel_bzimage}" \
233-
-append "root=/dev/vda rw console=ttyS0,115200"
249+
-append "root=/dev/vda rw console=${QEMU_CONSOLE}"
234250
}
235251

236252
copy_logs()
@@ -282,7 +298,7 @@ main()
282298
local kernel_checkout=$(realpath "${script_dir}"/../../../../)
283299
# By default the script searches for the kernel in the checkout directory but
284300
# it also obeys environment variables O= and KBUILD_OUTPUT=
285-
local kernel_bzimage="${kernel_checkout}/${X86_BZIMAGE}"
301+
local kernel_bzimage="${kernel_checkout}/${BZIMAGE}"
286302
local command="${DEFAULT_COMMAND}"
287303
local update_image="no"
288304
local exit_command="poweroff -f"
@@ -337,13 +353,13 @@ main()
337353
if is_rel_path "${O}"; then
338354
O="$(realpath "${PWD}/${O}")"
339355
fi
340-
kernel_bzimage="${O}/${X86_BZIMAGE}"
356+
kernel_bzimage="${O}/${BZIMAGE}"
341357
make_command="${make_command} O=${O}"
342358
elif [[ "${KBUILD_OUTPUT:=""}" != "" ]]; then
343359
if is_rel_path "${KBUILD_OUTPUT}"; then
344360
KBUILD_OUTPUT="$(realpath "${PWD}/${KBUILD_OUTPUT}")"
345361
fi
346-
kernel_bzimage="${KBUILD_OUTPUT}/${X86_BZIMAGE}"
362+
kernel_bzimage="${KBUILD_OUTPUT}/${BZIMAGE}"
347363
make_command="${make_command} KBUILD_OUTPUT=${KBUILD_OUTPUT}"
348364
fi
349365

0 commit comments

Comments
 (0)