blob: b7ccdc5f104fe17004a5ab9df0dae2863bced7aa [file] [log] [blame]
Bob Badour1ded0a12021-12-03 17:16:14 -08001// Copyright 2021 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package main
16
17import (
18 "bytes"
19 "fmt"
Colin Crossd0f05c92022-01-27 15:40:29 -080020 "os"
Bob Badour1ded0a12021-12-03 17:16:14 -080021 "strings"
22 "testing"
Colin Cross38a61932022-01-27 15:26:49 -080023
24 "android/soong/tools/compliance"
Bob Badour1ded0a12021-12-03 17:16:14 -080025)
26
Colin Crossd0f05c92022-01-27 15:40:29 -080027func TestMain(m *testing.M) {
28 // Change into the parent directory before running the tests
29 // so they can find the testdata directory.
30 if err := os.Chdir(".."); err != nil {
31 fmt.Printf("failed to change to testdata directory: %s\n", err)
32 os.Exit(1)
33 }
34 os.Exit(m.Run())
35}
36
Bob Badour1ded0a12021-12-03 17:16:14 -080037func Test_plaintext(t *testing.T) {
38 tests := []struct {
39 condition string
40 name string
41 roots []string
42 ctx context
43 expectedOut []string
44 }{
45 {
46 condition: "firstparty",
47 name: "apex",
48 roots: []string{"highest.apex.meta_lic"},
49 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -080050 "testdata/firstparty/bin/bin1.meta_lic testdata/firstparty/bin/bin1.meta_lic notice",
51 "testdata/firstparty/bin/bin1.meta_lic testdata/firstparty/lib/liba.so.meta_lic notice",
52 "testdata/firstparty/bin/bin1.meta_lic testdata/firstparty/lib/libc.a.meta_lic notice",
53 "testdata/firstparty/bin/bin2.meta_lic testdata/firstparty/bin/bin2.meta_lic notice",
54 "testdata/firstparty/highest.apex.meta_lic testdata/firstparty/bin/bin1.meta_lic notice",
55 "testdata/firstparty/highest.apex.meta_lic testdata/firstparty/bin/bin2.meta_lic notice",
56 "testdata/firstparty/highest.apex.meta_lic testdata/firstparty/highest.apex.meta_lic notice",
57 "testdata/firstparty/highest.apex.meta_lic testdata/firstparty/lib/liba.so.meta_lic notice",
58 "testdata/firstparty/highest.apex.meta_lic testdata/firstparty/lib/libb.so.meta_lic notice",
59 "testdata/firstparty/highest.apex.meta_lic testdata/firstparty/lib/libc.a.meta_lic notice",
60 "testdata/firstparty/lib/liba.so.meta_lic testdata/firstparty/lib/liba.so.meta_lic notice",
61 "testdata/firstparty/lib/libb.so.meta_lic testdata/firstparty/lib/libb.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -080062 },
63 },
64 {
65 condition: "firstparty",
66 name: "apex_trimmed",
67 roots: []string{"highest.apex.meta_lic"},
68 ctx: context{stripPrefix: "testdata/firstparty/"},
69 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -080070 "bin/bin1.meta_lic bin/bin1.meta_lic notice",
71 "bin/bin1.meta_lic lib/liba.so.meta_lic notice",
72 "bin/bin1.meta_lic lib/libc.a.meta_lic notice",
73 "bin/bin2.meta_lic bin/bin2.meta_lic notice",
74 "highest.apex.meta_lic bin/bin1.meta_lic notice",
75 "highest.apex.meta_lic bin/bin2.meta_lic notice",
76 "highest.apex.meta_lic highest.apex.meta_lic notice",
77 "highest.apex.meta_lic lib/liba.so.meta_lic notice",
78 "highest.apex.meta_lic lib/libb.so.meta_lic notice",
79 "highest.apex.meta_lic lib/libc.a.meta_lic notice",
80 "lib/liba.so.meta_lic lib/liba.so.meta_lic notice",
81 "lib/libb.so.meta_lic lib/libb.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -080082 },
83 },
84 {
85 condition: "firstparty",
86 name: "apex_trimmed_notice",
87 roots: []string{"highest.apex.meta_lic"},
88 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -080089 conditions: []compliance.LicenseCondition{compliance.NoticeCondition},
Bob Badour1ded0a12021-12-03 17:16:14 -080090 stripPrefix: "testdata/firstparty/",
91 },
92 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -080093 "bin/bin1.meta_lic bin/bin1.meta_lic notice",
94 "bin/bin1.meta_lic lib/liba.so.meta_lic notice",
95 "bin/bin1.meta_lic lib/libc.a.meta_lic notice",
96 "bin/bin2.meta_lic bin/bin2.meta_lic notice",
97 "highest.apex.meta_lic bin/bin1.meta_lic notice",
98 "highest.apex.meta_lic bin/bin2.meta_lic notice",
99 "highest.apex.meta_lic highest.apex.meta_lic notice",
100 "highest.apex.meta_lic lib/liba.so.meta_lic notice",
101 "highest.apex.meta_lic lib/libb.so.meta_lic notice",
102 "highest.apex.meta_lic lib/libc.a.meta_lic notice",
103 "lib/liba.so.meta_lic lib/liba.so.meta_lic notice",
104 "lib/libb.so.meta_lic lib/libb.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800105 },
106 },
107 {
108 condition: "firstparty",
109 name: "apex_trimmed_share",
110 roots: []string{"highest.apex.meta_lic"},
111 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800112 conditions: compliance.ImpliesShared.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -0800113 stripPrefix: "testdata/firstparty/",
114 },
115 expectedOut: []string{},
116 },
117 {
118 condition: "firstparty",
119 name: "apex_trimmed_private",
120 roots: []string{"highest.apex.meta_lic"},
121 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800122 conditions: compliance.ImpliesPrivate.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -0800123 stripPrefix: "testdata/firstparty/",
124 },
125 expectedOut: []string{},
126 },
127 {
128 condition: "firstparty",
129 name: "apex_trimmed_share_private",
130 roots: []string{"highest.apex.meta_lic"},
131 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800132 conditions: append(compliance.ImpliesPrivate.AsList(), compliance.ImpliesShared.AsList()...),
Bob Badour1ded0a12021-12-03 17:16:14 -0800133 stripPrefix: "testdata/firstparty/",
134 },
135 expectedOut: []string{},
136 },
137 {
138 condition: "firstparty",
139 name: "apex_trimmed_labelled",
140 roots: []string{"highest.apex.meta_lic"},
141 ctx: context{stripPrefix: "testdata/firstparty/", labelConditions: true},
142 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800143 "bin/bin1.meta_lic:notice bin/bin1.meta_lic:notice notice",
144 "bin/bin1.meta_lic:notice lib/liba.so.meta_lic:notice notice",
145 "bin/bin1.meta_lic:notice lib/libc.a.meta_lic:notice notice",
146 "bin/bin2.meta_lic:notice bin/bin2.meta_lic:notice notice",
147 "highest.apex.meta_lic:notice bin/bin1.meta_lic:notice notice",
148 "highest.apex.meta_lic:notice bin/bin2.meta_lic:notice notice",
149 "highest.apex.meta_lic:notice highest.apex.meta_lic:notice notice",
150 "highest.apex.meta_lic:notice lib/liba.so.meta_lic:notice notice",
151 "highest.apex.meta_lic:notice lib/libb.so.meta_lic:notice notice",
152 "highest.apex.meta_lic:notice lib/libc.a.meta_lic:notice notice",
153 "lib/liba.so.meta_lic:notice lib/liba.so.meta_lic:notice notice",
154 "lib/libb.so.meta_lic:notice lib/libb.so.meta_lic:notice notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800155 },
156 },
157 {
158 condition: "firstparty",
159 name: "container",
160 roots: []string{"container.zip.meta_lic"},
161 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800162 "testdata/firstparty/bin/bin1.meta_lic testdata/firstparty/bin/bin1.meta_lic notice",
163 "testdata/firstparty/bin/bin1.meta_lic testdata/firstparty/lib/liba.so.meta_lic notice",
164 "testdata/firstparty/bin/bin1.meta_lic testdata/firstparty/lib/libc.a.meta_lic notice",
165 "testdata/firstparty/bin/bin2.meta_lic testdata/firstparty/bin/bin2.meta_lic notice",
166 "testdata/firstparty/container.zip.meta_lic testdata/firstparty/bin/bin1.meta_lic notice",
167 "testdata/firstparty/container.zip.meta_lic testdata/firstparty/bin/bin2.meta_lic notice",
168 "testdata/firstparty/container.zip.meta_lic testdata/firstparty/container.zip.meta_lic notice",
169 "testdata/firstparty/container.zip.meta_lic testdata/firstparty/lib/liba.so.meta_lic notice",
170 "testdata/firstparty/container.zip.meta_lic testdata/firstparty/lib/libb.so.meta_lic notice",
171 "testdata/firstparty/container.zip.meta_lic testdata/firstparty/lib/libc.a.meta_lic notice",
172 "testdata/firstparty/lib/liba.so.meta_lic testdata/firstparty/lib/liba.so.meta_lic notice",
173 "testdata/firstparty/lib/libb.so.meta_lic testdata/firstparty/lib/libb.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800174 },
175 },
176 {
177 condition: "firstparty",
178 name: "application",
179 roots: []string{"application.meta_lic"},
180 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800181 "testdata/firstparty/application.meta_lic testdata/firstparty/application.meta_lic notice",
182 "testdata/firstparty/application.meta_lic testdata/firstparty/lib/liba.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800183 },
184 },
185 {
186 condition: "firstparty",
187 name: "binary",
188 roots: []string{"bin/bin1.meta_lic"},
189 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800190 "testdata/firstparty/bin/bin1.meta_lic testdata/firstparty/bin/bin1.meta_lic notice",
191 "testdata/firstparty/bin/bin1.meta_lic testdata/firstparty/lib/liba.so.meta_lic notice",
192 "testdata/firstparty/bin/bin1.meta_lic testdata/firstparty/lib/libc.a.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800193 },
194 },
195 {
196 condition: "firstparty",
197 name: "library",
198 roots: []string{"lib/libd.so.meta_lic"},
199 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800200 "testdata/firstparty/lib/libd.so.meta_lic testdata/firstparty/lib/libd.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800201 },
202 },
203 {
204 condition: "notice",
205 name: "apex",
206 roots: []string{"highest.apex.meta_lic"},
207 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800208 "testdata/notice/bin/bin1.meta_lic testdata/notice/bin/bin1.meta_lic notice",
209 "testdata/notice/bin/bin1.meta_lic testdata/notice/lib/liba.so.meta_lic notice",
210 "testdata/notice/bin/bin1.meta_lic testdata/notice/lib/libc.a.meta_lic notice",
211 "testdata/notice/bin/bin2.meta_lic testdata/notice/bin/bin2.meta_lic notice",
212 "testdata/notice/highest.apex.meta_lic testdata/notice/bin/bin1.meta_lic notice",
213 "testdata/notice/highest.apex.meta_lic testdata/notice/bin/bin2.meta_lic notice",
214 "testdata/notice/highest.apex.meta_lic testdata/notice/highest.apex.meta_lic notice",
215 "testdata/notice/highest.apex.meta_lic testdata/notice/lib/liba.so.meta_lic notice",
216 "testdata/notice/highest.apex.meta_lic testdata/notice/lib/libb.so.meta_lic notice",
217 "testdata/notice/highest.apex.meta_lic testdata/notice/lib/libc.a.meta_lic notice",
218 "testdata/notice/lib/liba.so.meta_lic testdata/notice/lib/liba.so.meta_lic notice",
219 "testdata/notice/lib/libb.so.meta_lic testdata/notice/lib/libb.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800220 },
221 },
222 {
223 condition: "notice",
224 name: "apex_trimmed",
225 roots: []string{"highest.apex.meta_lic"},
226 ctx: context{stripPrefix: "testdata/notice/"},
227 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800228 "bin/bin1.meta_lic bin/bin1.meta_lic notice",
229 "bin/bin1.meta_lic lib/liba.so.meta_lic notice",
230 "bin/bin1.meta_lic lib/libc.a.meta_lic notice",
231 "bin/bin2.meta_lic bin/bin2.meta_lic notice",
232 "highest.apex.meta_lic bin/bin1.meta_lic notice",
233 "highest.apex.meta_lic bin/bin2.meta_lic notice",
234 "highest.apex.meta_lic highest.apex.meta_lic notice",
235 "highest.apex.meta_lic lib/liba.so.meta_lic notice",
236 "highest.apex.meta_lic lib/libb.so.meta_lic notice",
237 "highest.apex.meta_lic lib/libc.a.meta_lic notice",
238 "lib/liba.so.meta_lic lib/liba.so.meta_lic notice",
239 "lib/libb.so.meta_lic lib/libb.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800240 },
241 },
242 {
243 condition: "notice",
244 name: "apex_trimmed_notice",
245 roots: []string{"highest.apex.meta_lic"},
246 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -0800247 conditions: []compliance.LicenseCondition{compliance.NoticeCondition},
Bob Badour1ded0a12021-12-03 17:16:14 -0800248 stripPrefix: "testdata/notice/",
249 },
250 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800251 "bin/bin1.meta_lic bin/bin1.meta_lic notice",
252 "bin/bin1.meta_lic lib/liba.so.meta_lic notice",
253 "bin/bin1.meta_lic lib/libc.a.meta_lic notice",
254 "bin/bin2.meta_lic bin/bin2.meta_lic notice",
255 "highest.apex.meta_lic bin/bin1.meta_lic notice",
256 "highest.apex.meta_lic bin/bin2.meta_lic notice",
257 "highest.apex.meta_lic highest.apex.meta_lic notice",
258 "highest.apex.meta_lic lib/liba.so.meta_lic notice",
259 "highest.apex.meta_lic lib/libb.so.meta_lic notice",
260 "highest.apex.meta_lic lib/libc.a.meta_lic notice",
261 "lib/liba.so.meta_lic lib/liba.so.meta_lic notice",
262 "lib/libb.so.meta_lic lib/libb.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800263 },
264 },
265 {
266 condition: "notice",
267 name: "apex_trimmed_share",
268 roots: []string{"highest.apex.meta_lic"},
269 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800270 conditions: compliance.ImpliesShared.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -0800271 stripPrefix: "testdata/notice/",
272 },
273 expectedOut: []string{},
274 },
275 {
276 condition: "notice",
277 name: "apex_trimmed_private",
278 roots: []string{"highest.apex.meta_lic"},
279 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800280 conditions: compliance.ImpliesPrivate.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -0800281 stripPrefix: "testdata/notice/",
282 },
283 expectedOut: []string{},
284 },
285 {
286 condition: "notice",
287 name: "apex_trimmed_share_private",
288 roots: []string{"highest.apex.meta_lic"},
289 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800290 conditions: append(compliance.ImpliesShared.AsList(), compliance.ImpliesPrivate.AsList()...),
Bob Badour1ded0a12021-12-03 17:16:14 -0800291 stripPrefix: "testdata/notice/",
292 },
293 expectedOut: []string{},
294 },
295 {
296 condition: "notice",
297 name: "apex_trimmed_labelled",
298 roots: []string{"highest.apex.meta_lic"},
299 ctx: context{stripPrefix: "testdata/notice/", labelConditions: true},
300 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800301 "bin/bin1.meta_lic:notice bin/bin1.meta_lic:notice notice",
302 "bin/bin1.meta_lic:notice lib/liba.so.meta_lic:notice notice",
303 "bin/bin1.meta_lic:notice lib/libc.a.meta_lic:notice notice",
304 "bin/bin2.meta_lic:notice bin/bin2.meta_lic:notice notice",
305 "highest.apex.meta_lic:notice bin/bin1.meta_lic:notice notice",
306 "highest.apex.meta_lic:notice bin/bin2.meta_lic:notice notice",
307 "highest.apex.meta_lic:notice highest.apex.meta_lic:notice notice",
308 "highest.apex.meta_lic:notice lib/liba.so.meta_lic:notice notice",
309 "highest.apex.meta_lic:notice lib/libb.so.meta_lic:notice notice",
310 "highest.apex.meta_lic:notice lib/libc.a.meta_lic:notice notice",
311 "lib/liba.so.meta_lic:notice lib/liba.so.meta_lic:notice notice",
312 "lib/libb.so.meta_lic:notice lib/libb.so.meta_lic:notice notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800313 },
314 },
315 {
316 condition: "notice",
317 name: "container",
318 roots: []string{"container.zip.meta_lic"},
319 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800320 "testdata/notice/bin/bin1.meta_lic testdata/notice/bin/bin1.meta_lic notice",
321 "testdata/notice/bin/bin1.meta_lic testdata/notice/lib/liba.so.meta_lic notice",
322 "testdata/notice/bin/bin1.meta_lic testdata/notice/lib/libc.a.meta_lic notice",
323 "testdata/notice/bin/bin2.meta_lic testdata/notice/bin/bin2.meta_lic notice",
324 "testdata/notice/container.zip.meta_lic testdata/notice/bin/bin1.meta_lic notice",
325 "testdata/notice/container.zip.meta_lic testdata/notice/bin/bin2.meta_lic notice",
326 "testdata/notice/container.zip.meta_lic testdata/notice/container.zip.meta_lic notice",
327 "testdata/notice/container.zip.meta_lic testdata/notice/lib/liba.so.meta_lic notice",
328 "testdata/notice/container.zip.meta_lic testdata/notice/lib/libb.so.meta_lic notice",
329 "testdata/notice/container.zip.meta_lic testdata/notice/lib/libc.a.meta_lic notice",
330 "testdata/notice/lib/liba.so.meta_lic testdata/notice/lib/liba.so.meta_lic notice",
331 "testdata/notice/lib/libb.so.meta_lic testdata/notice/lib/libb.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800332 },
333 },
334 {
335 condition: "notice",
336 name: "application",
337 roots: []string{"application.meta_lic"},
338 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800339 "testdata/notice/application.meta_lic testdata/notice/application.meta_lic notice",
340 "testdata/notice/application.meta_lic testdata/notice/lib/liba.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800341 },
342 },
343 {
344 condition: "notice",
345 name: "binary",
346 roots: []string{"bin/bin1.meta_lic"},
347 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800348 "testdata/notice/bin/bin1.meta_lic testdata/notice/bin/bin1.meta_lic notice",
349 "testdata/notice/bin/bin1.meta_lic testdata/notice/lib/liba.so.meta_lic notice",
350 "testdata/notice/bin/bin1.meta_lic testdata/notice/lib/libc.a.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800351 },
352 },
353 {
354 condition: "notice",
355 name: "library",
356 roots: []string{"lib/libd.so.meta_lic"},
357 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800358 "testdata/notice/lib/libd.so.meta_lic testdata/notice/lib/libd.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800359 },
360 },
361 {
362 condition: "reciprocal",
363 name: "apex",
364 roots: []string{"highest.apex.meta_lic"},
365 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800366 "testdata/reciprocal/bin/bin1.meta_lic testdata/reciprocal/bin/bin1.meta_lic notice",
367 "testdata/reciprocal/bin/bin1.meta_lic testdata/reciprocal/lib/liba.so.meta_lic reciprocal",
368 "testdata/reciprocal/bin/bin1.meta_lic testdata/reciprocal/lib/libc.a.meta_lic reciprocal",
369 "testdata/reciprocal/bin/bin2.meta_lic testdata/reciprocal/bin/bin2.meta_lic notice",
370 "testdata/reciprocal/highest.apex.meta_lic testdata/reciprocal/bin/bin1.meta_lic notice",
371 "testdata/reciprocal/highest.apex.meta_lic testdata/reciprocal/bin/bin2.meta_lic notice",
372 "testdata/reciprocal/highest.apex.meta_lic testdata/reciprocal/highest.apex.meta_lic notice",
373 "testdata/reciprocal/highest.apex.meta_lic testdata/reciprocal/lib/liba.so.meta_lic reciprocal",
374 "testdata/reciprocal/highest.apex.meta_lic testdata/reciprocal/lib/libb.so.meta_lic notice",
375 "testdata/reciprocal/highest.apex.meta_lic testdata/reciprocal/lib/libc.a.meta_lic reciprocal",
376 "testdata/reciprocal/lib/liba.so.meta_lic testdata/reciprocal/lib/liba.so.meta_lic reciprocal",
377 "testdata/reciprocal/lib/libb.so.meta_lic testdata/reciprocal/lib/libb.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800378 },
379 },
380 {
381 condition: "reciprocal",
382 name: "apex_trimmed",
383 roots: []string{"highest.apex.meta_lic"},
384 ctx: context{stripPrefix: "testdata/reciprocal/"},
385 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800386 "bin/bin1.meta_lic bin/bin1.meta_lic notice",
387 "bin/bin1.meta_lic lib/liba.so.meta_lic reciprocal",
388 "bin/bin1.meta_lic lib/libc.a.meta_lic reciprocal",
389 "bin/bin2.meta_lic bin/bin2.meta_lic notice",
390 "highest.apex.meta_lic bin/bin1.meta_lic notice",
391 "highest.apex.meta_lic bin/bin2.meta_lic notice",
392 "highest.apex.meta_lic highest.apex.meta_lic notice",
393 "highest.apex.meta_lic lib/liba.so.meta_lic reciprocal",
394 "highest.apex.meta_lic lib/libb.so.meta_lic notice",
395 "highest.apex.meta_lic lib/libc.a.meta_lic reciprocal",
396 "lib/liba.so.meta_lic lib/liba.so.meta_lic reciprocal",
397 "lib/libb.so.meta_lic lib/libb.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800398 },
399 },
400 {
401 condition: "reciprocal",
402 name: "apex_trimmed_notice",
403 roots: []string{"highest.apex.meta_lic"},
404 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -0800405 conditions: []compliance.LicenseCondition{compliance.NoticeCondition},
Bob Badour1ded0a12021-12-03 17:16:14 -0800406 stripPrefix: "testdata/reciprocal/",
407 },
408 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800409 "bin/bin1.meta_lic bin/bin1.meta_lic notice",
410 "bin/bin2.meta_lic bin/bin2.meta_lic notice",
411 "highest.apex.meta_lic bin/bin1.meta_lic notice",
412 "highest.apex.meta_lic bin/bin2.meta_lic notice",
413 "highest.apex.meta_lic highest.apex.meta_lic notice",
414 "highest.apex.meta_lic lib/libb.so.meta_lic notice",
415 "lib/libb.so.meta_lic lib/libb.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800416 },
417 },
418 {
419 condition: "reciprocal",
420 name: "apex_trimmed_share",
421 roots: []string{"highest.apex.meta_lic"},
422 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800423 conditions: compliance.ImpliesShared.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -0800424 stripPrefix: "testdata/reciprocal/",
425 },
426 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800427 "bin/bin1.meta_lic lib/liba.so.meta_lic reciprocal",
428 "bin/bin1.meta_lic lib/libc.a.meta_lic reciprocal",
429 "highest.apex.meta_lic lib/liba.so.meta_lic reciprocal",
430 "highest.apex.meta_lic lib/libc.a.meta_lic reciprocal",
431 "lib/liba.so.meta_lic lib/liba.so.meta_lic reciprocal",
Bob Badour1ded0a12021-12-03 17:16:14 -0800432 },
433 },
434 {
435 condition: "reciprocal",
436 name: "apex_trimmed_private",
437 roots: []string{"highest.apex.meta_lic"},
438 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800439 conditions: compliance.ImpliesPrivate.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -0800440 stripPrefix: "testdata/reciprocal/",
441 },
442 expectedOut: []string{},
443 },
444 {
445 condition: "reciprocal",
446 name: "apex_trimmed_share_private",
447 roots: []string{"highest.apex.meta_lic"},
448 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800449 conditions: append(compliance.ImpliesShared.AsList(), compliance.ImpliesPrivate.AsList()...),
Bob Badour1ded0a12021-12-03 17:16:14 -0800450 stripPrefix: "testdata/reciprocal/",
451 },
452 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800453 "bin/bin1.meta_lic lib/liba.so.meta_lic reciprocal",
454 "bin/bin1.meta_lic lib/libc.a.meta_lic reciprocal",
455 "highest.apex.meta_lic lib/liba.so.meta_lic reciprocal",
456 "highest.apex.meta_lic lib/libc.a.meta_lic reciprocal",
457 "lib/liba.so.meta_lic lib/liba.so.meta_lic reciprocal",
Bob Badour1ded0a12021-12-03 17:16:14 -0800458 },
459 },
460 {
461 condition: "reciprocal",
462 name: "apex_trimmed_labelled",
463 roots: []string{"highest.apex.meta_lic"},
464 ctx: context{stripPrefix: "testdata/reciprocal/", labelConditions: true},
465 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800466 "bin/bin1.meta_lic:notice bin/bin1.meta_lic:notice notice",
467 "bin/bin1.meta_lic:notice lib/liba.so.meta_lic:reciprocal reciprocal",
468 "bin/bin1.meta_lic:notice lib/libc.a.meta_lic:reciprocal reciprocal",
469 "bin/bin2.meta_lic:notice bin/bin2.meta_lic:notice notice",
470 "highest.apex.meta_lic:notice bin/bin1.meta_lic:notice notice",
471 "highest.apex.meta_lic:notice bin/bin2.meta_lic:notice notice",
472 "highest.apex.meta_lic:notice highest.apex.meta_lic:notice notice",
473 "highest.apex.meta_lic:notice lib/liba.so.meta_lic:reciprocal reciprocal",
474 "highest.apex.meta_lic:notice lib/libb.so.meta_lic:notice notice",
475 "highest.apex.meta_lic:notice lib/libc.a.meta_lic:reciprocal reciprocal",
476 "lib/liba.so.meta_lic:reciprocal lib/liba.so.meta_lic:reciprocal reciprocal",
477 "lib/libb.so.meta_lic:notice lib/libb.so.meta_lic:notice notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800478 },
479 },
480 {
481 condition: "reciprocal",
482 name: "container",
483 roots: []string{"container.zip.meta_lic"},
484 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800485 "testdata/reciprocal/bin/bin1.meta_lic testdata/reciprocal/bin/bin1.meta_lic notice",
486 "testdata/reciprocal/bin/bin1.meta_lic testdata/reciprocal/lib/liba.so.meta_lic reciprocal",
487 "testdata/reciprocal/bin/bin1.meta_lic testdata/reciprocal/lib/libc.a.meta_lic reciprocal",
488 "testdata/reciprocal/bin/bin2.meta_lic testdata/reciprocal/bin/bin2.meta_lic notice",
489 "testdata/reciprocal/container.zip.meta_lic testdata/reciprocal/bin/bin1.meta_lic notice",
490 "testdata/reciprocal/container.zip.meta_lic testdata/reciprocal/bin/bin2.meta_lic notice",
491 "testdata/reciprocal/container.zip.meta_lic testdata/reciprocal/container.zip.meta_lic notice",
492 "testdata/reciprocal/container.zip.meta_lic testdata/reciprocal/lib/liba.so.meta_lic reciprocal",
493 "testdata/reciprocal/container.zip.meta_lic testdata/reciprocal/lib/libb.so.meta_lic notice",
494 "testdata/reciprocal/container.zip.meta_lic testdata/reciprocal/lib/libc.a.meta_lic reciprocal",
495 "testdata/reciprocal/lib/liba.so.meta_lic testdata/reciprocal/lib/liba.so.meta_lic reciprocal",
496 "testdata/reciprocal/lib/libb.so.meta_lic testdata/reciprocal/lib/libb.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800497 },
498 },
499 {
500 condition: "reciprocal",
501 name: "application",
502 roots: []string{"application.meta_lic"},
503 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800504 "testdata/reciprocal/application.meta_lic testdata/reciprocal/application.meta_lic notice",
505 "testdata/reciprocal/application.meta_lic testdata/reciprocal/lib/liba.so.meta_lic reciprocal",
Bob Badour1ded0a12021-12-03 17:16:14 -0800506 },
507 },
508 {
509 condition: "reciprocal",
510 name: "binary",
511 roots: []string{"bin/bin1.meta_lic"},
512 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800513 "testdata/reciprocal/bin/bin1.meta_lic testdata/reciprocal/bin/bin1.meta_lic notice",
514 "testdata/reciprocal/bin/bin1.meta_lic testdata/reciprocal/lib/liba.so.meta_lic reciprocal",
515 "testdata/reciprocal/bin/bin1.meta_lic testdata/reciprocal/lib/libc.a.meta_lic reciprocal",
Bob Badour1ded0a12021-12-03 17:16:14 -0800516 },
517 },
518 {
519 condition: "reciprocal",
520 name: "library",
521 roots: []string{"lib/libd.so.meta_lic"},
522 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800523 "testdata/reciprocal/lib/libd.so.meta_lic testdata/reciprocal/lib/libd.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800524 },
525 },
526 {
527 condition: "restricted",
528 name: "apex",
529 roots: []string{"highest.apex.meta_lic"},
530 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800531 "testdata/restricted/bin/bin1.meta_lic testdata/restricted/bin/bin1.meta_lic notice:restricted_allows_dynamic_linking",
532 "testdata/restricted/bin/bin1.meta_lic testdata/restricted/lib/liba.so.meta_lic restricted_allows_dynamic_linking",
533 "testdata/restricted/bin/bin1.meta_lic testdata/restricted/lib/libc.a.meta_lic reciprocal:restricted_allows_dynamic_linking",
534 "testdata/restricted/bin/bin2.meta_lic testdata/restricted/bin/bin2.meta_lic notice:restricted",
535 "testdata/restricted/bin/bin2.meta_lic testdata/restricted/lib/libb.so.meta_lic restricted",
536 "testdata/restricted/highest.apex.meta_lic testdata/restricted/bin/bin1.meta_lic notice:restricted_allows_dynamic_linking",
537 "testdata/restricted/highest.apex.meta_lic testdata/restricted/bin/bin2.meta_lic notice:restricted",
538 "testdata/restricted/highest.apex.meta_lic testdata/restricted/highest.apex.meta_lic notice:restricted:restricted_allows_dynamic_linking",
539 "testdata/restricted/highest.apex.meta_lic testdata/restricted/lib/liba.so.meta_lic restricted_allows_dynamic_linking",
540 "testdata/restricted/highest.apex.meta_lic testdata/restricted/lib/libb.so.meta_lic restricted",
541 "testdata/restricted/highest.apex.meta_lic testdata/restricted/lib/libc.a.meta_lic reciprocal:restricted_allows_dynamic_linking",
542 "testdata/restricted/lib/liba.so.meta_lic testdata/restricted/lib/liba.so.meta_lic restricted_allows_dynamic_linking",
543 "testdata/restricted/lib/libb.so.meta_lic testdata/restricted/lib/libb.so.meta_lic restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -0800544 },
545 },
546 {
547 condition: "restricted",
548 name: "apex_trimmed",
549 roots: []string{"highest.apex.meta_lic"},
550 ctx: context{stripPrefix: "testdata/restricted/"},
551 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800552 "bin/bin1.meta_lic bin/bin1.meta_lic notice:restricted_allows_dynamic_linking",
553 "bin/bin1.meta_lic lib/liba.so.meta_lic restricted_allows_dynamic_linking",
554 "bin/bin1.meta_lic lib/libc.a.meta_lic reciprocal:restricted_allows_dynamic_linking",
555 "bin/bin2.meta_lic bin/bin2.meta_lic notice:restricted",
556 "bin/bin2.meta_lic lib/libb.so.meta_lic restricted",
557 "highest.apex.meta_lic bin/bin1.meta_lic notice:restricted_allows_dynamic_linking",
558 "highest.apex.meta_lic bin/bin2.meta_lic notice:restricted",
559 "highest.apex.meta_lic highest.apex.meta_lic notice:restricted:restricted_allows_dynamic_linking",
560 "highest.apex.meta_lic lib/liba.so.meta_lic restricted_allows_dynamic_linking",
561 "highest.apex.meta_lic lib/libb.so.meta_lic restricted",
562 "highest.apex.meta_lic lib/libc.a.meta_lic reciprocal:restricted_allows_dynamic_linking",
563 "lib/liba.so.meta_lic lib/liba.so.meta_lic restricted_allows_dynamic_linking",
564 "lib/libb.so.meta_lic lib/libb.so.meta_lic restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -0800565 },
566 },
567 {
568 condition: "restricted",
569 name: "apex_trimmed_notice",
570 roots: []string{"highest.apex.meta_lic"},
571 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -0800572 conditions: []compliance.LicenseCondition{compliance.NoticeCondition},
Bob Badour1ded0a12021-12-03 17:16:14 -0800573 stripPrefix: "testdata/restricted/",
574 },
575 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800576 "bin/bin1.meta_lic bin/bin1.meta_lic notice",
577 "bin/bin2.meta_lic bin/bin2.meta_lic notice",
578 "highest.apex.meta_lic bin/bin1.meta_lic notice",
579 "highest.apex.meta_lic bin/bin2.meta_lic notice",
580 "highest.apex.meta_lic highest.apex.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800581 },
582 },
583 {
584 condition: "restricted",
585 name: "apex_trimmed_share",
586 roots: []string{"highest.apex.meta_lic"},
587 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800588 conditions: compliance.ImpliesShared.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -0800589 stripPrefix: "testdata/restricted/",
590 },
591 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800592 "bin/bin1.meta_lic bin/bin1.meta_lic restricted_allows_dynamic_linking",
593 "bin/bin1.meta_lic lib/liba.so.meta_lic restricted_allows_dynamic_linking",
594 "bin/bin1.meta_lic lib/libc.a.meta_lic reciprocal:restricted_allows_dynamic_linking",
595 "bin/bin2.meta_lic bin/bin2.meta_lic restricted",
596 "bin/bin2.meta_lic lib/libb.so.meta_lic restricted",
597 "highest.apex.meta_lic bin/bin1.meta_lic restricted_allows_dynamic_linking",
598 "highest.apex.meta_lic bin/bin2.meta_lic restricted",
599 "highest.apex.meta_lic highest.apex.meta_lic restricted:restricted_allows_dynamic_linking",
600 "highest.apex.meta_lic lib/liba.so.meta_lic restricted_allows_dynamic_linking",
601 "highest.apex.meta_lic lib/libb.so.meta_lic restricted",
602 "highest.apex.meta_lic lib/libc.a.meta_lic reciprocal:restricted_allows_dynamic_linking",
603 "lib/liba.so.meta_lic lib/liba.so.meta_lic restricted_allows_dynamic_linking",
604 "lib/libb.so.meta_lic lib/libb.so.meta_lic restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -0800605 },
606 },
607 {
608 condition: "restricted",
609 name: "apex_trimmed_private",
610 roots: []string{"highest.apex.meta_lic"},
611 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800612 conditions: compliance.ImpliesPrivate.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -0800613 stripPrefix: "testdata/restricted/",
614 },
615 expectedOut: []string{},
616 },
617 {
618 condition: "restricted",
619 name: "apex_trimmed_share_private",
620 roots: []string{"highest.apex.meta_lic"},
621 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800622 conditions: append(compliance.ImpliesShared.AsList(), compliance.ImpliesPrivate.AsList()...),
Bob Badour1ded0a12021-12-03 17:16:14 -0800623 stripPrefix: "testdata/restricted/",
624 },
625 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800626 "bin/bin1.meta_lic bin/bin1.meta_lic restricted_allows_dynamic_linking",
627 "bin/bin1.meta_lic lib/liba.so.meta_lic restricted_allows_dynamic_linking",
628 "bin/bin1.meta_lic lib/libc.a.meta_lic reciprocal:restricted_allows_dynamic_linking",
629 "bin/bin2.meta_lic bin/bin2.meta_lic restricted",
630 "bin/bin2.meta_lic lib/libb.so.meta_lic restricted",
631 "highest.apex.meta_lic bin/bin1.meta_lic restricted_allows_dynamic_linking",
632 "highest.apex.meta_lic bin/bin2.meta_lic restricted",
633 "highest.apex.meta_lic highest.apex.meta_lic restricted:restricted_allows_dynamic_linking",
634 "highest.apex.meta_lic lib/liba.so.meta_lic restricted_allows_dynamic_linking",
635 "highest.apex.meta_lic lib/libb.so.meta_lic restricted",
636 "highest.apex.meta_lic lib/libc.a.meta_lic reciprocal:restricted_allows_dynamic_linking",
637 "lib/liba.so.meta_lic lib/liba.so.meta_lic restricted_allows_dynamic_linking",
638 "lib/libb.so.meta_lic lib/libb.so.meta_lic restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -0800639 },
640 },
641 {
642 condition: "restricted",
643 name: "apex_trimmed_labelled",
644 roots: []string{"highest.apex.meta_lic"},
645 ctx: context{stripPrefix: "testdata/restricted/", labelConditions: true},
646 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800647 "bin/bin1.meta_lic:notice bin/bin1.meta_lic:notice notice:restricted_allows_dynamic_linking",
648 "bin/bin1.meta_lic:notice lib/liba.so.meta_lic:restricted_allows_dynamic_linking restricted_allows_dynamic_linking",
649 "bin/bin1.meta_lic:notice lib/libc.a.meta_lic:reciprocal reciprocal:restricted_allows_dynamic_linking",
650 "bin/bin2.meta_lic:notice bin/bin2.meta_lic:notice notice:restricted",
651 "bin/bin2.meta_lic:notice lib/libb.so.meta_lic:restricted restricted",
652 "highest.apex.meta_lic:notice bin/bin1.meta_lic:notice notice:restricted_allows_dynamic_linking",
653 "highest.apex.meta_lic:notice bin/bin2.meta_lic:notice notice:restricted",
654 "highest.apex.meta_lic:notice highest.apex.meta_lic:notice notice:restricted:restricted_allows_dynamic_linking",
655 "highest.apex.meta_lic:notice lib/liba.so.meta_lic:restricted_allows_dynamic_linking restricted_allows_dynamic_linking",
656 "highest.apex.meta_lic:notice lib/libb.so.meta_lic:restricted restricted",
657 "highest.apex.meta_lic:notice lib/libc.a.meta_lic:reciprocal reciprocal:restricted_allows_dynamic_linking",
658 "lib/liba.so.meta_lic:restricted_allows_dynamic_linking lib/liba.so.meta_lic:restricted_allows_dynamic_linking restricted_allows_dynamic_linking",
659 "lib/libb.so.meta_lic:restricted lib/libb.so.meta_lic:restricted restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -0800660 },
661 },
662 {
663 condition: "restricted",
664 name: "container",
665 roots: []string{"container.zip.meta_lic"},
666 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800667 "testdata/restricted/bin/bin1.meta_lic testdata/restricted/bin/bin1.meta_lic notice:restricted_allows_dynamic_linking",
668 "testdata/restricted/bin/bin1.meta_lic testdata/restricted/lib/liba.so.meta_lic restricted_allows_dynamic_linking",
669 "testdata/restricted/bin/bin1.meta_lic testdata/restricted/lib/libc.a.meta_lic reciprocal:restricted_allows_dynamic_linking",
670 "testdata/restricted/bin/bin2.meta_lic testdata/restricted/bin/bin2.meta_lic notice:restricted",
671 "testdata/restricted/bin/bin2.meta_lic testdata/restricted/lib/libb.so.meta_lic restricted",
672 "testdata/restricted/container.zip.meta_lic testdata/restricted/bin/bin1.meta_lic notice:restricted_allows_dynamic_linking",
673 "testdata/restricted/container.zip.meta_lic testdata/restricted/bin/bin2.meta_lic notice:restricted",
674 "testdata/restricted/container.zip.meta_lic testdata/restricted/container.zip.meta_lic notice:restricted:restricted_allows_dynamic_linking",
675 "testdata/restricted/container.zip.meta_lic testdata/restricted/lib/liba.so.meta_lic restricted_allows_dynamic_linking",
676 "testdata/restricted/container.zip.meta_lic testdata/restricted/lib/libb.so.meta_lic restricted",
677 "testdata/restricted/container.zip.meta_lic testdata/restricted/lib/libc.a.meta_lic reciprocal:restricted_allows_dynamic_linking",
678 "testdata/restricted/lib/liba.so.meta_lic testdata/restricted/lib/liba.so.meta_lic restricted_allows_dynamic_linking",
679 "testdata/restricted/lib/libb.so.meta_lic testdata/restricted/lib/libb.so.meta_lic restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -0800680 },
681 },
682 {
683 condition: "restricted",
684 name: "application",
685 roots: []string{"application.meta_lic"},
686 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800687 "testdata/restricted/application.meta_lic testdata/restricted/application.meta_lic notice:restricted:restricted_allows_dynamic_linking",
688 "testdata/restricted/application.meta_lic testdata/restricted/lib/liba.so.meta_lic restricted:restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -0800689 },
690 },
691 {
692 condition: "restricted",
693 name: "binary",
694 roots: []string{"bin/bin1.meta_lic"},
695 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800696 "testdata/restricted/bin/bin1.meta_lic testdata/restricted/bin/bin1.meta_lic notice:restricted_allows_dynamic_linking",
697 "testdata/restricted/bin/bin1.meta_lic testdata/restricted/lib/liba.so.meta_lic restricted_allows_dynamic_linking",
698 "testdata/restricted/bin/bin1.meta_lic testdata/restricted/lib/libc.a.meta_lic reciprocal:restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -0800699 },
700 },
701 {
702 condition: "restricted",
703 name: "library",
704 roots: []string{"lib/libd.so.meta_lic"},
705 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800706 "testdata/restricted/lib/libd.so.meta_lic testdata/restricted/lib/libd.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800707 },
708 },
709 {
710 condition: "proprietary",
711 name: "apex",
712 roots: []string{"highest.apex.meta_lic"},
713 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800714 "testdata/proprietary/bin/bin1.meta_lic testdata/proprietary/bin/bin1.meta_lic notice",
715 "testdata/proprietary/bin/bin1.meta_lic testdata/proprietary/lib/liba.so.meta_lic proprietary:by_exception_only",
716 "testdata/proprietary/bin/bin1.meta_lic testdata/proprietary/lib/libc.a.meta_lic proprietary:by_exception_only",
717 "testdata/proprietary/bin/bin2.meta_lic testdata/proprietary/bin/bin2.meta_lic restricted:proprietary:by_exception_only",
718 "testdata/proprietary/bin/bin2.meta_lic testdata/proprietary/lib/libb.so.meta_lic restricted",
719 "testdata/proprietary/highest.apex.meta_lic testdata/proprietary/bin/bin1.meta_lic notice",
720 "testdata/proprietary/highest.apex.meta_lic testdata/proprietary/bin/bin2.meta_lic restricted:proprietary:by_exception_only",
721 "testdata/proprietary/highest.apex.meta_lic testdata/proprietary/highest.apex.meta_lic notice:restricted",
722 "testdata/proprietary/highest.apex.meta_lic testdata/proprietary/lib/liba.so.meta_lic proprietary:by_exception_only",
723 "testdata/proprietary/highest.apex.meta_lic testdata/proprietary/lib/libb.so.meta_lic restricted",
724 "testdata/proprietary/highest.apex.meta_lic testdata/proprietary/lib/libc.a.meta_lic proprietary:by_exception_only",
725 "testdata/proprietary/lib/liba.so.meta_lic testdata/proprietary/lib/liba.so.meta_lic proprietary:by_exception_only",
726 "testdata/proprietary/lib/libb.so.meta_lic testdata/proprietary/lib/libb.so.meta_lic restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -0800727 },
728 },
729 {
730 condition: "proprietary",
731 name: "apex_trimmed",
732 roots: []string{"highest.apex.meta_lic"},
733 ctx: context{stripPrefix: "testdata/proprietary/"},
734 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800735 "bin/bin1.meta_lic bin/bin1.meta_lic notice",
736 "bin/bin1.meta_lic lib/liba.so.meta_lic proprietary:by_exception_only",
737 "bin/bin1.meta_lic lib/libc.a.meta_lic proprietary:by_exception_only",
738 "bin/bin2.meta_lic bin/bin2.meta_lic restricted:proprietary:by_exception_only",
739 "bin/bin2.meta_lic lib/libb.so.meta_lic restricted",
740 "highest.apex.meta_lic bin/bin1.meta_lic notice",
741 "highest.apex.meta_lic bin/bin2.meta_lic restricted:proprietary:by_exception_only",
742 "highest.apex.meta_lic highest.apex.meta_lic notice:restricted",
743 "highest.apex.meta_lic lib/liba.so.meta_lic proprietary:by_exception_only",
744 "highest.apex.meta_lic lib/libb.so.meta_lic restricted",
745 "highest.apex.meta_lic lib/libc.a.meta_lic proprietary:by_exception_only",
746 "lib/liba.so.meta_lic lib/liba.so.meta_lic proprietary:by_exception_only",
747 "lib/libb.so.meta_lic lib/libb.so.meta_lic restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -0800748 },
749 },
750 {
751 condition: "proprietary",
752 name: "apex_trimmed_notice",
753 roots: []string{"highest.apex.meta_lic"},
754 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -0800755 conditions: []compliance.LicenseCondition{compliance.NoticeCondition},
Bob Badour1ded0a12021-12-03 17:16:14 -0800756 stripPrefix: "testdata/proprietary/",
757 },
758 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800759 "bin/bin1.meta_lic bin/bin1.meta_lic notice",
760 "highest.apex.meta_lic bin/bin1.meta_lic notice",
761 "highest.apex.meta_lic highest.apex.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800762 },
763 },
764 {
765 condition: "proprietary",
766 name: "apex_trimmed_share",
767 roots: []string{"highest.apex.meta_lic"},
768 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800769 conditions: compliance.ImpliesShared.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -0800770 stripPrefix: "testdata/proprietary/",
771 },
772 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800773 "bin/bin2.meta_lic bin/bin2.meta_lic restricted",
774 "bin/bin2.meta_lic lib/libb.so.meta_lic restricted",
775 "highest.apex.meta_lic bin/bin2.meta_lic restricted",
776 "highest.apex.meta_lic highest.apex.meta_lic restricted",
777 "highest.apex.meta_lic lib/libb.so.meta_lic restricted",
778 "lib/libb.so.meta_lic lib/libb.so.meta_lic restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -0800779 },
780 },
781 {
782 condition: "proprietary",
783 name: "apex_trimmed_private",
784 roots: []string{"highest.apex.meta_lic"},
785 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800786 conditions: compliance.ImpliesPrivate.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -0800787 stripPrefix: "testdata/proprietary/",
788 },
789 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800790 "bin/bin1.meta_lic lib/liba.so.meta_lic proprietary",
791 "bin/bin1.meta_lic lib/libc.a.meta_lic proprietary",
792 "bin/bin2.meta_lic bin/bin2.meta_lic proprietary",
793 "highest.apex.meta_lic bin/bin2.meta_lic proprietary",
794 "highest.apex.meta_lic lib/liba.so.meta_lic proprietary",
795 "highest.apex.meta_lic lib/libc.a.meta_lic proprietary",
796 "lib/liba.so.meta_lic lib/liba.so.meta_lic proprietary",
Bob Badour1ded0a12021-12-03 17:16:14 -0800797 },
798 },
799 {
800 condition: "proprietary",
801 name: "apex_trimmed_share_private",
802 roots: []string{"highest.apex.meta_lic"},
803 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800804 conditions: append(compliance.ImpliesShared.AsList(), compliance.ImpliesPrivate.AsList()...),
Bob Badour1ded0a12021-12-03 17:16:14 -0800805 stripPrefix: "testdata/proprietary/",
806 },
807 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800808 "bin/bin1.meta_lic lib/liba.so.meta_lic proprietary",
809 "bin/bin1.meta_lic lib/libc.a.meta_lic proprietary",
810 "bin/bin2.meta_lic bin/bin2.meta_lic restricted:proprietary",
811 "bin/bin2.meta_lic lib/libb.so.meta_lic restricted",
812 "highest.apex.meta_lic bin/bin2.meta_lic restricted:proprietary",
813 "highest.apex.meta_lic highest.apex.meta_lic restricted",
814 "highest.apex.meta_lic lib/liba.so.meta_lic proprietary",
815 "highest.apex.meta_lic lib/libb.so.meta_lic restricted",
816 "highest.apex.meta_lic lib/libc.a.meta_lic proprietary",
817 "lib/liba.so.meta_lic lib/liba.so.meta_lic proprietary",
818 "lib/libb.so.meta_lic lib/libb.so.meta_lic restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -0800819 },
820 },
821 {
822 condition: "proprietary",
823 name: "apex_trimmed_labelled",
824 roots: []string{"highest.apex.meta_lic"},
825 ctx: context{stripPrefix: "testdata/proprietary/", labelConditions: true},
826 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800827 "bin/bin1.meta_lic:notice bin/bin1.meta_lic:notice notice",
828 "bin/bin1.meta_lic:notice lib/liba.so.meta_lic:proprietary:by_exception_only proprietary:by_exception_only",
829 "bin/bin1.meta_lic:notice lib/libc.a.meta_lic:proprietary:by_exception_only proprietary:by_exception_only",
830 "bin/bin2.meta_lic:proprietary:by_exception_only bin/bin2.meta_lic:proprietary:by_exception_only restricted:proprietary:by_exception_only",
831 "bin/bin2.meta_lic:proprietary:by_exception_only lib/libb.so.meta_lic:restricted restricted",
832 "highest.apex.meta_lic:notice bin/bin1.meta_lic:notice notice",
833 "highest.apex.meta_lic:notice bin/bin2.meta_lic:proprietary:by_exception_only restricted:proprietary:by_exception_only",
834 "highest.apex.meta_lic:notice highest.apex.meta_lic:notice notice:restricted",
835 "highest.apex.meta_lic:notice lib/liba.so.meta_lic:proprietary:by_exception_only proprietary:by_exception_only",
836 "highest.apex.meta_lic:notice lib/libb.so.meta_lic:restricted restricted",
837 "highest.apex.meta_lic:notice lib/libc.a.meta_lic:proprietary:by_exception_only proprietary:by_exception_only",
838 "lib/liba.so.meta_lic:proprietary:by_exception_only lib/liba.so.meta_lic:proprietary:by_exception_only proprietary:by_exception_only",
839 "lib/libb.so.meta_lic:restricted lib/libb.so.meta_lic:restricted restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -0800840 },
841 },
842 {
843 condition: "proprietary",
844 name: "container",
845 roots: []string{"container.zip.meta_lic"},
846 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800847 "testdata/proprietary/bin/bin1.meta_lic testdata/proprietary/bin/bin1.meta_lic notice",
848 "testdata/proprietary/bin/bin1.meta_lic testdata/proprietary/lib/liba.so.meta_lic proprietary:by_exception_only",
849 "testdata/proprietary/bin/bin1.meta_lic testdata/proprietary/lib/libc.a.meta_lic proprietary:by_exception_only",
850 "testdata/proprietary/bin/bin2.meta_lic testdata/proprietary/bin/bin2.meta_lic restricted:proprietary:by_exception_only",
851 "testdata/proprietary/bin/bin2.meta_lic testdata/proprietary/lib/libb.so.meta_lic restricted",
852 "testdata/proprietary/container.zip.meta_lic testdata/proprietary/bin/bin1.meta_lic notice",
853 "testdata/proprietary/container.zip.meta_lic testdata/proprietary/bin/bin2.meta_lic restricted:proprietary:by_exception_only",
854 "testdata/proprietary/container.zip.meta_lic testdata/proprietary/container.zip.meta_lic notice:restricted",
855 "testdata/proprietary/container.zip.meta_lic testdata/proprietary/lib/liba.so.meta_lic proprietary:by_exception_only",
856 "testdata/proprietary/container.zip.meta_lic testdata/proprietary/lib/libb.so.meta_lic restricted",
857 "testdata/proprietary/container.zip.meta_lic testdata/proprietary/lib/libc.a.meta_lic proprietary:by_exception_only",
858 "testdata/proprietary/lib/liba.so.meta_lic testdata/proprietary/lib/liba.so.meta_lic proprietary:by_exception_only",
859 "testdata/proprietary/lib/libb.so.meta_lic testdata/proprietary/lib/libb.so.meta_lic restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -0800860 },
861 },
862 {
863 condition: "proprietary",
864 name: "application",
865 roots: []string{"application.meta_lic"},
866 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800867 "testdata/proprietary/application.meta_lic testdata/proprietary/application.meta_lic notice:restricted",
868 "testdata/proprietary/application.meta_lic testdata/proprietary/lib/liba.so.meta_lic restricted:proprietary:by_exception_only",
Bob Badour1ded0a12021-12-03 17:16:14 -0800869 },
870 },
871 {
872 condition: "proprietary",
873 name: "binary",
874 roots: []string{"bin/bin1.meta_lic"},
875 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800876 "testdata/proprietary/bin/bin1.meta_lic testdata/proprietary/bin/bin1.meta_lic notice",
877 "testdata/proprietary/bin/bin1.meta_lic testdata/proprietary/lib/liba.so.meta_lic proprietary:by_exception_only",
878 "testdata/proprietary/bin/bin1.meta_lic testdata/proprietary/lib/libc.a.meta_lic proprietary:by_exception_only",
Bob Badour1ded0a12021-12-03 17:16:14 -0800879 },
880 },
881 {
882 condition: "proprietary",
883 name: "library",
884 roots: []string{"lib/libd.so.meta_lic"},
885 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800886 "testdata/proprietary/lib/libd.so.meta_lic testdata/proprietary/lib/libd.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800887 },
888 },
889 }
890 for _, tt := range tests {
891 t.Run(tt.condition+" "+tt.name, func(t *testing.T) {
892 expectedOut := &bytes.Buffer{}
893 for _, eo := range tt.expectedOut {
894 expectedOut.WriteString(eo)
895 expectedOut.WriteString("\n")
896 }
897
898 stdout := &bytes.Buffer{}
899 stderr := &bytes.Buffer{}
900
901 rootFiles := make([]string, 0, len(tt.roots))
902 for _, r := range tt.roots {
903 rootFiles = append(rootFiles, "testdata/"+tt.condition+"/"+r)
904 }
Bob Badour103eb0f2022-01-10 13:50:57 -0800905 _, err := dumpResolutions(&tt.ctx, stdout, stderr, rootFiles...)
Bob Badour1ded0a12021-12-03 17:16:14 -0800906 if err != nil {
907 t.Fatalf("dumpresolutions: error = %v, stderr = %v", err, stderr)
908 return
909 }
910 if stderr.Len() > 0 {
911 t.Errorf("dumpresolutions: gotStderr = %v, want none", stderr)
912 }
913 out := stdout.String()
914 expected := expectedOut.String()
915 if out != expected {
916 outList := strings.Split(out, "\n")
917 expectedList := strings.Split(expected, "\n")
918 startLine := 0
919 for len(outList) > startLine && len(expectedList) > startLine && outList[startLine] == expectedList[startLine] {
920 startLine++
921 }
Bob Badour91af68b2022-01-31 13:11:11 -0800922 t.Errorf("dumpresoliutions: gotStdout = %v, want %v, somewhere near line %d Stdout = %v, want %v",
Bob Badour1ded0a12021-12-03 17:16:14 -0800923 out, expected, startLine+1, outList[startLine], expectedList[startLine])
924 }
925 })
926 }
927}
928
929type testContext struct {
930 nextNode int
931 nodes map[string]string
932}
933
934type matcher interface {
Bob Badour103eb0f2022-01-10 13:50:57 -0800935 matchString(*testContext, *compliance.LicenseGraph) string
Bob Badour1ded0a12021-12-03 17:16:14 -0800936 typeString() string
937}
938
939type targetMatcher struct {
940 target string
941 conditions []string
942}
943
Bob Badour103eb0f2022-01-10 13:50:57 -0800944// newTestCondition constructs a test license condition in the license graph.
Colin Cross35f79c32022-01-27 15:18:52 -0800945func newTestCondition(lg *compliance.LicenseGraph, conditionName ...string) compliance.LicenseConditionSet {
Bob Badour103eb0f2022-01-10 13:50:57 -0800946 cs := compliance.NewLicenseConditionSet()
947 for _, name := range conditionName {
948 cs = cs.Plus(compliance.RecognizedConditionNames[name])
949 }
950 if cs.IsEmpty() && len(conditionName) != 0 {
951 panic(fmt.Errorf("attempt to create unrecognized condition: %q", conditionName))
952 }
953 return cs
954}
955
956func (tm *targetMatcher) matchString(ctx *testContext, lg *compliance.LicenseGraph) string {
957 cs := newTestCondition(lg, tm.conditions...)
Bob Badour1ded0a12021-12-03 17:16:14 -0800958 m := tm.target
Bob Badour103eb0f2022-01-10 13:50:57 -0800959 if !cs.IsEmpty() {
960 m += "\\n" + strings.Join(cs.Names(), "\\n")
Bob Badour1ded0a12021-12-03 17:16:14 -0800961 }
962 m = ctx.nodes[tm.target] + " [label=\"" + m + "\"];"
963 return m
964}
965
966func (tm *targetMatcher) typeString() string {
967 return "target"
968}
969
970type resolutionMatcher struct {
971 appliesTo string
972 actsOn string
Bob Badour1ded0a12021-12-03 17:16:14 -0800973 conditions []string
974}
975
Bob Badour103eb0f2022-01-10 13:50:57 -0800976func (rm *resolutionMatcher) matchString(ctx *testContext, lg *compliance.LicenseGraph) string {
977 cs := newTestCondition(lg, rm.conditions...)
978 return ctx.nodes[rm.appliesTo] + " -> " + ctx.nodes[rm.actsOn] +
979 " [label=\"" + strings.Join(cs.Names(), "\\n") + "\"];"
Bob Badour1ded0a12021-12-03 17:16:14 -0800980}
981
982func (rm *resolutionMatcher) typeString() string {
983 return "resolution"
984}
985
986type getMatcher func(*testContext) matcher
987
988func matchTarget(target string, conditions ...string) getMatcher {
989 return func(ctx *testContext) matcher {
990 ctx.nodes[target] = fmt.Sprintf("n%d", ctx.nextNode)
991 ctx.nextNode++
992 return &targetMatcher{target, append([]string{}, conditions...)}
993 }
994}
995
Bob Badour103eb0f2022-01-10 13:50:57 -0800996func matchResolution(appliesTo, actsOn string, conditions ...string) getMatcher {
Bob Badour1ded0a12021-12-03 17:16:14 -0800997 return func(ctx *testContext) matcher {
998 if _, ok := ctx.nodes[appliesTo]; !ok {
999 ctx.nodes[appliesTo] = fmt.Sprintf("unknown%d", ctx.nextNode)
1000 ctx.nextNode++
1001 }
1002 if _, ok := ctx.nodes[actsOn]; !ok {
1003 ctx.nodes[actsOn] = fmt.Sprintf("unknown%d", ctx.nextNode)
1004 ctx.nextNode++
1005 }
Bob Badour103eb0f2022-01-10 13:50:57 -08001006 return &resolutionMatcher{appliesTo, actsOn, append([]string{}, conditions...)}
Bob Badour1ded0a12021-12-03 17:16:14 -08001007 }
1008}
1009
1010func Test_graphviz(t *testing.T) {
1011 tests := []struct {
1012 condition string
1013 name string
1014 roots []string
1015 ctx context
1016 expectedOut []getMatcher
1017 }{
1018 {
1019 condition: "firstparty",
1020 name: "apex",
1021 roots: []string{"highest.apex.meta_lic"},
1022 expectedOut: []getMatcher{
1023 matchTarget("testdata/firstparty/bin/bin1.meta_lic"),
1024 matchTarget("testdata/firstparty/lib/liba.so.meta_lic"),
1025 matchTarget("testdata/firstparty/lib/libc.a.meta_lic"),
1026 matchTarget("testdata/firstparty/bin/bin2.meta_lic"),
1027 matchTarget("testdata/firstparty/highest.apex.meta_lic"),
1028 matchTarget("testdata/firstparty/lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08001029 matchResolution(
1030 "testdata/firstparty/bin/bin1.meta_lic",
1031 "testdata/firstparty/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001032 "notice"),
1033 matchResolution(
1034 "testdata/firstparty/bin/bin1.meta_lic",
1035 "testdata/firstparty/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001036 "notice"),
1037 matchResolution(
1038 "testdata/firstparty/bin/bin1.meta_lic",
1039 "testdata/firstparty/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001040 "notice"),
1041 matchResolution(
1042 "testdata/firstparty/bin/bin2.meta_lic",
1043 "testdata/firstparty/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001044 "notice"),
1045 matchResolution(
1046 "testdata/firstparty/highest.apex.meta_lic",
1047 "testdata/firstparty/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001048 "notice"),
1049 matchResolution(
1050 "testdata/firstparty/highest.apex.meta_lic",
1051 "testdata/firstparty/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001052 "notice"),
1053 matchResolution(
1054 "testdata/firstparty/highest.apex.meta_lic",
1055 "testdata/firstparty/highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001056 "notice"),
1057 matchResolution(
1058 "testdata/firstparty/highest.apex.meta_lic",
1059 "testdata/firstparty/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001060 "notice"),
1061 matchResolution(
1062 "testdata/firstparty/highest.apex.meta_lic",
1063 "testdata/firstparty/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001064 "notice"),
1065 matchResolution(
1066 "testdata/firstparty/highest.apex.meta_lic",
1067 "testdata/firstparty/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001068 "notice"),
1069 matchResolution(
1070 "testdata/firstparty/lib/liba.so.meta_lic",
1071 "testdata/firstparty/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001072 "notice"),
1073 matchResolution(
1074 "testdata/firstparty/lib/libb.so.meta_lic",
1075 "testdata/firstparty/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001076 "notice"),
1077 },
1078 },
1079 {
1080 condition: "firstparty",
1081 name: "apex_trimmed",
1082 roots: []string{"highest.apex.meta_lic"},
1083 ctx: context{stripPrefix: "testdata/firstparty/"},
1084 expectedOut: []getMatcher{
1085 matchTarget("bin/bin1.meta_lic"),
1086 matchTarget("lib/liba.so.meta_lic"),
1087 matchTarget("lib/libc.a.meta_lic"),
1088 matchTarget("bin/bin2.meta_lic"),
1089 matchTarget("highest.apex.meta_lic"),
1090 matchTarget("lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08001091 matchResolution(
1092 "bin/bin1.meta_lic",
1093 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001094 "notice"),
1095 matchResolution(
1096 "bin/bin1.meta_lic",
1097 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001098 "notice"),
1099 matchResolution(
1100 "bin/bin1.meta_lic",
1101 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001102 "notice"),
1103 matchResolution(
1104 "bin/bin2.meta_lic",
1105 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001106 "notice"),
1107 matchResolution(
1108 "highest.apex.meta_lic",
1109 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001110 "notice"),
1111 matchResolution(
1112 "highest.apex.meta_lic",
1113 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001114 "notice"),
1115 matchResolution(
1116 "highest.apex.meta_lic",
1117 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001118 "notice"),
1119 matchResolution(
1120 "highest.apex.meta_lic",
1121 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001122 "notice"),
1123 matchResolution(
1124 "highest.apex.meta_lic",
1125 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001126 "notice"),
1127 matchResolution(
1128 "highest.apex.meta_lic",
1129 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001130 "notice"),
1131 matchResolution(
1132 "lib/liba.so.meta_lic",
1133 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001134 "notice"),
1135 matchResolution(
1136 "lib/libb.so.meta_lic",
1137 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001138 "notice"),
1139 },
1140 },
1141 {
1142 condition: "firstparty",
1143 name: "apex_trimmed_notice",
1144 roots: []string{"highest.apex.meta_lic"},
1145 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08001146 conditions: []compliance.LicenseCondition{compliance.NoticeCondition},
Bob Badour1ded0a12021-12-03 17:16:14 -08001147 stripPrefix: "testdata/firstparty/",
1148 },
1149 expectedOut: []getMatcher{
1150 matchTarget("bin/bin1.meta_lic"),
1151 matchTarget("lib/liba.so.meta_lic"),
1152 matchTarget("lib/libc.a.meta_lic"),
1153 matchTarget("bin/bin2.meta_lic"),
1154 matchTarget("highest.apex.meta_lic"),
1155 matchTarget("lib/libb.so.meta_lic"),
1156 matchResolution(
1157 "bin/bin1.meta_lic",
1158 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001159 "notice"),
1160 matchResolution(
1161 "bin/bin1.meta_lic",
1162 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001163 "notice"),
1164 matchResolution(
1165 "bin/bin1.meta_lic",
1166 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001167 "notice"),
1168 matchResolution(
1169 "bin/bin2.meta_lic",
1170 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001171 "notice"),
1172 matchResolution(
1173 "highest.apex.meta_lic",
1174 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001175 "notice"),
1176 matchResolution(
1177 "highest.apex.meta_lic",
1178 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001179 "notice"),
1180 matchResolution(
1181 "highest.apex.meta_lic",
1182 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001183 "notice"),
1184 matchResolution(
1185 "highest.apex.meta_lic",
1186 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001187 "notice"),
1188 matchResolution(
1189 "highest.apex.meta_lic",
1190 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001191 "notice"),
1192 matchResolution(
1193 "highest.apex.meta_lic",
1194 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001195 "notice"),
1196 matchResolution(
1197 "lib/liba.so.meta_lic",
1198 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001199 "notice"),
1200 matchResolution(
1201 "lib/libb.so.meta_lic",
1202 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001203 "notice"),
1204 },
1205 },
1206 {
1207 condition: "firstparty",
1208 name: "apex_trimmed_share",
1209 roots: []string{"highest.apex.meta_lic"},
1210 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08001211 conditions: compliance.ImpliesShared.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -08001212 stripPrefix: "testdata/firstparty/",
1213 },
1214 expectedOut: []getMatcher{},
1215 },
1216 {
1217 condition: "firstparty",
1218 name: "apex_trimmed_private",
1219 roots: []string{"highest.apex.meta_lic"},
1220 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08001221 conditions: compliance.ImpliesPrivate.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -08001222 stripPrefix: "testdata/firstparty/",
1223 },
1224 expectedOut: []getMatcher{},
1225 },
1226 {
1227 condition: "firstparty",
1228 name: "apex_trimmed_share_private",
1229 roots: []string{"highest.apex.meta_lic"},
1230 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08001231 conditions: compliance.ImpliesShared.Union(compliance.ImpliesPrivate).AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -08001232 stripPrefix: "testdata/firstparty/",
1233 },
1234 expectedOut: []getMatcher{},
1235 },
1236 {
1237 condition: "firstparty",
1238 name: "apex_trimmed_labelled",
1239 roots: []string{"highest.apex.meta_lic"},
1240 ctx: context{stripPrefix: "testdata/firstparty/", labelConditions: true},
1241 expectedOut: []getMatcher{
1242 matchTarget("bin/bin1.meta_lic", "notice"),
1243 matchTarget("lib/liba.so.meta_lic", "notice"),
1244 matchTarget("lib/libc.a.meta_lic", "notice"),
1245 matchTarget("bin/bin2.meta_lic", "notice"),
1246 matchTarget("highest.apex.meta_lic", "notice"),
1247 matchTarget("lib/libb.so.meta_lic", "notice"),
Bob Badour1ded0a12021-12-03 17:16:14 -08001248 matchResolution(
1249 "bin/bin1.meta_lic",
1250 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001251 "notice"),
1252 matchResolution(
1253 "bin/bin1.meta_lic",
1254 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001255 "notice"),
1256 matchResolution(
1257 "bin/bin1.meta_lic",
1258 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001259 "notice"),
1260 matchResolution(
1261 "bin/bin2.meta_lic",
1262 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001263 "notice"),
1264 matchResolution(
1265 "highest.apex.meta_lic",
1266 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001267 "notice"),
1268 matchResolution(
1269 "highest.apex.meta_lic",
1270 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001271 "notice"),
1272 matchResolution(
1273 "highest.apex.meta_lic",
1274 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001275 "notice"),
1276 matchResolution(
1277 "highest.apex.meta_lic",
1278 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001279 "notice"),
1280 matchResolution(
1281 "highest.apex.meta_lic",
1282 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001283 "notice"),
1284 matchResolution(
1285 "highest.apex.meta_lic",
1286 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001287 "notice"),
1288 matchResolution(
1289 "lib/liba.so.meta_lic",
1290 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001291 "notice"),
1292 matchResolution(
1293 "lib/libb.so.meta_lic",
1294 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001295 "notice"),
1296 },
1297 },
1298 {
1299 condition: "firstparty",
1300 name: "container",
1301 roots: []string{"container.zip.meta_lic"},
1302 expectedOut: []getMatcher{
1303 matchTarget("testdata/firstparty/bin/bin1.meta_lic"),
1304 matchTarget("testdata/firstparty/lib/liba.so.meta_lic"),
1305 matchTarget("testdata/firstparty/lib/libc.a.meta_lic"),
1306 matchTarget("testdata/firstparty/bin/bin2.meta_lic"),
1307 matchTarget("testdata/firstparty/container.zip.meta_lic"),
1308 matchTarget("testdata/firstparty/lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08001309 matchResolution(
1310 "testdata/firstparty/bin/bin1.meta_lic",
1311 "testdata/firstparty/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001312 "notice"),
1313 matchResolution(
1314 "testdata/firstparty/bin/bin1.meta_lic",
1315 "testdata/firstparty/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001316 "notice"),
1317 matchResolution(
1318 "testdata/firstparty/bin/bin1.meta_lic",
1319 "testdata/firstparty/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001320 "notice"),
1321 matchResolution(
1322 "testdata/firstparty/bin/bin2.meta_lic",
1323 "testdata/firstparty/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001324 "notice"),
1325 matchResolution(
1326 "testdata/firstparty/container.zip.meta_lic",
1327 "testdata/firstparty/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001328 "notice"),
1329 matchResolution(
1330 "testdata/firstparty/container.zip.meta_lic",
1331 "testdata/firstparty/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001332 "notice"),
1333 matchResolution(
1334 "testdata/firstparty/container.zip.meta_lic",
1335 "testdata/firstparty/container.zip.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001336 "notice"),
1337 matchResolution(
1338 "testdata/firstparty/container.zip.meta_lic",
1339 "testdata/firstparty/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001340 "notice"),
1341 matchResolution(
1342 "testdata/firstparty/container.zip.meta_lic",
1343 "testdata/firstparty/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001344 "notice"),
1345 matchResolution(
1346 "testdata/firstparty/container.zip.meta_lic",
1347 "testdata/firstparty/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001348 "notice"),
1349 matchResolution(
1350 "testdata/firstparty/lib/liba.so.meta_lic",
1351 "testdata/firstparty/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001352 "notice"),
1353 matchResolution(
1354 "testdata/firstparty/lib/libb.so.meta_lic",
1355 "testdata/firstparty/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001356 "notice"),
1357 },
1358 },
1359 {
1360 condition: "firstparty",
1361 name: "application",
1362 roots: []string{"application.meta_lic"},
1363 expectedOut: []getMatcher{
1364 matchTarget("testdata/firstparty/application.meta_lic"),
1365 matchTarget("testdata/firstparty/lib/liba.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08001366 matchResolution(
1367 "testdata/firstparty/application.meta_lic",
1368 "testdata/firstparty/application.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001369 "notice"),
1370 matchResolution(
1371 "testdata/firstparty/application.meta_lic",
1372 "testdata/firstparty/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001373 "notice"),
1374 },
1375 },
1376 {
1377 condition: "firstparty",
1378 name: "binary",
1379 roots: []string{"bin/bin1.meta_lic"},
1380 expectedOut: []getMatcher{
1381 matchTarget("testdata/firstparty/bin/bin1.meta_lic"),
1382 matchTarget("testdata/firstparty/lib/liba.so.meta_lic"),
1383 matchTarget("testdata/firstparty/lib/libc.a.meta_lic"),
1384 matchResolution(
1385 "testdata/firstparty/bin/bin1.meta_lic",
1386 "testdata/firstparty/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001387 "notice"),
1388 matchResolution(
1389 "testdata/firstparty/bin/bin1.meta_lic",
1390 "testdata/firstparty/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001391 "notice"),
1392 matchResolution(
1393 "testdata/firstparty/bin/bin1.meta_lic",
1394 "testdata/firstparty/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001395 "notice"),
1396 },
1397 },
1398 {
1399 condition: "firstparty",
1400 name: "library",
1401 roots: []string{"lib/libd.so.meta_lic"},
1402 expectedOut: []getMatcher{
1403 matchTarget("testdata/firstparty/lib/libd.so.meta_lic"),
1404 matchResolution(
1405 "testdata/firstparty/lib/libd.so.meta_lic",
1406 "testdata/firstparty/lib/libd.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001407 "notice"),
1408 },
1409 },
1410 {
1411 condition: "notice",
1412 name: "apex",
1413 roots: []string{"highest.apex.meta_lic"},
1414 expectedOut: []getMatcher{
1415 matchTarget("testdata/notice/bin/bin1.meta_lic"),
1416 matchTarget("testdata/notice/lib/liba.so.meta_lic"),
1417 matchTarget("testdata/notice/lib/libc.a.meta_lic"),
1418 matchTarget("testdata/notice/bin/bin2.meta_lic"),
1419 matchTarget("testdata/notice/highest.apex.meta_lic"),
1420 matchTarget("testdata/notice/lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08001421 matchResolution(
1422 "testdata/notice/bin/bin1.meta_lic",
1423 "testdata/notice/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001424 "notice"),
1425 matchResolution(
1426 "testdata/notice/bin/bin1.meta_lic",
1427 "testdata/notice/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001428 "notice"),
1429 matchResolution(
1430 "testdata/notice/bin/bin1.meta_lic",
1431 "testdata/notice/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001432 "notice"),
1433 matchResolution(
1434 "testdata/notice/bin/bin2.meta_lic",
1435 "testdata/notice/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001436 "notice"),
1437 matchResolution(
1438 "testdata/notice/highest.apex.meta_lic",
1439 "testdata/notice/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001440 "notice"),
1441 matchResolution(
1442 "testdata/notice/highest.apex.meta_lic",
1443 "testdata/notice/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001444 "notice"),
1445 matchResolution(
1446 "testdata/notice/highest.apex.meta_lic",
1447 "testdata/notice/highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001448 "notice"),
1449 matchResolution(
1450 "testdata/notice/highest.apex.meta_lic",
1451 "testdata/notice/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001452 "notice"),
1453 matchResolution(
1454 "testdata/notice/highest.apex.meta_lic",
1455 "testdata/notice/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001456 "notice"),
1457 matchResolution(
1458 "testdata/notice/highest.apex.meta_lic",
1459 "testdata/notice/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001460 "notice"),
1461 matchResolution(
1462 "testdata/notice/lib/liba.so.meta_lic",
1463 "testdata/notice/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001464 "notice"),
1465 matchResolution(
1466 "testdata/notice/lib/libb.so.meta_lic",
1467 "testdata/notice/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001468 "notice"),
1469 },
1470 },
1471 {
1472 condition: "notice",
1473 name: "apex_trimmed",
1474 roots: []string{"highest.apex.meta_lic"},
1475 ctx: context{stripPrefix: "testdata/notice/"},
1476 expectedOut: []getMatcher{
1477 matchTarget("bin/bin1.meta_lic"),
1478 matchTarget("lib/liba.so.meta_lic"),
1479 matchTarget("lib/libc.a.meta_lic"),
1480 matchTarget("bin/bin2.meta_lic"),
1481 matchTarget("highest.apex.meta_lic"),
1482 matchTarget("lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08001483 matchResolution(
1484 "bin/bin1.meta_lic",
1485 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001486 "notice"),
1487 matchResolution(
1488 "bin/bin1.meta_lic",
1489 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001490 "notice"),
1491 matchResolution(
1492 "bin/bin1.meta_lic",
1493 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001494 "notice"),
1495 matchResolution(
1496 "bin/bin2.meta_lic",
1497 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001498 "notice"),
1499 matchResolution(
1500 "highest.apex.meta_lic",
1501 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001502 "notice"),
1503 matchResolution(
1504 "highest.apex.meta_lic",
1505 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001506 "notice"),
1507 matchResolution(
1508 "highest.apex.meta_lic",
1509 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001510 "notice"),
1511 matchResolution(
1512 "highest.apex.meta_lic",
1513 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001514 "notice"),
1515 matchResolution(
1516 "highest.apex.meta_lic",
1517 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001518 "notice"),
1519 matchResolution(
1520 "highest.apex.meta_lic",
1521 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001522 "notice"),
1523 matchResolution(
1524 "lib/liba.so.meta_lic",
1525 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001526 "notice"),
1527 matchResolution(
1528 "lib/libb.so.meta_lic",
1529 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001530 "notice"),
1531 },
1532 },
1533 {
1534 condition: "notice",
1535 name: "apex_trimmed_notice",
1536 roots: []string{"highest.apex.meta_lic"},
1537 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08001538 conditions: []compliance.LicenseCondition{compliance.NoticeCondition},
Bob Badour1ded0a12021-12-03 17:16:14 -08001539 stripPrefix: "testdata/notice/",
1540 },
1541 expectedOut: []getMatcher{
1542 matchTarget("bin/bin1.meta_lic"),
1543 matchTarget("lib/liba.so.meta_lic"),
1544 matchTarget("lib/libc.a.meta_lic"),
1545 matchTarget("bin/bin2.meta_lic"),
1546 matchTarget("highest.apex.meta_lic"),
1547 matchTarget("lib/libb.so.meta_lic"),
1548 matchResolution(
1549 "bin/bin1.meta_lic",
1550 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001551 "notice"),
1552 matchResolution(
1553 "bin/bin1.meta_lic",
1554 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001555 "notice"),
1556 matchResolution(
1557 "bin/bin1.meta_lic",
1558 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001559 "notice"),
1560 matchResolution(
1561 "bin/bin2.meta_lic",
1562 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001563 "notice"),
1564 matchResolution(
1565 "highest.apex.meta_lic",
1566 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001567 "notice"),
1568 matchResolution(
1569 "highest.apex.meta_lic",
1570 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001571 "notice"),
1572 matchResolution(
1573 "highest.apex.meta_lic",
1574 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001575 "notice"),
1576 matchResolution(
1577 "highest.apex.meta_lic",
1578 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001579 "notice"),
1580 matchResolution(
1581 "highest.apex.meta_lic",
1582 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001583 "notice"),
1584 matchResolution(
1585 "highest.apex.meta_lic",
1586 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001587 "notice"),
1588 matchResolution(
1589 "lib/liba.so.meta_lic",
1590 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001591 "notice"),
1592 matchResolution(
1593 "lib/libb.so.meta_lic",
1594 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001595 "notice"),
1596 },
1597 },
1598 {
1599 condition: "notice",
1600 name: "apex_trimmed_share",
1601 roots: []string{"highest.apex.meta_lic"},
1602 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08001603 conditions: compliance.ImpliesShared.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -08001604 stripPrefix: "testdata/notice/",
1605 },
1606 expectedOut: []getMatcher{},
1607 },
1608 {
1609 condition: "notice",
1610 name: "apex_trimmed_private",
1611 roots: []string{"highest.apex.meta_lic"},
1612 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08001613 conditions: compliance.ImpliesPrivate.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -08001614 stripPrefix: "testdata/notice/",
1615 },
1616 expectedOut: []getMatcher{},
1617 },
1618 {
1619 condition: "notice",
1620 name: "apex_trimmed_share_private",
1621 roots: []string{"highest.apex.meta_lic"},
1622 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08001623 conditions: compliance.ImpliesShared.Union(compliance.ImpliesPrivate).AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -08001624 stripPrefix: "testdata/notice/",
1625 },
1626 expectedOut: []getMatcher{},
1627 },
1628 {
1629 condition: "notice",
1630 name: "apex_trimmed_labelled",
1631 roots: []string{"highest.apex.meta_lic"},
1632 ctx: context{stripPrefix: "testdata/notice/", labelConditions: true},
1633 expectedOut: []getMatcher{
1634 matchTarget("bin/bin1.meta_lic", "notice"),
1635 matchTarget("lib/liba.so.meta_lic", "notice"),
1636 matchTarget("lib/libc.a.meta_lic", "notice"),
1637 matchTarget("bin/bin2.meta_lic", "notice"),
1638 matchTarget("highest.apex.meta_lic", "notice"),
1639 matchTarget("lib/libb.so.meta_lic", "notice"),
Bob Badour1ded0a12021-12-03 17:16:14 -08001640 matchResolution(
1641 "bin/bin1.meta_lic",
1642 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001643 "notice"),
1644 matchResolution(
1645 "bin/bin1.meta_lic",
1646 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001647 "notice"),
1648 matchResolution(
1649 "bin/bin1.meta_lic",
1650 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001651 "notice"),
1652 matchResolution(
1653 "bin/bin2.meta_lic",
1654 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001655 "notice"),
1656 matchResolution(
1657 "highest.apex.meta_lic",
1658 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001659 "notice"),
1660 matchResolution(
1661 "highest.apex.meta_lic",
1662 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001663 "notice"),
1664 matchResolution(
1665 "highest.apex.meta_lic",
1666 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001667 "notice"),
1668 matchResolution(
1669 "highest.apex.meta_lic",
1670 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001671 "notice"),
1672 matchResolution(
1673 "highest.apex.meta_lic",
1674 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001675 "notice"),
1676 matchResolution(
1677 "highest.apex.meta_lic",
1678 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001679 "notice"),
1680 matchResolution(
1681 "lib/liba.so.meta_lic",
1682 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001683 "notice"),
1684 matchResolution(
1685 "lib/libb.so.meta_lic",
1686 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001687 "notice"),
1688 },
1689 },
1690 {
1691 condition: "notice",
1692 name: "container",
1693 roots: []string{"container.zip.meta_lic"},
1694 expectedOut: []getMatcher{
1695 matchTarget("testdata/notice/bin/bin1.meta_lic"),
1696 matchTarget("testdata/notice/lib/liba.so.meta_lic"),
1697 matchTarget("testdata/notice/lib/libc.a.meta_lic"),
1698 matchTarget("testdata/notice/bin/bin2.meta_lic"),
1699 matchTarget("testdata/notice/container.zip.meta_lic"),
1700 matchTarget("testdata/notice/lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08001701 matchResolution(
1702 "testdata/notice/bin/bin1.meta_lic",
1703 "testdata/notice/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001704 "notice"),
1705 matchResolution(
1706 "testdata/notice/bin/bin1.meta_lic",
1707 "testdata/notice/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001708 "notice"),
1709 matchResolution(
1710 "testdata/notice/bin/bin1.meta_lic",
1711 "testdata/notice/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001712 "notice"),
1713 matchResolution(
1714 "testdata/notice/bin/bin2.meta_lic",
1715 "testdata/notice/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001716 "notice"),
1717 matchResolution(
1718 "testdata/notice/container.zip.meta_lic",
1719 "testdata/notice/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001720 "notice"),
1721 matchResolution(
1722 "testdata/notice/container.zip.meta_lic",
1723 "testdata/notice/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001724 "notice"),
1725 matchResolution(
1726 "testdata/notice/container.zip.meta_lic",
1727 "testdata/notice/container.zip.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001728 "notice"),
1729 matchResolution(
1730 "testdata/notice/container.zip.meta_lic",
1731 "testdata/notice/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001732 "notice"),
1733 matchResolution(
1734 "testdata/notice/container.zip.meta_lic",
1735 "testdata/notice/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001736 "notice"),
1737 matchResolution(
1738 "testdata/notice/container.zip.meta_lic",
1739 "testdata/notice/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001740 "notice"),
1741 matchResolution(
1742 "testdata/notice/lib/liba.so.meta_lic",
1743 "testdata/notice/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001744 "notice"),
1745 matchResolution(
1746 "testdata/notice/lib/libb.so.meta_lic",
1747 "testdata/notice/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001748 "notice"),
1749 },
1750 },
1751 {
1752 condition: "notice",
1753 name: "application",
1754 roots: []string{"application.meta_lic"},
1755 expectedOut: []getMatcher{
1756 matchTarget("testdata/notice/application.meta_lic"),
1757 matchTarget("testdata/notice/lib/liba.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08001758 matchResolution(
1759 "testdata/notice/application.meta_lic",
1760 "testdata/notice/application.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001761 "notice"),
1762 matchResolution(
1763 "testdata/notice/application.meta_lic",
1764 "testdata/notice/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001765 "notice"),
1766 },
1767 },
1768 {
1769 condition: "notice",
1770 name: "binary",
1771 roots: []string{"bin/bin1.meta_lic"},
1772 expectedOut: []getMatcher{
1773 matchTarget("testdata/notice/bin/bin1.meta_lic"),
1774 matchTarget("testdata/notice/lib/liba.so.meta_lic"),
1775 matchTarget("testdata/notice/lib/libc.a.meta_lic"),
1776 matchResolution(
1777 "testdata/notice/bin/bin1.meta_lic",
1778 "testdata/notice/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001779 "notice"),
1780 matchResolution(
1781 "testdata/notice/bin/bin1.meta_lic",
1782 "testdata/notice/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001783 "notice"),
1784 matchResolution(
1785 "testdata/notice/bin/bin1.meta_lic",
1786 "testdata/notice/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001787 "notice"),
1788 },
1789 },
1790 {
1791 condition: "notice",
1792 name: "library",
1793 roots: []string{"lib/libd.so.meta_lic"},
1794 expectedOut: []getMatcher{
1795 matchTarget("testdata/notice/lib/libd.so.meta_lic"),
1796 matchResolution(
1797 "testdata/notice/lib/libd.so.meta_lic",
1798 "testdata/notice/lib/libd.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001799 "notice"),
1800 },
1801 },
1802 {
1803 condition: "reciprocal",
1804 name: "apex",
1805 roots: []string{"highest.apex.meta_lic"},
1806 expectedOut: []getMatcher{
1807 matchTarget("testdata/reciprocal/bin/bin1.meta_lic"),
1808 matchTarget("testdata/reciprocal/lib/liba.so.meta_lic"),
1809 matchTarget("testdata/reciprocal/lib/libc.a.meta_lic"),
1810 matchTarget("testdata/reciprocal/bin/bin2.meta_lic"),
1811 matchTarget("testdata/reciprocal/highest.apex.meta_lic"),
1812 matchTarget("testdata/reciprocal/lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08001813 matchResolution(
1814 "testdata/reciprocal/bin/bin1.meta_lic",
1815 "testdata/reciprocal/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001816 "notice"),
1817 matchResolution(
1818 "testdata/reciprocal/bin/bin1.meta_lic",
1819 "testdata/reciprocal/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001820 "reciprocal"),
1821 matchResolution(
1822 "testdata/reciprocal/bin/bin1.meta_lic",
1823 "testdata/reciprocal/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001824 "reciprocal"),
1825 matchResolution(
1826 "testdata/reciprocal/bin/bin2.meta_lic",
1827 "testdata/reciprocal/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001828 "notice"),
1829 matchResolution(
1830 "testdata/reciprocal/highest.apex.meta_lic",
1831 "testdata/reciprocal/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001832 "notice"),
1833 matchResolution(
1834 "testdata/reciprocal/highest.apex.meta_lic",
1835 "testdata/reciprocal/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001836 "notice"),
1837 matchResolution(
1838 "testdata/reciprocal/highest.apex.meta_lic",
1839 "testdata/reciprocal/highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001840 "notice"),
1841 matchResolution(
1842 "testdata/reciprocal/highest.apex.meta_lic",
1843 "testdata/reciprocal/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001844 "reciprocal"),
1845 matchResolution(
1846 "testdata/reciprocal/highest.apex.meta_lic",
1847 "testdata/reciprocal/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001848 "notice"),
1849 matchResolution(
1850 "testdata/reciprocal/highest.apex.meta_lic",
1851 "testdata/reciprocal/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001852 "reciprocal"),
1853 matchResolution(
1854 "testdata/reciprocal/lib/liba.so.meta_lic",
1855 "testdata/reciprocal/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001856 "reciprocal"),
1857 matchResolution(
1858 "testdata/reciprocal/lib/libb.so.meta_lic",
1859 "testdata/reciprocal/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001860 "notice"),
1861 },
1862 },
1863 {
1864 condition: "reciprocal",
1865 name: "apex_trimmed",
1866 roots: []string{"highest.apex.meta_lic"},
1867 ctx: context{stripPrefix: "testdata/reciprocal/"},
1868 expectedOut: []getMatcher{
1869 matchTarget("bin/bin1.meta_lic"),
1870 matchTarget("lib/liba.so.meta_lic"),
1871 matchTarget("lib/libc.a.meta_lic"),
1872 matchTarget("bin/bin2.meta_lic"),
1873 matchTarget("highest.apex.meta_lic"),
1874 matchTarget("lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08001875 matchResolution(
1876 "bin/bin1.meta_lic",
1877 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001878 "notice"),
1879 matchResolution(
1880 "bin/bin1.meta_lic",
1881 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001882 "reciprocal"),
1883 matchResolution(
1884 "bin/bin1.meta_lic",
1885 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001886 "reciprocal"),
1887 matchResolution(
1888 "bin/bin2.meta_lic",
1889 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001890 "notice"),
1891 matchResolution(
1892 "highest.apex.meta_lic",
1893 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001894 "notice"),
1895 matchResolution(
1896 "highest.apex.meta_lic",
1897 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001898 "notice"),
1899 matchResolution(
1900 "highest.apex.meta_lic",
1901 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001902 "notice"),
1903 matchResolution(
1904 "highest.apex.meta_lic",
1905 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001906 "reciprocal"),
1907 matchResolution(
1908 "highest.apex.meta_lic",
1909 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001910 "notice"),
1911 matchResolution(
1912 "highest.apex.meta_lic",
1913 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001914 "reciprocal"),
1915 matchResolution(
1916 "lib/liba.so.meta_lic",
1917 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001918 "reciprocal"),
1919 matchResolution(
1920 "lib/libb.so.meta_lic",
1921 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001922 "notice"),
1923 },
1924 },
1925 {
1926 condition: "reciprocal",
1927 name: "apex_trimmed_notice",
1928 roots: []string{"highest.apex.meta_lic"},
1929 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08001930 conditions: []compliance.LicenseCondition{compliance.NoticeCondition},
Bob Badour1ded0a12021-12-03 17:16:14 -08001931 stripPrefix: "testdata/reciprocal/",
1932 },
1933 expectedOut: []getMatcher{
1934 matchTarget("bin/bin1.meta_lic"),
1935 matchTarget("bin/bin2.meta_lic"),
1936 matchTarget("highest.apex.meta_lic"),
1937 matchTarget("lib/libb.so.meta_lic"),
1938 matchResolution(
1939 "bin/bin1.meta_lic",
1940 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001941 "notice"),
1942 matchResolution(
1943 "bin/bin2.meta_lic",
1944 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001945 "notice"),
1946 matchResolution(
1947 "highest.apex.meta_lic",
1948 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001949 "notice"),
1950 matchResolution(
1951 "highest.apex.meta_lic",
1952 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001953 "notice"),
1954 matchResolution(
1955 "highest.apex.meta_lic",
1956 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001957 "notice"),
1958 matchResolution(
1959 "highest.apex.meta_lic",
1960 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001961 "notice"),
1962 matchResolution(
1963 "lib/libb.so.meta_lic",
1964 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001965 "notice"),
1966 },
1967 },
1968 {
1969 condition: "reciprocal",
1970 name: "apex_trimmed_share",
1971 roots: []string{"highest.apex.meta_lic"},
1972 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08001973 conditions: compliance.ImpliesShared.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -08001974 stripPrefix: "testdata/reciprocal/",
1975 },
1976 expectedOut: []getMatcher{
1977 matchTarget("bin/bin1.meta_lic"),
1978 matchTarget("lib/liba.so.meta_lic"),
1979 matchTarget("lib/libc.a.meta_lic"),
1980 matchTarget("highest.apex.meta_lic"),
1981 matchResolution(
1982 "bin/bin1.meta_lic",
1983 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001984 "reciprocal"),
1985 matchResolution(
1986 "bin/bin1.meta_lic",
1987 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001988 "reciprocal"),
1989 matchResolution(
1990 "highest.apex.meta_lic",
1991 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001992 "reciprocal"),
1993 matchResolution(
1994 "highest.apex.meta_lic",
1995 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001996 "reciprocal"),
1997 matchResolution(
1998 "lib/liba.so.meta_lic",
1999 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002000 "reciprocal"),
2001 },
2002 },
2003 {
2004 condition: "reciprocal",
2005 name: "apex_trimmed_private",
2006 roots: []string{"highest.apex.meta_lic"},
2007 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08002008 conditions: compliance.ImpliesPrivate.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -08002009 stripPrefix: "testdata/reciprocal/",
2010 },
2011 expectedOut: []getMatcher{},
2012 },
2013 {
2014 condition: "reciprocal",
2015 name: "apex_trimmed_share_private",
2016 roots: []string{"highest.apex.meta_lic"},
2017 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08002018 conditions: compliance.ImpliesShared.Union(compliance.ImpliesPrivate).AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -08002019 stripPrefix: "testdata/reciprocal/",
2020 },
2021 expectedOut: []getMatcher{
2022 matchTarget("bin/bin1.meta_lic"),
2023 matchTarget("lib/liba.so.meta_lic"),
2024 matchTarget("lib/libc.a.meta_lic"),
2025 matchTarget("highest.apex.meta_lic"),
2026 matchResolution(
2027 "bin/bin1.meta_lic",
2028 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002029 "reciprocal"),
2030 matchResolution(
2031 "bin/bin1.meta_lic",
2032 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002033 "reciprocal"),
2034 matchResolution(
2035 "highest.apex.meta_lic",
2036 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002037 "reciprocal"),
2038 matchResolution(
2039 "highest.apex.meta_lic",
2040 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002041 "reciprocal"),
2042 matchResolution(
2043 "lib/liba.so.meta_lic",
2044 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002045 "reciprocal"),
2046 },
2047 },
2048 {
2049 condition: "reciprocal",
2050 name: "apex_trimmed_labelled",
2051 roots: []string{"highest.apex.meta_lic"},
2052 ctx: context{stripPrefix: "testdata/reciprocal/", labelConditions: true},
2053 expectedOut: []getMatcher{
2054 matchTarget("bin/bin1.meta_lic", "notice"),
2055 matchTarget("lib/liba.so.meta_lic", "reciprocal"),
2056 matchTarget("lib/libc.a.meta_lic", "reciprocal"),
2057 matchTarget("bin/bin2.meta_lic", "notice"),
2058 matchTarget("highest.apex.meta_lic", "notice"),
2059 matchTarget("lib/libb.so.meta_lic", "notice"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002060 matchResolution(
2061 "bin/bin1.meta_lic",
2062 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002063 "notice"),
2064 matchResolution(
2065 "bin/bin1.meta_lic",
2066 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002067 "reciprocal"),
2068 matchResolution(
2069 "bin/bin1.meta_lic",
2070 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002071 "reciprocal"),
2072 matchResolution(
2073 "bin/bin2.meta_lic",
2074 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002075 "notice"),
2076 matchResolution(
2077 "highest.apex.meta_lic",
2078 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002079 "notice"),
2080 matchResolution(
2081 "highest.apex.meta_lic",
2082 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002083 "notice"),
2084 matchResolution(
2085 "highest.apex.meta_lic",
2086 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002087 "notice"),
2088 matchResolution(
2089 "highest.apex.meta_lic",
2090 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002091 "reciprocal"),
2092 matchResolution(
2093 "highest.apex.meta_lic",
2094 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002095 "notice"),
2096 matchResolution(
2097 "highest.apex.meta_lic",
2098 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002099 "reciprocal"),
2100 matchResolution(
2101 "lib/liba.so.meta_lic",
2102 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002103 "reciprocal"),
2104 matchResolution(
2105 "lib/libb.so.meta_lic",
2106 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002107 "notice"),
2108 },
2109 },
2110 {
2111 condition: "reciprocal",
2112 name: "container",
2113 roots: []string{"container.zip.meta_lic"},
2114 expectedOut: []getMatcher{
2115 matchTarget("testdata/reciprocal/bin/bin1.meta_lic"),
2116 matchTarget("testdata/reciprocal/lib/liba.so.meta_lic"),
2117 matchTarget("testdata/reciprocal/lib/libc.a.meta_lic"),
2118 matchTarget("testdata/reciprocal/bin/bin2.meta_lic"),
2119 matchTarget("testdata/reciprocal/container.zip.meta_lic"),
2120 matchTarget("testdata/reciprocal/lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002121 matchResolution(
2122 "testdata/reciprocal/bin/bin1.meta_lic",
2123 "testdata/reciprocal/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002124 "notice"),
2125 matchResolution(
2126 "testdata/reciprocal/bin/bin1.meta_lic",
2127 "testdata/reciprocal/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002128 "reciprocal"),
2129 matchResolution(
2130 "testdata/reciprocal/bin/bin1.meta_lic",
2131 "testdata/reciprocal/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002132 "reciprocal"),
2133 matchResolution(
2134 "testdata/reciprocal/bin/bin2.meta_lic",
2135 "testdata/reciprocal/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002136 "notice"),
2137 matchResolution(
2138 "testdata/reciprocal/container.zip.meta_lic",
2139 "testdata/reciprocal/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002140 "notice"),
2141 matchResolution(
2142 "testdata/reciprocal/container.zip.meta_lic",
2143 "testdata/reciprocal/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002144 "notice"),
2145 matchResolution(
2146 "testdata/reciprocal/container.zip.meta_lic",
2147 "testdata/reciprocal/container.zip.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002148 "notice"),
2149 matchResolution(
2150 "testdata/reciprocal/container.zip.meta_lic",
2151 "testdata/reciprocal/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002152 "reciprocal"),
2153 matchResolution(
2154 "testdata/reciprocal/container.zip.meta_lic",
2155 "testdata/reciprocal/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002156 "notice"),
2157 matchResolution(
2158 "testdata/reciprocal/container.zip.meta_lic",
2159 "testdata/reciprocal/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002160 "reciprocal"),
2161 matchResolution(
2162 "testdata/reciprocal/lib/liba.so.meta_lic",
2163 "testdata/reciprocal/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002164 "reciprocal"),
2165 matchResolution(
2166 "testdata/reciprocal/lib/libb.so.meta_lic",
2167 "testdata/reciprocal/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002168 "notice"),
2169 },
2170 },
2171 {
2172 condition: "reciprocal",
2173 name: "application",
2174 roots: []string{"application.meta_lic"},
2175 expectedOut: []getMatcher{
2176 matchTarget("testdata/reciprocal/application.meta_lic"),
2177 matchTarget("testdata/reciprocal/lib/liba.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002178 matchResolution(
2179 "testdata/reciprocal/application.meta_lic",
2180 "testdata/reciprocal/application.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002181 "notice"),
2182 matchResolution(
2183 "testdata/reciprocal/application.meta_lic",
2184 "testdata/reciprocal/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002185 "reciprocal"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002186 },
2187 },
2188 {
2189 condition: "reciprocal",
2190 name: "binary",
2191 roots: []string{"bin/bin1.meta_lic"},
2192 expectedOut: []getMatcher{
2193 matchTarget("testdata/reciprocal/bin/bin1.meta_lic"),
2194 matchTarget("testdata/reciprocal/lib/liba.so.meta_lic"),
2195 matchTarget("testdata/reciprocal/lib/libc.a.meta_lic"),
2196 matchResolution(
2197 "testdata/reciprocal/bin/bin1.meta_lic",
2198 "testdata/reciprocal/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002199 "notice"),
2200 matchResolution(
2201 "testdata/reciprocal/bin/bin1.meta_lic",
2202 "testdata/reciprocal/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002203 "reciprocal"),
2204 matchResolution(
2205 "testdata/reciprocal/bin/bin1.meta_lic",
2206 "testdata/reciprocal/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002207 "reciprocal"),
2208 },
2209 },
2210 {
2211 condition: "reciprocal",
2212 name: "library",
2213 roots: []string{"lib/libd.so.meta_lic"},
2214 expectedOut: []getMatcher{
2215 matchTarget("testdata/reciprocal/lib/libd.so.meta_lic"),
2216 matchResolution(
2217 "testdata/reciprocal/lib/libd.so.meta_lic",
2218 "testdata/reciprocal/lib/libd.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002219 "notice"),
2220 },
2221 },
2222 {
2223 condition: "restricted",
2224 name: "apex",
2225 roots: []string{"highest.apex.meta_lic"},
2226 expectedOut: []getMatcher{
2227 matchTarget("testdata/restricted/bin/bin1.meta_lic"),
2228 matchTarget("testdata/restricted/lib/liba.so.meta_lic"),
2229 matchTarget("testdata/restricted/lib/libc.a.meta_lic"),
2230 matchTarget("testdata/restricted/bin/bin2.meta_lic"),
2231 matchTarget("testdata/restricted/lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002232 matchTarget("testdata/restricted/highest.apex.meta_lic"),
2233 matchResolution(
2234 "testdata/restricted/bin/bin1.meta_lic",
2235 "testdata/restricted/bin/bin1.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002236 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002237 "notice"),
2238 matchResolution(
2239 "testdata/restricted/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002240 "testdata/restricted/lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002241 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002242 matchResolution(
2243 "testdata/restricted/bin/bin1.meta_lic",
2244 "testdata/restricted/lib/libc.a.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002245 "reciprocal",
2246 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002247 matchResolution(
2248 "testdata/restricted/bin/bin2.meta_lic",
2249 "testdata/restricted/bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002250 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002251 "notice"),
2252 matchResolution(
2253 "testdata/restricted/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002254 "testdata/restricted/lib/libb.so.meta_lic",
2255 "restricted"),
2256 matchResolution(
2257 "testdata/restricted/highest.apex.meta_lic",
2258 "testdata/restricted/bin/bin1.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002259 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002260 "notice"),
2261 matchResolution(
2262 "testdata/restricted/highest.apex.meta_lic",
2263 "testdata/restricted/bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002264 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002265 "notice"),
2266 matchResolution(
2267 "testdata/restricted/highest.apex.meta_lic",
2268 "testdata/restricted/highest.apex.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002269 "restricted",
2270 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002271 "notice"),
Bob Badour103eb0f2022-01-10 13:50:57 -08002272 matchResolution(
2273 "testdata/restricted/highest.apex.meta_lic",
2274 "testdata/restricted/lib/liba.so.meta_lic",
2275 "restricted_allows_dynamic_linking"),
2276 matchResolution(
2277 "testdata/restricted/highest.apex.meta_lic",
2278 "testdata/restricted/lib/libb.so.meta_lic",
2279 "restricted"),
2280 matchResolution(
2281 "testdata/restricted/highest.apex.meta_lic",
2282 "testdata/restricted/lib/libc.a.meta_lic",
2283 "reciprocal",
2284 "restricted_allows_dynamic_linking"),
2285 matchResolution(
2286 "testdata/restricted/lib/liba.so.meta_lic",
2287 "testdata/restricted/lib/liba.so.meta_lic",
2288 "restricted_allows_dynamic_linking"),
2289 matchResolution(
2290 "testdata/restricted/lib/libb.so.meta_lic",
2291 "testdata/restricted/lib/libb.so.meta_lic",
2292 "restricted"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002293 },
2294 },
2295 {
2296 condition: "restricted",
2297 name: "apex_trimmed",
2298 roots: []string{"highest.apex.meta_lic"},
2299 ctx: context{stripPrefix: "testdata/restricted/"},
2300 expectedOut: []getMatcher{
2301 matchTarget("bin/bin1.meta_lic"),
2302 matchTarget("lib/liba.so.meta_lic"),
2303 matchTarget("lib/libc.a.meta_lic"),
2304 matchTarget("bin/bin2.meta_lic"),
2305 matchTarget("lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002306 matchTarget("highest.apex.meta_lic"),
2307 matchResolution(
2308 "bin/bin1.meta_lic",
2309 "bin/bin1.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002310 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002311 "notice"),
2312 matchResolution(
2313 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002314 "lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002315 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002316 matchResolution(
2317 "bin/bin1.meta_lic",
2318 "lib/libc.a.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002319 "reciprocal",
2320 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002321 matchResolution(
2322 "bin/bin2.meta_lic",
2323 "bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002324 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002325 "notice"),
2326 matchResolution(
2327 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002328 "lib/libb.so.meta_lic",
2329 "restricted"),
2330 matchResolution(
2331 "highest.apex.meta_lic",
2332 "bin/bin1.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002333 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002334 "notice"),
2335 matchResolution(
2336 "highest.apex.meta_lic",
2337 "bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002338 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002339 "notice"),
2340 matchResolution(
2341 "highest.apex.meta_lic",
2342 "highest.apex.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002343 "restricted",
2344 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002345 "notice"),
Bob Badour103eb0f2022-01-10 13:50:57 -08002346 matchResolution(
2347 "highest.apex.meta_lic",
2348 "lib/liba.so.meta_lic",
2349 "restricted_allows_dynamic_linking"),
2350 matchResolution(
2351 "highest.apex.meta_lic",
2352 "lib/libb.so.meta_lic",
2353 "restricted"),
2354 matchResolution(
2355 "highest.apex.meta_lic",
2356 "lib/libc.a.meta_lic",
2357 "reciprocal",
2358 "restricted_allows_dynamic_linking"),
2359 matchResolution(
2360 "lib/liba.so.meta_lic",
2361 "lib/liba.so.meta_lic",
2362 "restricted_allows_dynamic_linking"),
2363 matchResolution(
2364 "lib/libb.so.meta_lic",
2365 "lib/libb.so.meta_lic",
2366 "restricted"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002367 },
2368 },
2369 {
2370 condition: "restricted",
2371 name: "apex_trimmed_notice",
2372 roots: []string{"highest.apex.meta_lic"},
2373 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08002374 conditions: []compliance.LicenseCondition{compliance.NoticeCondition},
Bob Badour1ded0a12021-12-03 17:16:14 -08002375 stripPrefix: "testdata/restricted/",
2376 },
2377 expectedOut: []getMatcher{
2378 matchTarget("bin/bin1.meta_lic"),
2379 matchTarget("bin/bin2.meta_lic"),
2380 matchTarget("highest.apex.meta_lic"),
2381 matchResolution(
2382 "bin/bin1.meta_lic",
2383 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002384 "notice"),
2385 matchResolution(
2386 "bin/bin2.meta_lic",
2387 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002388 "notice"),
2389 matchResolution(
2390 "highest.apex.meta_lic",
2391 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002392 "notice"),
2393 matchResolution(
2394 "highest.apex.meta_lic",
2395 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002396 "notice"),
2397 matchResolution(
2398 "highest.apex.meta_lic",
2399 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002400 "notice"),
2401 },
2402 },
2403 {
2404 condition: "restricted",
2405 name: "apex_trimmed_share",
2406 roots: []string{"highest.apex.meta_lic"},
2407 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08002408 conditions: compliance.ImpliesShared.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -08002409 stripPrefix: "testdata/restricted/",
2410 },
2411 expectedOut: []getMatcher{
2412 matchTarget("bin/bin1.meta_lic"),
2413 matchTarget("lib/liba.so.meta_lic"),
2414 matchTarget("lib/libc.a.meta_lic"),
2415 matchTarget("bin/bin2.meta_lic"),
2416 matchTarget("lib/libb.so.meta_lic"),
2417 matchTarget("highest.apex.meta_lic"),
2418 matchResolution(
2419 "bin/bin1.meta_lic",
2420 "bin/bin1.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002421 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002422 matchResolution(
2423 "bin/bin1.meta_lic",
2424 "lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002425 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002426 matchResolution(
2427 "bin/bin1.meta_lic",
2428 "lib/libc.a.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002429 "reciprocal",
2430 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002431 matchResolution(
2432 "bin/bin2.meta_lic",
2433 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002434 "restricted"),
2435 matchResolution(
2436 "bin/bin2.meta_lic",
2437 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002438 "restricted"),
2439 matchResolution(
2440 "highest.apex.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002441 "bin/bin1.meta_lic",
2442 "restricted_allows_dynamic_linking"),
2443 matchResolution(
Bob Badour1ded0a12021-12-03 17:16:14 -08002444 "highest.apex.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002445 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002446 "restricted"),
2447 matchResolution(
2448 "highest.apex.meta_lic",
2449 "highest.apex.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002450 "restricted",
2451 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002452 matchResolution(
2453 "highest.apex.meta_lic",
2454 "lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002455 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002456 matchResolution(
2457 "highest.apex.meta_lic",
2458 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002459 "restricted"),
2460 matchResolution(
2461 "highest.apex.meta_lic",
2462 "lib/libc.a.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002463 "reciprocal",
2464 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002465 matchResolution(
2466 "lib/liba.so.meta_lic",
2467 "lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002468 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002469 matchResolution(
2470 "lib/libb.so.meta_lic",
2471 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002472 "restricted"),
2473 },
2474 },
2475 {
2476 condition: "restricted",
2477 name: "apex_trimmed_private",
2478 roots: []string{"highest.apex.meta_lic"},
2479 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08002480 conditions: compliance.ImpliesPrivate.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -08002481 stripPrefix: "testdata/restricted/",
2482 },
2483 expectedOut: []getMatcher{},
2484 },
2485 {
2486 condition: "restricted",
2487 name: "apex_trimmed_share_private",
2488 roots: []string{"highest.apex.meta_lic"},
2489 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08002490 conditions: compliance.ImpliesShared.Union(compliance.ImpliesPrivate).AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -08002491 stripPrefix: "testdata/restricted/",
2492 },
2493 expectedOut: []getMatcher{
2494 matchTarget("bin/bin1.meta_lic"),
2495 matchTarget("lib/liba.so.meta_lic"),
2496 matchTarget("lib/libc.a.meta_lic"),
2497 matchTarget("bin/bin2.meta_lic"),
2498 matchTarget("lib/libb.so.meta_lic"),
2499 matchTarget("highest.apex.meta_lic"),
2500 matchResolution(
2501 "bin/bin1.meta_lic",
2502 "bin/bin1.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002503 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002504 matchResolution(
2505 "bin/bin1.meta_lic",
2506 "lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002507 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002508 matchResolution(
2509 "bin/bin1.meta_lic",
2510 "lib/libc.a.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002511 "reciprocal",
2512 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002513 matchResolution(
2514 "bin/bin2.meta_lic",
2515 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002516 "restricted"),
2517 matchResolution(
2518 "bin/bin2.meta_lic",
2519 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002520 "restricted"),
2521 matchResolution(
2522 "highest.apex.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002523 "bin/bin1.meta_lic",
2524 "restricted_allows_dynamic_linking"),
2525 matchResolution(
Bob Badour1ded0a12021-12-03 17:16:14 -08002526 "highest.apex.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002527 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002528 "restricted"),
2529 matchResolution(
2530 "highest.apex.meta_lic",
2531 "highest.apex.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002532 "restricted",
2533 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002534 matchResolution(
2535 "highest.apex.meta_lic",
2536 "lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002537 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002538 matchResolution(
2539 "highest.apex.meta_lic",
2540 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002541 "restricted"),
2542 matchResolution(
2543 "highest.apex.meta_lic",
2544 "lib/libc.a.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002545 "reciprocal",
2546 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002547 matchResolution(
2548 "lib/liba.so.meta_lic",
2549 "lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002550 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002551 matchResolution(
2552 "lib/libb.so.meta_lic",
2553 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002554 "restricted"),
2555 },
2556 },
2557 {
2558 condition: "restricted",
2559 name: "apex_trimmed_labelled",
2560 roots: []string{"highest.apex.meta_lic"},
2561 ctx: context{stripPrefix: "testdata/restricted/", labelConditions: true},
2562 expectedOut: []getMatcher{
2563 matchTarget("bin/bin1.meta_lic", "notice"),
Bob Badour103eb0f2022-01-10 13:50:57 -08002564 matchTarget("lib/liba.so.meta_lic", "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002565 matchTarget("lib/libc.a.meta_lic", "reciprocal"),
2566 matchTarget("bin/bin2.meta_lic", "notice"),
2567 matchTarget("lib/libb.so.meta_lic", "restricted"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002568 matchTarget("highest.apex.meta_lic", "notice"),
2569 matchResolution(
2570 "bin/bin1.meta_lic",
2571 "bin/bin1.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002572 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002573 "notice"),
2574 matchResolution(
2575 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002576 "lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002577 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002578 matchResolution(
2579 "bin/bin1.meta_lic",
2580 "lib/libc.a.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002581 "reciprocal",
2582 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002583 matchResolution(
2584 "bin/bin2.meta_lic",
2585 "bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002586 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002587 "notice"),
2588 matchResolution(
2589 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002590 "lib/libb.so.meta_lic",
2591 "restricted"),
2592 matchResolution(
2593 "highest.apex.meta_lic",
2594 "bin/bin1.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002595 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002596 "notice"),
2597 matchResolution(
2598 "highest.apex.meta_lic",
2599 "bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002600 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002601 "notice"),
2602 matchResolution(
2603 "highest.apex.meta_lic",
2604 "highest.apex.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002605 "restricted",
2606 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002607 "notice"),
Bob Badour103eb0f2022-01-10 13:50:57 -08002608 matchResolution(
2609 "highest.apex.meta_lic",
2610 "lib/liba.so.meta_lic",
2611 "restricted_allows_dynamic_linking"),
2612 matchResolution(
2613 "highest.apex.meta_lic",
2614 "lib/libb.so.meta_lic",
2615 "restricted"),
2616 matchResolution(
2617 "highest.apex.meta_lic",
2618 "lib/libc.a.meta_lic",
2619 "reciprocal",
2620 "restricted_allows_dynamic_linking"),
2621 matchResolution(
2622 "lib/liba.so.meta_lic",
2623 "lib/liba.so.meta_lic",
2624 "restricted_allows_dynamic_linking"),
2625 matchResolution(
2626 "lib/libb.so.meta_lic",
2627 "lib/libb.so.meta_lic",
2628 "restricted"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002629 },
2630 },
2631 {
2632 condition: "restricted",
2633 name: "container",
2634 roots: []string{"container.zip.meta_lic"},
2635 expectedOut: []getMatcher{
2636 matchTarget("testdata/restricted/bin/bin1.meta_lic"),
2637 matchTarget("testdata/restricted/lib/liba.so.meta_lic"),
2638 matchTarget("testdata/restricted/lib/libc.a.meta_lic"),
2639 matchTarget("testdata/restricted/bin/bin2.meta_lic"),
2640 matchTarget("testdata/restricted/lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002641 matchTarget("testdata/restricted/container.zip.meta_lic"),
2642 matchResolution(
2643 "testdata/restricted/bin/bin1.meta_lic",
2644 "testdata/restricted/bin/bin1.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002645 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002646 "notice"),
2647 matchResolution(
2648 "testdata/restricted/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002649 "testdata/restricted/lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002650 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002651 matchResolution(
2652 "testdata/restricted/bin/bin1.meta_lic",
2653 "testdata/restricted/lib/libc.a.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002654 "reciprocal",
2655 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002656 matchResolution(
2657 "testdata/restricted/bin/bin2.meta_lic",
2658 "testdata/restricted/bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002659 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002660 "notice"),
2661 matchResolution(
2662 "testdata/restricted/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002663 "testdata/restricted/lib/libb.so.meta_lic",
2664 "restricted"),
2665 matchResolution(
2666 "testdata/restricted/container.zip.meta_lic",
2667 "testdata/restricted/bin/bin1.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002668 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002669 "notice"),
2670 matchResolution(
2671 "testdata/restricted/container.zip.meta_lic",
2672 "testdata/restricted/bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002673 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002674 "notice"),
2675 matchResolution(
2676 "testdata/restricted/container.zip.meta_lic",
2677 "testdata/restricted/container.zip.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002678 "restricted",
2679 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002680 "notice"),
Bob Badour103eb0f2022-01-10 13:50:57 -08002681 matchResolution(
2682 "testdata/restricted/container.zip.meta_lic",
2683 "testdata/restricted/lib/liba.so.meta_lic",
2684 "restricted_allows_dynamic_linking"),
2685 matchResolution(
2686 "testdata/restricted/container.zip.meta_lic",
2687 "testdata/restricted/lib/libb.so.meta_lic",
2688 "restricted"),
2689 matchResolution(
2690 "testdata/restricted/container.zip.meta_lic",
2691 "testdata/restricted/lib/libc.a.meta_lic",
2692 "reciprocal",
2693 "restricted_allows_dynamic_linking"),
2694 matchResolution(
2695 "testdata/restricted/lib/liba.so.meta_lic",
2696 "testdata/restricted/lib/liba.so.meta_lic",
2697 "restricted_allows_dynamic_linking"),
2698 matchResolution(
2699 "testdata/restricted/lib/libb.so.meta_lic",
2700 "testdata/restricted/lib/libb.so.meta_lic",
2701 "restricted"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002702 },
2703 },
2704 {
2705 condition: "restricted",
2706 name: "application",
2707 roots: []string{"application.meta_lic"},
2708 expectedOut: []getMatcher{
2709 matchTarget("testdata/restricted/application.meta_lic"),
2710 matchTarget("testdata/restricted/lib/liba.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002711 matchResolution(
2712 "testdata/restricted/application.meta_lic",
2713 "testdata/restricted/application.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002714 "restricted",
2715 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002716 "notice"),
2717 matchResolution(
2718 "testdata/restricted/application.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002719 "testdata/restricted/lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002720 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002721 "restricted"),
2722 },
2723 },
2724 {
2725 condition: "restricted",
2726 name: "binary",
2727 roots: []string{"bin/bin1.meta_lic"},
2728 expectedOut: []getMatcher{
2729 matchTarget("testdata/restricted/bin/bin1.meta_lic"),
2730 matchTarget("testdata/restricted/lib/liba.so.meta_lic"),
2731 matchTarget("testdata/restricted/lib/libc.a.meta_lic"),
2732 matchResolution(
2733 "testdata/restricted/bin/bin1.meta_lic",
2734 "testdata/restricted/bin/bin1.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002735 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002736 "notice"),
2737 matchResolution(
2738 "testdata/restricted/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002739 "testdata/restricted/lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002740 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002741 matchResolution(
2742 "testdata/restricted/bin/bin1.meta_lic",
2743 "testdata/restricted/lib/libc.a.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002744 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002745 "reciprocal"),
2746 },
2747 },
2748 {
2749 condition: "restricted",
2750 name: "library",
2751 roots: []string{"lib/libd.so.meta_lic"},
2752 expectedOut: []getMatcher{
2753 matchTarget("testdata/restricted/lib/libd.so.meta_lic"),
2754 matchResolution(
2755 "testdata/restricted/lib/libd.so.meta_lic",
2756 "testdata/restricted/lib/libd.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002757 "notice"),
2758 },
2759 },
2760 {
2761 condition: "proprietary",
2762 name: "apex",
2763 roots: []string{"highest.apex.meta_lic"},
2764 expectedOut: []getMatcher{
2765 matchTarget("testdata/proprietary/bin/bin1.meta_lic"),
2766 matchTarget("testdata/proprietary/lib/liba.so.meta_lic"),
2767 matchTarget("testdata/proprietary/lib/libc.a.meta_lic"),
2768 matchTarget("testdata/proprietary/bin/bin2.meta_lic"),
2769 matchTarget("testdata/proprietary/lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002770 matchTarget("testdata/proprietary/highest.apex.meta_lic"),
2771 matchResolution(
2772 "testdata/proprietary/bin/bin1.meta_lic",
2773 "testdata/proprietary/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002774 "notice"),
2775 matchResolution(
2776 "testdata/proprietary/bin/bin1.meta_lic",
2777 "testdata/proprietary/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002778 "by_exception_only",
2779 "proprietary"),
2780 matchResolution(
2781 "testdata/proprietary/bin/bin1.meta_lic",
2782 "testdata/proprietary/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002783 "by_exception_only",
2784 "proprietary"),
2785 matchResolution(
2786 "testdata/proprietary/bin/bin2.meta_lic",
2787 "testdata/proprietary/bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002788 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002789 "by_exception_only",
2790 "proprietary"),
2791 matchResolution(
2792 "testdata/proprietary/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002793 "testdata/proprietary/lib/libb.so.meta_lic",
2794 "restricted"),
2795 matchResolution(
2796 "testdata/proprietary/highest.apex.meta_lic",
2797 "testdata/proprietary/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002798 "notice"),
2799 matchResolution(
2800 "testdata/proprietary/highest.apex.meta_lic",
2801 "testdata/proprietary/bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002802 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002803 "by_exception_only",
2804 "proprietary"),
2805 matchResolution(
2806 "testdata/proprietary/highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002807 "testdata/proprietary/highest.apex.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002808 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002809 "notice"),
2810 matchResolution(
2811 "testdata/proprietary/highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002812 "testdata/proprietary/lib/liba.so.meta_lic",
2813 "by_exception_only",
2814 "proprietary"),
2815 matchResolution(
2816 "testdata/proprietary/highest.apex.meta_lic",
2817 "testdata/proprietary/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002818 "restricted"),
2819 matchResolution(
2820 "testdata/proprietary/highest.apex.meta_lic",
2821 "testdata/proprietary/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002822 "by_exception_only",
2823 "proprietary"),
2824 matchResolution(
Bob Badour1ded0a12021-12-03 17:16:14 -08002825 "testdata/proprietary/lib/liba.so.meta_lic",
2826 "testdata/proprietary/lib/liba.so.meta_lic",
2827 "by_exception_only",
2828 "proprietary"),
2829 matchResolution(
2830 "testdata/proprietary/lib/libb.so.meta_lic",
2831 "testdata/proprietary/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002832 "restricted"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002833 },
2834 },
2835 {
2836 condition: "proprietary",
2837 name: "apex_trimmed",
2838 roots: []string{"highest.apex.meta_lic"},
2839 ctx: context{stripPrefix: "testdata/proprietary/"},
2840 expectedOut: []getMatcher{
2841 matchTarget("bin/bin1.meta_lic"),
2842 matchTarget("lib/liba.so.meta_lic"),
2843 matchTarget("lib/libc.a.meta_lic"),
2844 matchTarget("bin/bin2.meta_lic"),
2845 matchTarget("lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002846 matchTarget("highest.apex.meta_lic"),
2847 matchResolution(
2848 "bin/bin1.meta_lic",
2849 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002850 "notice"),
2851 matchResolution(
2852 "bin/bin1.meta_lic",
2853 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002854 "by_exception_only",
2855 "proprietary"),
2856 matchResolution(
2857 "bin/bin1.meta_lic",
2858 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002859 "by_exception_only",
2860 "proprietary"),
2861 matchResolution(
2862 "bin/bin2.meta_lic",
2863 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002864 "by_exception_only",
Bob Badour103eb0f2022-01-10 13:50:57 -08002865 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002866 "proprietary"),
2867 matchResolution(
2868 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002869 "lib/libb.so.meta_lic",
2870 "restricted"),
2871 matchResolution(
2872 "highest.apex.meta_lic",
2873 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002874 "notice"),
2875 matchResolution(
2876 "highest.apex.meta_lic",
2877 "bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002878 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002879 "by_exception_only",
2880 "proprietary"),
2881 matchResolution(
2882 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002883 "highest.apex.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002884 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002885 "notice"),
2886 matchResolution(
2887 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002888 "lib/liba.so.meta_lic",
2889 "by_exception_only",
2890 "proprietary"),
2891 matchResolution(
2892 "highest.apex.meta_lic",
2893 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002894 "restricted"),
2895 matchResolution(
2896 "highest.apex.meta_lic",
2897 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002898 "by_exception_only",
2899 "proprietary"),
2900 matchResolution(
Bob Badour1ded0a12021-12-03 17:16:14 -08002901 "lib/liba.so.meta_lic",
2902 "lib/liba.so.meta_lic",
2903 "by_exception_only",
2904 "proprietary"),
2905 matchResolution(
2906 "lib/libb.so.meta_lic",
2907 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002908 "restricted"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002909 },
2910 },
2911 {
2912 condition: "proprietary",
2913 name: "apex_trimmed_notice",
2914 roots: []string{"highest.apex.meta_lic"},
2915 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08002916 conditions: []compliance.LicenseCondition{compliance.NoticeCondition},
Bob Badour1ded0a12021-12-03 17:16:14 -08002917 stripPrefix: "testdata/proprietary/",
2918 },
2919 expectedOut: []getMatcher{
2920 matchTarget("bin/bin1.meta_lic"),
2921 matchTarget("highest.apex.meta_lic"),
2922 matchResolution(
2923 "bin/bin1.meta_lic",
2924 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002925 "notice"),
2926 matchResolution(
2927 "highest.apex.meta_lic",
2928 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002929 "notice"),
2930 matchResolution(
2931 "highest.apex.meta_lic",
2932 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002933 "notice"),
2934 },
2935 },
2936 {
2937 condition: "proprietary",
2938 name: "apex_trimmed_share",
2939 roots: []string{"highest.apex.meta_lic"},
2940 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08002941 conditions: compliance.ImpliesShared.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -08002942 stripPrefix: "testdata/proprietary/",
2943 },
2944 expectedOut: []getMatcher{
2945 matchTarget("bin/bin2.meta_lic"),
2946 matchTarget("lib/libb.so.meta_lic"),
2947 matchTarget("highest.apex.meta_lic"),
2948 matchResolution(
2949 "bin/bin2.meta_lic",
2950 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002951 "restricted"),
2952 matchResolution(
2953 "bin/bin2.meta_lic",
2954 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002955 "restricted"),
2956 matchResolution(
2957 "highest.apex.meta_lic",
2958 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002959 "restricted"),
2960 matchResolution(
2961 "highest.apex.meta_lic",
2962 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002963 "restricted"),
2964 matchResolution(
2965 "highest.apex.meta_lic",
2966 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002967 "restricted"),
2968 matchResolution(
2969 "lib/libb.so.meta_lic",
2970 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002971 "restricted"),
2972 },
2973 },
2974 {
2975 condition: "proprietary",
2976 name: "apex_trimmed_private",
2977 roots: []string{"highest.apex.meta_lic"},
2978 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08002979 conditions: compliance.ImpliesPrivate.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -08002980 stripPrefix: "testdata/proprietary/",
2981 },
2982 expectedOut: []getMatcher{
2983 matchTarget("bin/bin1.meta_lic"),
2984 matchTarget("lib/liba.so.meta_lic"),
2985 matchTarget("lib/libc.a.meta_lic"),
2986 matchTarget("bin/bin2.meta_lic"),
2987 matchTarget("highest.apex.meta_lic"),
2988 matchResolution(
2989 "bin/bin1.meta_lic",
2990 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002991 "proprietary"),
2992 matchResolution(
2993 "bin/bin1.meta_lic",
2994 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002995 "proprietary"),
2996 matchResolution(
2997 "bin/bin2.meta_lic",
2998 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002999 "proprietary"),
3000 matchResolution(
3001 "highest.apex.meta_lic",
3002 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003003 "proprietary"),
3004 matchResolution(
3005 "highest.apex.meta_lic",
3006 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003007 "proprietary"),
3008 matchResolution(
3009 "highest.apex.meta_lic",
3010 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003011 "proprietary"),
3012 matchResolution(
3013 "lib/liba.so.meta_lic",
3014 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003015 "proprietary"),
3016 },
3017 },
3018 {
3019 condition: "proprietary",
3020 name: "apex_trimmed_share_private",
3021 roots: []string{"highest.apex.meta_lic"},
3022 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08003023 conditions: compliance.ImpliesShared.Union(compliance.ImpliesPrivate).AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -08003024 stripPrefix: "testdata/proprietary/",
3025 },
3026 expectedOut: []getMatcher{
3027 matchTarget("bin/bin1.meta_lic"),
3028 matchTarget("lib/liba.so.meta_lic"),
3029 matchTarget("lib/libc.a.meta_lic"),
3030 matchTarget("bin/bin2.meta_lic"),
3031 matchTarget("lib/libb.so.meta_lic"),
3032 matchTarget("highest.apex.meta_lic"),
3033 matchResolution(
3034 "bin/bin1.meta_lic",
3035 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003036 "proprietary"),
3037 matchResolution(
3038 "bin/bin1.meta_lic",
3039 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003040 "proprietary"),
3041 matchResolution(
3042 "bin/bin2.meta_lic",
3043 "bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08003044 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08003045 "proprietary"),
3046 matchResolution(
3047 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003048 "lib/libb.so.meta_lic",
3049 "restricted"),
3050 matchResolution(
3051 "highest.apex.meta_lic",
3052 "bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08003053 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08003054 "proprietary"),
3055 matchResolution(
3056 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003057 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003058 "restricted"),
3059 matchResolution(
3060 "highest.apex.meta_lic",
3061 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003062 "proprietary"),
3063 matchResolution(
3064 "highest.apex.meta_lic",
3065 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003066 "restricted"),
3067 matchResolution(
3068 "highest.apex.meta_lic",
3069 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003070 "proprietary"),
3071 matchResolution(
3072 "lib/liba.so.meta_lic",
3073 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003074 "proprietary"),
3075 matchResolution(
3076 "lib/libb.so.meta_lic",
3077 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003078 "restricted"),
3079 },
3080 },
3081 {
3082 condition: "proprietary",
3083 name: "apex_trimmed_labelled",
3084 roots: []string{"highest.apex.meta_lic"},
3085 ctx: context{stripPrefix: "testdata/proprietary/", labelConditions: true},
3086 expectedOut: []getMatcher{
3087 matchTarget("bin/bin1.meta_lic", "notice"),
3088 matchTarget("lib/liba.so.meta_lic", "by_exception_only", "proprietary"),
3089 matchTarget("lib/libc.a.meta_lic", "by_exception_only", "proprietary"),
3090 matchTarget("bin/bin2.meta_lic", "by_exception_only", "proprietary"),
3091 matchTarget("lib/libb.so.meta_lic", "restricted"),
Bob Badour1ded0a12021-12-03 17:16:14 -08003092 matchTarget("highest.apex.meta_lic", "notice"),
3093 matchResolution(
3094 "bin/bin1.meta_lic",
3095 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003096 "notice"),
3097 matchResolution(
3098 "bin/bin1.meta_lic",
3099 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003100 "by_exception_only",
3101 "proprietary"),
3102 matchResolution(
3103 "bin/bin1.meta_lic",
3104 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003105 "by_exception_only",
3106 "proprietary"),
3107 matchResolution(
3108 "bin/bin2.meta_lic",
3109 "bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08003110 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08003111 "by_exception_only",
3112 "proprietary"),
3113 matchResolution(
3114 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003115 "lib/libb.so.meta_lic",
3116 "restricted"),
3117 matchResolution(
3118 "highest.apex.meta_lic",
3119 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003120 "notice"),
3121 matchResolution(
3122 "highest.apex.meta_lic",
3123 "bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08003124 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08003125 "by_exception_only",
3126 "proprietary"),
3127 matchResolution(
3128 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003129 "highest.apex.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08003130 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08003131 "notice"),
3132 matchResolution(
3133 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003134 "lib/liba.so.meta_lic",
3135 "by_exception_only",
3136 "proprietary"),
3137 matchResolution(
3138 "highest.apex.meta_lic",
3139 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003140 "restricted"),
3141 matchResolution(
3142 "highest.apex.meta_lic",
3143 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003144 "by_exception_only",
3145 "proprietary"),
3146 matchResolution(
Bob Badour1ded0a12021-12-03 17:16:14 -08003147 "lib/liba.so.meta_lic",
3148 "lib/liba.so.meta_lic",
3149 "by_exception_only",
3150 "proprietary"),
3151 matchResolution(
3152 "lib/libb.so.meta_lic",
3153 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003154 "restricted"),
Bob Badour1ded0a12021-12-03 17:16:14 -08003155 },
3156 },
3157 {
3158 condition: "proprietary",
3159 name: "container",
3160 roots: []string{"container.zip.meta_lic"},
3161 expectedOut: []getMatcher{
3162 matchTarget("testdata/proprietary/bin/bin1.meta_lic"),
3163 matchTarget("testdata/proprietary/lib/liba.so.meta_lic"),
3164 matchTarget("testdata/proprietary/lib/libc.a.meta_lic"),
3165 matchTarget("testdata/proprietary/bin/bin2.meta_lic"),
3166 matchTarget("testdata/proprietary/lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08003167 matchTarget("testdata/proprietary/container.zip.meta_lic"),
3168 matchResolution(
3169 "testdata/proprietary/bin/bin1.meta_lic",
3170 "testdata/proprietary/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003171 "notice"),
3172 matchResolution(
3173 "testdata/proprietary/bin/bin1.meta_lic",
3174 "testdata/proprietary/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003175 "by_exception_only",
3176 "proprietary"),
3177 matchResolution(
3178 "testdata/proprietary/bin/bin1.meta_lic",
3179 "testdata/proprietary/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003180 "by_exception_only",
3181 "proprietary"),
3182 matchResolution(
3183 "testdata/proprietary/bin/bin2.meta_lic",
3184 "testdata/proprietary/bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08003185 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08003186 "by_exception_only",
3187 "proprietary"),
3188 matchResolution(
3189 "testdata/proprietary/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003190 "testdata/proprietary/lib/libb.so.meta_lic",
3191 "restricted"),
3192 matchResolution(
3193 "testdata/proprietary/container.zip.meta_lic",
3194 "testdata/proprietary/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003195 "notice"),
3196 matchResolution(
3197 "testdata/proprietary/container.zip.meta_lic",
3198 "testdata/proprietary/bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08003199 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08003200 "by_exception_only",
3201 "proprietary"),
3202 matchResolution(
3203 "testdata/proprietary/container.zip.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003204 "testdata/proprietary/container.zip.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08003205 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08003206 "notice"),
3207 matchResolution(
3208 "testdata/proprietary/container.zip.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003209 "testdata/proprietary/lib/liba.so.meta_lic",
3210 "by_exception_only",
3211 "proprietary"),
3212 matchResolution(
3213 "testdata/proprietary/container.zip.meta_lic",
3214 "testdata/proprietary/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003215 "restricted"),
3216 matchResolution(
3217 "testdata/proprietary/container.zip.meta_lic",
3218 "testdata/proprietary/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003219 "by_exception_only",
3220 "proprietary"),
3221 matchResolution(
Bob Badour1ded0a12021-12-03 17:16:14 -08003222 "testdata/proprietary/lib/liba.so.meta_lic",
3223 "testdata/proprietary/lib/liba.so.meta_lic",
3224 "by_exception_only",
3225 "proprietary"),
3226 matchResolution(
3227 "testdata/proprietary/lib/libb.so.meta_lic",
3228 "testdata/proprietary/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003229 "restricted"),
Bob Badour1ded0a12021-12-03 17:16:14 -08003230 },
3231 },
3232 {
3233 condition: "proprietary",
3234 name: "application",
3235 roots: []string{"application.meta_lic"},
3236 expectedOut: []getMatcher{
3237 matchTarget("testdata/proprietary/application.meta_lic"),
3238 matchTarget("testdata/proprietary/lib/liba.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08003239 matchResolution(
3240 "testdata/proprietary/application.meta_lic",
3241 "testdata/proprietary/application.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08003242 "notice",
Bob Badour1ded0a12021-12-03 17:16:14 -08003243 "restricted"),
3244 matchResolution(
3245 "testdata/proprietary/application.meta_lic",
3246 "testdata/proprietary/lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08003247 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08003248 "by_exception_only",
3249 "proprietary"),
Bob Badour1ded0a12021-12-03 17:16:14 -08003250 },
3251 },
3252 {
3253 condition: "proprietary",
3254 name: "binary",
3255 roots: []string{"bin/bin1.meta_lic"},
3256 expectedOut: []getMatcher{
3257 matchTarget("testdata/proprietary/bin/bin1.meta_lic"),
3258 matchTarget("testdata/proprietary/lib/liba.so.meta_lic"),
3259 matchTarget("testdata/proprietary/lib/libc.a.meta_lic"),
3260 matchResolution(
3261 "testdata/proprietary/bin/bin1.meta_lic",
3262 "testdata/proprietary/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003263 "notice"),
3264 matchResolution(
3265 "testdata/proprietary/bin/bin1.meta_lic",
3266 "testdata/proprietary/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003267 "by_exception_only",
3268 "proprietary"),
3269 matchResolution(
3270 "testdata/proprietary/bin/bin1.meta_lic",
3271 "testdata/proprietary/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003272 "by_exception_only",
3273 "proprietary"),
3274 },
3275 },
3276 {
3277 condition: "proprietary",
3278 name: "library",
3279 roots: []string{"lib/libd.so.meta_lic"},
3280 expectedOut: []getMatcher{
3281 matchTarget("testdata/proprietary/lib/libd.so.meta_lic"),
3282 matchResolution(
3283 "testdata/proprietary/lib/libd.so.meta_lic",
3284 "testdata/proprietary/lib/libd.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003285 "notice"),
3286 },
3287 },
3288 }
3289 for _, tt := range tests {
3290 t.Run(tt.condition+" "+tt.name, func(t *testing.T) {
3291 ctx := &testContext{0, make(map[string]string)}
3292
Bob Badour1ded0a12021-12-03 17:16:14 -08003293 stdout := &bytes.Buffer{}
3294 stderr := &bytes.Buffer{}
3295
3296 rootFiles := make([]string, 0, len(tt.roots))
3297 for _, r := range tt.roots {
3298 rootFiles = append(rootFiles, "testdata/"+tt.condition+"/"+r)
3299 }
3300 tt.ctx.graphViz = true
Bob Badour103eb0f2022-01-10 13:50:57 -08003301 lg, err := dumpResolutions(&tt.ctx, stdout, stderr, rootFiles...)
Bob Badour1ded0a12021-12-03 17:16:14 -08003302 if err != nil {
3303 t.Fatalf("dumpresolutions: error = %v, stderr = %v", err, stderr)
3304 return
3305 }
3306 if stderr.Len() > 0 {
3307 t.Errorf("dumpresolutions: gotStderr = %v, want none", stderr)
3308 }
Bob Badour103eb0f2022-01-10 13:50:57 -08003309
3310 expectedOut := &bytes.Buffer{}
3311 for _, eo := range tt.expectedOut {
3312 m := eo(ctx)
3313 expectedOut.WriteString(m.matchString(ctx, lg))
3314 expectedOut.WriteString("\n")
3315 }
3316
Bob Badour1ded0a12021-12-03 17:16:14 -08003317 outList := strings.Split(stdout.String(), "\n")
3318 outLine := 0
3319 if outList[outLine] != "strict digraph {" {
Colin Cross179ec3e2022-01-27 15:47:09 -08003320 t.Errorf("dumpresolutions: got 1st line %v, want strict digraph {", outList[outLine])
Bob Badour1ded0a12021-12-03 17:16:14 -08003321 }
3322 outLine++
3323 if strings.HasPrefix(strings.TrimLeft(outList[outLine], " \t"), "rankdir") {
3324 outLine++
3325 }
3326 endOut := len(outList)
3327 for endOut > 0 && strings.TrimLeft(outList[endOut-1], " \t") == "" {
3328 endOut--
3329 }
3330 if outList[endOut-1] != "}" {
3331 t.Errorf("dumpresolutions: got last line %v, want }", outList[endOut-1])
3332 }
3333 endOut--
3334 if strings.HasPrefix(strings.TrimLeft(outList[endOut-1], " \t"), "{rank=same") {
3335 endOut--
3336 }
3337 expectedList := strings.Split(expectedOut.String(), "\n")
3338 for len(expectedList) > 0 && expectedList[len(expectedList)-1] == "" {
3339 expectedList = expectedList[0 : len(expectedList)-1]
3340 }
3341 matchLine := 0
3342
3343 for outLine < endOut && matchLine < len(expectedList) && strings.TrimLeft(outList[outLine], " \t") == expectedList[matchLine] {
3344 outLine++
3345 matchLine++
3346 }
3347 if outLine < endOut || matchLine < len(expectedList) {
3348 if outLine >= endOut {
3349 t.Errorf("dumpresolutions: missing lines at end of graph, want %d lines %v", len(expectedList)-matchLine, strings.Join(expectedList[matchLine:], "\n"))
3350 } else if matchLine >= len(expectedList) {
3351 t.Errorf("dumpresolutions: unexpected lines at end of graph starting line %d, got %v, want nothing", outLine+1, strings.Join(outList[outLine:], "\n"))
3352 } else {
3353 t.Errorf("dumpresolutions: at line %d, got %v, want %v", outLine+1, strings.Join(outList[outLine:], "\n"), strings.Join(expectedList[matchLine:], "\n"))
3354 }
3355 }
3356 })
3357 }
3358}