diff options
author | Jaewoong Jung <jungjw@google.com> | 2020-06-10 17:23:46 -0700 |
---|---|---|
committer | Jaewoong Jung <jungjw@google.com> | 2020-06-18 17:15:48 -0700 |
commit | 4aedc86c6c9a24c74ecabf380b7b0b12f66f589e (patch) | |
tree | 596ecf8fbf4586962917f86dbe4a6180c732ef10 /sh/sh_binary_test.go | |
parent | 0e63a8e76180fe7a92000b6aa3bc0d5e64e2c564 (diff) |
Add module name to sh_test install path.
This relands Ibb1d774709ea421e18d5350009c203f83c5b2d60 after fixing
a backward compatibility issue where some test configs rely on sh_tests
not having a module name in their paths when sub_dir is specified.
Bug: 156980228
Test: m ziptool-tests
Test: sh_binary_test.go
Change-Id: If0521a008e7170d94b601f3df9dd0c12d1c96d21
Diffstat (limited to 'sh/sh_binary_test.go')
-rw-r--r-- | sh/sh_binary_test.go | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/sh/sh_binary_test.go b/sh/sh_binary_test.go index 6c0d96abe..3bfe6110a 100644 --- a/sh/sh_binary_test.go +++ b/sh/sh_binary_test.go @@ -55,7 +55,27 @@ func testShBinary(t *testing.T, bp string) (*android.TestContext, android.Config return ctx, config } -func TestShTestTestData(t *testing.T) { +func TestShTestSubDir(t *testing.T) { + ctx, config := testShBinary(t, ` + sh_test { + name: "foo", + src: "test.sh", + sub_dir: "foo_test" + } + `) + + mod := ctx.ModuleForTests("foo", "android_arm64_armv8-a").Module().(*ShTest) + + entries := android.AndroidMkEntriesForTest(t, config, "", mod)[0] + + expectedPath := "/tmp/target/product/test_device/data/nativetest64/foo_test" + actualPath := entries.EntryMap["LOCAL_MODULE_PATH"][0] + if expectedPath != actualPath { + t.Errorf("Unexpected LOCAL_MODULE_PATH expected: %q, actual: %q", expectedPath, actualPath) + } +} + +func TestShTest(t *testing.T) { ctx, config := testShBinary(t, ` sh_test { name: "foo", @@ -71,10 +91,17 @@ func TestShTestTestData(t *testing.T) { mod := ctx.ModuleForTests("foo", "android_arm64_armv8-a").Module().(*ShTest) entries := android.AndroidMkEntriesForTest(t, config, "", mod)[0] - expected := []string{":testdata/data1", ":testdata/sub/data2"} - actual := entries.EntryMap["LOCAL_TEST_DATA"] - if !reflect.DeepEqual(expected, actual) { - t.Errorf("Unexpected test data expected: %q, actual: %q", expected, actual) + + expectedPath := "/tmp/target/product/test_device/data/nativetest64/foo" + actualPath := entries.EntryMap["LOCAL_MODULE_PATH"][0] + if expectedPath != actualPath { + t.Errorf("Unexpected LOCAL_MODULE_PATH expected: %q, actual: %q", expectedPath, actualPath) + } + + expectedData := []string{":testdata/data1", ":testdata/sub/data2"} + actualData := entries.EntryMap["LOCAL_TEST_DATA"] + if !reflect.DeepEqual(expectedData, actualData) { + t.Errorf("Unexpected test data expected: %q, actual: %q", expectedData, actualData) } } |