diff options
author | Dan Willemsen <dwillemsen@google.com> | 2017-07-06 16:59:48 -0700 |
---|---|---|
committer | Dan Willemsen <dwillemsen@google.com> | 2017-07-06 18:09:46 -0700 |
commit | 00269f23ee1c2d03d7fa88aada4911f7da25f531 (patch) | |
tree | be521c20e103466b23a9bf91bd4e73806d3f62f9 /android/paths_test.go | |
parent | 4c35af09ea774288959b347d81365329b13be3a1 (diff) | |
download | build_soong-00269f23ee1c2d03d7fa88aada4911f7da25f531.tar.gz build_soong-00269f23ee1c2d03d7fa88aada4911f7da25f531.tar.bz2 build_soong-00269f23ee1c2d03d7fa88aada4911f7da25f531.zip |
Fix install location for vendor tests
These should be install in /data/nativetest* with the rest of the tests,
but had been moved to /vendor/nativetest* accidentally. Add some tests
so that this doesn't happen again.
Bug: 63393698
Test: m -j blueprint_tools
Test: compare out/soong/Android-aosp_arm64.mk
Test: compare out/soong/build.ninja
Change-Id: Id3b08a7e3908955df18a043a02ea576dc88086c3
Diffstat (limited to 'android/paths_test.go')
-rw-r--r-- | android/paths_test.go | 160 |
1 files changed, 160 insertions, 0 deletions
diff --git a/android/paths_test.go b/android/paths_test.go index 9d69473a..3986b71c 100644 --- a/android/paths_test.go +++ b/android/paths_test.go @@ -20,6 +20,8 @@ import ( "reflect" "strings" "testing" + + "github.com/google/blueprint/pathtools" ) type strsTestCase struct { @@ -180,3 +182,161 @@ func p(in interface{}) string { return fmt.Sprintf("%#v", in) } } + +type moduleInstallPathContextImpl struct { + androidBaseContextImpl + + inData bool + inSanitizerDir bool +} + +func (moduleInstallPathContextImpl) Fs() pathtools.FileSystem { + return pathtools.MockFs(nil) +} + +func (m moduleInstallPathContextImpl) Config() interface{} { + return m.androidBaseContextImpl.config +} + +func (moduleInstallPathContextImpl) AddNinjaFileDeps(deps ...string) {} + +func (m moduleInstallPathContextImpl) InstallInData() bool { + return m.inData +} + +func (m moduleInstallPathContextImpl) InstallInSanitizerDir() bool { + return m.inSanitizerDir +} + +func TestPathForModuleInstall(t *testing.T) { + testConfig := TestConfig("") + + hostTarget := Target{Os: Linux} + deviceTarget := Target{Os: Android} + + testCases := []struct { + name string + ctx *moduleInstallPathContextImpl + in []string + out string + }{ + { + name: "host binary", + ctx: &moduleInstallPathContextImpl{ + androidBaseContextImpl: androidBaseContextImpl{ + target: hostTarget, + }, + }, + in: []string{"bin", "my_test"}, + out: "host/linux-x86/bin/my_test", + }, + + { + name: "system binary", + ctx: &moduleInstallPathContextImpl{ + androidBaseContextImpl: androidBaseContextImpl{ + target: deviceTarget, + }, + }, + in: []string{"bin", "my_test"}, + out: "target/product/test_device/system/bin/my_test", + }, + { + name: "vendor binary", + ctx: &moduleInstallPathContextImpl{ + androidBaseContextImpl: androidBaseContextImpl{ + target: deviceTarget, + vendor: true, + }, + }, + in: []string{"bin", "my_test"}, + out: "target/product/test_device/vendor/bin/my_test", + }, + + { + name: "system native test binary", + ctx: &moduleInstallPathContextImpl{ + androidBaseContextImpl: androidBaseContextImpl{ + target: deviceTarget, + }, + inData: true, + }, + in: []string{"nativetest", "my_test"}, + out: "target/product/test_device/data/nativetest/my_test", + }, + { + name: "vendor native test binary", + ctx: &moduleInstallPathContextImpl{ + androidBaseContextImpl: androidBaseContextImpl{ + target: deviceTarget, + vendor: true, + }, + inData: true, + }, + in: []string{"nativetest", "my_test"}, + out: "target/product/test_device/data/nativetest/my_test", + }, + + { + name: "sanitized system binary", + ctx: &moduleInstallPathContextImpl{ + androidBaseContextImpl: androidBaseContextImpl{ + target: deviceTarget, + }, + inSanitizerDir: true, + }, + in: []string{"bin", "my_test"}, + out: "target/product/test_device/data/asan/system/bin/my_test", + }, + { + name: "sanitized vendor binary", + ctx: &moduleInstallPathContextImpl{ + androidBaseContextImpl: androidBaseContextImpl{ + target: deviceTarget, + vendor: true, + }, + inSanitizerDir: true, + }, + in: []string{"bin", "my_test"}, + out: "target/product/test_device/data/asan/vendor/bin/my_test", + }, + + { + name: "sanitized system native test binary", + ctx: &moduleInstallPathContextImpl{ + androidBaseContextImpl: androidBaseContextImpl{ + target: deviceTarget, + }, + inData: true, + inSanitizerDir: true, + }, + in: []string{"nativetest", "my_test"}, + out: "target/product/test_device/data/asan/data/nativetest/my_test", + }, + { + name: "sanitized vendor native test binary", + ctx: &moduleInstallPathContextImpl{ + androidBaseContextImpl: androidBaseContextImpl{ + target: deviceTarget, + vendor: true, + }, + inData: true, + inSanitizerDir: true, + }, + in: []string{"nativetest", "my_test"}, + out: "target/product/test_device/data/asan/data/nativetest/my_test", + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + tc.ctx.androidBaseContextImpl.config = testConfig + output := PathForModuleInstall(tc.ctx, tc.in...) + if output.basePath.path != tc.out { + t.Errorf("unexpected path:\n got: %q\nwant: %q\n", + output.basePath.path, + tc.out) + } + }) + } +} |