On Wed, Dec 2, 2020 at 11:46 AM Florian Lehner <dev@xxxxxxxxxxx> wrote: > > Print a message when the returned error is about a program type being > not supported or because of permission problems. > These messages are expected if the program to test was actually > executed. > > Cc: Krzesimir Nowak <krzesimir@xxxxxxxxxx> > Signed-off-by: Florian Lehner <dev@xxxxxxxxxxx> > --- > tools/testing/selftests/bpf/test_verifier.c | 26 +++++++++++++++++---- > 1 file changed, 21 insertions(+), 5 deletions(-) > > diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c > index ceea9409639e..86ef28dd9919 100644 > --- a/tools/testing/selftests/bpf/test_verifier.c > +++ b/tools/testing/selftests/bpf/test_verifier.c > @@ -875,19 +875,35 @@ static int do_prog_test_run(int fd_prog, bool unpriv, uint32_t expected_val, > __u8 tmp[TEST_DATA_LEN << 2]; > __u32 size_tmp = sizeof(tmp); > uint32_t retval; > - int err; > + int err, saved_errno; > > if (unpriv) > set_admin(true); > err = bpf_prog_test_run(fd_prog, 1, data, size_data, > tmp, &size_tmp, &retval, NULL); > + saved_errno = errno; > + > if (unpriv) > set_admin(false); > - if (err && errno != 524/*ENOTSUPP*/ && errno != EPERM) { > - printf("Unexpected bpf_prog_test_run error "); > - return err; > + > + if (err) { > + switch (saved_errno) { > + case 524/*ENOTSUPP*/: > + printf("Did not run the program (not supported) "); > + return 0; > + case EPERM: > + if (unpriv) { > + printf("Did not run the program (no permission) "); > + return 0; > + } I see people specifying /* fallthrough; */ to make explicit that we expect falling through into default case? > + default: > + printf("FAIL: Unexpected bpf_prog_test_run error (%s) ", > + strerror(saved_errno)); > + return err; > + } > } > - if (!err && retval != expected_val && > + > + if (retval != expected_val && > expected_val != POINTER_VALUE) { > printf("FAIL retval %d != %d ", retval, expected_val); > return 1; > -- > 2.28.0 >