Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Yonghong Song <yhs@fb.com>
To: Andrii Nakryiko <andriin@fb.com>, <bpf@vger.kernel.org>,
	<netdev@vger.kernel.org>, <ast@fb.com>, <daniel@iogearbox.net>
Cc: <andrii.nakryiko@gmail.com>, <kernel-team@fb.com>
Subject: Re: [PATCH v2 bpf-next 5/5] selftests/bpf: add tests for ENUMVAL_EXISTS/ENUMVAL_VALUE relocations
Date: Wed, 19 Aug 2020 09:44:32 -0700	[thread overview]
Message-ID: <494555f1-7c3b-76e3-b8ad-bfd56cf36a8d@fb.com> (raw)
In-Reply-To: <20200819052849.336700-6-andriin@fb.com>



On 8/18/20 10:28 PM, Andrii Nakryiko wrote:
> Add tests validating existence and value relocations for enum value-based
> relocations. If __builtin_preserve_enum_value() built-in is not supported,
> skip tests.
> 
> Signed-off-by: Andrii Nakryiko <andriin@fb.com>
> ---
>   .../selftests/bpf/prog_tests/core_reloc.c     | 56 +++++++++++++
>   .../bpf/progs/btf__core_reloc_enumval.c       |  3 +
>   .../progs/btf__core_reloc_enumval___diff.c    |  3 +
>   .../btf__core_reloc_enumval___err_missing.c   |  3 +
>   .../btf__core_reloc_enumval___val3_missing.c  |  3 +
>   .../selftests/bpf/progs/core_reloc_types.h    | 84 +++++++++++++++++++
>   .../bpf/progs/test_core_reloc_enumval.c       | 73 ++++++++++++++++
>   7 files changed, 225 insertions(+)
>   create mode 100644 tools/testing/selftests/bpf/progs/btf__core_reloc_enumval.c
>   create mode 100644 tools/testing/selftests/bpf/progs/btf__core_reloc_enumval___diff.c
>   create mode 100644 tools/testing/selftests/bpf/progs/btf__core_reloc_enumval___err_missing.c
>   create mode 100644 tools/testing/selftests/bpf/progs/btf__core_reloc_enumval___val3_missing.c
>   create mode 100644 tools/testing/selftests/bpf/progs/test_core_reloc_enumval.c
> 
> diff --git a/tools/testing/selftests/bpf/prog_tests/core_reloc.c b/tools/testing/selftests/bpf/prog_tests/core_reloc.c
> index ad550510ef69..30e40ff4b0d8 100644
> --- a/tools/testing/selftests/bpf/prog_tests/core_reloc.c
> +++ b/tools/testing/selftests/bpf/prog_tests/core_reloc.c
> @@ -289,6 +289,23 @@ static int duration = 0;
>   	.fails = true,							\
>   }
>   
[...]
> +
> +SEC("raw_tracepoint/sys_enter")
> +int test_core_enumval(void *ctx)
> +{
> +#if __has_builtin(__builtin_preserve_enum_value)
> +	struct core_reloc_enumval_output *out = (void *)&data.out;
> +	enum named_enum named = 0;
> +	anon_enum anon = 0;
> +
> +	out->named_val1_exists = bpf_core_enum_value_exists(named, NAMED_ENUM_VAL1);
> +	out->named_val2_exists = bpf_core_enum_value_exists(enum named_enum, NAMED_ENUM_VAL2);
> +	out->named_val3_exists = bpf_core_enum_value_exists(enum named_enum, NAMED_ENUM_VAL3);
> +
> +	out->anon_val1_exists = bpf_core_enum_value_exists(anon, ANON_ENUM_VAL1);
> +	out->anon_val2_exists = bpf_core_enum_value_exists(anon_enum, ANON_ENUM_VAL2);
> +	out->anon_val3_exists = bpf_core_enum_value_exists(anon_enum, ANON_ENUM_VAL3);
> +
> +	out->named_val1 = bpf_core_enum_value(named, NAMED_ENUM_VAL1);
> +	out->named_val2 = bpf_core_enum_value(named, NAMED_ENUM_VAL2);
> +	/* NAMED_ENUM_VAL3 value is optional */
> +
> +	out->anon_val1 = bpf_core_enum_value(anon, ANON_ENUM_VAL1);
> +	out->anon_val2 = bpf_core_enum_value(anon, ANON_ENUM_VAL2);
> +	/* ANON_ENUM_VAL3 value is optional */
> +#else
> +	data.skip = true;
> +#endif
> +
> +	return 0;
> +}
> +

empty line at the end of file?

  reply	other threads:[~2020-08-19 16:45 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-19  5:28 [PATCH v2 bpf-next 0/5] Add support for type-based and enum value-based CO-RE relocations Andrii Nakryiko
2020-08-19  5:28 ` [PATCH v2 bpf-next 1/5] libbpf: implement type-based CO-RE relocations support Andrii Nakryiko
2020-08-19  5:28 ` [PATCH v2 bpf-next 2/5] selftests/bpf: test TYPE_EXISTS and TYPE_SIZE CO-RE relocations Andrii Nakryiko
2020-08-19 16:30   ` Yonghong Song
2020-08-19 19:29     ` Andrii Nakryiko
2020-08-19  5:28 ` [PATCH v2 bpf-next 3/5] selftests/bpf: add CO-RE relo test for TYPE_ID_LOCAL/TYPE_ID_TARGET Andrii Nakryiko
2020-08-19 16:43   ` Yonghong Song
2020-08-19 19:30     ` Andrii Nakryiko
2020-08-19  5:28 ` [PATCH v2 bpf-next 4/5] libbpf: implement enum value-based CO-RE relocations Andrii Nakryiko
2020-08-19  5:28 ` [PATCH v2 bpf-next 5/5] selftests/bpf: add tests for ENUMVAL_EXISTS/ENUMVAL_VALUE relocations Andrii Nakryiko
2020-08-19 16:44   ` Yonghong Song [this message]
2020-08-19 16:24 ` [PATCH v2 bpf-next 0/5] Add support for type-based and enum value-based CO-RE relocations Yonghong Song

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=494555f1-7c3b-76e3-b8ad-bfd56cf36a8d@fb.com \
    --to=yhs@fb.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=andriin@fb.com \
    --cc=ast@fb.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@fb.com \
    --cc=netdev@vger.kernel.org \
    --subject='Re: [PATCH v2 bpf-next 5/5] selftests/bpf: add tests for ENUMVAL_EXISTS/ENUMVAL_VALUE relocations' \
    /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).