Re: [PATCH net-next 02/13] selftests: ncdevmem: Remove validation
From: Mina Almasry <hidden>
Date: 2024-09-12 20:36:41
On Thu, Sep 12, 2024 at 10:12 AM Stanislav Fomichev [off-list ref] wrote:
quoted hunk ↗ jump to hunk
ncdevmem should (see next patches) print the payload on the stdout. The validation can and should be done by the callers: $ ncdevmem -l ... > file $ sha256sum file Cc: Mina Almasry <redacted> Signed-off-by: Stanislav Fomichev <sdf@fomichev.me> --- tools/testing/selftests/net/ncdevmem.c | 56 +++----------------------- 1 file changed, 6 insertions(+), 50 deletions(-)diff --git a/tools/testing/selftests/net/ncdevmem.c b/tools/testing/selftests/net/ncdevmem.c index 352dba211fb0..3712296d997b 100644 --- a/tools/testing/selftests/net/ncdevmem.c +++ b/tools/testing/selftests/net/ncdevmem.c@@ -64,24 +64,13 @@ static char *server_ip = "192.168.1.4"; static char *client_ip = "192.168.1.2"; static char *port = "5201"; -static size_t do_validation; static int start_queue = 8; static int num_queues = 8; static char *ifname = "eth1"; static unsigned int ifindex; static unsigned int dmabuf_id; -void print_bytes(void *ptr, size_t size) -{ - unsigned char *p = ptr; - int i; - - for (i = 0; i < size; i++) - printf("%02hhX ", p[i]); - printf("\n"); -} - -void print_nonzero_bytes(void *ptr, size_t size) +static void print_nonzero_bytes(void *ptr, size_t size) { unsigned char *p = ptr; unsigned int i;@@ -91,30 +80,6 @@ void print_nonzero_bytes(void *ptr, size_t size) printf("\n"); } -void validate_buffer(void *line, size_t size) -{ - static unsigned char seed = 1; - unsigned char *ptr = line; - int errors = 0; - size_t i; - - for (i = 0; i < size; i++) { - if (ptr[i] != seed) { - fprintf(stderr, - "Failed validation: expected=%u, actual=%u, index=%lu\n", - seed, ptr[i], i); - errors++;
FWIW the index at where the validation started to fail often gives
critical clues about where the bug is, along with this line, which I'm
glad is not removed:
printf("received frag_page=%llu, in_page_offset=%llu,
frag_offset=%llu, frag_size=%u, token=%u, total_received=%lu,
dmabuf_id=%u\n",
I think we can ensure that what is doing the validation above ncdevmem
prints enough context about the error. Although, just to understand
your thinking a bit, why not have this binary do the validation
itself?
--
Thanks,
Mina