Commit 46bc0277 authored by Benjamin Tissoires's avatar Benjamin Tissoires

selftests/hid: vmtest.sh: allow finer control on the build steps

vmtest.sh works great for a one shot test, but not so much for CI where
I want to build (with different configs) the bzImage in a separate
job than the one I am running it.

Add a "build_only" option to specify whether we need to boot the currently
built kernel in the vm.
Reviewed-by: default avatarPeter Hutterer <peter.hutterer@who-t.net>
Acked-by: default avatarJiri Kosina <jkosina@suse.com>
Link: https://lore.kernel.org/r/20231206-wip-selftests-v2-2-c0350c2f5986@kernel.orgSigned-off-by: default avatarBenjamin Tissoires <bentiss@kernel.org>
parent 887f8094
...@@ -32,7 +32,7 @@ DEFAULT_COMMAND="pip3 install hid-tools; make -C tools/testing/selftests TARGETS ...@@ -32,7 +32,7 @@ DEFAULT_COMMAND="pip3 install hid-tools; make -C tools/testing/selftests TARGETS
usage() usage()
{ {
cat <<EOF cat <<EOF
Usage: $0 [-i] [-s] [-d <output_dir>] -- [<command>] Usage: $0 [-j N] [-s] [-b] [-d <output_dir>] -- [<command>]
<command> is the command you would normally run when you are in <command> is the command you would normally run when you are in
the source kernel direcory. e.g: the source kernel direcory. e.g:
...@@ -55,6 +55,7 @@ Options: ...@@ -55,6 +55,7 @@ Options:
-u) Update the boot2container script to a newer version. -u) Update the boot2container script to a newer version.
-d) Update the output directory (default: ${OUTPUT_DIR}) -d) Update the output directory (default: ${OUTPUT_DIR})
-b) Run only the build steps for the kernel and the selftests
-j) Number of jobs for compilation, similar to -j in make -j) Number of jobs for compilation, similar to -j in make
(default: ${NUM_COMPILE_JOBS}) (default: ${NUM_COMPILE_JOBS})
-s) Instead of powering off the VM, start an interactive -s) Instead of powering off the VM, start an interactive
...@@ -191,8 +192,9 @@ main() ...@@ -191,8 +192,9 @@ main()
local command="${DEFAULT_COMMAND}" local command="${DEFAULT_COMMAND}"
local update_b2c="no" local update_b2c="no"
local debug_shell="no" local debug_shell="no"
local build_only="no"
while getopts ':hsud:j:' opt; do while getopts ':hsud:j:b' opt; do
case ${opt} in case ${opt} in
u) u)
update_b2c="yes" update_b2c="yes"
...@@ -207,6 +209,9 @@ main() ...@@ -207,6 +209,9 @@ main()
command="/bin/sh" command="/bin/sh"
debug_shell="yes" debug_shell="yes"
;; ;;
b)
build_only="yes"
;;
h) h)
usage usage
exit 0 exit 0
...@@ -226,8 +231,7 @@ main() ...@@ -226,8 +231,7 @@ main()
shift $((OPTIND -1)) shift $((OPTIND -1))
# trap 'catch "$?"' EXIT # trap 'catch "$?"' EXIT
if [[ "${build_only}" == "no" && "${debug_shell}" == "no" ]]; then
if [[ "${debug_shell}" == "no" ]]; then
if [[ $# -eq 0 ]]; then if [[ $# -eq 0 ]]; then
echo "No command specified, will run ${DEFAULT_COMMAND} in the vm" echo "No command specified, will run ${DEFAULT_COMMAND} in the vm"
else else
...@@ -267,24 +271,26 @@ main() ...@@ -267,24 +271,26 @@ main()
update_kconfig "${kernel_checkout}" "${kconfig_file}" update_kconfig "${kernel_checkout}" "${kconfig_file}"
recompile_kernel "${kernel_checkout}" "${make_command}" recompile_kernel "${kernel_checkout}" "${make_command}"
update_selftests "${kernel_checkout}" "${make_command}"
if [[ "${update_b2c}" == "no" && ! -f "${b2c}" ]]; then if [[ "${build_only}" == "no" ]]; then
echo "vm2c script not found in ${b2c}" if [[ "${update_b2c}" == "no" && ! -f "${b2c}" ]]; then
update_b2c="yes" echo "vm2c script not found in ${b2c}"
fi update_b2c="yes"
fi
if [[ "${update_b2c}" == "yes" ]]; then if [[ "${update_b2c}" == "yes" ]]; then
download $B2C_URL $b2c download $B2C_URL $b2c
chmod +x $b2c chmod +x $b2c
fi fi
update_selftests "${kernel_checkout}" "${make_command}" run_vm "${kernel_checkout}" $b2c "${kernel_bzimage}" "${command}"
run_vm "${kernel_checkout}" $b2c "${kernel_bzimage}" "${command}" if [[ "${debug_shell}" != "yes" ]]; then
if [[ "${debug_shell}" != "yes" ]]; then echo "Logs saved in ${OUTPUT_DIR}/${LOG_FILE}"
echo "Logs saved in ${OUTPUT_DIR}/${LOG_FILE}" fi
fi
exit $(cat ${OUTPUT_DIR}/${EXIT_STATUS_FILE}) exit $(cat ${OUTPUT_DIR}/${EXIT_STATUS_FILE})
fi
} }
main "$@" main "$@"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment