* [PATCH bpf-next] selftests/bpf: Add an option for a debug shell in vmtest.sh
@ 2021-03-22 16:36 KP Singh
2021-03-22 17:54 ` Andrii Nakryiko
0 siblings, 1 reply; 4+ messages in thread
From: KP Singh @ 2021-03-22 16:36 UTC (permalink / raw)
To: bpf
Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Florent Revest, Brendan Jackman
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@kernel.org>
---
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>]
<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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH bpf-next] selftests/bpf: Add an option for a debug shell in vmtest.sh
2021-03-22 16:36 [PATCH bpf-next] selftests/bpf: Add an option for a debug shell in vmtest.sh KP Singh
@ 2021-03-22 17:54 ` Andrii Nakryiko
2021-03-22 18:33 ` KP Singh
0 siblings, 1 reply; 4+ messages in thread
From: Andrii Nakryiko @ 2021-03-22 17:54 UTC (permalink / raw)
To: KP Singh
Cc: bpf, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Florent Revest, Brendan Jackman
On Mon, Mar 22, 2021 at 9:37 AM KP Singh <kpsingh@kernel.org> 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@kernel.org>
> ---
> 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
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH bpf-next] selftests/bpf: Add an option for a debug shell in vmtest.sh
2021-03-22 17:54 ` Andrii Nakryiko
@ 2021-03-22 18:33 ` KP Singh
2021-03-22 19:16 ` Andrii Nakryiko
0 siblings, 1 reply; 4+ messages in thread
From: KP Singh @ 2021-03-22 18:33 UTC (permalink / raw)
To: Andrii Nakryiko
Cc: bpf, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Florent Revest, Brendan Jackman
On Mon, Mar 22, 2021 at 6:54 PM Andrii Nakryiko
<andrii.nakryiko@gmail.com> wrote:
>
> On Mon, Mar 22, 2021 at 9:37 AM KP Singh <kpsingh@kernel.org> 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@kernel.org>
> > ---
> > 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.
>
Yep, that would be better indeed. Will send an updated v2.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH bpf-next] selftests/bpf: Add an option for a debug shell in vmtest.sh
2021-03-22 18:33 ` KP Singh
@ 2021-03-22 19:16 ` Andrii Nakryiko
0 siblings, 0 replies; 4+ messages in thread
From: Andrii Nakryiko @ 2021-03-22 19:16 UTC (permalink / raw)
To: KP Singh
Cc: bpf, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Florent Revest, Brendan Jackman
On Mon, Mar 22, 2021 at 11:33 AM KP Singh <kpsingh@kernel.org> wrote:
>
> On Mon, Mar 22, 2021 at 6:54 PM Andrii Nakryiko
> <andrii.nakryiko@gmail.com> wrote:
> >
> > On Mon, Mar 22, 2021 at 9:37 AM KP Singh <kpsingh@kernel.org> 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@kernel.org>
> > > ---
> > > 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.
> >
>
> Yep, that would be better indeed. Will send an updated v2.
Cool. If it's not too hard, it still makes sense to run <command> in
bash, if it was specified explicitly.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-03-22 19:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-22 16:36 [PATCH bpf-next] selftests/bpf: Add an option for a debug shell in vmtest.sh KP Singh
2021-03-22 17:54 ` Andrii Nakryiko
2021-03-22 18:33 ` KP Singh
2021-03-22 19:16 ` Andrii Nakryiko
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.