diff mbox series

[bpf-next,v2,10/11] selftests/xsk: display command line options with -h

Message ID 20230824122853.3494-11-magnus.karlsson@gmail.com (mailing list archive)
State Changes Requested
Delegated to: BPF
Headers show
Series seltests/xsk: various improvements to xskxceiver | expand

Checks

Context Check Description
bpf/vmtest-bpf-next-PR success PR summary
bpf/vmtest-bpf-next-VM_Test-24 success Logs for test_verifier on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-26 success Logs for test_verifier on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-27 success Logs for test_verifier on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-8 success Logs for test_maps on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-9 success Logs for test_maps on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-10 success Logs for test_progs on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-12 success Logs for test_progs on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-13 success Logs for test_progs on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-14 success Logs for test_progs_no_alu32 on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-16 success Logs for test_progs_no_alu32 on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-17 success Logs for test_progs_no_alu32 on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-18 success Logs for test_progs_no_alu32_parallel on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-19 success Logs for test_progs_no_alu32_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-20 success Logs for test_progs_no_alu32_parallel on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-21 success Logs for test_progs_parallel on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-22 success Logs for test_progs_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-23 success Logs for test_progs_parallel on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-28 success Logs for veristat
bpf/vmtest-bpf-next-VM_Test-25 success Logs for test_verifier on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-11 success Logs for test_progs on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-15 success Logs for test_progs_no_alu32 on s390x with gcc
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for bpf-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 9 this patch: 9
netdev/cc_maintainers warning 5 maintainers not CCed: shuah@kernel.org yonghong.song@linux.dev mykolal@fb.com linux-kselftest@vger.kernel.org jonathan.lemon@gmail.com
netdev/build_clang success Errors and warnings before: 9 this patch: 9
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success net selftest script(s) already in Makefile
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 9 this patch: 9
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 57 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
bpf/vmtest-bpf-next-VM_Test-1 success Logs for ShellCheck
bpf/vmtest-bpf-next-VM_Test-2 success Logs for build for aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-3 fail Logs for build for s390x with gcc
bpf/vmtest-bpf-next-VM_Test-0 success Logs for ${{ matrix.test }} on ${{ matrix.arch }} with ${{ matrix.toolchain_full }}
bpf/vmtest-bpf-next-VM_Test-5 success Logs for build for x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-4 success Logs for build for x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-6 success Logs for set-matrix
bpf/vmtest-bpf-next-VM_Test-7 success Logs for veristat

Commit Message

Magnus Karlsson Aug. 24, 2023, 12:28 p.m. UTC
From: Magnus Karlsson <magnus.karlsson@intel.com>

Add the -h option to display all available command line options
available for test_xsk.sh and xskxceiver.

Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
---
 tools/testing/selftests/bpf/test_xsk.sh  | 11 ++++++++++-
 tools/testing/selftests/bpf/xskxceiver.c |  5 ++++-
 2 files changed, 14 insertions(+), 2 deletions(-)

Comments

Maciej Fijalkowski Aug. 25, 2023, 12:49 p.m. UTC | #1
On Thu, Aug 24, 2023 at 02:28:52PM +0200, Magnus Karlsson wrote:
> From: Magnus Karlsson <magnus.karlsson@intel.com>
> 
> Add the -h option to display all available command line options
> available for test_xsk.sh and xskxceiver.
> 
> Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
> ---
>  tools/testing/selftests/bpf/test_xsk.sh  | 11 ++++++++++-
>  tools/testing/selftests/bpf/xskxceiver.c |  5 ++++-
>  2 files changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/testing/selftests/bpf/test_xsk.sh b/tools/testing/selftests/bpf/test_xsk.sh
> index b7186ae48497..9ec718043c1a 100755
> --- a/tools/testing/selftests/bpf/test_xsk.sh
> +++ b/tools/testing/selftests/bpf/test_xsk.sh
> @@ -82,12 +82,15 @@
>  #
>  # Run a specific test from the test suite
>  #   sudo ./test_xsk.sh -t TEST_NAME
> +#
> +# Display the available command line options
> +#   ./test_xsk.sh -h
>  
>  . xsk_prereqs.sh
>  
>  ETH=""
>  
> -while getopts "vi:dm:lt:" flag
> +while getopts "vi:dm:lt:h" flag
>  do
>  	case "${flag}" in
>  		v) verbose=1;;
> @@ -96,6 +99,7 @@ do
>  		m) XSKTEST_MODE=${OPTARG};;
>  		l) list=1;;
>  		t) XSKTEST_TEST=${OPTARG};;
> +		h) help=1;;
>  	esac
>  done
>  
> @@ -148,6 +152,11 @@ if [[ $list -eq 1 ]]; then
>          exit
>  fi
>  
> +if [[ $help -eq 1 ]]; then
> +	./${XSKOBJ}
> +        exit
> +fi
> +
>  if [ ! -z $ETH ]; then
>  	VETH0=${ETH}
>  	VETH1=${ETH}
> diff --git a/tools/testing/selftests/bpf/xskxceiver.c b/tools/testing/selftests/bpf/xskxceiver.c
> index 19db9a827c30..9feb476d647f 100644
> --- a/tools/testing/selftests/bpf/xskxceiver.c
> +++ b/tools/testing/selftests/bpf/xskxceiver.c
> @@ -318,6 +318,7 @@ static struct option long_options[] = {
>  	{"mode", required_argument, 0, 'm'},
>  	{"list", no_argument, 0, 'l'},
>  	{"test", required_argument, 0, 't'},
> +	{"help", no_argument, 0, 'h'},
>  	{0, 0, 0, 0}
>  };
>  
> @@ -331,7 +332,8 @@ static void print_usage(char **argv)
>  		"  -b, --busy-poll      Enable busy poll\n"
>  		"  -m, --mode           Run only mode skb, drv, or zc\n"
>  		"  -l, --list           List all available tests\n"
> -		"  -t, --test           Run a specific test. Enter number from -l option.\n";
> +		"  -t, --test           Run a specific test. Enter number from -l option.\n"
> +		"  -h, --help           Display this help and exit\n";
>  
>  	ksft_print_msg(str, basename(argv[0]));
>  	ksft_exit_xfail();
> @@ -406,6 +408,7 @@ static void parse_command_line(struct ifobject *ifobj_tx, struct ifobject *ifobj
>  			if (errno)
>  				print_usage(argv);
>  			break;
> +		case 'h':

do you need 'fallthrough' here?

>  		default:
>  			print_usage(argv);
>  		}
> -- 
> 2.34.1
>
Magnus Karlsson Aug. 25, 2023, 12:54 p.m. UTC | #2
On Fri, 25 Aug 2023 at 14:50, Maciej Fijalkowski
<maciej.fijalkowski@intel.com> wrote:
>
> On Thu, Aug 24, 2023 at 02:28:52PM +0200, Magnus Karlsson wrote:
> > From: Magnus Karlsson <magnus.karlsson@intel.com>
> >
> > Add the -h option to display all available command line options
> > available for test_xsk.sh and xskxceiver.
> >
> > Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
> > ---
> >  tools/testing/selftests/bpf/test_xsk.sh  | 11 ++++++++++-
> >  tools/testing/selftests/bpf/xskxceiver.c |  5 ++++-
> >  2 files changed, 14 insertions(+), 2 deletions(-)
> >
> > diff --git a/tools/testing/selftests/bpf/test_xsk.sh b/tools/testing/selftests/bpf/test_xsk.sh
> > index b7186ae48497..9ec718043c1a 100755
> > --- a/tools/testing/selftests/bpf/test_xsk.sh
> > +++ b/tools/testing/selftests/bpf/test_xsk.sh
> > @@ -82,12 +82,15 @@
> >  #
> >  # Run a specific test from the test suite
> >  #   sudo ./test_xsk.sh -t TEST_NAME
> > +#
> > +# Display the available command line options
> > +#   ./test_xsk.sh -h
> >
> >  . xsk_prereqs.sh
> >
> >  ETH=""
> >
> > -while getopts "vi:dm:lt:" flag
> > +while getopts "vi:dm:lt:h" flag
> >  do
> >       case "${flag}" in
> >               v) verbose=1;;
> > @@ -96,6 +99,7 @@ do
> >               m) XSKTEST_MODE=${OPTARG};;
> >               l) list=1;;
> >               t) XSKTEST_TEST=${OPTARG};;
> > +             h) help=1;;
> >       esac
> >  done
> >
> > @@ -148,6 +152,11 @@ if [[ $list -eq 1 ]]; then
> >          exit
> >  fi
> >
> > +if [[ $help -eq 1 ]]; then
> > +     ./${XSKOBJ}
> > +        exit
> > +fi
> > +
> >  if [ ! -z $ETH ]; then
> >       VETH0=${ETH}
> >       VETH1=${ETH}
> > diff --git a/tools/testing/selftests/bpf/xskxceiver.c b/tools/testing/selftests/bpf/xskxceiver.c
> > index 19db9a827c30..9feb476d647f 100644
> > --- a/tools/testing/selftests/bpf/xskxceiver.c
> > +++ b/tools/testing/selftests/bpf/xskxceiver.c
> > @@ -318,6 +318,7 @@ static struct option long_options[] = {
> >       {"mode", required_argument, 0, 'm'},
> >       {"list", no_argument, 0, 'l'},
> >       {"test", required_argument, 0, 't'},
> > +     {"help", no_argument, 0, 'h'},
> >       {0, 0, 0, 0}
> >  };
> >
> > @@ -331,7 +332,8 @@ static void print_usage(char **argv)
> >               "  -b, --busy-poll      Enable busy poll\n"
> >               "  -m, --mode           Run only mode skb, drv, or zc\n"
> >               "  -l, --list           List all available tests\n"
> > -             "  -t, --test           Run a specific test. Enter number from -l option.\n";
> > +             "  -t, --test           Run a specific test. Enter number from -l option.\n"
> > +             "  -h, --help           Display this help and exit\n";
> >
> >       ksft_print_msg(str, basename(argv[0]));
> >       ksft_exit_xfail();
> > @@ -406,6 +408,7 @@ static void parse_command_line(struct ifobject *ifobj_tx, struct ifobject *ifobj
> >                       if (errno)
> >                               print_usage(argv);
> >                       break;
> > +             case 'h':
>
> do you need 'fallthrough' here?

Did not get any complaints from checkpatch, so do not know since it is
a case without any content on its own. I would say it is obvious that
it is "falling through" in this case :-). But I do not know what the
rule is.

