Move filesystem into Config
The filesystem object was available through ModuleContext.Fs(), but
gives too much access to the filesystem without enforicing correct
dependencies. In order to support sandboxing the soong_build
process move the filesystem into the Config. The next change will
make it private.
Bug: 146437378
Test: all Soong tests
Change-Id: I5d3ae9108f120fd335b21efd612aefa078378813
diff --git a/bpf/bpf_test.go b/bpf/bpf_test.go
index 73b90ba..eeca057 100644
--- a/bpf/bpf_test.go
+++ b/bpf/bpf_test.go
@@ -48,21 +48,24 @@
os.Exit(run())
}
-func testContext(bp string) *android.TestContext {
+func testConfig(buildDir string, env map[string]string, bp string) android.Config {
mockFS := map[string][]byte{
"bpf.c": nil,
"BpfTest.cpp": nil,
}
- ctx := cc.CreateTestContext(bp, mockFS, android.Android)
+ return cc.TestConfig(buildDir, android.Android, env, bp, mockFS)
+}
+
+func testContext(config android.Config) *android.TestContext {
+ ctx := cc.CreateTestContext()
ctx.RegisterModuleType("bpf", bpfFactory)
- ctx.Register()
+ ctx.Register(config)
return ctx
}
func TestBpfDataDependency(t *testing.T) {
- config := android.TestArchConfig(buildDir, nil)
bp := `
bpf {
name: "bpf.o",
@@ -77,7 +80,9 @@
}
`
- ctx := testContext(bp)
+ config := testConfig(buildDir, nil, bp)
+ ctx := testContext(config)
+
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
if errs == nil {
_, errs = ctx.PrepareBuildActions(config)