diff options
| author | Mark Brown <broonie@kernel.org> | 2020-12-11 17:47:55 +0000 | 
|---|---|---|
| committer | Mark Brown <broonie@kernel.org> | 2020-12-11 17:47:55 +0000 | 
| commit | 031616c434db05ce766f76c62865f55698e0924f (patch) | |
| tree | 7f29aa1ff3e7b51a8058cd570fb785c6e769b245 /tools/testing/selftests/bpf/prog_tests/resolve_btfids.c | |
| parent | 064841ccfc49b2315dc0b797239862d3a343aa07 (diff) | |
| parent | 85a7555575a0e48f9b73db310d0d762a08a46d63 (diff) | |
Merge remote-tracking branch 'asoc/for-5.10' into asoc-linus
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/resolve_btfids.c')
| -rw-r--r-- | tools/testing/selftests/bpf/prog_tests/resolve_btfids.c | 45 | 
1 files changed, 44 insertions, 1 deletions
| diff --git a/tools/testing/selftests/bpf/prog_tests/resolve_btfids.c b/tools/testing/selftests/bpf/prog_tests/resolve_btfids.c index 3b127cab4864..6ace5e9efec1 100644 --- a/tools/testing/selftests/bpf/prog_tests/resolve_btfids.c +++ b/tools/testing/selftests/bpf/prog_tests/resolve_btfids.c @@ -28,6 +28,12 @@ struct symbol test_symbols[] = {  	{ "func",    BTF_KIND_FUNC,    -1 },  }; +/* Align the .BTF_ids section to 4 bytes */ +asm ( +".pushsection " BTF_IDS_SECTION " ,\"a\"; \n" +".balign 4, 0;                            \n" +".popsection;                             \n"); +  BTF_ID_LIST(test_list_local)  BTF_ID_UNUSED  BTF_ID(typedef, S) @@ -47,6 +53,15 @@ BTF_ID(struct,  S)  BTF_ID(union,   U)  BTF_ID(func,    func) +BTF_SET_START(test_set) +BTF_ID(typedef, S) +BTF_ID(typedef, T) +BTF_ID(typedef, U) +BTF_ID(struct,  S) +BTF_ID(union,   U) +BTF_ID(func,    func) +BTF_SET_END(test_set) +  static int  __resolve_symbol(struct btf *btf, int type_id)  { @@ -116,12 +131,40 @@ int test_resolve_btfids(void)  	 */  	for (j = 0; j < ARRAY_SIZE(test_lists); j++) {  		test_list = test_lists[j]; -		for (i = 0; i < ARRAY_SIZE(test_symbols) && !ret; i++) { +		for (i = 0; i < ARRAY_SIZE(test_symbols); i++) {  			ret = CHECK(test_list[i] != test_symbols[i].id,  				    "id_check",  				    "wrong ID for %s (%d != %d)\n",  				    test_symbols[i].name,  				    test_list[i], test_symbols[i].id); +			if (ret) +				return ret; +		} +	} + +	/* Check BTF_SET_START(test_set) IDs */ +	for (i = 0; i < test_set.cnt; i++) { +		bool found = false; + +		for (j = 0; j < ARRAY_SIZE(test_symbols); j++) { +			if (test_symbols[j].id != test_set.ids[i]) +				continue; +			found = true; +			break; +		} + +		ret = CHECK(!found, "id_check", +			    "ID %d not found in test_symbols\n", +			    test_set.ids[i]); +		if (ret) +			break; + +		if (i > 0) { +			ret = CHECK(test_set.ids[i - 1] > test_set.ids[i], +				    "sort_check", +				    "test_set is not sorted\n"); +			if (ret) +				break;  		}  	} | 
