Merge "Disallow '_' in bpf source name"
This commit is contained in:
commit
d8cded58fe
3 changed files with 28 additions and 11 deletions
|
@ -619,7 +619,7 @@ func TestDefaults(t *testing.T) {
|
||||||
java_libs: ["myjar"],
|
java_libs: ["myjar"],
|
||||||
apps: ["AppFoo"],
|
apps: ["AppFoo"],
|
||||||
rros: ["rro"],
|
rros: ["rro"],
|
||||||
bpfs: ["bpf", "netd_test"],
|
bpfs: ["bpf", "netdTest"],
|
||||||
updatable: false,
|
updatable: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -673,8 +673,8 @@ func TestDefaults(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bpf {
|
bpf {
|
||||||
name: "netd_test",
|
name: "netdTest",
|
||||||
srcs: ["netd_test.c"],
|
srcs: ["netdTest.c"],
|
||||||
sub_dir: "netd",
|
sub_dir: "netd",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -687,7 +687,7 @@ func TestDefaults(t *testing.T) {
|
||||||
"overlay/blue/rro.apk",
|
"overlay/blue/rro.apk",
|
||||||
"etc/bpf/bpf.o",
|
"etc/bpf/bpf.o",
|
||||||
"etc/bpf/bpf2.o",
|
"etc/bpf/bpf2.o",
|
||||||
"etc/bpf/netd/netd_test.o",
|
"etc/bpf/netd/netdTest.o",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6153,7 +6153,7 @@ func TestOverrideApex(t *testing.T) {
|
||||||
name: "override_myapex",
|
name: "override_myapex",
|
||||||
base: "myapex",
|
base: "myapex",
|
||||||
apps: ["override_app"],
|
apps: ["override_app"],
|
||||||
bpfs: ["override_bpf"],
|
bpfs: ["overrideBpf"],
|
||||||
prebuilts: ["override_myetc"],
|
prebuilts: ["override_myetc"],
|
||||||
bootclasspath_fragments: ["override_bootclasspath_fragment"],
|
bootclasspath_fragments: ["override_bootclasspath_fragment"],
|
||||||
systemserverclasspath_fragments: ["override_systemserverclasspath_fragment"],
|
systemserverclasspath_fragments: ["override_systemserverclasspath_fragment"],
|
||||||
|
@ -6203,8 +6203,8 @@ func TestOverrideApex(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bpf {
|
bpf {
|
||||||
name: "override_bpf",
|
name: "overrideBpf",
|
||||||
srcs: ["override_bpf.c"],
|
srcs: ["overrideBpf.c"],
|
||||||
}
|
}
|
||||||
|
|
||||||
prebuilt_etc {
|
prebuilt_etc {
|
||||||
|
@ -6307,7 +6307,7 @@ func TestOverrideApex(t *testing.T) {
|
||||||
ensureContains(t, copyCmds, "image.apex/app/override_app@TEST.BUILD_ID/override_app.apk")
|
ensureContains(t, copyCmds, "image.apex/app/override_app@TEST.BUILD_ID/override_app.apk")
|
||||||
|
|
||||||
ensureNotContains(t, copyCmds, "image.apex/etc/bpf/bpf.o")
|
ensureNotContains(t, copyCmds, "image.apex/etc/bpf/bpf.o")
|
||||||
ensureContains(t, copyCmds, "image.apex/etc/bpf/override_bpf.o")
|
ensureContains(t, copyCmds, "image.apex/etc/bpf/overrideBpf.o")
|
||||||
|
|
||||||
ensureNotContains(t, copyCmds, "image.apex/etc/myetc")
|
ensureNotContains(t, copyCmds, "image.apex/etc/myetc")
|
||||||
ensureContains(t, copyCmds, "image.apex/etc/override_myetc")
|
ensureContains(t, copyCmds, "image.apex/etc/override_myetc")
|
||||||
|
@ -6341,7 +6341,7 @@ func TestOverrideApex(t *testing.T) {
|
||||||
data.Custom(&builder, name, "TARGET_", "", data)
|
data.Custom(&builder, name, "TARGET_", "", data)
|
||||||
androidMk := builder.String()
|
androidMk := builder.String()
|
||||||
ensureContains(t, androidMk, "LOCAL_MODULE := override_app.override_myapex")
|
ensureContains(t, androidMk, "LOCAL_MODULE := override_app.override_myapex")
|
||||||
ensureContains(t, androidMk, "LOCAL_MODULE := override_bpf.o.override_myapex")
|
ensureContains(t, androidMk, "LOCAL_MODULE := overrideBpf.o.override_myapex")
|
||||||
ensureContains(t, androidMk, "LOCAL_MODULE := apex_manifest.pb.override_myapex")
|
ensureContains(t, androidMk, "LOCAL_MODULE := apex_manifest.pb.override_myapex")
|
||||||
ensureContains(t, androidMk, "LOCAL_MODULE := override_bcplib.override_myapex")
|
ensureContains(t, androidMk, "LOCAL_MODULE := override_bcplib.override_myapex")
|
||||||
ensureContains(t, androidMk, "LOCAL_MODULE := override_systemserverlib.override_myapex")
|
ensureContains(t, androidMk, "LOCAL_MODULE := override_systemserverlib.override_myapex")
|
||||||
|
|
|
@ -17,6 +17,7 @@ package bpf
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
|
@ -154,6 +155,9 @@ func (bpf *bpf) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
srcs := android.PathsForModuleSrc(ctx, bpf.properties.Srcs)
|
srcs := android.PathsForModuleSrc(ctx, bpf.properties.Srcs)
|
||||||
|
|
||||||
for _, src := range srcs {
|
for _, src := range srcs {
|
||||||
|
if strings.ContainsRune(filepath.Base(src.String()), '_') {
|
||||||
|
ctx.ModuleErrorf("invalid character '_' in source name")
|
||||||
|
}
|
||||||
obj := android.ObjPathWithExt(ctx, "unstripped", src, "o")
|
obj := android.ObjPathWithExt(ctx, "unstripped", src, "o")
|
||||||
|
|
||||||
ctx.Build(pctx, android.BuildParams{
|
ctx.Build(pctx, android.BuildParams{
|
||||||
|
|
|
@ -31,6 +31,7 @@ var prepareForBpfTest = android.GroupFixturePreparers(
|
||||||
android.FixtureMergeMockFs(
|
android.FixtureMergeMockFs(
|
||||||
map[string][]byte{
|
map[string][]byte{
|
||||||
"bpf.c": nil,
|
"bpf.c": nil,
|
||||||
|
"bpf_invalid_name.c": nil,
|
||||||
"BpfTest.cpp": nil,
|
"BpfTest.cpp": nil,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -58,3 +59,15 @@ func TestBpfDataDependency(t *testing.T) {
|
||||||
// value is not available for testing from this package.
|
// value is not available for testing from this package.
|
||||||
// TODO(jungjw): Add a check for data or move this test to the cc 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)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue