diff options
| author | mosimchah <mosimchah@gmail.com> | 2025-12-02 09:27:38 -0500 |
|---|---|---|
| committer | mosimchah <mosimchah@gmail.com> | 2025-12-02 09:27:38 -0500 |
| commit | c7bade461dc55726f62997d13a48582f7c4b4655 (patch) | |
| tree | ea0588da76060a2038f54f67efd046ca77634b10 /python/python_test.go | |
| parent | 0f5414d19317805e8bbbe7c4db5f0fd78769bad5 (diff) | |
| parent | 89d78cff8b00d3b20a90074635c3fe5a2ee49474 (diff) | |
Merge branch 'lineage-23.1' of https://github.com/LineageOS/android_build_soong into HEADw16.1
* 'lineage-23.1' of https://github.com/LineageOS/android_build_soong: (528 commits)
Revert "install_symlink: Make symlink target configurable"
Reapply "Clear as much of cc.Module as possible after GenerateBuildActions"
Revert "rust: config: Fix missing CPU variant LD flags in Rust"
Rename build-flag in outdir
Revert^4 "cipd: Default CIPD proxy server to on, add opt-out"
Convert check-vintf-all to phony with actions
Create a partial implementation of check-vintf-all for soong-only
Configure RBE rust pool based on build variant
Revert^3 "Add sdk version check to arr"
Add jdk.internal.invoke to the allowlist
Make droid always depend on symbols zip
Import Device and Odm skus
Don't install gob_gen in Soong
Remove bazel reference from run_integration_tests.sh
Fix bootstrap_test.sh
Don't panic in aconfig libraries when AllowMissingDependencies is set
Avoid returning nil paths from PathForModuleSrc
Revert "Flag controled clang version"
Rework module target dependencies on required deps
Revert^2 "Add sdk version check to arr"
...
Change-Id: I6e9a63fa14fda917a42e426e5dcebbad7f67e1de
Diffstat (limited to 'python/python_test.go')
| -rw-r--r-- | python/python_test.go | 97 |
1 files changed, 90 insertions, 7 deletions
diff --git a/python/python_test.go b/python/python_test.go index 5f971cdd1..696c27ff1 100644 --- a/python/python_test.go +++ b/python/python_test.go @@ -23,8 +23,6 @@ import ( "android/soong/android" "android/soong/cc" - - "github.com/google/blueprint" ) type pyModule struct { @@ -37,7 +35,7 @@ type pyModule struct { var ( buildNamePrefix = "soong_python_test" - moduleVariantErrTemplate = `%s: module %q variant "[a-zA-Z0-9_]*": ` + moduleVariantErrTemplate = `%s: module %q variant "[a-zA-Z0-9_\-]*": ` pkgPathErrTemplate = moduleVariantErrTemplate + "pkg_path: %q must be a relative path contained in par file." badIdentifierErrTemplate = moduleVariantErrTemplate + @@ -46,9 +44,11 @@ var ( "found two files to be placed at the same location within zip %q." + " First file: in module %s at path %q." + " Second file: in module %s at path %q." - badSrcFileExtErr = moduleVariantErrTemplate + `srcs: found non \(.py\|.proto\) file: %q!` - badDataFileExtErr = moduleVariantErrTemplate + `data: found \(.py\) file: %q!` - bpFile = "Android.bp" + badSrcFileExtErr = moduleVariantErrTemplate + `srcs: found non \(.py\|.proto\) file: %q!` + badDataFileExtErr = moduleVariantErrTemplate + `data: found \(.py\) file: %q!` + sharedLibErrTemplate = moduleVariantErrTemplate + + "shared_libs: shared_libs is not supported for device builds" + bpFile = "Android.bp" data = []struct { desc string @@ -206,6 +206,27 @@ var ( "lib1", "dir/c/file1.py"), }, }, + { + desc: "device module with shared libs", + mockFiles: map[string][]byte{ + filepath.Join("dir", bpFile): []byte( + `python_library { + name: "lib1", + srcs: [ + "file1.py", + ], + shared_libs: [ + "clib1", + ], + }`, + ), + "dir/file1.py": nil, + }, + errors: []string{ + fmt.Sprintf(sharedLibErrTemplate, + "dir/Android.bp:6:18", "lib1"), + }, + }, } ) @@ -268,7 +289,7 @@ func TestTestOnlyProvider(t *testing.T) { // marked as test-only are marked as test-only. actualTestOnly := []string{} - ctx.VisitAllModules(func(m blueprint.Module) { + ctx.VisitAllModules(func(m android.Module) { if provider, ok := android.OtherModuleProvider(ctx.TestContext.OtherModuleProviderAdaptor(), m, android.TestOnlyProviderKey); ok { if provider.TestOnly { actualTestOnly = append(actualTestOnly, m.Name()) @@ -312,6 +333,68 @@ func TestInvalidTestOnlyTargets(t *testing.T) { } } +func TestSharedLib(t *testing.T) { + ctx := android.GroupFixturePreparers( + android.PrepareForTestWithDefaults, + android.PrepareForTestWithArchMutator, + android.PrepareForTestWithAllowMissingDependencies, + cc.PrepareForTestWithCcDefaultModules, + PrepareForTestWithPythonBuildComponents, + ).RunTestWithBp( + t, + `python_library_host { + name: "py-lib-host", + srcs: ["py-lib-host.py"], + shared_libs: ["clib-host"], + } + + cc_library_shared { + name: "clib-host", + host_supported: true, + shared_libs: ["clib-host-2"], + } + + cc_library_shared { + name: "clib-host-2", + host_supported: true, + }`, + ) + if len(ctx.Errs) > 0 { + t.Errorf("Expected got: %s, want: 0 errs", ctx.Errs) + } + + mod, modOk := ctx.ModuleForTests(t, "py-lib-host", ctx.Config.BuildOSTarget.String()).Module().(*PythonLibraryModule) + if !modOk { + t.Fatalf("py-lib-host is not Python library!") + } + // ensure the shared lib is included in the data path mappings + dataPathMappings := mod.getDataPathMappings() + if len(dataPathMappings) != 1 { + t.Fatalf("expected 1 data file, got: %d", len(dataPathMappings)) + } + android.AssertStringMatches( + t, + "data path included shared lib", + dataPathMappings[0].dest, + "clib-host(.so|.dylib)", + ) + // ensure any dependencies of the shared lib are included in the bundle shared + // libs + android.AssertStringMatches( + t, + "shared libs", + mod.getBundleSharedLibs()[0].String(), + "clib-host-2(.so|.dylib)$", + ) + android.AssertStringMatches( + t, + "shared libs", + mod.getBundleSharedLibs()[1].String(), + "libc\\+\\+(.so|.dylib)$", + ) + +} + func expectModule(t *testing.T, ctx *android.TestContext, name, variant, expectedSrcsZip string, expectedPyRunfiles []string) { module := ctx.ModuleForTests(t, name, variant) |
