diff options
author | Dan Shi <dshi@google.com> | 2021-05-24 12:04:54 -0700 |
---|---|---|
committer | Dan Shi <dshi@google.com> | 2021-05-24 12:06:23 -0700 |
commit | b40deac01840308f302174b6d85da4ee81ad4d04 (patch) | |
tree | 1984c9f2f8e0b6d87c65db40c2db30b447c4c760 /sh | |
parent | 18cf19745e2fffb184a7b42f50609ea98d4adb1d (diff) | |
download | soong-b40deac01840308f302174b6d85da4ee81ad4d04.tar.gz |
Add unit_test test option in sh_test_host
This change allows sh_test_host to be included
in host-unit-tests suite when test option `unit_test` is set to true.
Bug: 183209767
Test: m host-unit-tests
Change-Id: I5b441d5f49468cb681eb414dade8a1309c6e810a
Diffstat (limited to 'sh')
-rw-r--r-- | sh/sh_binary.go | 12 | ||||
-rw-r--r-- | sh/sh_binary_test.go | 7 |
2 files changed, 19 insertions, 0 deletions
diff --git a/sh/sh_binary.go b/sh/sh_binary.go index 42d5680f1..4805846b7 100644 --- a/sh/sh_binary.go +++ b/sh/sh_binary.go @@ -104,6 +104,12 @@ type shBinaryProperties struct { Recovery_available *bool } +// Test option struct. +type TestOptions struct { + // If the test is a hostside(no device required) unittest that shall be run during presubmit check. + Unit_test *bool +} + type TestProperties struct { // list of compatibility suites (for example "cts", "vts") that the module should be // installed into. @@ -143,6 +149,9 @@ type TestProperties struct { // list of device library modules that should be installed alongside the test. // Only available for host sh_test modules. Data_device_libs []string `android:"path,arch_variant"` + + // Test options. + Test_options TestOptions } type ShBinary struct { @@ -440,6 +449,9 @@ func (s *ShTest) AndroidMkEntries() []android.AndroidMkEntries { dir := strings.TrimSuffix(s.dataModules[relPath].String(), relPath) entries.AddStrings("LOCAL_TEST_DATA", dir+":"+relPath) } + if Bool(s.testProperties.Test_options.Unit_test) { + entries.SetBool("LOCAL_IS_UNIT_TEST", true) + } }, }, }} diff --git a/sh/sh_binary_test.go b/sh/sh_binary_test.go index 9e7e59462..20317d88c 100644 --- a/sh/sh_binary_test.go +++ b/sh/sh_binary_test.go @@ -3,6 +3,7 @@ package sh import ( "os" "path/filepath" + "strconv" "testing" "android/soong/android" @@ -148,6 +149,9 @@ func TestShTestHost(t *testing.T) { "testdata/data1", "testdata/sub/data2", ], + test_options: { + unit_test: true, + }, } `) @@ -156,6 +160,9 @@ func TestShTestHost(t *testing.T) { if !mod.Host() { t.Errorf("host bit is not set for a sh_test_host module.") } + entries := android.AndroidMkEntriesForTest(t, ctx, mod)[0] + actualData, _ := strconv.ParseBool(entries.EntryMap["LOCAL_IS_UNIT_TEST"][0]) + android.AssertBoolEquals(t, "LOCAL_IS_UNIT_TEST", true, actualData) } func TestShTestHost_dataDeviceModules(t *testing.T) { |