Skip to content

Commit 7d0b3f1

Browse files
committed
selftests: hid: make vmtest rely on make
Having a default binary is simple enough, but this also means that we need to keep the targets in sync as we are adding them in the Makefile. So instead of doing that manual work, make vmtest.sh generic enough to actually be capable of running 'make -C tools/testing/selftests/hid'. The new image we use has make installed, which the base fedora image doesn't. Signed-off-by: Benjamin Tissoires <[email protected]>
1 parent 2653e3f commit 7d0b3f1

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

tools/testing/selftests/hid/vmtest.sh

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ x86_64)
1616
exit 1
1717
;;
1818
esac
19-
DEFAULT_COMMAND="./hid_bpf"
2019
SCRIPT_DIR="$(dirname $(realpath $0))"
2120
OUTPUT_DIR="$SCRIPT_DIR/results"
2221
KCONFIG_REL_PATHS=("${SCRIPT_DIR}/config" "${SCRIPT_DIR}/config.common" "${SCRIPT_DIR}/config.${ARCH}")
@@ -25,29 +24,32 @@ NUM_COMPILE_JOBS="$(nproc)"
2524
LOG_FILE_BASE="$(date +"hid_selftests.%Y-%m-%d_%H-%M-%S")"
2625
LOG_FILE="${LOG_FILE_BASE}.log"
2726
EXIT_STATUS_FILE="${LOG_FILE_BASE}.exit_status"
28-
CONTAINER_IMAGE="registry.fedoraproject.org/fedora:36"
27+
CONTAINER_IMAGE="registry.freedesktop.org/libevdev/hid-tools/fedora/37:2023-02-17.1"
28+
29+
TARGETS="${TARGETS:=$(basename ${SCRIPT_DIR})}"
30+
DEFAULT_COMMAND="make -C tools/testing/selftests TARGETS=${TARGETS} run_tests"
2931

3032
usage()
3133
{
3234
cat <<EOF
3335
Usage: $0 [-i] [-s] [-d <output_dir>] -- [<command>]
3436
3537
<command> is the command you would normally run when you are in
36-
tools/testing/selftests/bpf. e.g:
38+
the source kernel direcory. e.g:
3739
38-
$0 -- ./hid_bpf
40+
$0 -- ./tools/testing/selftests/hid/hid_bpf
3941
4042
If no command is specified and a debug shell (-s) is not requested,
4143
"${DEFAULT_COMMAND}" will be run by default.
4244
4345
If you build your kernel using KBUILD_OUTPUT= or O= options, these
4446
can be passed as environment variables to the script:
4547
46-
O=<kernel_build_path> $0 -- ./hid_bpf
48+
O=<kernel_build_path> $0 -- ./tools/testing/selftests/hid/hid_bpf
4749
4850
or
4951
50-
KBUILD_OUTPUT=<kernel_build_path> $0 -- ./hid_bpf
52+
KBUILD_OUTPUT=<kernel_build_path> $0 -- ./tools/testing/selftests/hid/hid_bpf
5153
5254
Options:
5355
@@ -91,11 +93,14 @@ update_selftests()
9193

9294
run_vm()
9395
{
94-
local b2c="$1"
95-
local kernel_bzimage="$2"
96-
local command="$3"
96+
local run_dir="$1"
97+
local b2c="$2"
98+
local kernel_bzimage="$3"
99+
local command="$4"
97100
local post_command=""
98101

102+
cd "${run_dir}"
103+
99104
if ! which "${QEMU_BINARY}" &> /dev/null; then
100105
cat <<EOF
101106
Could not find ${QEMU_BINARY}
@@ -273,7 +278,7 @@ main()
273278
fi
274279

275280
update_selftests "${kernel_checkout}" "${make_command}"
276-
run_vm $b2c "${kernel_bzimage}" "${command}"
281+
run_vm "${kernel_checkout}" $b2c "${kernel_bzimage}" "${command}"
277282
if [[ "${debug_shell}" != "yes" ]]; then
278283
echo "Logs saved in ${OUTPUT_DIR}/${LOG_FILE}"
279284
fi

0 commit comments

Comments
 (0)