diff options
| author | Jaewoong Jung <jungjw@google.com> | 2019-07-01 09:08:50 -0700 |
|---|---|---|
| committer | Rashed Abdel-Tawab <rashed@linux.com> | 2019-09-27 20:31:01 -0700 |
| commit | adb44249fcb9db2ade144ea62fed0fa9fd02a016 (patch) | |
| tree | 4c7596030356cedc835f55840e95adcc83e412b2 | |
| parent | cc8db23a1603ef9d51c64998c66d162c62023791 (diff) | |
| download | build_soong-adb44249fcb9db2ade144ea62fed0fa9fd02a016.tar.gz build_soong-adb44249fcb9db2ade144ea62fed0fa9fd02a016.tar.bz2 build_soong-adb44249fcb9db2ade144ea62fed0fa9fd02a016.zip | |
Add sh_test_host.
Fixes: 136272143
Test: sh_binary_test.go
Change-Id: I2e6580286fcdf43ab20020fcd147648a3009aa9f
| -rw-r--r-- | android/sh_binary.go | 12 | ||||
| -rw-r--r-- | android/sh_binary_test.go | 21 |
2 files changed, 33 insertions, 0 deletions
diff --git a/android/sh_binary.go b/android/sh_binary.go index fb7446dc..2855aa04 100644 --- a/android/sh_binary.go +++ b/android/sh_binary.go @@ -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 { @@ -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) @@ -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 +} diff --git a/android/sh_binary_test.go b/android/sh_binary_test.go index becb35a2..67360830 100644 --- a/android/sh_binary_test.go +++ b/android/sh_binary_test.go @@ -18,6 +18,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), @@ -56,3 +57,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.") + } +} |
