Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Magnus Karlsson <magnus.karlsson@gmail.com>
To: magnus.karlsson@intel.com, bjorn@kernel.org, ast@kernel.org,
	daniel@iogearbox.net, netdev@vger.kernel.org,
	maciej.fijalkowski@intel.com
Cc: jonathan.lemon@gmail.com, ciara.loftus@intel.com,
	bpf@vger.kernel.org, yhs@fb.com, andrii@kernel.org
Subject: [PATCH bpf-next v2 18/20] selftests: xsk: eliminate test specific if-statement in test runner
Date: Tue,  7 Sep 2021 09:19:26 +0200	[thread overview]
Message-ID: <20210907071928.9750-19-magnus.karlsson@gmail.com> (raw)
In-Reply-To: <20210907071928.9750-1-magnus.karlsson@gmail.com>

From: Magnus Karlsson <magnus.karlsson@intel.com>

Eliminate a test specific if-statement for the RX_FILL_EMTPY stats
test that is present in the test runner. We can do this as we now have
the use_addr_for_fill option. Just create and empty Rx packet stream
and indicated that the test runner should use the addresses in that to
populate the fill ring. As there are no packets in the stream, the
fill ring will be empty and we will get the error stats that we want
to test.

Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
---
 tools/testing/selftests/bpf/xdpxceiver.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/bpf/xdpxceiver.c b/tools/testing/selftests/bpf/xdpxceiver.c
index 7cc75d1481e2..4d86c4b62aa9 100644
--- a/tools/testing/selftests/bpf/xdpxceiver.c
+++ b/tools/testing/selftests/bpf/xdpxceiver.c
@@ -458,8 +458,10 @@ static void pkt_stream_delete(struct pkt_stream *pkt_stream)
 
 static void pkt_stream_restore_default(struct test_spec *test)
 {
-	pkt_stream_delete(test->ifobj_tx->pkt_stream);
-	test->ifobj_tx->pkt_stream = test->pkt_stream_default;
+	if (test->ifobj_tx->pkt_stream != test->pkt_stream_default) {
+		pkt_stream_delete(test->ifobj_tx->pkt_stream);
+		test->ifobj_tx->pkt_stream = test->pkt_stream_default;
+	}
 	test->ifobj_rx->pkt_stream = test->pkt_stream_default;
 }
 
@@ -931,8 +933,7 @@ static void *worker_testapp_validate_rx(void *arg)
 	if (test->current_step == 1)
 		thread_common_ops(test, ifobject);
 
-	if (stat_test_type != STAT_TEST_RX_FILL_EMPTY)
-		xsk_populate_fill_ring(ifobject->umem, ifobject->pkt_stream);
+	xsk_populate_fill_ring(ifobject->umem, ifobject->pkt_stream);
 
 	fds.fd = xsk_socket__fd(ifobject->xsk->xsk);
 	fds.events = POLLIN;
@@ -1065,7 +1066,14 @@ static void testapp_stats(struct test_spec *test)
 			break;
 		case STAT_TEST_RX_FILL_EMPTY:
 			test_spec_set_name(test, "STAT_RX_FILL_EMPTY");
+			test->ifobj_rx->pkt_stream = pkt_stream_generate(test->ifobj_rx->umem, 0,
+									 MIN_PKT_SIZE);
+			if (!test->ifobj_rx->pkt_stream)
+				exit_with_error(ENOMEM);
+			test->ifobj_rx->pkt_stream->use_addr_for_fill = true;
 			testapp_validate_traffic(test);
+
+			pkt_stream_restore_default(test);
 			break;
 		default:
 			break;
-- 
2.29.0


  parent reply	other threads:[~2021-09-07  7:21 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-07  7:19 [PATCH bpf-next v2 00/20] selftests: xsk: facilitate adding tests Magnus Karlsson
2021-09-07  7:19 ` [PATCH bpf-next v2 01/20] selftests: xsk: simplify xsk and umem arrays Magnus Karlsson
2021-09-07  7:19 ` [PATCH bpf-next v2 02/20] selftests: xsk: introduce type for thread function Magnus Karlsson
2021-09-07  7:19 ` [PATCH bpf-next v2 03/20] selftests: xsk: introduce test specifications Magnus Karlsson
2021-09-07  7:19 ` [PATCH bpf-next v2 04/20] selftests: xsk: move num_frames and frame_headroom to xsk_umem_info Magnus Karlsson
2021-09-07  7:19 ` [PATCH bpf-next v2 05/20] selftests: xsk: move rxqsize into xsk_socket_info Magnus Karlsson
2021-09-07  7:19 ` [PATCH bpf-next v2 06/20] selftests: xsk: make frame_size configurable Magnus Karlsson
2021-09-07  7:19 ` [PATCH bpf-next v2 07/20] selftests: xsx: introduce test name in test spec Magnus Karlsson
2021-09-07  7:19 ` [PATCH bpf-next v2 08/20] selftests: xsk: add use_poll to ifobject Magnus Karlsson
2021-09-07  7:19 ` [PATCH bpf-next v2 09/20] selftests: xsk: introduce rx_on and tx_on in ifobject Magnus Karlsson
2021-09-07  7:19 ` [PATCH bpf-next v2 10/20] selftests: xsk: replace second_step global variable Magnus Karlsson
2021-09-07  7:19 ` [PATCH bpf-next v2 11/20] selftests: xsk: specify number of sockets to create Magnus Karlsson
2021-09-07  7:19 ` [PATCH bpf-next v2 12/20] selftests: xsk: make xdp_flags and bind_flags local Magnus Karlsson
2021-09-07  7:19 ` [PATCH bpf-next v2 13/20] selftests: xsx: make pthreads local scope Magnus Karlsson
2021-09-07  7:19 ` [PATCH bpf-next v2 14/20] selftests: xsk: eliminate MAX_SOCKS define Magnus Karlsson
2021-09-07  7:19 ` [PATCH bpf-next v2 15/20] selftests: xsk: allow for invalid packets Magnus Karlsson
2021-09-07  7:19 ` [PATCH bpf-next v2 16/20] selftests: xsk: introduce replacing the default packet stream Magnus Karlsson
2021-09-07  7:19 ` [PATCH bpf-next v2 17/20] selftests: xsk: add test for unaligned mode Magnus Karlsson
2021-09-07  7:19 ` Magnus Karlsson [this message]
2021-09-07  7:19 ` [PATCH bpf-next v2 19/20] selftests: xsk: add tests for invalid xsk descriptors Magnus Karlsson
2021-09-07  7:19 ` [PATCH bpf-next v2 20/20] selftests: xsk: add tests for 2K frame size Magnus Karlsson
2021-09-10 12:54 ` [PATCH bpf-next v2 00/20] selftests: xsk: facilitate adding tests Maciej Fijalkowski
2021-09-10 19:20 ` patchwork-bot+netdevbpf

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=20210907071928.9750-19-magnus.karlsson@gmail.com \
    --to=magnus.karlsson@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bjorn@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=ciara.loftus@intel.com \
    --cc=daniel@iogearbox.net \
    --cc=jonathan.lemon@gmail.com \
    --cc=maciej.fijalkowski@intel.com \
    --cc=magnus.karlsson@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=yhs@fb.com \
    --subject='Re: [PATCH bpf-next v2 18/20] selftests: xsk: eliminate test specific if-statement in test runner' \
    /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

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).