linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: John Fastabend <john.fastabend@gmail.com>
To: Lorenz Bauer <lmb@cloudflare.com>, Shuah Khan <shuah@kernel.org>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
	Yonghong Song <yhs@fb.com>, Andrii Nakryiko <andriin@fb.com>
Cc: Lorenz Bauer <lmb@cloudflare.com>,
	linux-kselftest@vger.kernel.org, netdev@vger.kernel.org,
	bpf@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: RE: [PATCH bpf 3/4] selftests: bpf: make reuseport test output more legible
Date: Fri, 24 Jan 2020 11:46:27 -0800	[thread overview]
Message-ID: <5e2b4993c633c_551b2aaf5fbda5b826@john-XPS-13-9370.notmuch> (raw)
In-Reply-To: <20200123165934.9584-4-lmb@cloudflare.com>

Lorenz Bauer wrote:
> Include the name of the mismatching result in human readable format
> when reporting an error. The new output looks like the following:
> 
>   unexpected result
>    result: [1, 0, 0, 0, 0, 0]
>   expected: [0, 0, 0, 0, 0, 0]
>   mismatch on DROP_ERR_INNER_MAP (bpf_prog_linum:153)
>   check_results:FAIL:382
> 
> Signed-off-by: Lorenz Bauer <lmb@cloudflare.com>
> ---
>  .../bpf/prog_tests/select_reuseport.c         | 30 ++++++++++++++++---
>  1 file changed, 26 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/testing/selftests/bpf/prog_tests/select_reuseport.c b/tools/testing/selftests/bpf/prog_tests/select_reuseport.c
> index 2c37ae7dc214..09a536af139a 100644
> --- a/tools/testing/selftests/bpf/prog_tests/select_reuseport.c
> +++ b/tools/testing/selftests/bpf/prog_tests/select_reuseport.c
> @@ -316,6 +316,28 @@ static void check_data(int type, sa_family_t family, const struct cmd *cmd,
>  		       expected.len, result.len, get_linum());
>  }
>  
> +static const char *result_to_str(enum result res)
> +{
> +	switch (res) {
> +	case DROP_ERR_INNER_MAP:
> +		return "DROP_ERR_INNER_MAP";
> +	case DROP_ERR_SKB_DATA:
> +		return "DROP_ERR_SKB_DATA";
> +	case DROP_ERR_SK_SELECT_REUSEPORT:
> +		return "DROP_ERR_SK_SELECT_REUSEPORT";
> +	case DROP_MISC:
> +		return "DROP_MISC";
> +	case PASS:
> +		return "PASS";
> +	case PASS_ERR_SK_SELECT_REUSEPORT:
> +		return "PASS_ERR_SK_SELECT_REUSEPORT";
> +	case NR_RESULTS:
> +		return "NR_RESULTS";
> +	default:
> +		return "UNKNOWN";
> +	}
> +}
> +
>  static void check_results(void)
>  {
>  	__u32 results[NR_RESULTS];
> @@ -351,10 +373,10 @@ static void check_results(void)
>  		printf(", %u", expected_results[i]);
>  	printf("]\n");
>  
> -	RET_IF(expected_results[broken] != results[broken],
> -	       "unexpected result",
> -	       "expected_results[%u] != results[%u] bpf_prog_linum:%ld\n",
> -	       broken, broken, get_linum());
> +	printf("mismatch on %s (bpf_prog_linum:%ld)\n", result_to_str(broken),
> +	       get_linum());
> +
> +	CHECK_FAIL(true);
>  }
>  
>  static int send_data(int type, sa_family_t family, void *data, size_t len,
> -- 
> 2.20.1
> 

Acked-by: John Fastabend <john.fastabend@gmail.com>

  parent reply	other threads:[~2020-01-24 19:46 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20200123165934.9584-1-lmb@cloudflare.com>
2020-01-23 16:59 ` [PATCH bpf 1/4] selftests: bpf: use a temporary file in test_sockmap Lorenz Bauer
2020-01-23 18:34   ` Martin Lau
2020-01-24 19:50     ` John Fastabend
2020-01-24  9:20   ` Jakub Sitnicki
2020-01-24 19:43   ` John Fastabend
2020-01-23 16:59 ` [PATCH bpf 2/4] selftests: bpf: ignore RST packets for reuseport tests Lorenz Bauer
2020-01-23 17:16   ` Martin Lau
2020-01-23 17:18     ` Lorenz Bauer
2020-01-23 21:53   ` Martin Lau
2020-01-24  9:00     ` Lorenz Bauer
2020-01-24  9:32       ` Daniel Borkmann
2020-01-24 19:45   ` John Fastabend
2020-01-23 16:59 ` [PATCH bpf 3/4] selftests: bpf: make reuseport test output more legible Lorenz Bauer
2020-01-23 17:26   ` Martin Lau
2020-01-24 19:46   ` John Fastabend [this message]
2020-01-23 16:59 ` [PATCH bpf 4/4] selftests: bpf: reset global state between reuseport test runs Lorenz Bauer
2020-01-23 17:56   ` Martin Lau
     [not found] ` <20200124112754.19664-1-lmb@cloudflare.com>
2020-01-24 11:27   ` [PATCH bpf-next v2 1/4] selftests: bpf: use a temporary file in test_sockmap Lorenz Bauer
2020-01-24 11:27   ` [PATCH bpf-next v2 2/4] selftests: bpf: ignore FIN packets for reuseport tests Lorenz Bauer
2020-01-24 11:27   ` [PATCH bpf-next v2 3/4] selftests: bpf: make reuseport test output more legible Lorenz Bauer
2020-01-24 11:27   ` [PATCH bpf-next v2 4/4] selftests: bpf: reset global state between reuseport test runs Lorenz Bauer

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=5e2b4993c633c_551b2aaf5fbda5b826@john-XPS-13-9370.notmuch \
    --to=john.fastabend@gmail.com \
    --cc=andriin@fb.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kafai@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=lmb@cloudflare.com \
    --cc=netdev@vger.kernel.org \
    --cc=shuah@kernel.org \
    --cc=songliubraving@fb.com \
    --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).