From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
To: Magnus Karlsson <magnus.karlsson@gmail.com>
Cc: <magnus.karlsson@intel.com>, <bjorn@kernel.org>, <ast@kernel.org>,
<daniel@iogearbox.net>, <netdev@vger.kernel.org>,
<bpf@vger.kernel.org>, <yhs@fb.com>, <andrii@kernel.org>,
<martin.lau@linux.dev>, <song@kernel.org>,
<john.fastabend@gmail.com>, <kpsingh@kernel.org>,
<sdf@google.com>, <haoluo@google.com>, <jolsa@kernel.org>,
<przemyslaw.kitszel@intel.com>
Subject: Re: [PATCH bpf-next v2 03/11] selftests/xsk: add option to only run tests in a single mode
Date: Fri, 25 Aug 2023 14:02:03 +0200 [thread overview]
Message-ID: <ZOiYOw0eSsU6dfRX@boxer> (raw)
In-Reply-To: <20230824122853.3494-4-magnus.karlsson@gmail.com>
On Thu, Aug 24, 2023 at 02:28:45PM +0200, Magnus Karlsson wrote:
> From: Magnus Karlsson <magnus.karlsson@intel.com>
>
> Add an option -m on the command line that allows the user to run the
> tests in a single mode instead of all of them. Valid modes are skb,
> drv, and zc (zero-copy). An example:
>
> To run test suite in drv mode only:
>
> ./test_xsk.sh -m drv
>
> Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
> ---
> tools/testing/selftests/bpf/test_xsk.sh | 10 ++++++-
> tools/testing/selftests/bpf/xskxceiver.c | 34 +++++++++++++++++++++---
> tools/testing/selftests/bpf/xskxceiver.h | 4 +--
> 3 files changed, 40 insertions(+), 8 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/test_xsk.sh b/tools/testing/selftests/bpf/test_xsk.sh
> index 2aa5a3445056..5ae2b3c27e21 100755
> --- a/tools/testing/selftests/bpf/test_xsk.sh
> +++ b/tools/testing/selftests/bpf/test_xsk.sh
> @@ -73,17 +73,21 @@
> #
> # Run test suite for physical device in loopback mode
> # sudo ./test_xsk.sh -i IFACE
> +#
> +# Run test suite in a specific mode only [skb,drv,zc]
> +# sudo ./test_xsk.sh -m MODE
>
> . xsk_prereqs.sh
>
> ETH=""
>
> -while getopts "vi:d" flag
> +while getopts "vi:dm:" flag
> do
> case "${flag}" in
> v) verbose=1;;
> d) debug=1;;
> i) ETH=${OPTARG};;
> + m) XSKTEST_MODE=${OPTARG};;
> esac
> done
>
> @@ -153,6 +157,10 @@ if [[ $verbose -eq 1 ]]; then
> ARGS+="-v "
> fi
>
> +if [ -n "$XSKTEST_MODE" ]; then
> + ARGS+="-m ${XSKTEST_MODE} "
> +fi
> +
> retval=$?
> test_status $retval "${TEST_NAME}"
>
> diff --git a/tools/testing/selftests/bpf/xskxceiver.c b/tools/testing/selftests/bpf/xskxceiver.c
> index 514fe994e02b..9f79c2b6aa97 100644
> --- a/tools/testing/selftests/bpf/xskxceiver.c
> +++ b/tools/testing/selftests/bpf/xskxceiver.c
> @@ -107,6 +107,9 @@
> static const char *MAC1 = "\x00\x0A\x56\x9E\xEE\x62";
> static const char *MAC2 = "\x00\x0A\x56\x9E\xEE\x61";
>
> +static bool opt_verbose;
> +static enum test_mode opt_mode = TEST_MODE_ALL;
> +
> static void __exit_with_error(int error, const char *file, const char *func, int line)
> {
> ksft_test_result_fail("[%s:%s:%i]: ERROR: %d/\"%s\"\n", file, func, line, error,
> @@ -310,17 +313,19 @@ static struct option long_options[] = {
> {"interface", required_argument, 0, 'i'},
> {"busy-poll", no_argument, 0, 'b'},
> {"verbose", no_argument, 0, 'v'},
> + {"mode", required_argument, 0, 'm'},
> {0, 0, 0, 0}
> };
>
> static void usage(const char *prog)
> {
> const char *str =
> - " Usage: %s [OPTIONS]\n"
> + " Usage: xskxceiver [OPTIONS]\n"
> " Options:\n"
> " -i, --interface Use interface\n"
> " -v, --verbose Verbose output\n"
> - " -b, --busy-poll Enable busy poll\n";
> + " -b, --busy-poll Enable busy poll\n"
> + " -m, --mode Run only mode skb, drv, or zc\n";
>
> ksft_print_msg(str, prog);
> }
> @@ -342,7 +347,7 @@ static void parse_command_line(struct ifobject *ifobj_tx, struct ifobject *ifobj
> opterr = 0;
>
> for (;;) {
> - c = getopt_long(argc, argv, "i:vb", long_options, &option_index);
> + c = getopt_long(argc, argv, "i:vbm:", long_options, &option_index);
> if (c == -1)
> break;
>
> @@ -371,6 +376,21 @@ static void parse_command_line(struct ifobject *ifobj_tx, struct ifobject *ifobj
> ifobj_tx->busy_poll = true;
> ifobj_rx->busy_poll = true;
> break;
> + case 'm':
> + if (!strncmp("skb", optarg, min_t(size_t, strlen(optarg),
> + strlen("skb")))) {
> + opt_mode = TEST_MODE_SKB;
> + } else if (!strncmp("drv", optarg, min_t(size_t, strlen(optarg),
> + strlen("drv")))) {
> + opt_mode = TEST_MODE_DRV;
> + } else if (!strncmp("zc", optarg, min_t(size_t, strlen(optarg),
> + strlen("zc")))) {
> + opt_mode = TEST_MODE_ZC;
> + } else {
> + usage(basename(argv[0]));
> + ksft_exit_xfail();
> + }
> + break;
> default:
> usage(basename(argv[0]));
> ksft_exit_xfail();
> @@ -2365,9 +2385,15 @@ int main(int argc, char **argv)
> test.tx_pkt_stream_default = tx_pkt_stream_default;
> test.rx_pkt_stream_default = rx_pkt_stream_default;
>
> - ksft_set_plan(modes * TEST_TYPE_MAX);
> + if (opt_mode == TEST_MODE_ALL)
> + ksft_set_plan(modes * TEST_TYPE_MAX);
> + else
> + ksft_set_plan(TEST_TYPE_MAX);
what will happen if i run zc mode for a device that does not support it?
what will happen if i run xdp mode for a device that does not support it?
I know we will do nothing and exit gracefully, but i am wondering if
xskxceiver should catch it.
>
> for (i = 0; i < modes; i++) {
> + if (opt_mode != TEST_MODE_ALL && i != opt_mode)
> + continue;
> +
> for (j = 0; j < TEST_TYPE_MAX; j++) {
> test_spec_init(&test, ifobj_tx, ifobj_rx, i);
> run_pkt_test(&test, i, j);
> diff --git a/tools/testing/selftests/bpf/xskxceiver.h b/tools/testing/selftests/bpf/xskxceiver.h
> index 233b66cef64a..1412492e9618 100644
> --- a/tools/testing/selftests/bpf/xskxceiver.h
> +++ b/tools/testing/selftests/bpf/xskxceiver.h
> @@ -63,7 +63,7 @@ enum test_mode {
> TEST_MODE_SKB,
> TEST_MODE_DRV,
> TEST_MODE_ZC,
> - TEST_MODE_MAX
> + TEST_MODE_ALL
> };
>
> enum test_type {
> @@ -98,8 +98,6 @@ enum test_type {
> TEST_TYPE_MAX
> };
>
> -static bool opt_verbose;
> -
> struct xsk_umem_info {
> struct xsk_ring_prod fq;
> struct xsk_ring_cons cq;
> --
> 2.34.1
>
next prev parent reply other threads:[~2023-08-25 12:02 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-24 12:28 [PATCH bpf-next v2 00/11] seltests/xsk: various improvements to xskxceiver Magnus Karlsson
2023-08-24 12:28 ` [PATCH bpf-next v2 01/11] selftests/xsk: print per packet info in verbose mode Magnus Karlsson
2023-08-24 12:28 ` [PATCH bpf-next v2 02/11] selftests/xsk: add timeout for Tx thread Magnus Karlsson
2023-08-24 12:28 ` [PATCH bpf-next v2 03/11] selftests/xsk: add option to only run tests in a single mode Magnus Karlsson
2023-08-25 12:02 ` Maciej Fijalkowski [this message]
2023-08-25 12:30 ` Magnus Karlsson
2023-08-24 12:28 ` [PATCH bpf-next v2 04/11] selftests/xsk: move all tests to separate functions Magnus Karlsson
2023-08-24 12:28 ` [PATCH bpf-next v2 05/11] selftests/xsk: declare test names in struct Magnus Karlsson
2023-08-25 12:06 ` Maciej Fijalkowski
2023-08-24 12:28 ` [PATCH bpf-next v2 06/11] selftests/xsk: add option that lists all tests Magnus Karlsson
2023-08-24 12:28 ` [PATCH bpf-next v2 07/11] selftests/xsk: add option to run single test Magnus Karlsson
2023-08-25 12:44 ` Maciej Fijalkowski
2023-08-25 12:50 ` Magnus Karlsson
2023-08-24 12:28 ` [PATCH bpf-next v2 08/11] selftests/xsk: use ksft_print_msg uniformly Magnus Karlsson
2023-08-24 12:28 ` [PATCH bpf-next v2 09/11] selftests/xsk: fail single test instead of all tests Magnus Karlsson
2023-08-25 12:48 ` Maciej Fijalkowski
2023-08-24 12:28 ` [PATCH bpf-next v2 10/11] selftests/xsk: display command line options with -h Magnus Karlsson
2023-08-25 12:49 ` Maciej Fijalkowski
2023-08-25 12:54 ` Magnus Karlsson
2023-08-25 13:06 ` Maciej Fijalkowski
2023-08-24 12:28 ` [PATCH bpf-next v2 11/11] selftests/xsk: introduce XSKTEST_ETH environment variable Magnus Karlsson
2023-08-25 12:57 ` Maciej Fijalkowski
2023-08-25 13:03 ` Magnus Karlsson
2023-08-25 13:19 ` Maciej Fijalkowski
2023-08-25 13:34 ` Magnus Karlsson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZOiYOw0eSsU6dfRX@boxer \
--to=maciej.fijalkowski@intel.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bjorn@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=magnus.karlsson@gmail.com \
--cc=magnus.karlsson@intel.com \
--cc=martin.lau@linux.dev \
--cc=netdev@vger.kernel.org \
--cc=przemyslaw.kitszel@intel.com \
--cc=sdf@google.com \
--cc=song@kernel.org \
--cc=yhs@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).