Merge "Regression testcase for shipped vs nonshipped." am: 3a0656307c

Original change: https://android-review.googlesource.com/c/platform/build/+/1946016

Change-Id: I1e37a97e0600ee5155de3ca2b5a0bc8baa367bf6
This commit is contained in:
Treehugger Robot
2022-01-12 23:58:16 +00:00
committed by Automerger Merge Worker
18 changed files with 419 additions and 1 deletions

View File

@@ -357,6 +357,98 @@ func Test(t *testing.T) {
roots: []string{"lib/libd.so.meta_lic"},
expectedOut: []projectShare{},
},
{
condition: "regressgpl1",
name: "container",
roots: []string{"container.zip.meta_lic"},
expectedOut: []projectShare{
{
project: "bin/threelibraries",
conditions: []string{"restricted"},
},
{
project: "container/zip",
conditions: []string{"restricted"},
},
},
},
{
condition: "regressgpl1",
name: "containerplus",
roots: []string{"container.zip.meta_lic", "lib/libapache.so.meta_lic", "lib/libc++.so.meta_lic"},
expectedOut: []projectShare{
{
project: "bin/threelibraries",
conditions: []string{"restricted"},
},
{
project: "container/zip",
conditions: []string{"restricted"},
},
{
project: "lib/apache",
conditions: []string{"restricted"},
},
{
project: "lib/c++",
conditions: []string{"restricted"},
},
},
},
{
condition: "regressgpl2",
name: "container",
roots: []string{"container.zip.meta_lic"},
expectedOut: []projectShare{
{
project: "bin/threelibraries",
conditions: []string{"restricted"},
},
{
project: "container/zip",
conditions: []string{"restricted"},
},
{
project: "lib/apache",
conditions: []string{"restricted"},
},
{
project: "lib/c++",
conditions: []string{"restricted"},
},
{
project: "lib/gpl",
conditions: []string{"restricted"},
},
},
},
{
condition: "regressgpl2",
name: "containerplus",
roots: []string{"container.zip.meta_lic", "lib/libapache.so.meta_lic", "lib/libc++.so.meta_lic"},
expectedOut: []projectShare{
{
project: "bin/threelibraries",
conditions: []string{"restricted"},
},
{
project: "container/zip",
conditions: []string{"restricted"},
},
{
project: "lib/apache",
conditions: []string{"restricted"},
},
{
project: "lib/c++",
conditions: []string{"restricted"},
},
{
project: "lib/gpl",
conditions: []string{"restricted"},
},
},
},
}
for _, tt := range tests {
t.Run(tt.condition+" "+tt.name, func(t *testing.T) {

View File

@@ -1,9 +1,12 @@
## Test data
Each directory under testdata/ defines a similar build graph.
Each non-regression directory under testdata/ defines a similar build graph.
All have the same structure, but different versions of the graph have different
license metadata.
The regression* directories can have whatever structure is required for the
specific test case.
### Testdata build graph structure:
The structure is meant to simulate some common scenarios:

View File

@@ -0,0 +1,32 @@
## Shipped versus non-shipped libraries with restricted license
### Testdata build graph structure:
A restricted licensed library sandwiched between a notice library and a notice
binary. The source-code for the libraries only needs to be shared if shipped
alongside the container with the binaries.
```dot
strict digraph {
rankdir=LR;
bin1 [label="bin/bin1.meta_lic\nnotice"];
bin2 [label="bin/bin2.meta_lic\nnotice"];
bin3 [label="bin/bin3.meta_lic\nnotice"];
container [label="container.zip.meta_lic\nnotice"];
libapache [label="lib/libapache.so.meta_lic\nnotice"];
libcxx [label="lib/libc++.so.meta_lic\nnotice"];
libgpl [label="lib/libgpl.so.meta_lic\nrestricted"];
container -> bin1[label="static"];
container -> bin2 [label="static"];
container -> bin3 [label="static"];
bin1 -> libcxx [label="dynamic"];
bin2 -> libapache [label="dynamic"];
bin2 -> libcxx [label="dynamic"];
bin3 -> libapache [label="dynamic"];
bin3 -> libcxx [label="dynamic"];
bin3 -> libgpl [label="dynamic"];
libapache -> libcxx [label="dynamic"];
libgpl -> libcxx [label="dynamic"];
{rank=same; container}
}
```

View File

@@ -0,0 +1,14 @@
package_name: "Android"
module_classes: "EXECUTABLES"
projects: "bin/onelibrary"
license_kinds: "SPDX-license-identifier-Apache-2.0"
license_conditions: "notice"
license_texts: "build/soong/licenses/LICENSE"
is_container: false
built: "out/target/product/fictional/obj/EXECUTABLES/bin_intermediates/bin1"
installed: "out/target/product/fictional/system/bin/bin1"
sources: "out/target/product/fictional/system/lib/libc++.so"
deps: {
file: "testdata/regressgpl1/lib/libc++.so.meta_lic"
annotations: "dynamic"
}

View File

@@ -0,0 +1,19 @@
package_name: "Android"
module_classes: "EXECUTABLES"
projects: "bin/twolibraries"
license_kinds: "SPDX-license-identifier-Apache-2.0"
license_conditions: "notice"
license_texts: "build/soong/licenses/LICENSE"
is_container: false
built: "out/target/product/fictional/obj/EXECUTABLES/bin_intermediates/bin2"
installed: "out/target/product/fictional/system/bin/bin2"
sources: "out/target/product/fictional/system/lib/libc++.so"
sources: "out/target/product/fictional/system/lib/libapache.so"
deps: {
file: "testdata/regressgpl1/lib/libc++.so.meta_lic"
annotations: "dynamic"
}
deps: {
file: "testdata/regressgpl1/lib/libapache.so.meta_lic"
annotations: "dynamic"
}

View File

@@ -0,0 +1,23 @@
package_name: "Compiler"
module_classes: "EXECUTABLES"
projects: "bin/threelibraries"
license_kinds: "SPDX-license-identifier-NCSA"
license_conditions: "notice"
is_container: false
built: "out/target/product/fictional/obj/EXECUTABLES/bin_intermediates/bin3"
installed: "out/target/product/fictional/system/bin/bin3"
sources: "out/target/product/fictional/system/lib/libc++.so"
sources: "out/target/product/fictional/system/lib/libapache.so"
sources: "out/target/product/fictional/system/lib/libgpl.so"
deps: {
file: "testdata/regressgpl1/lib/libc++.so.meta_lic"
annotations: "dynamic"
}
deps: {
file: "testdata/regressgpl1/lib/libapache.so.meta_lic"
annotations: "dynamic"
}
deps: {
file: "testdata/regressgpl1/lib/libgpl.so.meta_lic"
annotations: "dynamic"
}

View File

@@ -0,0 +1,32 @@
package_name: "Android"
projects: "container/zip"
license_kinds: "SPDX-license-identifier-Apache-2.0"
license_conditions: "notice"
license_texts: "build/soong/licenses/LICENSE"
is_container: true
built: "out/target/product/fictional/obj/ETC/container_intermediates/container.zip"
installed: "out/target/product/fictional/data/container.zip"
install_map {
from_path: "out/target/product/fictional/system/lib/"
container_path: ""
}
install_map {
from_path: "out/target/product/fictional/system/bin/"
container_path: ""
}
sources: "out/target/product/fictional/system/bin/bin1"
sources: "out/target/product/fictional/system/bin/bin2"
sources: "out/target/product/fictional/system/bin/bin3"
sources: "out/target/product/fictional/system/lib/libapache.so"
deps: {
file: "testdata/regressgpl1/bin/bin1.meta_lic"
annotations: "static"
}
deps: {
file: "testdata/regressgpl1/bin/bin2.meta_lic"
annotations: "static"
}
deps: {
file: "testdata/regressgpl1/bin/bin3.meta_lic"
annotations: "static"
}

View File

@@ -0,0 +1,14 @@
package_name: "Android"
projects: "lib/apache"
license_kinds: "SPDX-license-identifier-Apache-2.0"
license_conditions: "notice"
license_texts: "build/soong/licenses/LICENSE"
is_container: false
built: "out/target/product/fictional/obj/SHARED_LIBRARIES/lib_intermediates/libapache.so"
built: "out/target/product/fictional/obj/SHARED_LIBRARIES/lib_intermediates/libapache.a"
installed: "out/target/product/fictional/system/lib/libapache.so"
sources: "out/target/product/fictional/system/lib/libc++.so"
deps: {
file: "testdata/regressgpl1/lib/libc++.so.meta_lic"
annotations: "dynamic"
}

View File

@@ -0,0 +1,8 @@
package_name: "Device"
projects: "lib/c++"
license_kinds: "SPDX-license-identifier-BSD"
license_conditions: "notice"
is_container: false
built: "out/target/product/fictional/obj/SHARED_LIBRARIES/lib_intermediates/libc++.so"
built: "out/target/product/fictional/obj/SHARED_LIBRARIES/lib_intermediates/libc++.a"
installed: "out/target/product/fictional/system/lib/libc++.so"

View File

@@ -0,0 +1,12 @@
package_name: "External"
projects: "lib/gpl"
license_kinds: "SPDX-license-identifier-GPL-2.0"
license_conditions: "restricted"
is_container: false
built: "out/target/product/fictional/obj/SHARED_LIBRARIES/lib_intermediates/libgpl.so"
installed: "out/target/product/fictional/system/lib/libgpl.so"
sources: "out/target/product/fictional/system/lib/libc++.so"
deps: {
file: "testdata/regressgpl1/lib/libc++.so.meta_lic"
annotations: "dynamic"
}

View File

@@ -0,0 +1,35 @@
## Libraries shipped inside container with restricted license
### Testdata build graph structure:
A restricted licensed library sandwiched between a notice library and a notice
binary. The source-code for the libraries needs to be shared when shipped as
part of the container with the binaries.
```dot
strict digraph {
rankdir=LR;
bin1 [label="bin/bin1.meta_lic\nnotice"];
bin2 [label="bin/bin2.meta_lic\nnotice"];
bin3 [label="bin/bin3.meta_lic\nnotice"];
container [label="container.zip.meta_lic\nnotice"];
libapache [label="lib/libapache.so.meta_lic\nnotice"];
libcxx [label="lib/libc++.so.meta_lic\nnotice"];
libgpl [label="lib/libgpl.so.meta_lic\nrestricted"];
container -> bin1[label="static"];
container -> bin2 [label="static"];
container -> bin3 [label="static"];
container -> libapache [label="static"];
container -> libcxx [label="static"];
container -> libgpl [label="static"];
bin1 -> libcxx [label="dynamic"];
bin2 -> libapache [label="dynamic"];
bin2 -> libcxx [label="dynamic"];
bin3 -> libapache [label="dynamic"];
bin3 -> libcxx [label="dynamic"];
bin3 -> libgpl [label="dynamic"];
libapache -> libcxx [label="dynamic"];
libgpl -> libcxx [label="dynamic"];
{rank=same; container}
}
```

View File

@@ -0,0 +1,14 @@
package_name: "Android"
module_classes: "EXECUTABLES"
projects: "bin/onelibrary"
license_kinds: "SPDX-license-identifier-Apache-2.0"
license_conditions: "notice"
license_texts: "build/soong/licenses/LICENSE"
is_container: false
built: "out/target/product/fictional/obj/EXECUTABLES/bin_intermediates/bin1"
installed: "out/target/product/fictional/system/bin/bin1"
sources: "out/target/product/fictional/system/lib/libc++.so"
deps: {
file: "testdata/regressgpl2/lib/libc++.so.meta_lic"
annotations: "dynamic"
}

View File

@@ -0,0 +1,19 @@
package_name: "Android"
module_classes: "EXECUTABLES"
projects: "bin/twolibraries"
license_kinds: "SPDX-license-identifier-Apache-2.0"
license_conditions: "notice"
license_texts: "build/soong/licenses/LICENSE"
is_container: false
built: "out/target/product/fictional/obj/EXECUTABLES/bin_intermediates/bin2"
installed: "out/target/product/fictional/system/bin/bin2"
sources: "out/target/product/fictional/system/lib/libc++.so"
sources: "out/target/product/fictional/system/lib/libapache.so"
deps: {
file: "testdata/regressgpl2/lib/libc++.so.meta_lic"
annotations: "dynamic"
}
deps: {
file: "testdata/regressgpl2/lib/libapache.so.meta_lic"
annotations: "dynamic"
}

View File

@@ -0,0 +1,23 @@
package_name: "Compiler"
module_classes: "EXECUTABLES"
projects: "bin/threelibraries"
license_kinds: "SPDX-license-identifier-NCSA"
license_conditions: "notice"
is_container: false
built: "out/target/product/fictional/obj/EXECUTABLES/bin_intermediates/bin3"
installed: "out/target/product/fictional/system/bin/bin3"
sources: "out/target/product/fictional/system/lib/libc++.so"
sources: "out/target/product/fictional/system/lib/libapache.so"
sources: "out/target/product/fictional/system/lib/libgpl.so"
deps: {
file: "testdata/regressgpl2/lib/libc++.so.meta_lic"
annotations: "dynamic"
}
deps: {
file: "testdata/regressgpl2/lib/libapache.so.meta_lic"
annotations: "dynamic"
}
deps: {
file: "testdata/regressgpl2/lib/libgpl.so.meta_lic"
annotations: "dynamic"
}

View File

@@ -0,0 +1,44 @@
package_name: "Android"
projects: "container/zip"
license_kinds: "SPDX-license-identifier-Apache-2.0"
license_conditions: "notice"
license_texts: "build/soong/licenses/LICENSE"
is_container: true
built: "out/target/product/fictional/obj/ETC/container_intermediates/container.zip"
installed: "out/target/product/fictional/data/container.zip"
install_map {
from_path: "out/target/product/fictional/system/lib/"
container_path: ""
}
install_map {
from_path: "out/target/product/fictional/system/bin/"
container_path: ""
}
sources: "out/target/product/fictional/system/bin/bin1"
sources: "out/target/product/fictional/system/bin/bin2"
sources: "out/target/product/fictional/system/bin/bin3"
sources: "out/target/product/fictional/system/lib/libapache.so"
deps: {
file: "testdata/regressgpl2/bin/bin1.meta_lic"
annotations: "static"
}
deps: {
file: "testdata/regressgpl2/bin/bin2.meta_lic"
annotations: "static"
}
deps: {
file: "testdata/regressgpl2/bin/bin3.meta_lic"
annotations: "static"
}
deps: {
file: "testdata/regressgpl2/lib/libapache.so.meta_lic"
annotations: "static"
}
deps: {
file: "testdata/regressgpl2/lib/libc++.so.meta_lic"
annotations: "static"
}
deps: {
file: "testdata/regressgpl2/lib/libgpl.so.meta_lic"
annotations: "static"
}

View File

@@ -0,0 +1,14 @@
package_name: "Android"
projects: "lib/apache"
license_kinds: "SPDX-license-identifier-Apache-2.0"
license_conditions: "notice"
license_texts: "build/soong/licenses/LICENSE"
is_container: false
built: "out/target/product/fictional/obj/SHARED_LIBRARIES/lib_intermediates/libapache.so"
built: "out/target/product/fictional/obj/SHARED_LIBRARIES/lib_intermediates/libapache.a"
installed: "out/target/product/fictional/system/lib/libapache.so"
sources: "out/target/product/fictional/system/lib/libc++.so"
deps: {
file: "testdata/regressgpl2/lib/libc++.so.meta_lic"
annotations: "dynamic"
}

View File

@@ -0,0 +1,8 @@
package_name: "Device"
projects: "lib/c++"
license_kinds: "SPDX-license-identifier-BSD"
license_conditions: "notice"
is_container: false
built: "out/target/product/fictional/obj/SHARED_LIBRARIES/lib_intermediates/libc++.so"
built: "out/target/product/fictional/obj/SHARED_LIBRARIES/lib_intermediates/libc++.a"
installed: "out/target/product/fictional/system/lib/libc++.so"

View File

@@ -0,0 +1,12 @@
package_name: "External"
projects: "lib/gpl"
license_kinds: "SPDX-license-identifier-GPL-2.0"
license_conditions: "restricted"
is_container: false
built: "out/target/product/fictional/obj/SHARED_LIBRARIES/lib_intermediates/libgpl.so"
installed: "out/target/product/fictional/system/lib/libgpl.so"
sources: "out/target/product/fictional/system/lib/libc++.so"
deps: {
file: "testdata/regressgpl2/lib/libc++.so.meta_lic"
annotations: "dynamic"
}