Message ID | 20210322163659.2873534-1-kpsingh@kernel.org (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | BPF |
Headers | show |
Series | [bpf-next] selftests/bpf: Add an option for a debug shell in vmtest.sh | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | success | Link |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Clearly marked for bpf-next |
netdev/subject_prefix | success | Link |
netdev/cc_maintainers | warning | 7 maintainers not CCed: linux-kselftest@vger.kernel.org netdev@vger.kernel.org yhs@fb.com kafai@fb.com john.fastabend@gmail.com songliubraving@fb.com shuah@kernel.org |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 0 this patch: 0 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 58 lines checked |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 0 this patch: 0 |
netdev/header_inline | success | Link |
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 >
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.
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.
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}"
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(-)