Re: [PATCH bpf-next] selftests/bpf: Add an option for a debug shell in vmtest.sh

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Mar 22, 2021 at 9:37 AM KP Singh <kpsingh@xxxxxxxxxx> wrote:
>
> The newly introduced -s command line option starts an interactive shell
> after running the intended command in instead of powering off the VM.
> It's useful to have a shell especially when debugging failing
> tests or developing new tests.
>
> Signed-off-by: KP Singh <kpsingh@xxxxxxxxxx>
> ---
>  tools/testing/selftests/bpf/vmtest.sh | 15 +++++++++++----
>  1 file changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/vmtest.sh b/tools/testing/selftests/bpf/vmtest.sh
> index 22554894db99..3f248e755755 100755
> --- a/tools/testing/selftests/bpf/vmtest.sh
> +++ b/tools/testing/selftests/bpf/vmtest.sh
> @@ -24,7 +24,7 @@ EXIT_STATUS_FILE="${LOG_FILE_BASE}.exit_status"
>  usage()
>  {
>         cat <<EOF
> -Usage: $0 [-i] [-d <output_dir>] -- [<command>]
> +Usage: $0 [-i] [-s] [-d <output_dir>] -- [<command>]

wouldn't it make more sense to just run bash without any default
commands, if -s is specified? So "shell mode" gets you into shell.
Then you can run whatever you want.

>
>  <command> is the command you would normally run when you are in
>  tools/testing/selftests/bpf. e.g:
> @@ -49,6 +49,8 @@ Options:
>         -d)             Update the output directory (default: ${OUTPUT_DIR})
>         -j)             Number of jobs for compilation, similar to -j in make
>                         (default: ${NUM_COMPILE_JOBS})
> +       -s)             Instead of powering off the VM, run an interactive debug
> +                       shell after <command> finishes.
>  EOF
>  }
>
> @@ -149,6 +151,7 @@ update_init_script()
>         local init_script_dir="${OUTPUT_DIR}/${MOUNT_DIR}/etc/rcS.d"
>         local init_script="${init_script_dir}/S50-startup"
>         local command="$1"
> +       local exit_command="$2"
>
>         mount_image
>
> @@ -175,7 +178,7 @@ echo "130" > "/root/${EXIT_STATUS_FILE}"
>         stdbuf -oL -eL ${command}
>         echo "\$?" > "/root/${EXIT_STATUS_FILE}"
>  } 2>&1 | tee "/root/${LOG_FILE}"
> -poweroff -f
> +${exit_command}
>  EOF
>
>         sudo chmod a+x "${init_script}"
> @@ -277,8 +280,9 @@ main()
>         local kernel_bzimage="${kernel_checkout}/${X86_BZIMAGE}"
>         local command="${DEFAULT_COMMAND}"
>         local update_image="no"
> +       local exit_command="poweroff -f"
>
> -       while getopts 'hkid:j:' opt; do
> +       while getopts 'hskid:j:' opt; do
>                 case ${opt} in
>                 i)
>                         update_image="yes"
> @@ -289,6 +293,9 @@ main()
>                 j)
>                         NUM_COMPILE_JOBS="$OPTARG"
>                         ;;
> +               s)
> +                       exit_command="bash"
> +                       ;;
>                 h)
>                         usage
>                         exit 0
> @@ -355,7 +362,7 @@ main()
>         fi
>
>         update_selftests "${kernel_checkout}" "${make_command}"
> -       update_init_script "${command}"
> +       update_init_script "${command}" "${exit_command}"
>         run_vm "${kernel_bzimage}"
>         copy_logs
>         echo "Logs saved in ${OUTPUT_DIR}/${LOG_FILE}"
> --
> 2.31.0.rc2.261.g7f71774620-goog
>



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux