Skip to content

Commit

Permalink
selftests/xsk: display command line options with -h
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
magnus-karlsson authored and Kernel Patches Daemon committed Sep 14, 2023
1 parent ce0a2d8 commit 8a8284d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
11 changes: 10 additions & 1 deletion tools/testing/selftests/bpf/test_xsk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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;;
Expand All @@ -96,6 +99,7 @@ do
m) MODE=${OPTARG};;
l) list=1;;
t) TEST=${OPTARG};;
h) help=1;;
esac
done

Expand Down Expand Up @@ -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}
Expand Down
5 changes: 4 additions & 1 deletion tools/testing/selftests/bpf/xskxceiver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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}
};

Expand All @@ -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();
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 8a8284d

Please sign in to comment.