diff options
author | Jaewoong Jung <jungjw@google.com> | 2019-05-16 14:58:29 -0700 |
---|---|---|
committer | Michael Bestas <mkbestas@lineageos.org> | 2019-12-11 19:03:32 +0200 |
commit | 8ce0a3785542060ec0d985a4c911d89f5aa94998 (patch) | |
tree | bda51ab90b00be685adfc2952b7c0c3ef90ba629 /android/sh_binary_test.go | |
parent | 644902ccf9240fb31d4f598af85549536c144d09 (diff) | |
download | android_build_soong-8ce0a3785542060ec0d985a4c911d89f5aa94998.tar.gz android_build_soong-8ce0a3785542060ec0d985a4c911d89f5aa94998.tar.bz2 android_build_soong-8ce0a3785542060ec0d985a4c911d89f5aa94998.zip |
Add data property to sh_test.
Fixes: 131861785
Test: sh_binary_test.go, a real sh_test with added data
Change-Id: Ic78022d2db38a530074c70823ef16773d8ba6821
Diffstat (limited to 'android/sh_binary_test.go')
-rw-r--r-- | android/sh_binary_test.go | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/android/sh_binary_test.go b/android/sh_binary_test.go new file mode 100644 index 00000000..becb35a2 --- /dev/null +++ b/android/sh_binary_test.go @@ -0,0 +1,58 @@ +package android + +import ( + "io/ioutil" + "os" + "reflect" + "testing" +) + +func testShBinary(t *testing.T, bp string) (*TestContext, Config) { + buildDir, err := ioutil.TempDir("", "soong_sh_binary_test") + if err != nil { + t.Fatal(err) + } + defer os.RemoveAll(buildDir) + + config := TestArchConfig(buildDir, nil) + + ctx := NewTestArchContext() + ctx.RegisterModuleType("sh_test", ModuleFactoryAdaptor(ShTestFactory)) + ctx.Register() + mockFiles := map[string][]byte{ + "Android.bp": []byte(bp), + "test.sh": nil, + "testdata/data1": nil, + "testdata/sub/data2": nil, + } + ctx.MockFileSystem(mockFiles) + _, errs := ctx.ParseFileList(".", []string{"Android.bp"}) + FailIfErrored(t, errs) + _, errs = ctx.PrepareBuildActions(config) + FailIfErrored(t, errs) + + return ctx, config +} + +func TestShTestTestData(t *testing.T) { + ctx, config := testShBinary(t, ` + sh_test { + name: "foo", + src: "test.sh", + filename: "test.sh", + data: [ + "testdata/data1", + "testdata/sub/data2", + ], + } + `) + + mod := ctx.ModuleForTests("foo", "android_arm64_armv8-a").Module().(*ShTest) + + entries := AndroidMkEntriesForTest(t, config, "", mod) + 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) + } +} |