diff options
author | 2022-07-07 17:48:06 +0800 | |
---|---|---|
committer | 2022-07-07 20:02:28 +0800 | |
commit | 5372a243758bd6f85f5d461915be55d9bc160b3f (patch) | |
tree | 9ea4b8ca1a9a9bd17f822885e8c3cc93303656a7 /bpf/bpf_test.go | |
parent | 100c7ad7f28c44ca9110f73b9886c22d00a005d1 (diff) |
Disallow '_' in bpf source name
Current design:
1. The bpf compiled object name is derived from the source name
(e.g. foo.c -> foo.o).
2. Full bpf program/map name are concatenated by object name + '_' +
program/map name in run-time. (e.g. obj name: x.o; program name: y_z;
full bpf program name will be x_y_z)
Issue:
x.o with map y_z and x_y.o with map z can cause naming collision in
run-time, since both result in x_y_z. This commit prevents it from
happening with a build-time check.
Bug: 236706995
Test: m
Change-Id: Ic03bfcf07a5748ed63246b71d5ae8de0405e658a
Diffstat (limited to 'bpf/bpf_test.go')
-rw-r--r-- | bpf/bpf_test.go | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/bpf/bpf_test.go b/bpf/bpf_test.go index 51fbc15e1..6e3909680 100644 --- a/bpf/bpf_test.go +++ b/bpf/bpf_test.go @@ -30,8 +30,9 @@ var prepareForBpfTest = android.GroupFixturePreparers( cc.PrepareForTestWithCcDefaultModules, android.FixtureMergeMockFs( map[string][]byte{ - "bpf.c": nil, - "BpfTest.cpp": nil, + "bpf.c": nil, + "bpf_invalid_name.c": nil, + "BpfTest.cpp": nil, }, ), PrepareForTestWithBpf, @@ -58,3 +59,15 @@ func TestBpfDataDependency(t *testing.T) { // value is not available for testing from this package. // TODO(jungjw): Add a check for data or move this test to the cc package. } + +func TestBpfSourceName(t *testing.T) { + bp := ` + bpf { + name: "bpf_invalid_name.o", + srcs: ["bpf_invalid_name.c"], + } + ` + prepareForBpfTest.ExtendWithErrorHandler(android.FixtureExpectsOneErrorPattern( + `\QAndroid.bp:2:3: module "bpf_invalid_name.o" variant "android_common": invalid character '_' in source name\E`)). + RunTestWithBp(t, bp) +} |