44set -u
55set -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
1229DEFAULT_COMMAND=" ./test_progs"
1330MOUNT_DIR=" mnt"
1431ROOTFS_IMAGE=" root.img"
1532OUTPUT_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} "
1835INDEX_URL=" https://raw.githubusercontent.com/libbpf/libbpf/master/travis-ci/vmtest/configs/INDEX"
1936NUM_COMPILE_JOBS=" $( nproc) "
2037LOG_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
236252copy_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