Loading android/neverallow.go +10 −0 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ func createNeverAllows() []*rule { rules = append(rules, createTrebleRules()...) rules = append(rules, createLibcoreRules()...) rules = append(rules, createJavaDeviceForHostRules()...) rules = append(rules, createJavaLibraryHostRules()...) return rules } Loading Loading @@ -127,6 +128,15 @@ func createJavaDeviceForHostRules() []*rule { } } func createJavaLibraryHostRules() []*rule { return []*rule{ neverallow(). moduleType("java_library_host"). with("no_standard_libs", "true"). because("no_standard_libs makes no sense with java_library_host"), } } func neverallowMutator(ctx BottomUpMutatorContext) { m, ok := ctx.Module().(Module) if !ok { Loading android/neverallow_test.go +13 −0 Original line number Diff line number Diff line Loading @@ -178,6 +178,18 @@ var neverallowTests = []struct { }`), }, }, // java_library_host rule tests { name: "java_library_host with no_standard_libs: true", fs: map[string][]byte{ "libcore/Blueprints": []byte(` java_library_host { name: "inside_core_libraries", no_standard_libs: true, }`), }, expectedError: "module \"inside_core_libraries\": violates neverallow", }, } func TestNeverallow(t *testing.T) { Loading @@ -200,6 +212,7 @@ func testNeverallow(t *testing.T, config Config, fs map[string][]byte) (*TestCon ctx := NewTestContext() ctx.RegisterModuleType("cc_library", ModuleFactoryAdaptor(newMockCcLibraryModule)) ctx.RegisterModuleType("java_library", ModuleFactoryAdaptor(newMockJavaLibraryModule)) ctx.RegisterModuleType("java_library_host", ModuleFactoryAdaptor(newMockJavaLibraryModule)) ctx.RegisterModuleType("java_device_for_host", ModuleFactoryAdaptor(newMockJavaLibraryModule)) ctx.PostDepsMutators(registerNeverallowMutator) ctx.Register() Loading java/sdk_test.go +0 −7 Original line number Diff line number Diff line Loading @@ -136,13 +136,6 @@ func TestClasspath(t *testing.T) { bootclasspath: []string{"jdk8/jre/lib/jce.jar", "jdk8/jre/lib/rt.jar"}, classpath: []string{}, }, { name: "host nostdlib", moduleType: "java_library_host", host: android.Host, properties: `no_standard_libs: true`, classpath: []string{}, }, { name: "host supported default", Loading Loading
android/neverallow.go +10 −0 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ func createNeverAllows() []*rule { rules = append(rules, createTrebleRules()...) rules = append(rules, createLibcoreRules()...) rules = append(rules, createJavaDeviceForHostRules()...) rules = append(rules, createJavaLibraryHostRules()...) return rules } Loading Loading @@ -127,6 +128,15 @@ func createJavaDeviceForHostRules() []*rule { } } func createJavaLibraryHostRules() []*rule { return []*rule{ neverallow(). moduleType("java_library_host"). with("no_standard_libs", "true"). because("no_standard_libs makes no sense with java_library_host"), } } func neverallowMutator(ctx BottomUpMutatorContext) { m, ok := ctx.Module().(Module) if !ok { Loading
android/neverallow_test.go +13 −0 Original line number Diff line number Diff line Loading @@ -178,6 +178,18 @@ var neverallowTests = []struct { }`), }, }, // java_library_host rule tests { name: "java_library_host with no_standard_libs: true", fs: map[string][]byte{ "libcore/Blueprints": []byte(` java_library_host { name: "inside_core_libraries", no_standard_libs: true, }`), }, expectedError: "module \"inside_core_libraries\": violates neverallow", }, } func TestNeverallow(t *testing.T) { Loading @@ -200,6 +212,7 @@ func testNeverallow(t *testing.T, config Config, fs map[string][]byte) (*TestCon ctx := NewTestContext() ctx.RegisterModuleType("cc_library", ModuleFactoryAdaptor(newMockCcLibraryModule)) ctx.RegisterModuleType("java_library", ModuleFactoryAdaptor(newMockJavaLibraryModule)) ctx.RegisterModuleType("java_library_host", ModuleFactoryAdaptor(newMockJavaLibraryModule)) ctx.RegisterModuleType("java_device_for_host", ModuleFactoryAdaptor(newMockJavaLibraryModule)) ctx.PostDepsMutators(registerNeverallowMutator) ctx.Register() Loading
java/sdk_test.go +0 −7 Original line number Diff line number Diff line Loading @@ -136,13 +136,6 @@ func TestClasspath(t *testing.T) { bootclasspath: []string{"jdk8/jre/lib/jce.jar", "jdk8/jre/lib/rt.jar"}, classpath: []string{}, }, { name: "host nostdlib", moduleType: "java_library_host", host: android.Host, properties: `no_standard_libs: true`, classpath: []string{}, }, { name: "host supported default", Loading