> >               default:
> >                       print_usage(argv);
> >               }
> > --
> > 2.34.1
> >
Maciej Fijalkowski Aug. 25, 2023, 1:06 p.m. UTC | #3
On Fri, Aug 25, 2023 at 02:54:01PM +0200, Magnus Karlsson wrote:
> On Fri, 25 Aug 2023 at 14:50, Maciej Fijalkowski
> <maciej.fijalkowski@intel.com> wrote:
> >
> > On Thu, Aug 24, 2023 at 02:28:52PM +0200, Magnus Karlsson wrote:
> > > From: Magnus Karlsson <magnus.karlsson@intel.com>
> > >
> > > Add the -h option to display all available command line options
> > > available for test_xsk.sh and xskxceiver.
> > >
> > > Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
> > > ---
> > >  tools/testing/selftests/bpf/test_xsk.sh  | 11 ++++++++++-
> > >  tools/testing/selftests/bpf/xskxceiver.c |  5 ++++-
> > >  2 files changed, 14 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/tools/testing/selftests/bpf/test_xsk.sh b/tools/testing/selftests/bpf/test_xsk.sh
> > > index b7186ae48497..9ec718043c1a 100755
> > > --- a/tools/testing/selftests/bpf/test_xsk.sh
> > > +++ b/tools/testing/selftests/bpf/test_xsk.sh
> > > @@ -82,12 +82,15 @@
> > >  #
> > >  # Run a specific test from the test suite
> > >  #   sudo ./test_xsk.sh -t TEST_NAME
> > > +#
> > > +# Display the available command line options
> > > +#   ./test_xsk.sh -h
> > >
> > >  . xsk_prereqs.sh
> > >
> > >  ETH=""
> > >
> > > -while getopts "vi:dm:lt:" flag
> > > +while getopts "vi:dm:lt:h" flag
> > >  do
> > >       case "${flag}" in
> > >               v) verbose=1;;
> > > @@ -96,6 +99,7 @@ do
> > >               m) XSKTEST_MODE=${OPTARG};;
> > >               l) list=1;;
> > >               t) XSKTEST_TEST=${OPTARG};;
> > > +             h) help=1;;
> > >       esac
> > >  done
> > >
> > > @@ -148,6 +152,11 @@ if [[ $list -eq 1 ]]; then
> > >          exit
> > >  fi
> > >
> > > +if [[ $help -eq 1 ]]; then
> > > +     ./${XSKOBJ}
> > > +        exit
> > > +fi
> > > +
> > >  if [ ! -z $ETH ]; then
> > >       VETH0=${ETH}
> > >       VETH1=${ETH}
> > > diff --git a/tools/testing/selftests/bpf/xskxceiver.c b/tools/testing/selftests/bpf/xskxceiver.c
> > > index 19db9a827c30..9feb476d647f 100644
> > > --- a/tools/testing/selftests/bpf/xskxceiver.c
> > > +++ b/tools/testing/selftests/bpf/xskxceiver.c
> > > @@ -318,6 +318,7 @@ static struct option long_options[] = {
> > >       {"mode", required_argument, 0, 'm'},
> > >       {"list", no_argument, 0, 'l'},
> > >       {"test", required_argument, 0, 't'},
> > > +     {"help", no_argument, 0, 'h'},
> > >       {0, 0, 0, 0}
> > >  };
> > >
> > > @@ -331,7 +332,8 @@ static void print_usage(char **argv)
> > >               "  -b, --busy-poll      Enable busy poll\n"
> > >               "  -m, --mode           Run only mode skb, drv, or zc\n"
> > >               "  -l, --list           List all available tests\n"
> > > -             "  -t, --test           Run a specific test. Enter number from -l option.\n";
> > > +             "  -t, --test           Run a specific test. Enter number from -l option.\n"
> > > +             "  -h, --help           Display this help and exit\n";
> > >
> > >       ksft_print_msg(str, basename(argv[0]));
> > >       ksft_exit_xfail();
> > > @@ -406,6 +408,7 @@ static void parse_command_line(struct ifobject *ifobj_tx, struct ifobject *ifobj
> > >                       if (errno)
> > >                               print_usage(argv);
> > >                       break;
> > > +             case 'h':
> >
> > do you need 'fallthrough' here?
> 
> Did not get any complaints from checkpatch, so do not know since it is
> a case without any content on its own. I would say it is obvious that
> it is "falling through" in this case :-). But I do not know what the
> rule is.

Sorry for the noise it's fine i quickly tested that with
-Wimplicit-fallthrough.

> 
> > >               default:
> > >                       print_usage(argv);
> > >               }
> > > --
> > > 2.34.1
> > >
diff mbox series

Patch

diff --git a/tools/testing/selftests/bpf/test_xsk.sh b/tools/testing/selftests/bpf/test_xsk.sh
index b7186ae48497..9ec718043c1a 100755
--- a/tools/testing/selftests/bpf/test_xsk.sh
+++ b/tools/testing/selftests/bpf/test_xsk.sh
@@ -82,12 +82,15 @@ 
 #
 # Run a specific test from the test suite
 #   sudo ./test_xsk.sh -t TEST_NAME
+#
+# Display the available command line options
+#   ./test_xsk.sh -h
 
 . xsk_prereqs.sh
 
 ETH=""
 
-while getopts "vi:dm:lt:" flag
+while getopts "vi:dm:lt:h" flag
 do
 	case "${flag}" in
 		v) verbose=1;;
@@ -96,6 +99,7 @@  do
 		m) XSKTEST_MODE=${OPTARG};;
 		l) list=1;;
 		t) XSKTEST_TEST=${OPTARG};;
+		h) help=1;;
 	esac
 done
 
@@ -148,6 +152,11 @@  if [[ $list -eq 1 ]]; then
         exit
 fi
 
+if [[ $help -eq 1 ]]; then
+	./${XSKOBJ}
+        exit
+fi
+
 if [ ! -z $ETH ]; then
 	VETH0=${ETH}
 	VETH1=${ETH}
diff --git a/tools/testing/selftests/bpf/xskxceiver.c b/tools/testing/selftests/bpf/xskxceiver.c
index 19db9a827c30..9feb476d647f 100644
--- a/tools/testing/selftests/bpf/xskxceiver.c
+++ b/tools/testing/selftests/bpf/xskxceiver.c
@@ -318,6 +318,7 @@  static struct option long_options[] = {
 	{"mode", required_argument, 0, 'm'},
 	{"list", no_argument, 0, 'l'},
 	{"test", required_argument, 0, 't'},
+	{"help", no_argument, 0, 'h'},
 	{0, 0, 0, 0}
 };
 
@@ -331,7 +332,8 @@  static void print_usage(char **argv)
 		"  -b, --busy-poll      Enable busy poll\n"
 		"  -m, --mode           Run only mode skb, drv, or zc\n"
 		"  -l, --list           List all available tests\n"
-		"  -t, --test           Run a specific test. Enter number from -l option.\n";
+		"  -t, --test           Run a specific test. Enter number from -l option.\n"
+		"  -h, --help           Display this help and exit\n";
 
 	ksft_print_msg(str, basename(argv[0]));
 	ksft_exit_xfail();
@@ -406,6 +408,7 @@  static void parse_command_line(struct ifobject *ifobj_tx, struct ifobject *ifobj
 			if (errno)
 				print_usage(argv);
 			break;
+		case 'h':
 		default:
 			print_usage(argv);
 		}