Skip to content

Commit 2294073

Browse files
Pu LehuiAlexei Starovoitov
authored andcommitted
selftests/bpf: Support local rootfs image for vmtest
Support vmtest to use local rootfs image generated by [0] that is consistent with BPF CI. Now we can specify the local rootfs image through the `-l` parameter like as follows: vmtest.sh -l ./libbpf-vmtest-rootfs-2024.08.22-noble-amd64.tar.zst -- ./test_progs Meanwhile, some descriptions have been flushed. Link: https://github.com/libbpf/ci/blob/main/rootfs/mkrootfs_debian.sh [0] Acked-by: Eduard Zingerman <[email protected]> Signed-off-by: Pu Lehui <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 0c3fc33 commit 2294073

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

tools/testing/selftests/bpf/README.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,6 @@ In case of linker errors when running selftests, try using static linking:
8585
If you want to change pahole and llvm, you can change `PATH` environment
8686
variable in the beginning of script.
8787

88-
.. note:: The script currently only supports x86_64 and s390x architectures.
89-
9088
Additional information about selftest failures are
9189
documented here.
9290

tools/testing/selftests/bpf/vmtest.sh

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
set -u
55
set -e
66

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.
7+
# This script currently only works for the following platforms,
8+
# as it is based on the VM image used by the BPF CI, which is
9+
# available only for these architectures. We can also specify
10+
# the local rootfs image generated by the following script:
11+
# https://github.com/libbpf/ci/blob/main/rootfs/mkrootfs_debian.sh
1012
ARCH="$(uname -m)"
1113
case "${ARCH}" in
1214
s390x)
@@ -34,6 +36,7 @@ aarch64)
3436
esac
3537
DEFAULT_COMMAND="./test_progs"
3638
MOUNT_DIR="mnt"
39+
LOCAL_ROOTFS_IMAGE=""
3740
ROOTFS_IMAGE="root.img"
3841
OUTPUT_DIR="$HOME/.bpf_selftests"
3942
KCONFIG_REL_PATHS=("tools/testing/selftests/bpf/config"
@@ -69,6 +72,7 @@ or
6972
7073
Options:
7174
75+
-l) Specify the path to the local rootfs image.
7276
-i) Update the rootfs image with a newer version.
7377
-d) Update the output directory (default: ${OUTPUT_DIR})
7478
-j) Number of jobs for compilation, similar to -j in make
@@ -128,7 +132,11 @@ load_rootfs()
128132
exit 1
129133
fi
130134

131-
download_rootfs | zstd -d | sudo tar -C "$dir" -x
135+
if [[ -n "${LOCAL_ROOTFS_IMAGE}" ]]; then
136+
cat "${LOCAL_ROOTFS_IMAGE}" | zstd -d | sudo tar -C "$dir" -x
137+
else
138+
download_rootfs | zstd -d | sudo tar -C "$dir" -x
139+
fi
132140
}
133141

134142
recompile_kernel()
@@ -342,8 +350,11 @@ main()
342350
local exit_command="poweroff -f"
343351
local debug_shell="no"
344352

345-
while getopts ':hskid:j:' opt; do
353+
while getopts ':hskl:id:j:' opt; do
346354
case ${opt} in
355+
l)
356+
LOCAL_ROOTFS_IMAGE="$OPTARG"
357+
;;
347358
i)
348359
update_image="yes"
349360
;;

0 commit comments

Comments
 (0)