Re: [PATCH v2 bpf-next 10/12] selftests/bpf: merge test_stub.c into testing_helpers.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Nov 3, 2021 at 3:09 PM Andrii Nakryiko <andrii@xxxxxxxxxx> wrote:
>
> Move testing prog and object load wrappers (bpf_prog_test_load and
> bpf_test_load_program) into testing_helpers.{c,h} and get rid of
> otherwise useless test_stub.c. Make testing_helpers.c available to
> non-test_progs binaries as well.
>
> Signed-off-by: Andrii Nakryiko <andrii@xxxxxxxxxx>
...
> -int extra_prog_load_log_flags = 0;
> -
> -int bpf_prog_test_load(const char *file, enum bpf_prog_type type,
> -                      struct bpf_object **pobj, int *prog_fd)
> -{
> -       struct bpf_prog_load_attr attr;
> -
> -       memset(&attr, 0, sizeof(struct bpf_prog_load_attr));
> -       attr.file = file;
> -       attr.prog_type = type;
> -       attr.expected_attach_type = 0;
> -       attr.prog_flags = BPF_F_TEST_RND_HI32;
> -       attr.log_level = extra_prog_load_log_flags;
> -
> -       return bpf_prog_load_xattr(&attr, pobj, prog_fd);
> -}

> +int extra_prog_load_log_flags = 0;
> +
> +int bpf_prog_test_load(const char *file, enum bpf_prog_type type,
> +                      struct bpf_object **pobj, int *prog_fd)
> +{
> +       struct bpf_object *obj;
> +       struct bpf_program *prog;
> +       int err;
> +
> +       obj = bpf_object__open(file);
> +       if (!obj)
> +               return -errno;
> +
> +       prog = bpf_object__next_program(obj, NULL);
> +       if (!prog) {
> +               err = -ENOENT;
> +               goto err_out;
> +       }
> +
> +       if (type != BPF_PROG_TYPE_UNSPEC)
> +               bpf_program__set_type(prog, type);
> +
> +       err = bpf_object__load(obj);
> +       if (err)
> +               goto err_out;
> +
> +       *pobj = obj;
> +       *prog_fd = bpf_program__fd(prog);
> +
> +       return 0;
> +err_out:
> +       bpf_object__close(obj);
> +       return err;
> +}

Andrii,
That part of the commit broke verbose output in the test.
-v and -vv no longer work for tests that use bpf_prog_test_load()
because extra_prog_load_log_flags are ignored.

Please fix.



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux