Loading android/sh_binary.go +12 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ func init() { RegisterModuleType("sh_binary", ShBinaryFactory) RegisterModuleType("sh_binary_host", ShBinaryHostFactory) RegisterModuleType("sh_test", ShTestFactory) RegisterModuleType("sh_test_host", ShTestHostFactory) } type shBinaryProperties struct { Loading Loading @@ -195,6 +196,7 @@ func ShBinaryHostFactory() Module { return module } // sh_test defines a shell script based test module. func ShTestFactory() Module { module := &ShTest{} InitShBinaryModule(&module.ShBinary) Loading @@ -203,3 +205,13 @@ func ShTestFactory() Module { InitAndroidArchModule(module, HostAndDeviceSupported, MultilibFirst) return module } // sh_test_host defines a shell script based test module that runs on a host. func ShTestHostFactory() Module { module := &ShTest{} InitShBinaryModule(&module.ShBinary) module.AddProperties(&module.testProperties) InitAndroidArchModule(module, HostSupported, MultilibFirst) return module } android/sh_binary_test.go +21 −0 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ func testShBinary(t *testing.T, bp string) (*TestContext, Config) { ctx := NewTestArchContext() ctx.RegisterModuleType("sh_test", ModuleFactoryAdaptor(ShTestFactory)) ctx.RegisterModuleType("sh_test_host", ModuleFactoryAdaptor(ShTestHostFactory)) ctx.Register() mockFiles := map[string][]byte{ "Android.bp": []byte(bp), Loading Loading @@ -48,3 +49,23 @@ func TestShTestTestData(t *testing.T) { t.Errorf("Unexpected test data expected: %q, actual: %q", expected, actual) } } func TestShTestHost(t *testing.T) { ctx, _ := testShBinary(t, ` sh_test_host { name: "foo", src: "test.sh", filename: "test.sh", data: [ "testdata/data1", "testdata/sub/data2", ], } `) buildOS := BuildOs.String() mod := ctx.ModuleForTests("foo", buildOS+"_x86_64").Module().(*ShTest) if !mod.Host() { t.Errorf("host bit is not set for a sh_test_host module.") } } Loading
android/sh_binary.go +12 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ func init() { RegisterModuleType("sh_binary", ShBinaryFactory) RegisterModuleType("sh_binary_host", ShBinaryHostFactory) RegisterModuleType("sh_test", ShTestFactory) RegisterModuleType("sh_test_host", ShTestHostFactory) } type shBinaryProperties struct { Loading Loading @@ -195,6 +196,7 @@ func ShBinaryHostFactory() Module { return module } // sh_test defines a shell script based test module. func ShTestFactory() Module { module := &ShTest{} InitShBinaryModule(&module.ShBinary) Loading @@ -203,3 +205,13 @@ func ShTestFactory() Module { InitAndroidArchModule(module, HostAndDeviceSupported, MultilibFirst) return module } // sh_test_host defines a shell script based test module that runs on a host. func ShTestHostFactory() Module { module := &ShTest{} InitShBinaryModule(&module.ShBinary) module.AddProperties(&module.testProperties) InitAndroidArchModule(module, HostSupported, MultilibFirst) return module }
android/sh_binary_test.go +21 −0 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ func testShBinary(t *testing.T, bp string) (*TestContext, Config) { ctx := NewTestArchContext() ctx.RegisterModuleType("sh_test", ModuleFactoryAdaptor(ShTestFactory)) ctx.RegisterModuleType("sh_test_host", ModuleFactoryAdaptor(ShTestHostFactory)) ctx.Register() mockFiles := map[string][]byte{ "Android.bp": []byte(bp), Loading Loading @@ -48,3 +49,23 @@ func TestShTestTestData(t *testing.T) { t.Errorf("Unexpected test data expected: %q, actual: %q", expected, actual) } } func TestShTestHost(t *testing.T) { ctx, _ := testShBinary(t, ` sh_test_host { name: "foo", src: "test.sh", filename: "test.sh", data: [ "testdata/data1", "testdata/sub/data2", ], } `) buildOS := BuildOs.String() mod := ctx.ModuleForTests("foo", buildOS+"_x86_64").Module().(*ShTest) if !mod.Host() { t.Errorf("host bit is not set for a sh_test_host module.") } }