Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <benjamin.tissoires@redhat.com>

+15 -10
+15 -10
tools/testing/selftests/hid/vmtest.sh
··· 16 16 exit 1 17 17 ;; 18 18 esac 19 - DEFAULT_COMMAND="./hid_bpf" 20 19 SCRIPT_DIR="$(dirname $(realpath $0))" 21 20 OUTPUT_DIR="$SCRIPT_DIR/results" 22 21 KCONFIG_REL_PATHS=("${SCRIPT_DIR}/config" "${SCRIPT_DIR}/config.common" "${SCRIPT_DIR}/config.${ARCH}") ··· 24 25 LOG_FILE_BASE="$(date +"hid_selftests.%Y-%m-%d_%H-%M-%S")" 25 26 LOG_FILE="${LOG_FILE_BASE}.log" 26 27 EXIT_STATUS_FILE="${LOG_FILE_BASE}.exit_status" 27 - CONTAINER_IMAGE="registry.fedoraproject.org/fedora:36" 28 + CONTAINER_IMAGE="registry.freedesktop.org/libevdev/hid-tools/fedora/37:2023-02-17.1" 29 + 30 + TARGETS="${TARGETS:=$(basename ${SCRIPT_DIR})}" 31 + DEFAULT_COMMAND="make -C tools/testing/selftests TARGETS=${TARGETS} run_tests" 28 32 29 33 usage() 30 34 { ··· 35 33 Usage: $0 [-i] [-s] [-d <output_dir>] -- [<command>] 36 34 37 35 <command> is the command you would normally run when you are in 38 - tools/testing/selftests/bpf. e.g: 36 + the source kernel direcory. e.g: 39 37 40 - $0 -- ./hid_bpf 38 + $0 -- ./tools/testing/selftests/hid/hid_bpf 41 39 42 40 If no command is specified and a debug shell (-s) is not requested, 43 41 "${DEFAULT_COMMAND}" will be run by default. ··· 45 43 If you build your kernel using KBUILD_OUTPUT= or O= options, these 46 44 can be passed as environment variables to the script: 47 45 48 - O=<kernel_build_path> $0 -- ./hid_bpf 46 + O=<kernel_build_path> $0 -- ./tools/testing/selftests/hid/hid_bpf 49 47 50 48 or 51 49 52 - KBUILD_OUTPUT=<kernel_build_path> $0 -- ./hid_bpf 50 + KBUILD_OUTPUT=<kernel_build_path> $0 -- ./tools/testing/selftests/hid/hid_bpf 53 51 54 52 Options: 55 53 ··· 93 91 94 92 run_vm() 95 93 { 96 - local b2c="$1" 97 - local kernel_bzimage="$2" 98 - local command="$3" 94 + local run_dir="$1" 95 + local b2c="$2" 96 + local kernel_bzimage="$3" 97 + local command="$4" 99 98 local post_command="" 99 + 100 + cd "${run_dir}" 100 101 101 102 if ! which "${QEMU_BINARY}" &> /dev/null; then 102 103 cat <<EOF ··· 278 273 fi 279 274 280 275 update_selftests "${kernel_checkout}" "${make_command}" 281 - run_vm $b2c "${kernel_bzimage}" "${command}" 276 + run_vm "${kernel_checkout}" $b2c "${kernel_bzimage}" "${command}" 282 277 if [[ "${debug_shell}" != "yes" ]]; then 283 278 echo "Logs saved in ${OUTPUT_DIR}/${LOG_FILE}" 284 279 fi