Re: [PATCH bpf-next v1 4/4] selftests/bpf: Add kfunc set test to resolve_btfids

Eduard Zingerman <[email protected]>
Newsgroups org.kernel.vger.linux-kbuild,org.kernel.vger.bpf
Message-ID <[email protected]>
On Wed, 2026-06-17 at 14:06 -0700, Ihor Solodrai wrote:

[...]

> @@ -161,6 +189,27 @@ void test_resolve_btfids(void)
>  			ASSERT_LE(test_set.ids[i - 1], test_set.ids[i], "sort_check");
>  	}
>  
> +	/* Check BTF_KFUNCS_START(test_kfunc_set) */
> +	ASSERT_EQ(test_kfunc_set.flags, BTF_SET8_KFUNCS, "kfunc_set_flags");
> +	ASSERT_EQ(test_kfunc_set.cnt, ARRAY_SIZE(kfunc_symbols), "kfunc_set_cnt");
> +
> +	for (i = 0; i < test_kfunc_set.cnt; i++) {
> +		for (j = 0; j < ARRAY_SIZE(kfunc_symbols); j++) {
> +			if (kfunc_symbols[j].id == (s32)test_kfunc_set.pairs[i].id) {
> +				ASSERT_EQ(test_kfunc_set.pairs[i].flags,
> +					  kfunc_symbols[j].flags, "kfunc_flags_check");
> +				break;
> +			}
> +		}
> +
> +		ASSERT_TRUE(j < ARRAY_SIZE(kfunc_symbols), "kfunc_id_found");
> +
> +		if (i > 0) {
> +			ASSERT_LE(test_kfunc_set.pairs[i - 1].id,
> +				  test_kfunc_set.pairs[i].id, "kfunc_sort_check");
> +		}

To assert the sorted property, should one define two sets?
{ a, b } and { b, a }? And check both.
Otherwise the id assignments might be an artifact of compiler BTF
generation logic.

> +	}
> +
>  out:
>  	btf__free(btf);
>  }

[...]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.