]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
selftests/bpf: impose global ordering for test decl_tags
authorEduard Zingerman <eddyz87@gmail.com>
Sat, 11 Apr 2026 07:33:46 +0000 (00:33 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Sat, 11 Apr 2026 14:17:06 +0000 (07:17 -0700)
commit713db9fd0336e8fade7e776ab807c21fd8b7a0f1
treeb9e9c7c7e64f5c650253f5965fbe2c89af6fcb71
parent5160e584c3616e744252d0a571264f9745bc6e11
selftests/bpf: impose global ordering for test decl_tags

Impose global ordering for all decl tags used by test_loader.c based
tests (__success, __failure, __msg, etc):
- change every tag to expand as
  __attribute__((btf_decl_tag("comment:" XSTR(__COUNTER__) ...)))
- change parse_test_spec() to collect all decl tags before
  processing and sort them using strverscmp().

The ordering is necessary for gcc-bpf.
Neither GCC nor the C standard defines the order in which function
attributes are consumed. While Clang tends to preserve definition order,
GCC may process them out of sequence. This inconsistency causes BPF
tests with multiple __msg entries to fail when compiled with GCC.

Signed-off-by: Cupertino Miranda <cupertino.miranda@oracle.com>
Reviewed-by: Puranjay Mohan <puranjay@kernel.org>
Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
Link: https://lore.kernel.org/r/20260410-selftests-global-tags-ordering-v2-3-c566ec9781bf@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/progs/bpf_misc.h
tools/testing/selftests/bpf/test_loader.c