blob: a3a298e9889064d9f2e8cecf2461bdfbad251ca9 [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"
Bob Badour103eb0f2022-01-10 13:50:57 -080019 "compliance"
Bob Badour1ded0a12021-12-03 17:16:14 -080020 "fmt"
21 "strings"
22 "testing"
23)
24
25func Test_plaintext(t *testing.T) {
26 tests := []struct {
27 condition string
28 name string
29 roots []string
30 ctx context
31 expectedOut []string
32 }{
33 {
34 condition: "firstparty",
35 name: "apex",
36 roots: []string{"highest.apex.meta_lic"},
37 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -080038 "testdata/firstparty/bin/bin1.meta_lic testdata/firstparty/bin/bin1.meta_lic notice",
39 "testdata/firstparty/bin/bin1.meta_lic testdata/firstparty/lib/liba.so.meta_lic notice",
40 "testdata/firstparty/bin/bin1.meta_lic testdata/firstparty/lib/libc.a.meta_lic notice",
41 "testdata/firstparty/bin/bin2.meta_lic testdata/firstparty/bin/bin2.meta_lic notice",
42 "testdata/firstparty/highest.apex.meta_lic testdata/firstparty/bin/bin1.meta_lic notice",
43 "testdata/firstparty/highest.apex.meta_lic testdata/firstparty/bin/bin2.meta_lic notice",
44 "testdata/firstparty/highest.apex.meta_lic testdata/firstparty/highest.apex.meta_lic notice",
45 "testdata/firstparty/highest.apex.meta_lic testdata/firstparty/lib/liba.so.meta_lic notice",
46 "testdata/firstparty/highest.apex.meta_lic testdata/firstparty/lib/libb.so.meta_lic notice",
47 "testdata/firstparty/highest.apex.meta_lic testdata/firstparty/lib/libc.a.meta_lic notice",
48 "testdata/firstparty/lib/liba.so.meta_lic testdata/firstparty/lib/liba.so.meta_lic notice",
49 "testdata/firstparty/lib/libb.so.meta_lic testdata/firstparty/lib/libb.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -080050 },
51 },
52 {
53 condition: "firstparty",
54 name: "apex_trimmed",
55 roots: []string{"highest.apex.meta_lic"},
56 ctx: context{stripPrefix: "testdata/firstparty/"},
57 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -080058 "bin/bin1.meta_lic bin/bin1.meta_lic notice",
59 "bin/bin1.meta_lic lib/liba.so.meta_lic notice",
60 "bin/bin1.meta_lic lib/libc.a.meta_lic notice",
61 "bin/bin2.meta_lic bin/bin2.meta_lic notice",
62 "highest.apex.meta_lic bin/bin1.meta_lic notice",
63 "highest.apex.meta_lic bin/bin2.meta_lic notice",
64 "highest.apex.meta_lic highest.apex.meta_lic notice",
65 "highest.apex.meta_lic lib/liba.so.meta_lic notice",
66 "highest.apex.meta_lic lib/libb.so.meta_lic notice",
67 "highest.apex.meta_lic lib/libc.a.meta_lic notice",
68 "lib/liba.so.meta_lic lib/liba.so.meta_lic notice",
69 "lib/libb.so.meta_lic lib/libb.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -080070 },
71 },
72 {
73 condition: "firstparty",
74 name: "apex_trimmed_notice",
75 roots: []string{"highest.apex.meta_lic"},
76 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -080077 conditions: []compliance.LicenseCondition{compliance.NoticeCondition},
Bob Badour1ded0a12021-12-03 17:16:14 -080078 stripPrefix: "testdata/firstparty/",
79 },
80 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -080081 "bin/bin1.meta_lic bin/bin1.meta_lic notice",
82 "bin/bin1.meta_lic lib/liba.so.meta_lic notice",
83 "bin/bin1.meta_lic lib/libc.a.meta_lic notice",
84 "bin/bin2.meta_lic bin/bin2.meta_lic notice",
85 "highest.apex.meta_lic bin/bin1.meta_lic notice",
86 "highest.apex.meta_lic bin/bin2.meta_lic notice",
87 "highest.apex.meta_lic highest.apex.meta_lic notice",
88 "highest.apex.meta_lic lib/liba.so.meta_lic notice",
89 "highest.apex.meta_lic lib/libb.so.meta_lic notice",
90 "highest.apex.meta_lic lib/libc.a.meta_lic notice",
91 "lib/liba.so.meta_lic lib/liba.so.meta_lic notice",
92 "lib/libb.so.meta_lic lib/libb.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -080093 },
94 },
95 {
96 condition: "firstparty",
97 name: "apex_trimmed_share",
98 roots: []string{"highest.apex.meta_lic"},
99 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800100 conditions: compliance.ImpliesShared.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -0800101 stripPrefix: "testdata/firstparty/",
102 },
103 expectedOut: []string{},
104 },
105 {
106 condition: "firstparty",
107 name: "apex_trimmed_private",
108 roots: []string{"highest.apex.meta_lic"},
109 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800110 conditions: compliance.ImpliesPrivate.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -0800111 stripPrefix: "testdata/firstparty/",
112 },
113 expectedOut: []string{},
114 },
115 {
116 condition: "firstparty",
117 name: "apex_trimmed_share_private",
118 roots: []string{"highest.apex.meta_lic"},
119 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800120 conditions: append(compliance.ImpliesPrivate.AsList(), compliance.ImpliesShared.AsList()...),
Bob Badour1ded0a12021-12-03 17:16:14 -0800121 stripPrefix: "testdata/firstparty/",
122 },
123 expectedOut: []string{},
124 },
125 {
126 condition: "firstparty",
127 name: "apex_trimmed_labelled",
128 roots: []string{"highest.apex.meta_lic"},
129 ctx: context{stripPrefix: "testdata/firstparty/", labelConditions: true},
130 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800131 "bin/bin1.meta_lic:notice bin/bin1.meta_lic:notice notice",
132 "bin/bin1.meta_lic:notice lib/liba.so.meta_lic:notice notice",
133 "bin/bin1.meta_lic:notice lib/libc.a.meta_lic:notice notice",
134 "bin/bin2.meta_lic:notice bin/bin2.meta_lic:notice notice",
135 "highest.apex.meta_lic:notice bin/bin1.meta_lic:notice notice",
136 "highest.apex.meta_lic:notice bin/bin2.meta_lic:notice notice",
137 "highest.apex.meta_lic:notice highest.apex.meta_lic:notice notice",
138 "highest.apex.meta_lic:notice lib/liba.so.meta_lic:notice notice",
139 "highest.apex.meta_lic:notice lib/libb.so.meta_lic:notice notice",
140 "highest.apex.meta_lic:notice lib/libc.a.meta_lic:notice notice",
141 "lib/liba.so.meta_lic:notice lib/liba.so.meta_lic:notice notice",
142 "lib/libb.so.meta_lic:notice lib/libb.so.meta_lic:notice notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800143 },
144 },
145 {
146 condition: "firstparty",
147 name: "container",
148 roots: []string{"container.zip.meta_lic"},
149 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800150 "testdata/firstparty/bin/bin1.meta_lic testdata/firstparty/bin/bin1.meta_lic notice",
151 "testdata/firstparty/bin/bin1.meta_lic testdata/firstparty/lib/liba.so.meta_lic notice",
152 "testdata/firstparty/bin/bin1.meta_lic testdata/firstparty/lib/libc.a.meta_lic notice",
153 "testdata/firstparty/bin/bin2.meta_lic testdata/firstparty/bin/bin2.meta_lic notice",
154 "testdata/firstparty/container.zip.meta_lic testdata/firstparty/bin/bin1.meta_lic notice",
155 "testdata/firstparty/container.zip.meta_lic testdata/firstparty/bin/bin2.meta_lic notice",
156 "testdata/firstparty/container.zip.meta_lic testdata/firstparty/container.zip.meta_lic notice",
157 "testdata/firstparty/container.zip.meta_lic testdata/firstparty/lib/liba.so.meta_lic notice",
158 "testdata/firstparty/container.zip.meta_lic testdata/firstparty/lib/libb.so.meta_lic notice",
159 "testdata/firstparty/container.zip.meta_lic testdata/firstparty/lib/libc.a.meta_lic notice",
160 "testdata/firstparty/lib/liba.so.meta_lic testdata/firstparty/lib/liba.so.meta_lic notice",
161 "testdata/firstparty/lib/libb.so.meta_lic testdata/firstparty/lib/libb.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800162 },
163 },
164 {
165 condition: "firstparty",
166 name: "application",
167 roots: []string{"application.meta_lic"},
168 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800169 "testdata/firstparty/application.meta_lic testdata/firstparty/application.meta_lic notice",
170 "testdata/firstparty/application.meta_lic testdata/firstparty/lib/liba.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800171 },
172 },
173 {
174 condition: "firstparty",
175 name: "binary",
176 roots: []string{"bin/bin1.meta_lic"},
177 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800178 "testdata/firstparty/bin/bin1.meta_lic testdata/firstparty/bin/bin1.meta_lic notice",
179 "testdata/firstparty/bin/bin1.meta_lic testdata/firstparty/lib/liba.so.meta_lic notice",
180 "testdata/firstparty/bin/bin1.meta_lic testdata/firstparty/lib/libc.a.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800181 },
182 },
183 {
184 condition: "firstparty",
185 name: "library",
186 roots: []string{"lib/libd.so.meta_lic"},
187 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800188 "testdata/firstparty/lib/libd.so.meta_lic testdata/firstparty/lib/libd.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800189 },
190 },
191 {
192 condition: "notice",
193 name: "apex",
194 roots: []string{"highest.apex.meta_lic"},
195 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800196 "testdata/notice/bin/bin1.meta_lic testdata/notice/bin/bin1.meta_lic notice",
197 "testdata/notice/bin/bin1.meta_lic testdata/notice/lib/liba.so.meta_lic notice",
198 "testdata/notice/bin/bin1.meta_lic testdata/notice/lib/libc.a.meta_lic notice",
199 "testdata/notice/bin/bin2.meta_lic testdata/notice/bin/bin2.meta_lic notice",
200 "testdata/notice/highest.apex.meta_lic testdata/notice/bin/bin1.meta_lic notice",
201 "testdata/notice/highest.apex.meta_lic testdata/notice/bin/bin2.meta_lic notice",
202 "testdata/notice/highest.apex.meta_lic testdata/notice/highest.apex.meta_lic notice",
203 "testdata/notice/highest.apex.meta_lic testdata/notice/lib/liba.so.meta_lic notice",
204 "testdata/notice/highest.apex.meta_lic testdata/notice/lib/libb.so.meta_lic notice",
205 "testdata/notice/highest.apex.meta_lic testdata/notice/lib/libc.a.meta_lic notice",
206 "testdata/notice/lib/liba.so.meta_lic testdata/notice/lib/liba.so.meta_lic notice",
207 "testdata/notice/lib/libb.so.meta_lic testdata/notice/lib/libb.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800208 },
209 },
210 {
211 condition: "notice",
212 name: "apex_trimmed",
213 roots: []string{"highest.apex.meta_lic"},
214 ctx: context{stripPrefix: "testdata/notice/"},
215 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800216 "bin/bin1.meta_lic bin/bin1.meta_lic notice",
217 "bin/bin1.meta_lic lib/liba.so.meta_lic notice",
218 "bin/bin1.meta_lic lib/libc.a.meta_lic notice",
219 "bin/bin2.meta_lic bin/bin2.meta_lic notice",
220 "highest.apex.meta_lic bin/bin1.meta_lic notice",
221 "highest.apex.meta_lic bin/bin2.meta_lic notice",
222 "highest.apex.meta_lic highest.apex.meta_lic notice",
223 "highest.apex.meta_lic lib/liba.so.meta_lic notice",
224 "highest.apex.meta_lic lib/libb.so.meta_lic notice",
225 "highest.apex.meta_lic lib/libc.a.meta_lic notice",
226 "lib/liba.so.meta_lic lib/liba.so.meta_lic notice",
227 "lib/libb.so.meta_lic lib/libb.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800228 },
229 },
230 {
231 condition: "notice",
232 name: "apex_trimmed_notice",
233 roots: []string{"highest.apex.meta_lic"},
234 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -0800235 conditions: []compliance.LicenseCondition{compliance.NoticeCondition},
Bob Badour1ded0a12021-12-03 17:16:14 -0800236 stripPrefix: "testdata/notice/",
237 },
238 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800239 "bin/bin1.meta_lic bin/bin1.meta_lic notice",
240 "bin/bin1.meta_lic lib/liba.so.meta_lic notice",
241 "bin/bin1.meta_lic lib/libc.a.meta_lic notice",
242 "bin/bin2.meta_lic bin/bin2.meta_lic notice",
243 "highest.apex.meta_lic bin/bin1.meta_lic notice",
244 "highest.apex.meta_lic bin/bin2.meta_lic notice",
245 "highest.apex.meta_lic highest.apex.meta_lic notice",
246 "highest.apex.meta_lic lib/liba.so.meta_lic notice",
247 "highest.apex.meta_lic lib/libb.so.meta_lic notice",
248 "highest.apex.meta_lic lib/libc.a.meta_lic notice",
249 "lib/liba.so.meta_lic lib/liba.so.meta_lic notice",
250 "lib/libb.so.meta_lic lib/libb.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800251 },
252 },
253 {
254 condition: "notice",
255 name: "apex_trimmed_share",
256 roots: []string{"highest.apex.meta_lic"},
257 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800258 conditions: compliance.ImpliesShared.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -0800259 stripPrefix: "testdata/notice/",
260 },
261 expectedOut: []string{},
262 },
263 {
264 condition: "notice",
265 name: "apex_trimmed_private",
266 roots: []string{"highest.apex.meta_lic"},
267 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800268 conditions: compliance.ImpliesPrivate.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -0800269 stripPrefix: "testdata/notice/",
270 },
271 expectedOut: []string{},
272 },
273 {
274 condition: "notice",
275 name: "apex_trimmed_share_private",
276 roots: []string{"highest.apex.meta_lic"},
277 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800278 conditions: append(compliance.ImpliesShared.AsList(), compliance.ImpliesPrivate.AsList()...),
Bob Badour1ded0a12021-12-03 17:16:14 -0800279 stripPrefix: "testdata/notice/",
280 },
281 expectedOut: []string{},
282 },
283 {
284 condition: "notice",
285 name: "apex_trimmed_labelled",
286 roots: []string{"highest.apex.meta_lic"},
287 ctx: context{stripPrefix: "testdata/notice/", labelConditions: true},
288 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800289 "bin/bin1.meta_lic:notice bin/bin1.meta_lic:notice notice",
290 "bin/bin1.meta_lic:notice lib/liba.so.meta_lic:notice notice",
291 "bin/bin1.meta_lic:notice lib/libc.a.meta_lic:notice notice",
292 "bin/bin2.meta_lic:notice bin/bin2.meta_lic:notice notice",
293 "highest.apex.meta_lic:notice bin/bin1.meta_lic:notice notice",
294 "highest.apex.meta_lic:notice bin/bin2.meta_lic:notice notice",
295 "highest.apex.meta_lic:notice highest.apex.meta_lic:notice notice",
296 "highest.apex.meta_lic:notice lib/liba.so.meta_lic:notice notice",
297 "highest.apex.meta_lic:notice lib/libb.so.meta_lic:notice notice",
298 "highest.apex.meta_lic:notice lib/libc.a.meta_lic:notice notice",
299 "lib/liba.so.meta_lic:notice lib/liba.so.meta_lic:notice notice",
300 "lib/libb.so.meta_lic:notice lib/libb.so.meta_lic:notice notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800301 },
302 },
303 {
304 condition: "notice",
305 name: "container",
306 roots: []string{"container.zip.meta_lic"},
307 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800308 "testdata/notice/bin/bin1.meta_lic testdata/notice/bin/bin1.meta_lic notice",
309 "testdata/notice/bin/bin1.meta_lic testdata/notice/lib/liba.so.meta_lic notice",
310 "testdata/notice/bin/bin1.meta_lic testdata/notice/lib/libc.a.meta_lic notice",
311 "testdata/notice/bin/bin2.meta_lic testdata/notice/bin/bin2.meta_lic notice",
312 "testdata/notice/container.zip.meta_lic testdata/notice/bin/bin1.meta_lic notice",
313 "testdata/notice/container.zip.meta_lic testdata/notice/bin/bin2.meta_lic notice",
314 "testdata/notice/container.zip.meta_lic testdata/notice/container.zip.meta_lic notice",
315 "testdata/notice/container.zip.meta_lic testdata/notice/lib/liba.so.meta_lic notice",
316 "testdata/notice/container.zip.meta_lic testdata/notice/lib/libb.so.meta_lic notice",
317 "testdata/notice/container.zip.meta_lic testdata/notice/lib/libc.a.meta_lic notice",
318 "testdata/notice/lib/liba.so.meta_lic testdata/notice/lib/liba.so.meta_lic notice",
319 "testdata/notice/lib/libb.so.meta_lic testdata/notice/lib/libb.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800320 },
321 },
322 {
323 condition: "notice",
324 name: "application",
325 roots: []string{"application.meta_lic"},
326 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800327 "testdata/notice/application.meta_lic testdata/notice/application.meta_lic notice",
328 "testdata/notice/application.meta_lic testdata/notice/lib/liba.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800329 },
330 },
331 {
332 condition: "notice",
333 name: "binary",
334 roots: []string{"bin/bin1.meta_lic"},
335 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800336 "testdata/notice/bin/bin1.meta_lic testdata/notice/bin/bin1.meta_lic notice",
337 "testdata/notice/bin/bin1.meta_lic testdata/notice/lib/liba.so.meta_lic notice",
338 "testdata/notice/bin/bin1.meta_lic testdata/notice/lib/libc.a.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800339 },
340 },
341 {
342 condition: "notice",
343 name: "library",
344 roots: []string{"lib/libd.so.meta_lic"},
345 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800346 "testdata/notice/lib/libd.so.meta_lic testdata/notice/lib/libd.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800347 },
348 },
349 {
350 condition: "reciprocal",
351 name: "apex",
352 roots: []string{"highest.apex.meta_lic"},
353 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800354 "testdata/reciprocal/bin/bin1.meta_lic testdata/reciprocal/bin/bin1.meta_lic notice",
355 "testdata/reciprocal/bin/bin1.meta_lic testdata/reciprocal/lib/liba.so.meta_lic reciprocal",
356 "testdata/reciprocal/bin/bin1.meta_lic testdata/reciprocal/lib/libc.a.meta_lic reciprocal",
357 "testdata/reciprocal/bin/bin2.meta_lic testdata/reciprocal/bin/bin2.meta_lic notice",
358 "testdata/reciprocal/highest.apex.meta_lic testdata/reciprocal/bin/bin1.meta_lic notice",
359 "testdata/reciprocal/highest.apex.meta_lic testdata/reciprocal/bin/bin2.meta_lic notice",
360 "testdata/reciprocal/highest.apex.meta_lic testdata/reciprocal/highest.apex.meta_lic notice",
361 "testdata/reciprocal/highest.apex.meta_lic testdata/reciprocal/lib/liba.so.meta_lic reciprocal",
362 "testdata/reciprocal/highest.apex.meta_lic testdata/reciprocal/lib/libb.so.meta_lic notice",
363 "testdata/reciprocal/highest.apex.meta_lic testdata/reciprocal/lib/libc.a.meta_lic reciprocal",
364 "testdata/reciprocal/lib/liba.so.meta_lic testdata/reciprocal/lib/liba.so.meta_lic reciprocal",
365 "testdata/reciprocal/lib/libb.so.meta_lic testdata/reciprocal/lib/libb.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800366 },
367 },
368 {
369 condition: "reciprocal",
370 name: "apex_trimmed",
371 roots: []string{"highest.apex.meta_lic"},
372 ctx: context{stripPrefix: "testdata/reciprocal/"},
373 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800374 "bin/bin1.meta_lic bin/bin1.meta_lic notice",
375 "bin/bin1.meta_lic lib/liba.so.meta_lic reciprocal",
376 "bin/bin1.meta_lic lib/libc.a.meta_lic reciprocal",
377 "bin/bin2.meta_lic bin/bin2.meta_lic notice",
378 "highest.apex.meta_lic bin/bin1.meta_lic notice",
379 "highest.apex.meta_lic bin/bin2.meta_lic notice",
380 "highest.apex.meta_lic highest.apex.meta_lic notice",
381 "highest.apex.meta_lic lib/liba.so.meta_lic reciprocal",
382 "highest.apex.meta_lic lib/libb.so.meta_lic notice",
383 "highest.apex.meta_lic lib/libc.a.meta_lic reciprocal",
384 "lib/liba.so.meta_lic lib/liba.so.meta_lic reciprocal",
385 "lib/libb.so.meta_lic lib/libb.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800386 },
387 },
388 {
389 condition: "reciprocal",
390 name: "apex_trimmed_notice",
391 roots: []string{"highest.apex.meta_lic"},
392 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -0800393 conditions: []compliance.LicenseCondition{compliance.NoticeCondition},
Bob Badour1ded0a12021-12-03 17:16:14 -0800394 stripPrefix: "testdata/reciprocal/",
395 },
396 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800397 "bin/bin1.meta_lic bin/bin1.meta_lic notice",
398 "bin/bin2.meta_lic bin/bin2.meta_lic notice",
399 "highest.apex.meta_lic bin/bin1.meta_lic notice",
400 "highest.apex.meta_lic bin/bin2.meta_lic notice",
401 "highest.apex.meta_lic highest.apex.meta_lic notice",
402 "highest.apex.meta_lic lib/libb.so.meta_lic notice",
403 "lib/libb.so.meta_lic lib/libb.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800404 },
405 },
406 {
407 condition: "reciprocal",
408 name: "apex_trimmed_share",
409 roots: []string{"highest.apex.meta_lic"},
410 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800411 conditions: compliance.ImpliesShared.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -0800412 stripPrefix: "testdata/reciprocal/",
413 },
414 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800415 "bin/bin1.meta_lic lib/liba.so.meta_lic reciprocal",
416 "bin/bin1.meta_lic lib/libc.a.meta_lic reciprocal",
417 "highest.apex.meta_lic lib/liba.so.meta_lic reciprocal",
418 "highest.apex.meta_lic lib/libc.a.meta_lic reciprocal",
419 "lib/liba.so.meta_lic lib/liba.so.meta_lic reciprocal",
Bob Badour1ded0a12021-12-03 17:16:14 -0800420 },
421 },
422 {
423 condition: "reciprocal",
424 name: "apex_trimmed_private",
425 roots: []string{"highest.apex.meta_lic"},
426 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800427 conditions: compliance.ImpliesPrivate.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -0800428 stripPrefix: "testdata/reciprocal/",
429 },
430 expectedOut: []string{},
431 },
432 {
433 condition: "reciprocal",
434 name: "apex_trimmed_share_private",
435 roots: []string{"highest.apex.meta_lic"},
436 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800437 conditions: append(compliance.ImpliesShared.AsList(), compliance.ImpliesPrivate.AsList()...),
Bob Badour1ded0a12021-12-03 17:16:14 -0800438 stripPrefix: "testdata/reciprocal/",
439 },
440 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800441 "bin/bin1.meta_lic lib/liba.so.meta_lic reciprocal",
442 "bin/bin1.meta_lic lib/libc.a.meta_lic reciprocal",
443 "highest.apex.meta_lic lib/liba.so.meta_lic reciprocal",
444 "highest.apex.meta_lic lib/libc.a.meta_lic reciprocal",
445 "lib/liba.so.meta_lic lib/liba.so.meta_lic reciprocal",
Bob Badour1ded0a12021-12-03 17:16:14 -0800446 },
447 },
448 {
449 condition: "reciprocal",
450 name: "apex_trimmed_labelled",
451 roots: []string{"highest.apex.meta_lic"},
452 ctx: context{stripPrefix: "testdata/reciprocal/", labelConditions: true},
453 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800454 "bin/bin1.meta_lic:notice bin/bin1.meta_lic:notice notice",
455 "bin/bin1.meta_lic:notice lib/liba.so.meta_lic:reciprocal reciprocal",
456 "bin/bin1.meta_lic:notice lib/libc.a.meta_lic:reciprocal reciprocal",
457 "bin/bin2.meta_lic:notice bin/bin2.meta_lic:notice notice",
458 "highest.apex.meta_lic:notice bin/bin1.meta_lic:notice notice",
459 "highest.apex.meta_lic:notice bin/bin2.meta_lic:notice notice",
460 "highest.apex.meta_lic:notice highest.apex.meta_lic:notice notice",
461 "highest.apex.meta_lic:notice lib/liba.so.meta_lic:reciprocal reciprocal",
462 "highest.apex.meta_lic:notice lib/libb.so.meta_lic:notice notice",
463 "highest.apex.meta_lic:notice lib/libc.a.meta_lic:reciprocal reciprocal",
464 "lib/liba.so.meta_lic:reciprocal lib/liba.so.meta_lic:reciprocal reciprocal",
465 "lib/libb.so.meta_lic:notice lib/libb.so.meta_lic:notice notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800466 },
467 },
468 {
469 condition: "reciprocal",
470 name: "container",
471 roots: []string{"container.zip.meta_lic"},
472 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800473 "testdata/reciprocal/bin/bin1.meta_lic testdata/reciprocal/bin/bin1.meta_lic notice",
474 "testdata/reciprocal/bin/bin1.meta_lic testdata/reciprocal/lib/liba.so.meta_lic reciprocal",
475 "testdata/reciprocal/bin/bin1.meta_lic testdata/reciprocal/lib/libc.a.meta_lic reciprocal",
476 "testdata/reciprocal/bin/bin2.meta_lic testdata/reciprocal/bin/bin2.meta_lic notice",
477 "testdata/reciprocal/container.zip.meta_lic testdata/reciprocal/bin/bin1.meta_lic notice",
478 "testdata/reciprocal/container.zip.meta_lic testdata/reciprocal/bin/bin2.meta_lic notice",
479 "testdata/reciprocal/container.zip.meta_lic testdata/reciprocal/container.zip.meta_lic notice",
480 "testdata/reciprocal/container.zip.meta_lic testdata/reciprocal/lib/liba.so.meta_lic reciprocal",
481 "testdata/reciprocal/container.zip.meta_lic testdata/reciprocal/lib/libb.so.meta_lic notice",
482 "testdata/reciprocal/container.zip.meta_lic testdata/reciprocal/lib/libc.a.meta_lic reciprocal",
483 "testdata/reciprocal/lib/liba.so.meta_lic testdata/reciprocal/lib/liba.so.meta_lic reciprocal",
484 "testdata/reciprocal/lib/libb.so.meta_lic testdata/reciprocal/lib/libb.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800485 },
486 },
487 {
488 condition: "reciprocal",
489 name: "application",
490 roots: []string{"application.meta_lic"},
491 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800492 "testdata/reciprocal/application.meta_lic testdata/reciprocal/application.meta_lic notice",
493 "testdata/reciprocal/application.meta_lic testdata/reciprocal/lib/liba.so.meta_lic reciprocal",
Bob Badour1ded0a12021-12-03 17:16:14 -0800494 },
495 },
496 {
497 condition: "reciprocal",
498 name: "binary",
499 roots: []string{"bin/bin1.meta_lic"},
500 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800501 "testdata/reciprocal/bin/bin1.meta_lic testdata/reciprocal/bin/bin1.meta_lic notice",
502 "testdata/reciprocal/bin/bin1.meta_lic testdata/reciprocal/lib/liba.so.meta_lic reciprocal",
503 "testdata/reciprocal/bin/bin1.meta_lic testdata/reciprocal/lib/libc.a.meta_lic reciprocal",
Bob Badour1ded0a12021-12-03 17:16:14 -0800504 },
505 },
506 {
507 condition: "reciprocal",
508 name: "library",
509 roots: []string{"lib/libd.so.meta_lic"},
510 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800511 "testdata/reciprocal/lib/libd.so.meta_lic testdata/reciprocal/lib/libd.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800512 },
513 },
514 {
515 condition: "restricted",
516 name: "apex",
517 roots: []string{"highest.apex.meta_lic"},
518 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800519 "testdata/restricted/bin/bin1.meta_lic testdata/restricted/bin/bin1.meta_lic notice:restricted_allows_dynamic_linking",
520 "testdata/restricted/bin/bin1.meta_lic testdata/restricted/lib/liba.so.meta_lic restricted_allows_dynamic_linking",
521 "testdata/restricted/bin/bin1.meta_lic testdata/restricted/lib/libc.a.meta_lic reciprocal:restricted_allows_dynamic_linking",
522 "testdata/restricted/bin/bin2.meta_lic testdata/restricted/bin/bin2.meta_lic notice:restricted",
523 "testdata/restricted/bin/bin2.meta_lic testdata/restricted/lib/libb.so.meta_lic restricted",
524 "testdata/restricted/highest.apex.meta_lic testdata/restricted/bin/bin1.meta_lic notice:restricted_allows_dynamic_linking",
525 "testdata/restricted/highest.apex.meta_lic testdata/restricted/bin/bin2.meta_lic notice:restricted",
526 "testdata/restricted/highest.apex.meta_lic testdata/restricted/highest.apex.meta_lic notice:restricted:restricted_allows_dynamic_linking",
527 "testdata/restricted/highest.apex.meta_lic testdata/restricted/lib/liba.so.meta_lic restricted_allows_dynamic_linking",
528 "testdata/restricted/highest.apex.meta_lic testdata/restricted/lib/libb.so.meta_lic restricted",
529 "testdata/restricted/highest.apex.meta_lic testdata/restricted/lib/libc.a.meta_lic reciprocal:restricted_allows_dynamic_linking",
530 "testdata/restricted/lib/liba.so.meta_lic testdata/restricted/lib/liba.so.meta_lic restricted_allows_dynamic_linking",
531 "testdata/restricted/lib/libb.so.meta_lic testdata/restricted/lib/libb.so.meta_lic restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -0800532 },
533 },
534 {
535 condition: "restricted",
536 name: "apex_trimmed",
537 roots: []string{"highest.apex.meta_lic"},
538 ctx: context{stripPrefix: "testdata/restricted/"},
539 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800540 "bin/bin1.meta_lic bin/bin1.meta_lic notice:restricted_allows_dynamic_linking",
541 "bin/bin1.meta_lic lib/liba.so.meta_lic restricted_allows_dynamic_linking",
542 "bin/bin1.meta_lic lib/libc.a.meta_lic reciprocal:restricted_allows_dynamic_linking",
543 "bin/bin2.meta_lic bin/bin2.meta_lic notice:restricted",
544 "bin/bin2.meta_lic lib/libb.so.meta_lic restricted",
545 "highest.apex.meta_lic bin/bin1.meta_lic notice:restricted_allows_dynamic_linking",
546 "highest.apex.meta_lic bin/bin2.meta_lic notice:restricted",
547 "highest.apex.meta_lic highest.apex.meta_lic notice:restricted:restricted_allows_dynamic_linking",
548 "highest.apex.meta_lic lib/liba.so.meta_lic restricted_allows_dynamic_linking",
549 "highest.apex.meta_lic lib/libb.so.meta_lic restricted",
550 "highest.apex.meta_lic lib/libc.a.meta_lic reciprocal:restricted_allows_dynamic_linking",
551 "lib/liba.so.meta_lic lib/liba.so.meta_lic restricted_allows_dynamic_linking",
552 "lib/libb.so.meta_lic lib/libb.so.meta_lic restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -0800553 },
554 },
555 {
556 condition: "restricted",
557 name: "apex_trimmed_notice",
558 roots: []string{"highest.apex.meta_lic"},
559 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -0800560 conditions: []compliance.LicenseCondition{compliance.NoticeCondition},
Bob Badour1ded0a12021-12-03 17:16:14 -0800561 stripPrefix: "testdata/restricted/",
562 },
563 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800564 "bin/bin1.meta_lic bin/bin1.meta_lic notice",
565 "bin/bin2.meta_lic bin/bin2.meta_lic notice",
566 "highest.apex.meta_lic bin/bin1.meta_lic notice",
567 "highest.apex.meta_lic bin/bin2.meta_lic notice",
568 "highest.apex.meta_lic highest.apex.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800569 },
570 },
571 {
572 condition: "restricted",
573 name: "apex_trimmed_share",
574 roots: []string{"highest.apex.meta_lic"},
575 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800576 conditions: compliance.ImpliesShared.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -0800577 stripPrefix: "testdata/restricted/",
578 },
579 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800580 "bin/bin1.meta_lic bin/bin1.meta_lic restricted_allows_dynamic_linking",
581 "bin/bin1.meta_lic lib/liba.so.meta_lic restricted_allows_dynamic_linking",
582 "bin/bin1.meta_lic lib/libc.a.meta_lic reciprocal:restricted_allows_dynamic_linking",
583 "bin/bin2.meta_lic bin/bin2.meta_lic restricted",
584 "bin/bin2.meta_lic lib/libb.so.meta_lic restricted",
585 "highest.apex.meta_lic bin/bin1.meta_lic restricted_allows_dynamic_linking",
586 "highest.apex.meta_lic bin/bin2.meta_lic restricted",
587 "highest.apex.meta_lic highest.apex.meta_lic restricted:restricted_allows_dynamic_linking",
588 "highest.apex.meta_lic lib/liba.so.meta_lic restricted_allows_dynamic_linking",
589 "highest.apex.meta_lic lib/libb.so.meta_lic restricted",
590 "highest.apex.meta_lic lib/libc.a.meta_lic reciprocal:restricted_allows_dynamic_linking",
591 "lib/liba.so.meta_lic lib/liba.so.meta_lic restricted_allows_dynamic_linking",
592 "lib/libb.so.meta_lic lib/libb.so.meta_lic restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -0800593 },
594 },
595 {
596 condition: "restricted",
597 name: "apex_trimmed_private",
598 roots: []string{"highest.apex.meta_lic"},
599 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800600 conditions: compliance.ImpliesPrivate.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -0800601 stripPrefix: "testdata/restricted/",
602 },
603 expectedOut: []string{},
604 },
605 {
606 condition: "restricted",
607 name: "apex_trimmed_share_private",
608 roots: []string{"highest.apex.meta_lic"},
609 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800610 conditions: append(compliance.ImpliesShared.AsList(), compliance.ImpliesPrivate.AsList()...),
Bob Badour1ded0a12021-12-03 17:16:14 -0800611 stripPrefix: "testdata/restricted/",
612 },
613 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800614 "bin/bin1.meta_lic bin/bin1.meta_lic restricted_allows_dynamic_linking",
615 "bin/bin1.meta_lic lib/liba.so.meta_lic restricted_allows_dynamic_linking",
616 "bin/bin1.meta_lic lib/libc.a.meta_lic reciprocal:restricted_allows_dynamic_linking",
617 "bin/bin2.meta_lic bin/bin2.meta_lic restricted",
618 "bin/bin2.meta_lic lib/libb.so.meta_lic restricted",
619 "highest.apex.meta_lic bin/bin1.meta_lic restricted_allows_dynamic_linking",
620 "highest.apex.meta_lic bin/bin2.meta_lic restricted",
621 "highest.apex.meta_lic highest.apex.meta_lic restricted:restricted_allows_dynamic_linking",
622 "highest.apex.meta_lic lib/liba.so.meta_lic restricted_allows_dynamic_linking",
623 "highest.apex.meta_lic lib/libb.so.meta_lic restricted",
624 "highest.apex.meta_lic lib/libc.a.meta_lic reciprocal:restricted_allows_dynamic_linking",
625 "lib/liba.so.meta_lic lib/liba.so.meta_lic restricted_allows_dynamic_linking",
626 "lib/libb.so.meta_lic lib/libb.so.meta_lic restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -0800627 },
628 },
629 {
630 condition: "restricted",
631 name: "apex_trimmed_labelled",
632 roots: []string{"highest.apex.meta_lic"},
633 ctx: context{stripPrefix: "testdata/restricted/", labelConditions: true},
634 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800635 "bin/bin1.meta_lic:notice bin/bin1.meta_lic:notice notice:restricted_allows_dynamic_linking",
636 "bin/bin1.meta_lic:notice lib/liba.so.meta_lic:restricted_allows_dynamic_linking restricted_allows_dynamic_linking",
637 "bin/bin1.meta_lic:notice lib/libc.a.meta_lic:reciprocal reciprocal:restricted_allows_dynamic_linking",
638 "bin/bin2.meta_lic:notice bin/bin2.meta_lic:notice notice:restricted",
639 "bin/bin2.meta_lic:notice lib/libb.so.meta_lic:restricted restricted",
640 "highest.apex.meta_lic:notice bin/bin1.meta_lic:notice notice:restricted_allows_dynamic_linking",
641 "highest.apex.meta_lic:notice bin/bin2.meta_lic:notice notice:restricted",
642 "highest.apex.meta_lic:notice highest.apex.meta_lic:notice notice:restricted:restricted_allows_dynamic_linking",
643 "highest.apex.meta_lic:notice lib/liba.so.meta_lic:restricted_allows_dynamic_linking restricted_allows_dynamic_linking",
644 "highest.apex.meta_lic:notice lib/libb.so.meta_lic:restricted restricted",
645 "highest.apex.meta_lic:notice lib/libc.a.meta_lic:reciprocal reciprocal:restricted_allows_dynamic_linking",
646 "lib/liba.so.meta_lic:restricted_allows_dynamic_linking lib/liba.so.meta_lic:restricted_allows_dynamic_linking restricted_allows_dynamic_linking",
647 "lib/libb.so.meta_lic:restricted lib/libb.so.meta_lic:restricted restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -0800648 },
649 },
650 {
651 condition: "restricted",
652 name: "container",
653 roots: []string{"container.zip.meta_lic"},
654 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800655 "testdata/restricted/bin/bin1.meta_lic testdata/restricted/bin/bin1.meta_lic notice:restricted_allows_dynamic_linking",
656 "testdata/restricted/bin/bin1.meta_lic testdata/restricted/lib/liba.so.meta_lic restricted_allows_dynamic_linking",
657 "testdata/restricted/bin/bin1.meta_lic testdata/restricted/lib/libc.a.meta_lic reciprocal:restricted_allows_dynamic_linking",
658 "testdata/restricted/bin/bin2.meta_lic testdata/restricted/bin/bin2.meta_lic notice:restricted",
659 "testdata/restricted/bin/bin2.meta_lic testdata/restricted/lib/libb.so.meta_lic restricted",
660 "testdata/restricted/container.zip.meta_lic testdata/restricted/bin/bin1.meta_lic notice:restricted_allows_dynamic_linking",
661 "testdata/restricted/container.zip.meta_lic testdata/restricted/bin/bin2.meta_lic notice:restricted",
662 "testdata/restricted/container.zip.meta_lic testdata/restricted/container.zip.meta_lic notice:restricted:restricted_allows_dynamic_linking",
663 "testdata/restricted/container.zip.meta_lic testdata/restricted/lib/liba.so.meta_lic restricted_allows_dynamic_linking",
664 "testdata/restricted/container.zip.meta_lic testdata/restricted/lib/libb.so.meta_lic restricted",
665 "testdata/restricted/container.zip.meta_lic testdata/restricted/lib/libc.a.meta_lic reciprocal:restricted_allows_dynamic_linking",
666 "testdata/restricted/lib/liba.so.meta_lic testdata/restricted/lib/liba.so.meta_lic restricted_allows_dynamic_linking",
667 "testdata/restricted/lib/libb.so.meta_lic testdata/restricted/lib/libb.so.meta_lic restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -0800668 },
669 },
670 {
671 condition: "restricted",
672 name: "application",
673 roots: []string{"application.meta_lic"},
674 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800675 "testdata/restricted/application.meta_lic testdata/restricted/application.meta_lic notice:restricted:restricted_allows_dynamic_linking",
676 "testdata/restricted/application.meta_lic testdata/restricted/lib/liba.so.meta_lic restricted:restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -0800677 },
678 },
679 {
680 condition: "restricted",
681 name: "binary",
682 roots: []string{"bin/bin1.meta_lic"},
683 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800684 "testdata/restricted/bin/bin1.meta_lic testdata/restricted/bin/bin1.meta_lic notice:restricted_allows_dynamic_linking",
685 "testdata/restricted/bin/bin1.meta_lic testdata/restricted/lib/liba.so.meta_lic restricted_allows_dynamic_linking",
686 "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 -0800687 },
688 },
689 {
690 condition: "restricted",
691 name: "library",
692 roots: []string{"lib/libd.so.meta_lic"},
693 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800694 "testdata/restricted/lib/libd.so.meta_lic testdata/restricted/lib/libd.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800695 },
696 },
697 {
698 condition: "proprietary",
699 name: "apex",
700 roots: []string{"highest.apex.meta_lic"},
701 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800702 "testdata/proprietary/bin/bin1.meta_lic testdata/proprietary/bin/bin1.meta_lic notice",
703 "testdata/proprietary/bin/bin1.meta_lic testdata/proprietary/lib/liba.so.meta_lic proprietary:by_exception_only",
704 "testdata/proprietary/bin/bin1.meta_lic testdata/proprietary/lib/libc.a.meta_lic proprietary:by_exception_only",
705 "testdata/proprietary/bin/bin2.meta_lic testdata/proprietary/bin/bin2.meta_lic restricted:proprietary:by_exception_only",
706 "testdata/proprietary/bin/bin2.meta_lic testdata/proprietary/lib/libb.so.meta_lic restricted",
707 "testdata/proprietary/highest.apex.meta_lic testdata/proprietary/bin/bin1.meta_lic notice",
708 "testdata/proprietary/highest.apex.meta_lic testdata/proprietary/bin/bin2.meta_lic restricted:proprietary:by_exception_only",
709 "testdata/proprietary/highest.apex.meta_lic testdata/proprietary/highest.apex.meta_lic notice:restricted",
710 "testdata/proprietary/highest.apex.meta_lic testdata/proprietary/lib/liba.so.meta_lic proprietary:by_exception_only",
711 "testdata/proprietary/highest.apex.meta_lic testdata/proprietary/lib/libb.so.meta_lic restricted",
712 "testdata/proprietary/highest.apex.meta_lic testdata/proprietary/lib/libc.a.meta_lic proprietary:by_exception_only",
713 "testdata/proprietary/lib/liba.so.meta_lic testdata/proprietary/lib/liba.so.meta_lic proprietary:by_exception_only",
714 "testdata/proprietary/lib/libb.so.meta_lic testdata/proprietary/lib/libb.so.meta_lic restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -0800715 },
716 },
717 {
718 condition: "proprietary",
719 name: "apex_trimmed",
720 roots: []string{"highest.apex.meta_lic"},
721 ctx: context{stripPrefix: "testdata/proprietary/"},
722 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800723 "bin/bin1.meta_lic bin/bin1.meta_lic notice",
724 "bin/bin1.meta_lic lib/liba.so.meta_lic proprietary:by_exception_only",
725 "bin/bin1.meta_lic lib/libc.a.meta_lic proprietary:by_exception_only",
726 "bin/bin2.meta_lic bin/bin2.meta_lic restricted:proprietary:by_exception_only",
727 "bin/bin2.meta_lic lib/libb.so.meta_lic restricted",
728 "highest.apex.meta_lic bin/bin1.meta_lic notice",
729 "highest.apex.meta_lic bin/bin2.meta_lic restricted:proprietary:by_exception_only",
730 "highest.apex.meta_lic highest.apex.meta_lic notice:restricted",
731 "highest.apex.meta_lic lib/liba.so.meta_lic proprietary:by_exception_only",
732 "highest.apex.meta_lic lib/libb.so.meta_lic restricted",
733 "highest.apex.meta_lic lib/libc.a.meta_lic proprietary:by_exception_only",
734 "lib/liba.so.meta_lic lib/liba.so.meta_lic proprietary:by_exception_only",
735 "lib/libb.so.meta_lic lib/libb.so.meta_lic restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -0800736 },
737 },
738 {
739 condition: "proprietary",
740 name: "apex_trimmed_notice",
741 roots: []string{"highest.apex.meta_lic"},
742 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -0800743 conditions: []compliance.LicenseCondition{compliance.NoticeCondition},
Bob Badour1ded0a12021-12-03 17:16:14 -0800744 stripPrefix: "testdata/proprietary/",
745 },
746 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800747 "bin/bin1.meta_lic bin/bin1.meta_lic notice",
748 "highest.apex.meta_lic bin/bin1.meta_lic notice",
749 "highest.apex.meta_lic highest.apex.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800750 },
751 },
752 {
753 condition: "proprietary",
754 name: "apex_trimmed_share",
755 roots: []string{"highest.apex.meta_lic"},
756 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800757 conditions: compliance.ImpliesShared.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -0800758 stripPrefix: "testdata/proprietary/",
759 },
760 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800761 "bin/bin2.meta_lic bin/bin2.meta_lic restricted",
762 "bin/bin2.meta_lic lib/libb.so.meta_lic restricted",
763 "highest.apex.meta_lic bin/bin2.meta_lic restricted",
764 "highest.apex.meta_lic highest.apex.meta_lic restricted",
765 "highest.apex.meta_lic lib/libb.so.meta_lic restricted",
766 "lib/libb.so.meta_lic lib/libb.so.meta_lic restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -0800767 },
768 },
769 {
770 condition: "proprietary",
771 name: "apex_trimmed_private",
772 roots: []string{"highest.apex.meta_lic"},
773 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800774 conditions: compliance.ImpliesPrivate.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -0800775 stripPrefix: "testdata/proprietary/",
776 },
777 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800778 "bin/bin1.meta_lic lib/liba.so.meta_lic proprietary",
779 "bin/bin1.meta_lic lib/libc.a.meta_lic proprietary",
780 "bin/bin2.meta_lic bin/bin2.meta_lic proprietary",
781 "highest.apex.meta_lic bin/bin2.meta_lic proprietary",
782 "highest.apex.meta_lic lib/liba.so.meta_lic proprietary",
783 "highest.apex.meta_lic lib/libc.a.meta_lic proprietary",
784 "lib/liba.so.meta_lic lib/liba.so.meta_lic proprietary",
Bob Badour1ded0a12021-12-03 17:16:14 -0800785 },
786 },
787 {
788 condition: "proprietary",
789 name: "apex_trimmed_share_private",
790 roots: []string{"highest.apex.meta_lic"},
791 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800792 conditions: append(compliance.ImpliesShared.AsList(), compliance.ImpliesPrivate.AsList()...),
Bob Badour1ded0a12021-12-03 17:16:14 -0800793 stripPrefix: "testdata/proprietary/",
794 },
795 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800796 "bin/bin1.meta_lic lib/liba.so.meta_lic proprietary",
797 "bin/bin1.meta_lic lib/libc.a.meta_lic proprietary",
798 "bin/bin2.meta_lic bin/bin2.meta_lic restricted:proprietary",
799 "bin/bin2.meta_lic lib/libb.so.meta_lic restricted",
800 "highest.apex.meta_lic bin/bin2.meta_lic restricted:proprietary",
801 "highest.apex.meta_lic highest.apex.meta_lic restricted",
802 "highest.apex.meta_lic lib/liba.so.meta_lic proprietary",
803 "highest.apex.meta_lic lib/libb.so.meta_lic restricted",
804 "highest.apex.meta_lic lib/libc.a.meta_lic proprietary",
805 "lib/liba.so.meta_lic lib/liba.so.meta_lic proprietary",
806 "lib/libb.so.meta_lic lib/libb.so.meta_lic restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -0800807 },
808 },
809 {
810 condition: "proprietary",
811 name: "apex_trimmed_labelled",
812 roots: []string{"highest.apex.meta_lic"},
813 ctx: context{stripPrefix: "testdata/proprietary/", labelConditions: true},
814 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800815 "bin/bin1.meta_lic:notice bin/bin1.meta_lic:notice notice",
816 "bin/bin1.meta_lic:notice lib/liba.so.meta_lic:proprietary:by_exception_only proprietary:by_exception_only",
817 "bin/bin1.meta_lic:notice lib/libc.a.meta_lic:proprietary:by_exception_only proprietary:by_exception_only",
818 "bin/bin2.meta_lic:proprietary:by_exception_only bin/bin2.meta_lic:proprietary:by_exception_only restricted:proprietary:by_exception_only",
819 "bin/bin2.meta_lic:proprietary:by_exception_only lib/libb.so.meta_lic:restricted restricted",
820 "highest.apex.meta_lic:notice bin/bin1.meta_lic:notice notice",
821 "highest.apex.meta_lic:notice bin/bin2.meta_lic:proprietary:by_exception_only restricted:proprietary:by_exception_only",
822 "highest.apex.meta_lic:notice highest.apex.meta_lic:notice notice:restricted",
823 "highest.apex.meta_lic:notice lib/liba.so.meta_lic:proprietary:by_exception_only proprietary:by_exception_only",
824 "highest.apex.meta_lic:notice lib/libb.so.meta_lic:restricted restricted",
825 "highest.apex.meta_lic:notice lib/libc.a.meta_lic:proprietary:by_exception_only proprietary:by_exception_only",
826 "lib/liba.so.meta_lic:proprietary:by_exception_only lib/liba.so.meta_lic:proprietary:by_exception_only proprietary:by_exception_only",
827 "lib/libb.so.meta_lic:restricted lib/libb.so.meta_lic:restricted restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -0800828 },
829 },
830 {
831 condition: "proprietary",
832 name: "container",
833 roots: []string{"container.zip.meta_lic"},
834 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800835 "testdata/proprietary/bin/bin1.meta_lic testdata/proprietary/bin/bin1.meta_lic notice",
836 "testdata/proprietary/bin/bin1.meta_lic testdata/proprietary/lib/liba.so.meta_lic proprietary:by_exception_only",
837 "testdata/proprietary/bin/bin1.meta_lic testdata/proprietary/lib/libc.a.meta_lic proprietary:by_exception_only",
838 "testdata/proprietary/bin/bin2.meta_lic testdata/proprietary/bin/bin2.meta_lic restricted:proprietary:by_exception_only",
839 "testdata/proprietary/bin/bin2.meta_lic testdata/proprietary/lib/libb.so.meta_lic restricted",
840 "testdata/proprietary/container.zip.meta_lic testdata/proprietary/bin/bin1.meta_lic notice",
841 "testdata/proprietary/container.zip.meta_lic testdata/proprietary/bin/bin2.meta_lic restricted:proprietary:by_exception_only",
842 "testdata/proprietary/container.zip.meta_lic testdata/proprietary/container.zip.meta_lic notice:restricted",
843 "testdata/proprietary/container.zip.meta_lic testdata/proprietary/lib/liba.so.meta_lic proprietary:by_exception_only",
844 "testdata/proprietary/container.zip.meta_lic testdata/proprietary/lib/libb.so.meta_lic restricted",
845 "testdata/proprietary/container.zip.meta_lic testdata/proprietary/lib/libc.a.meta_lic proprietary:by_exception_only",
846 "testdata/proprietary/lib/liba.so.meta_lic testdata/proprietary/lib/liba.so.meta_lic proprietary:by_exception_only",
847 "testdata/proprietary/lib/libb.so.meta_lic testdata/proprietary/lib/libb.so.meta_lic restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -0800848 },
849 },
850 {
851 condition: "proprietary",
852 name: "application",
853 roots: []string{"application.meta_lic"},
854 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800855 "testdata/proprietary/application.meta_lic testdata/proprietary/application.meta_lic notice:restricted",
856 "testdata/proprietary/application.meta_lic testdata/proprietary/lib/liba.so.meta_lic restricted:proprietary:by_exception_only",
Bob Badour1ded0a12021-12-03 17:16:14 -0800857 },
858 },
859 {
860 condition: "proprietary",
861 name: "binary",
862 roots: []string{"bin/bin1.meta_lic"},
863 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800864 "testdata/proprietary/bin/bin1.meta_lic testdata/proprietary/bin/bin1.meta_lic notice",
865 "testdata/proprietary/bin/bin1.meta_lic testdata/proprietary/lib/liba.so.meta_lic proprietary:by_exception_only",
866 "testdata/proprietary/bin/bin1.meta_lic testdata/proprietary/lib/libc.a.meta_lic proprietary:by_exception_only",
Bob Badour1ded0a12021-12-03 17:16:14 -0800867 },
868 },
869 {
870 condition: "proprietary",
871 name: "library",
872 roots: []string{"lib/libd.so.meta_lic"},
873 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800874 "testdata/proprietary/lib/libd.so.meta_lic testdata/proprietary/lib/libd.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800875 },
876 },
877 }
878 for _, tt := range tests {
879 t.Run(tt.condition+" "+tt.name, func(t *testing.T) {
880 expectedOut := &bytes.Buffer{}
881 for _, eo := range tt.expectedOut {
882 expectedOut.WriteString(eo)
883 expectedOut.WriteString("\n")
884 }
885
886 stdout := &bytes.Buffer{}
887 stderr := &bytes.Buffer{}
888
889 rootFiles := make([]string, 0, len(tt.roots))
890 for _, r := range tt.roots {
891 rootFiles = append(rootFiles, "testdata/"+tt.condition+"/"+r)
892 }
Bob Badour103eb0f2022-01-10 13:50:57 -0800893 _, err := dumpResolutions(&tt.ctx, stdout, stderr, rootFiles...)
Bob Badour1ded0a12021-12-03 17:16:14 -0800894 if err != nil {
895 t.Fatalf("dumpresolutions: error = %v, stderr = %v", err, stderr)
896 return
897 }
898 if stderr.Len() > 0 {
899 t.Errorf("dumpresolutions: gotStderr = %v, want none", stderr)
900 }
901 out := stdout.String()
902 expected := expectedOut.String()
903 if out != expected {
904 outList := strings.Split(out, "\n")
905 expectedList := strings.Split(expected, "\n")
906 startLine := 0
907 for len(outList) > startLine && len(expectedList) > startLine && outList[startLine] == expectedList[startLine] {
908 startLine++
909 }
910 t.Errorf("listshare: gotStdout = %v, want %v, somewhere near line %d Stdout = %v, want %v",
911 out, expected, startLine+1, outList[startLine], expectedList[startLine])
912 }
913 })
914 }
915}
916
917type testContext struct {
918 nextNode int
919 nodes map[string]string
920}
921
922type matcher interface {
Bob Badour103eb0f2022-01-10 13:50:57 -0800923 matchString(*testContext, *compliance.LicenseGraph) string
Bob Badour1ded0a12021-12-03 17:16:14 -0800924 typeString() string
925}
926
927type targetMatcher struct {
928 target string
929 conditions []string
930}
931
Bob Badour103eb0f2022-01-10 13:50:57 -0800932// newTestCondition constructs a test license condition in the license graph.
Colin Cross35f79c32022-01-27 15:18:52 -0800933func newTestCondition(lg *compliance.LicenseGraph, conditionName ...string) compliance.LicenseConditionSet {
Bob Badour103eb0f2022-01-10 13:50:57 -0800934 cs := compliance.NewLicenseConditionSet()
935 for _, name := range conditionName {
936 cs = cs.Plus(compliance.RecognizedConditionNames[name])
937 }
938 if cs.IsEmpty() && len(conditionName) != 0 {
939 panic(fmt.Errorf("attempt to create unrecognized condition: %q", conditionName))
940 }
941 return cs
942}
943
944func (tm *targetMatcher) matchString(ctx *testContext, lg *compliance.LicenseGraph) string {
945 cs := newTestCondition(lg, tm.conditions...)
Bob Badour1ded0a12021-12-03 17:16:14 -0800946 m := tm.target
Bob Badour103eb0f2022-01-10 13:50:57 -0800947 if !cs.IsEmpty() {
948 m += "\\n" + strings.Join(cs.Names(), "\\n")
Bob Badour1ded0a12021-12-03 17:16:14 -0800949 }
950 m = ctx.nodes[tm.target] + " [label=\"" + m + "\"];"
951 return m
952}
953
954func (tm *targetMatcher) typeString() string {
955 return "target"
956}
957
958type resolutionMatcher struct {
959 appliesTo string
960 actsOn string
Bob Badour1ded0a12021-12-03 17:16:14 -0800961 conditions []string
962}
963
Bob Badour103eb0f2022-01-10 13:50:57 -0800964func (rm *resolutionMatcher) matchString(ctx *testContext, lg *compliance.LicenseGraph) string {
965 cs := newTestCondition(lg, rm.conditions...)
966 return ctx.nodes[rm.appliesTo] + " -> " + ctx.nodes[rm.actsOn] +
967 " [label=\"" + strings.Join(cs.Names(), "\\n") + "\"];"
Bob Badour1ded0a12021-12-03 17:16:14 -0800968}
969
970func (rm *resolutionMatcher) typeString() string {
971 return "resolution"
972}
973
974type getMatcher func(*testContext) matcher
975
976func matchTarget(target string, conditions ...string) getMatcher {
977 return func(ctx *testContext) matcher {
978 ctx.nodes[target] = fmt.Sprintf("n%d", ctx.nextNode)
979 ctx.nextNode++
980 return &targetMatcher{target, append([]string{}, conditions...)}
981 }
982}
983
Bob Badour103eb0f2022-01-10 13:50:57 -0800984func matchResolution(appliesTo, actsOn string, conditions ...string) getMatcher {
Bob Badour1ded0a12021-12-03 17:16:14 -0800985 return func(ctx *testContext) matcher {
986 if _, ok := ctx.nodes[appliesTo]; !ok {
987 ctx.nodes[appliesTo] = fmt.Sprintf("unknown%d", ctx.nextNode)
988 ctx.nextNode++
989 }
990 if _, ok := ctx.nodes[actsOn]; !ok {
991 ctx.nodes[actsOn] = fmt.Sprintf("unknown%d", ctx.nextNode)
992 ctx.nextNode++
993 }
Bob Badour103eb0f2022-01-10 13:50:57 -0800994 return &resolutionMatcher{appliesTo, actsOn, append([]string{}, conditions...)}
Bob Badour1ded0a12021-12-03 17:16:14 -0800995 }
996}
997
998func Test_graphviz(t *testing.T) {
999 tests := []struct {
1000 condition string
1001 name string
1002 roots []string
1003 ctx context
1004 expectedOut []getMatcher
1005 }{
1006 {
1007 condition: "firstparty",
1008 name: "apex",
1009 roots: []string{"highest.apex.meta_lic"},
1010 expectedOut: []getMatcher{
1011 matchTarget("testdata/firstparty/bin/bin1.meta_lic"),
1012 matchTarget("testdata/firstparty/lib/liba.so.meta_lic"),
1013 matchTarget("testdata/firstparty/lib/libc.a.meta_lic"),
1014 matchTarget("testdata/firstparty/bin/bin2.meta_lic"),
1015 matchTarget("testdata/firstparty/highest.apex.meta_lic"),
1016 matchTarget("testdata/firstparty/lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08001017 matchResolution(
1018 "testdata/firstparty/bin/bin1.meta_lic",
1019 "testdata/firstparty/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001020 "notice"),
1021 matchResolution(
1022 "testdata/firstparty/bin/bin1.meta_lic",
1023 "testdata/firstparty/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001024 "notice"),
1025 matchResolution(
1026 "testdata/firstparty/bin/bin1.meta_lic",
1027 "testdata/firstparty/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001028 "notice"),
1029 matchResolution(
1030 "testdata/firstparty/bin/bin2.meta_lic",
1031 "testdata/firstparty/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001032 "notice"),
1033 matchResolution(
1034 "testdata/firstparty/highest.apex.meta_lic",
1035 "testdata/firstparty/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001036 "notice"),
1037 matchResolution(
1038 "testdata/firstparty/highest.apex.meta_lic",
1039 "testdata/firstparty/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001040 "notice"),
1041 matchResolution(
1042 "testdata/firstparty/highest.apex.meta_lic",
1043 "testdata/firstparty/highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001044 "notice"),
1045 matchResolution(
1046 "testdata/firstparty/highest.apex.meta_lic",
1047 "testdata/firstparty/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001048 "notice"),
1049 matchResolution(
1050 "testdata/firstparty/highest.apex.meta_lic",
1051 "testdata/firstparty/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001052 "notice"),
1053 matchResolution(
1054 "testdata/firstparty/highest.apex.meta_lic",
1055 "testdata/firstparty/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001056 "notice"),
1057 matchResolution(
1058 "testdata/firstparty/lib/liba.so.meta_lic",
1059 "testdata/firstparty/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001060 "notice"),
1061 matchResolution(
1062 "testdata/firstparty/lib/libb.so.meta_lic",
1063 "testdata/firstparty/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001064 "notice"),
1065 },
1066 },
1067 {
1068 condition: "firstparty",
1069 name: "apex_trimmed",
1070 roots: []string{"highest.apex.meta_lic"},
1071 ctx: context{stripPrefix: "testdata/firstparty/"},
1072 expectedOut: []getMatcher{
1073 matchTarget("bin/bin1.meta_lic"),
1074 matchTarget("lib/liba.so.meta_lic"),
1075 matchTarget("lib/libc.a.meta_lic"),
1076 matchTarget("bin/bin2.meta_lic"),
1077 matchTarget("highest.apex.meta_lic"),
1078 matchTarget("lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08001079 matchResolution(
1080 "bin/bin1.meta_lic",
1081 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001082 "notice"),
1083 matchResolution(
1084 "bin/bin1.meta_lic",
1085 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001086 "notice"),
1087 matchResolution(
1088 "bin/bin1.meta_lic",
1089 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001090 "notice"),
1091 matchResolution(
1092 "bin/bin2.meta_lic",
1093 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001094 "notice"),
1095 matchResolution(
1096 "highest.apex.meta_lic",
1097 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001098 "notice"),
1099 matchResolution(
1100 "highest.apex.meta_lic",
1101 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001102 "notice"),
1103 matchResolution(
1104 "highest.apex.meta_lic",
1105 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001106 "notice"),
1107 matchResolution(
1108 "highest.apex.meta_lic",
1109 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001110 "notice"),
1111 matchResolution(
1112 "highest.apex.meta_lic",
1113 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001114 "notice"),
1115 matchResolution(
1116 "highest.apex.meta_lic",
1117 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001118 "notice"),
1119 matchResolution(
1120 "lib/liba.so.meta_lic",
1121 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001122 "notice"),
1123 matchResolution(
1124 "lib/libb.so.meta_lic",
1125 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001126 "notice"),
1127 },
1128 },
1129 {
1130 condition: "firstparty",
1131 name: "apex_trimmed_notice",
1132 roots: []string{"highest.apex.meta_lic"},
1133 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08001134 conditions: []compliance.LicenseCondition{compliance.NoticeCondition},
Bob Badour1ded0a12021-12-03 17:16:14 -08001135 stripPrefix: "testdata/firstparty/",
1136 },
1137 expectedOut: []getMatcher{
1138 matchTarget("bin/bin1.meta_lic"),
1139 matchTarget("lib/liba.so.meta_lic"),
1140 matchTarget("lib/libc.a.meta_lic"),
1141 matchTarget("bin/bin2.meta_lic"),
1142 matchTarget("highest.apex.meta_lic"),
1143 matchTarget("lib/libb.so.meta_lic"),
1144 matchResolution(
1145 "bin/bin1.meta_lic",
1146 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001147 "notice"),
1148 matchResolution(
1149 "bin/bin1.meta_lic",
1150 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001151 "notice"),
1152 matchResolution(
1153 "bin/bin1.meta_lic",
1154 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001155 "notice"),
1156 matchResolution(
1157 "bin/bin2.meta_lic",
1158 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001159 "notice"),
1160 matchResolution(
1161 "highest.apex.meta_lic",
1162 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001163 "notice"),
1164 matchResolution(
1165 "highest.apex.meta_lic",
1166 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001167 "notice"),
1168 matchResolution(
1169 "highest.apex.meta_lic",
1170 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001171 "notice"),
1172 matchResolution(
1173 "highest.apex.meta_lic",
1174 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001175 "notice"),
1176 matchResolution(
1177 "highest.apex.meta_lic",
1178 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001179 "notice"),
1180 matchResolution(
1181 "highest.apex.meta_lic",
1182 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001183 "notice"),
1184 matchResolution(
1185 "lib/liba.so.meta_lic",
1186 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001187 "notice"),
1188 matchResolution(
1189 "lib/libb.so.meta_lic",
1190 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001191 "notice"),
1192 },
1193 },
1194 {
1195 condition: "firstparty",
1196 name: "apex_trimmed_share",
1197 roots: []string{"highest.apex.meta_lic"},
1198 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08001199 conditions: compliance.ImpliesShared.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -08001200 stripPrefix: "testdata/firstparty/",
1201 },
1202 expectedOut: []getMatcher{},
1203 },
1204 {
1205 condition: "firstparty",
1206 name: "apex_trimmed_private",
1207 roots: []string{"highest.apex.meta_lic"},
1208 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08001209 conditions: compliance.ImpliesPrivate.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -08001210 stripPrefix: "testdata/firstparty/",
1211 },
1212 expectedOut: []getMatcher{},
1213 },
1214 {
1215 condition: "firstparty",
1216 name: "apex_trimmed_share_private",
1217 roots: []string{"highest.apex.meta_lic"},
1218 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08001219 conditions: compliance.ImpliesShared.Union(compliance.ImpliesPrivate).AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -08001220 stripPrefix: "testdata/firstparty/",
1221 },
1222 expectedOut: []getMatcher{},
1223 },
1224 {
1225 condition: "firstparty",
1226 name: "apex_trimmed_labelled",
1227 roots: []string{"highest.apex.meta_lic"},
1228 ctx: context{stripPrefix: "testdata/firstparty/", labelConditions: true},
1229 expectedOut: []getMatcher{
1230 matchTarget("bin/bin1.meta_lic", "notice"),
1231 matchTarget("lib/liba.so.meta_lic", "notice"),
1232 matchTarget("lib/libc.a.meta_lic", "notice"),
1233 matchTarget("bin/bin2.meta_lic", "notice"),
1234 matchTarget("highest.apex.meta_lic", "notice"),
1235 matchTarget("lib/libb.so.meta_lic", "notice"),
Bob Badour1ded0a12021-12-03 17:16:14 -08001236 matchResolution(
1237 "bin/bin1.meta_lic",
1238 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001239 "notice"),
1240 matchResolution(
1241 "bin/bin1.meta_lic",
1242 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001243 "notice"),
1244 matchResolution(
1245 "bin/bin1.meta_lic",
1246 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001247 "notice"),
1248 matchResolution(
1249 "bin/bin2.meta_lic",
1250 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001251 "notice"),
1252 matchResolution(
1253 "highest.apex.meta_lic",
1254 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001255 "notice"),
1256 matchResolution(
1257 "highest.apex.meta_lic",
1258 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001259 "notice"),
1260 matchResolution(
1261 "highest.apex.meta_lic",
1262 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001263 "notice"),
1264 matchResolution(
1265 "highest.apex.meta_lic",
1266 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001267 "notice"),
1268 matchResolution(
1269 "highest.apex.meta_lic",
1270 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001271 "notice"),
1272 matchResolution(
1273 "highest.apex.meta_lic",
1274 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001275 "notice"),
1276 matchResolution(
1277 "lib/liba.so.meta_lic",
1278 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001279 "notice"),
1280 matchResolution(
1281 "lib/libb.so.meta_lic",
1282 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001283 "notice"),
1284 },
1285 },
1286 {
1287 condition: "firstparty",
1288 name: "container",
1289 roots: []string{"container.zip.meta_lic"},
1290 expectedOut: []getMatcher{
1291 matchTarget("testdata/firstparty/bin/bin1.meta_lic"),
1292 matchTarget("testdata/firstparty/lib/liba.so.meta_lic"),
1293 matchTarget("testdata/firstparty/lib/libc.a.meta_lic"),
1294 matchTarget("testdata/firstparty/bin/bin2.meta_lic"),
1295 matchTarget("testdata/firstparty/container.zip.meta_lic"),
1296 matchTarget("testdata/firstparty/lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08001297 matchResolution(
1298 "testdata/firstparty/bin/bin1.meta_lic",
1299 "testdata/firstparty/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001300 "notice"),
1301 matchResolution(
1302 "testdata/firstparty/bin/bin1.meta_lic",
1303 "testdata/firstparty/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001304 "notice"),
1305 matchResolution(
1306 "testdata/firstparty/bin/bin1.meta_lic",
1307 "testdata/firstparty/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001308 "notice"),
1309 matchResolution(
1310 "testdata/firstparty/bin/bin2.meta_lic",
1311 "testdata/firstparty/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001312 "notice"),
1313 matchResolution(
1314 "testdata/firstparty/container.zip.meta_lic",
1315 "testdata/firstparty/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001316 "notice"),
1317 matchResolution(
1318 "testdata/firstparty/container.zip.meta_lic",
1319 "testdata/firstparty/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001320 "notice"),
1321 matchResolution(
1322 "testdata/firstparty/container.zip.meta_lic",
1323 "testdata/firstparty/container.zip.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001324 "notice"),
1325 matchResolution(
1326 "testdata/firstparty/container.zip.meta_lic",
1327 "testdata/firstparty/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001328 "notice"),
1329 matchResolution(
1330 "testdata/firstparty/container.zip.meta_lic",
1331 "testdata/firstparty/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001332 "notice"),
1333 matchResolution(
1334 "testdata/firstparty/container.zip.meta_lic",
1335 "testdata/firstparty/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001336 "notice"),
1337 matchResolution(
1338 "testdata/firstparty/lib/liba.so.meta_lic",
1339 "testdata/firstparty/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001340 "notice"),
1341 matchResolution(
1342 "testdata/firstparty/lib/libb.so.meta_lic",
1343 "testdata/firstparty/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001344 "notice"),
1345 },
1346 },
1347 {
1348 condition: "firstparty",
1349 name: "application",
1350 roots: []string{"application.meta_lic"},
1351 expectedOut: []getMatcher{
1352 matchTarget("testdata/firstparty/application.meta_lic"),
1353 matchTarget("testdata/firstparty/lib/liba.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08001354 matchResolution(
1355 "testdata/firstparty/application.meta_lic",
1356 "testdata/firstparty/application.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001357 "notice"),
1358 matchResolution(
1359 "testdata/firstparty/application.meta_lic",
1360 "testdata/firstparty/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001361 "notice"),
1362 },
1363 },
1364 {
1365 condition: "firstparty",
1366 name: "binary",
1367 roots: []string{"bin/bin1.meta_lic"},
1368 expectedOut: []getMatcher{
1369 matchTarget("testdata/firstparty/bin/bin1.meta_lic"),
1370 matchTarget("testdata/firstparty/lib/liba.so.meta_lic"),
1371 matchTarget("testdata/firstparty/lib/libc.a.meta_lic"),
1372 matchResolution(
1373 "testdata/firstparty/bin/bin1.meta_lic",
1374 "testdata/firstparty/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001375 "notice"),
1376 matchResolution(
1377 "testdata/firstparty/bin/bin1.meta_lic",
1378 "testdata/firstparty/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001379 "notice"),
1380 matchResolution(
1381 "testdata/firstparty/bin/bin1.meta_lic",
1382 "testdata/firstparty/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001383 "notice"),
1384 },
1385 },
1386 {
1387 condition: "firstparty",
1388 name: "library",
1389 roots: []string{"lib/libd.so.meta_lic"},
1390 expectedOut: []getMatcher{
1391 matchTarget("testdata/firstparty/lib/libd.so.meta_lic"),
1392 matchResolution(
1393 "testdata/firstparty/lib/libd.so.meta_lic",
1394 "testdata/firstparty/lib/libd.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001395 "notice"),
1396 },
1397 },
1398 {
1399 condition: "notice",
1400 name: "apex",
1401 roots: []string{"highest.apex.meta_lic"},
1402 expectedOut: []getMatcher{
1403 matchTarget("testdata/notice/bin/bin1.meta_lic"),
1404 matchTarget("testdata/notice/lib/liba.so.meta_lic"),
1405 matchTarget("testdata/notice/lib/libc.a.meta_lic"),
1406 matchTarget("testdata/notice/bin/bin2.meta_lic"),
1407 matchTarget("testdata/notice/highest.apex.meta_lic"),
1408 matchTarget("testdata/notice/lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08001409 matchResolution(
1410 "testdata/notice/bin/bin1.meta_lic",
1411 "testdata/notice/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001412 "notice"),
1413 matchResolution(
1414 "testdata/notice/bin/bin1.meta_lic",
1415 "testdata/notice/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001416 "notice"),
1417 matchResolution(
1418 "testdata/notice/bin/bin1.meta_lic",
1419 "testdata/notice/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001420 "notice"),
1421 matchResolution(
1422 "testdata/notice/bin/bin2.meta_lic",
1423 "testdata/notice/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001424 "notice"),
1425 matchResolution(
1426 "testdata/notice/highest.apex.meta_lic",
1427 "testdata/notice/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001428 "notice"),
1429 matchResolution(
1430 "testdata/notice/highest.apex.meta_lic",
1431 "testdata/notice/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001432 "notice"),
1433 matchResolution(
1434 "testdata/notice/highest.apex.meta_lic",
1435 "testdata/notice/highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001436 "notice"),
1437 matchResolution(
1438 "testdata/notice/highest.apex.meta_lic",
1439 "testdata/notice/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001440 "notice"),
1441 matchResolution(
1442 "testdata/notice/highest.apex.meta_lic",
1443 "testdata/notice/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001444 "notice"),
1445 matchResolution(
1446 "testdata/notice/highest.apex.meta_lic",
1447 "testdata/notice/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001448 "notice"),
1449 matchResolution(
1450 "testdata/notice/lib/liba.so.meta_lic",
1451 "testdata/notice/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001452 "notice"),
1453 matchResolution(
1454 "testdata/notice/lib/libb.so.meta_lic",
1455 "testdata/notice/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001456 "notice"),
1457 },
1458 },
1459 {
1460 condition: "notice",
1461 name: "apex_trimmed",
1462 roots: []string{"highest.apex.meta_lic"},
1463 ctx: context{stripPrefix: "testdata/notice/"},
1464 expectedOut: []getMatcher{
1465 matchTarget("bin/bin1.meta_lic"),
1466 matchTarget("lib/liba.so.meta_lic"),
1467 matchTarget("lib/libc.a.meta_lic"),
1468 matchTarget("bin/bin2.meta_lic"),
1469 matchTarget("highest.apex.meta_lic"),
1470 matchTarget("lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08001471 matchResolution(
1472 "bin/bin1.meta_lic",
1473 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001474 "notice"),
1475 matchResolution(
1476 "bin/bin1.meta_lic",
1477 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001478 "notice"),
1479 matchResolution(
1480 "bin/bin1.meta_lic",
1481 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001482 "notice"),
1483 matchResolution(
1484 "bin/bin2.meta_lic",
1485 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001486 "notice"),
1487 matchResolution(
1488 "highest.apex.meta_lic",
1489 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001490 "notice"),
1491 matchResolution(
1492 "highest.apex.meta_lic",
1493 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001494 "notice"),
1495 matchResolution(
1496 "highest.apex.meta_lic",
1497 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001498 "notice"),
1499 matchResolution(
1500 "highest.apex.meta_lic",
1501 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001502 "notice"),
1503 matchResolution(
1504 "highest.apex.meta_lic",
1505 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001506 "notice"),
1507 matchResolution(
1508 "highest.apex.meta_lic",
1509 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001510 "notice"),
1511 matchResolution(
1512 "lib/liba.so.meta_lic",
1513 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001514 "notice"),
1515 matchResolution(
1516 "lib/libb.so.meta_lic",
1517 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001518 "notice"),
1519 },
1520 },
1521 {
1522 condition: "notice",
1523 name: "apex_trimmed_notice",
1524 roots: []string{"highest.apex.meta_lic"},
1525 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08001526 conditions: []compliance.LicenseCondition{compliance.NoticeCondition},
Bob Badour1ded0a12021-12-03 17:16:14 -08001527 stripPrefix: "testdata/notice/",
1528 },
1529 expectedOut: []getMatcher{
1530 matchTarget("bin/bin1.meta_lic"),
1531 matchTarget("lib/liba.so.meta_lic"),
1532 matchTarget("lib/libc.a.meta_lic"),
1533 matchTarget("bin/bin2.meta_lic"),
1534 matchTarget("highest.apex.meta_lic"),
1535 matchTarget("lib/libb.so.meta_lic"),
1536 matchResolution(
1537 "bin/bin1.meta_lic",
1538 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001539 "notice"),
1540 matchResolution(
1541 "bin/bin1.meta_lic",
1542 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001543 "notice"),
1544 matchResolution(
1545 "bin/bin1.meta_lic",
1546 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001547 "notice"),
1548 matchResolution(
1549 "bin/bin2.meta_lic",
1550 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001551 "notice"),
1552 matchResolution(
1553 "highest.apex.meta_lic",
1554 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001555 "notice"),
1556 matchResolution(
1557 "highest.apex.meta_lic",
1558 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001559 "notice"),
1560 matchResolution(
1561 "highest.apex.meta_lic",
1562 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001563 "notice"),
1564 matchResolution(
1565 "highest.apex.meta_lic",
1566 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001567 "notice"),
1568 matchResolution(
1569 "highest.apex.meta_lic",
1570 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001571 "notice"),
1572 matchResolution(
1573 "highest.apex.meta_lic",
1574 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001575 "notice"),
1576 matchResolution(
1577 "lib/liba.so.meta_lic",
1578 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001579 "notice"),
1580 matchResolution(
1581 "lib/libb.so.meta_lic",
1582 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001583 "notice"),
1584 },
1585 },
1586 {
1587 condition: "notice",
1588 name: "apex_trimmed_share",
1589 roots: []string{"highest.apex.meta_lic"},
1590 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08001591 conditions: compliance.ImpliesShared.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -08001592 stripPrefix: "testdata/notice/",
1593 },
1594 expectedOut: []getMatcher{},
1595 },
1596 {
1597 condition: "notice",
1598 name: "apex_trimmed_private",
1599 roots: []string{"highest.apex.meta_lic"},
1600 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08001601 conditions: compliance.ImpliesPrivate.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -08001602 stripPrefix: "testdata/notice/",
1603 },
1604 expectedOut: []getMatcher{},
1605 },
1606 {
1607 condition: "notice",
1608 name: "apex_trimmed_share_private",
1609 roots: []string{"highest.apex.meta_lic"},
1610 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08001611 conditions: compliance.ImpliesShared.Union(compliance.ImpliesPrivate).AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -08001612 stripPrefix: "testdata/notice/",
1613 },
1614 expectedOut: []getMatcher{},
1615 },
1616 {
1617 condition: "notice",
1618 name: "apex_trimmed_labelled",
1619 roots: []string{"highest.apex.meta_lic"},
1620 ctx: context{stripPrefix: "testdata/notice/", labelConditions: true},
1621 expectedOut: []getMatcher{
1622 matchTarget("bin/bin1.meta_lic", "notice"),
1623 matchTarget("lib/liba.so.meta_lic", "notice"),
1624 matchTarget("lib/libc.a.meta_lic", "notice"),
1625 matchTarget("bin/bin2.meta_lic", "notice"),
1626 matchTarget("highest.apex.meta_lic", "notice"),
1627 matchTarget("lib/libb.so.meta_lic", "notice"),
Bob Badour1ded0a12021-12-03 17:16:14 -08001628 matchResolution(
1629 "bin/bin1.meta_lic",
1630 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001631 "notice"),
1632 matchResolution(
1633 "bin/bin1.meta_lic",
1634 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001635 "notice"),
1636 matchResolution(
1637 "bin/bin1.meta_lic",
1638 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001639 "notice"),
1640 matchResolution(
1641 "bin/bin2.meta_lic",
1642 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001643 "notice"),
1644 matchResolution(
1645 "highest.apex.meta_lic",
1646 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001647 "notice"),
1648 matchResolution(
1649 "highest.apex.meta_lic",
1650 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001651 "notice"),
1652 matchResolution(
1653 "highest.apex.meta_lic",
1654 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001655 "notice"),
1656 matchResolution(
1657 "highest.apex.meta_lic",
1658 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001659 "notice"),
1660 matchResolution(
1661 "highest.apex.meta_lic",
1662 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001663 "notice"),
1664 matchResolution(
1665 "highest.apex.meta_lic",
1666 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001667 "notice"),
1668 matchResolution(
1669 "lib/liba.so.meta_lic",
1670 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001671 "notice"),
1672 matchResolution(
1673 "lib/libb.so.meta_lic",
1674 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001675 "notice"),
1676 },
1677 },
1678 {
1679 condition: "notice",
1680 name: "container",
1681 roots: []string{"container.zip.meta_lic"},
1682 expectedOut: []getMatcher{
1683 matchTarget("testdata/notice/bin/bin1.meta_lic"),
1684 matchTarget("testdata/notice/lib/liba.so.meta_lic"),
1685 matchTarget("testdata/notice/lib/libc.a.meta_lic"),
1686 matchTarget("testdata/notice/bin/bin2.meta_lic"),
1687 matchTarget("testdata/notice/container.zip.meta_lic"),
1688 matchTarget("testdata/notice/lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08001689 matchResolution(
1690 "testdata/notice/bin/bin1.meta_lic",
1691 "testdata/notice/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001692 "notice"),
1693 matchResolution(
1694 "testdata/notice/bin/bin1.meta_lic",
1695 "testdata/notice/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001696 "notice"),
1697 matchResolution(
1698 "testdata/notice/bin/bin1.meta_lic",
1699 "testdata/notice/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001700 "notice"),
1701 matchResolution(
1702 "testdata/notice/bin/bin2.meta_lic",
1703 "testdata/notice/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001704 "notice"),
1705 matchResolution(
1706 "testdata/notice/container.zip.meta_lic",
1707 "testdata/notice/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001708 "notice"),
1709 matchResolution(
1710 "testdata/notice/container.zip.meta_lic",
1711 "testdata/notice/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001712 "notice"),
1713 matchResolution(
1714 "testdata/notice/container.zip.meta_lic",
1715 "testdata/notice/container.zip.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001716 "notice"),
1717 matchResolution(
1718 "testdata/notice/container.zip.meta_lic",
1719 "testdata/notice/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001720 "notice"),
1721 matchResolution(
1722 "testdata/notice/container.zip.meta_lic",
1723 "testdata/notice/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001724 "notice"),
1725 matchResolution(
1726 "testdata/notice/container.zip.meta_lic",
1727 "testdata/notice/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001728 "notice"),
1729 matchResolution(
1730 "testdata/notice/lib/liba.so.meta_lic",
1731 "testdata/notice/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001732 "notice"),
1733 matchResolution(
1734 "testdata/notice/lib/libb.so.meta_lic",
1735 "testdata/notice/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001736 "notice"),
1737 },
1738 },
1739 {
1740 condition: "notice",
1741 name: "application",
1742 roots: []string{"application.meta_lic"},
1743 expectedOut: []getMatcher{
1744 matchTarget("testdata/notice/application.meta_lic"),
1745 matchTarget("testdata/notice/lib/liba.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08001746 matchResolution(
1747 "testdata/notice/application.meta_lic",
1748 "testdata/notice/application.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001749 "notice"),
1750 matchResolution(
1751 "testdata/notice/application.meta_lic",
1752 "testdata/notice/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001753 "notice"),
1754 },
1755 },
1756 {
1757 condition: "notice",
1758 name: "binary",
1759 roots: []string{"bin/bin1.meta_lic"},
1760 expectedOut: []getMatcher{
1761 matchTarget("testdata/notice/bin/bin1.meta_lic"),
1762 matchTarget("testdata/notice/lib/liba.so.meta_lic"),
1763 matchTarget("testdata/notice/lib/libc.a.meta_lic"),
1764 matchResolution(
1765 "testdata/notice/bin/bin1.meta_lic",
1766 "testdata/notice/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001767 "notice"),
1768 matchResolution(
1769 "testdata/notice/bin/bin1.meta_lic",
1770 "testdata/notice/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001771 "notice"),
1772 matchResolution(
1773 "testdata/notice/bin/bin1.meta_lic",
1774 "testdata/notice/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001775 "notice"),
1776 },
1777 },
1778 {
1779 condition: "notice",
1780 name: "library",
1781 roots: []string{"lib/libd.so.meta_lic"},
1782 expectedOut: []getMatcher{
1783 matchTarget("testdata/notice/lib/libd.so.meta_lic"),
1784 matchResolution(
1785 "testdata/notice/lib/libd.so.meta_lic",
1786 "testdata/notice/lib/libd.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001787 "notice"),
1788 },
1789 },
1790 {
1791 condition: "reciprocal",
1792 name: "apex",
1793 roots: []string{"highest.apex.meta_lic"},
1794 expectedOut: []getMatcher{
1795 matchTarget("testdata/reciprocal/bin/bin1.meta_lic"),
1796 matchTarget("testdata/reciprocal/lib/liba.so.meta_lic"),
1797 matchTarget("testdata/reciprocal/lib/libc.a.meta_lic"),
1798 matchTarget("testdata/reciprocal/bin/bin2.meta_lic"),
1799 matchTarget("testdata/reciprocal/highest.apex.meta_lic"),
1800 matchTarget("testdata/reciprocal/lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08001801 matchResolution(
1802 "testdata/reciprocal/bin/bin1.meta_lic",
1803 "testdata/reciprocal/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001804 "notice"),
1805 matchResolution(
1806 "testdata/reciprocal/bin/bin1.meta_lic",
1807 "testdata/reciprocal/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001808 "reciprocal"),
1809 matchResolution(
1810 "testdata/reciprocal/bin/bin1.meta_lic",
1811 "testdata/reciprocal/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001812 "reciprocal"),
1813 matchResolution(
1814 "testdata/reciprocal/bin/bin2.meta_lic",
1815 "testdata/reciprocal/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001816 "notice"),
1817 matchResolution(
1818 "testdata/reciprocal/highest.apex.meta_lic",
1819 "testdata/reciprocal/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001820 "notice"),
1821 matchResolution(
1822 "testdata/reciprocal/highest.apex.meta_lic",
1823 "testdata/reciprocal/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001824 "notice"),
1825 matchResolution(
1826 "testdata/reciprocal/highest.apex.meta_lic",
1827 "testdata/reciprocal/highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001828 "notice"),
1829 matchResolution(
1830 "testdata/reciprocal/highest.apex.meta_lic",
1831 "testdata/reciprocal/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001832 "reciprocal"),
1833 matchResolution(
1834 "testdata/reciprocal/highest.apex.meta_lic",
1835 "testdata/reciprocal/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001836 "notice"),
1837 matchResolution(
1838 "testdata/reciprocal/highest.apex.meta_lic",
1839 "testdata/reciprocal/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001840 "reciprocal"),
1841 matchResolution(
1842 "testdata/reciprocal/lib/liba.so.meta_lic",
1843 "testdata/reciprocal/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001844 "reciprocal"),
1845 matchResolution(
1846 "testdata/reciprocal/lib/libb.so.meta_lic",
1847 "testdata/reciprocal/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001848 "notice"),
1849 },
1850 },
1851 {
1852 condition: "reciprocal",
1853 name: "apex_trimmed",
1854 roots: []string{"highest.apex.meta_lic"},
1855 ctx: context{stripPrefix: "testdata/reciprocal/"},
1856 expectedOut: []getMatcher{
1857 matchTarget("bin/bin1.meta_lic"),
1858 matchTarget("lib/liba.so.meta_lic"),
1859 matchTarget("lib/libc.a.meta_lic"),
1860 matchTarget("bin/bin2.meta_lic"),
1861 matchTarget("highest.apex.meta_lic"),
1862 matchTarget("lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08001863 matchResolution(
1864 "bin/bin1.meta_lic",
1865 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001866 "notice"),
1867 matchResolution(
1868 "bin/bin1.meta_lic",
1869 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001870 "reciprocal"),
1871 matchResolution(
1872 "bin/bin1.meta_lic",
1873 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001874 "reciprocal"),
1875 matchResolution(
1876 "bin/bin2.meta_lic",
1877 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001878 "notice"),
1879 matchResolution(
1880 "highest.apex.meta_lic",
1881 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001882 "notice"),
1883 matchResolution(
1884 "highest.apex.meta_lic",
1885 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001886 "notice"),
1887 matchResolution(
1888 "highest.apex.meta_lic",
1889 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001890 "notice"),
1891 matchResolution(
1892 "highest.apex.meta_lic",
1893 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001894 "reciprocal"),
1895 matchResolution(
1896 "highest.apex.meta_lic",
1897 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001898 "notice"),
1899 matchResolution(
1900 "highest.apex.meta_lic",
1901 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001902 "reciprocal"),
1903 matchResolution(
1904 "lib/liba.so.meta_lic",
1905 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001906 "reciprocal"),
1907 matchResolution(
1908 "lib/libb.so.meta_lic",
1909 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001910 "notice"),
1911 },
1912 },
1913 {
1914 condition: "reciprocal",
1915 name: "apex_trimmed_notice",
1916 roots: []string{"highest.apex.meta_lic"},
1917 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08001918 conditions: []compliance.LicenseCondition{compliance.NoticeCondition},
Bob Badour1ded0a12021-12-03 17:16:14 -08001919 stripPrefix: "testdata/reciprocal/",
1920 },
1921 expectedOut: []getMatcher{
1922 matchTarget("bin/bin1.meta_lic"),
1923 matchTarget("bin/bin2.meta_lic"),
1924 matchTarget("highest.apex.meta_lic"),
1925 matchTarget("lib/libb.so.meta_lic"),
1926 matchResolution(
1927 "bin/bin1.meta_lic",
1928 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001929 "notice"),
1930 matchResolution(
1931 "bin/bin2.meta_lic",
1932 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001933 "notice"),
1934 matchResolution(
1935 "highest.apex.meta_lic",
1936 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001937 "notice"),
1938 matchResolution(
1939 "highest.apex.meta_lic",
1940 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001941 "notice"),
1942 matchResolution(
1943 "highest.apex.meta_lic",
1944 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001945 "notice"),
1946 matchResolution(
1947 "highest.apex.meta_lic",
1948 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001949 "notice"),
1950 matchResolution(
1951 "lib/libb.so.meta_lic",
1952 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001953 "notice"),
1954 },
1955 },
1956 {
1957 condition: "reciprocal",
1958 name: "apex_trimmed_share",
1959 roots: []string{"highest.apex.meta_lic"},
1960 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08001961 conditions: compliance.ImpliesShared.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -08001962 stripPrefix: "testdata/reciprocal/",
1963 },
1964 expectedOut: []getMatcher{
1965 matchTarget("bin/bin1.meta_lic"),
1966 matchTarget("lib/liba.so.meta_lic"),
1967 matchTarget("lib/libc.a.meta_lic"),
1968 matchTarget("highest.apex.meta_lic"),
1969 matchResolution(
1970 "bin/bin1.meta_lic",
1971 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001972 "reciprocal"),
1973 matchResolution(
1974 "bin/bin1.meta_lic",
1975 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001976 "reciprocal"),
1977 matchResolution(
1978 "highest.apex.meta_lic",
1979 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001980 "reciprocal"),
1981 matchResolution(
1982 "highest.apex.meta_lic",
1983 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001984 "reciprocal"),
1985 matchResolution(
1986 "lib/liba.so.meta_lic",
1987 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001988 "reciprocal"),
1989 },
1990 },
1991 {
1992 condition: "reciprocal",
1993 name: "apex_trimmed_private",
1994 roots: []string{"highest.apex.meta_lic"},
1995 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08001996 conditions: compliance.ImpliesPrivate.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -08001997 stripPrefix: "testdata/reciprocal/",
1998 },
1999 expectedOut: []getMatcher{},
2000 },
2001 {
2002 condition: "reciprocal",
2003 name: "apex_trimmed_share_private",
2004 roots: []string{"highest.apex.meta_lic"},
2005 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08002006 conditions: compliance.ImpliesShared.Union(compliance.ImpliesPrivate).AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -08002007 stripPrefix: "testdata/reciprocal/",
2008 },
2009 expectedOut: []getMatcher{
2010 matchTarget("bin/bin1.meta_lic"),
2011 matchTarget("lib/liba.so.meta_lic"),
2012 matchTarget("lib/libc.a.meta_lic"),
2013 matchTarget("highest.apex.meta_lic"),
2014 matchResolution(
2015 "bin/bin1.meta_lic",
2016 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002017 "reciprocal"),
2018 matchResolution(
2019 "bin/bin1.meta_lic",
2020 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002021 "reciprocal"),
2022 matchResolution(
2023 "highest.apex.meta_lic",
2024 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002025 "reciprocal"),
2026 matchResolution(
2027 "highest.apex.meta_lic",
2028 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002029 "reciprocal"),
2030 matchResolution(
2031 "lib/liba.so.meta_lic",
2032 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002033 "reciprocal"),
2034 },
2035 },
2036 {
2037 condition: "reciprocal",
2038 name: "apex_trimmed_labelled",
2039 roots: []string{"highest.apex.meta_lic"},
2040 ctx: context{stripPrefix: "testdata/reciprocal/", labelConditions: true},
2041 expectedOut: []getMatcher{
2042 matchTarget("bin/bin1.meta_lic", "notice"),
2043 matchTarget("lib/liba.so.meta_lic", "reciprocal"),
2044 matchTarget("lib/libc.a.meta_lic", "reciprocal"),
2045 matchTarget("bin/bin2.meta_lic", "notice"),
2046 matchTarget("highest.apex.meta_lic", "notice"),
2047 matchTarget("lib/libb.so.meta_lic", "notice"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002048 matchResolution(
2049 "bin/bin1.meta_lic",
2050 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002051 "notice"),
2052 matchResolution(
2053 "bin/bin1.meta_lic",
2054 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002055 "reciprocal"),
2056 matchResolution(
2057 "bin/bin1.meta_lic",
2058 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002059 "reciprocal"),
2060 matchResolution(
2061 "bin/bin2.meta_lic",
2062 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002063 "notice"),
2064 matchResolution(
2065 "highest.apex.meta_lic",
2066 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002067 "notice"),
2068 matchResolution(
2069 "highest.apex.meta_lic",
2070 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002071 "notice"),
2072 matchResolution(
2073 "highest.apex.meta_lic",
2074 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002075 "notice"),
2076 matchResolution(
2077 "highest.apex.meta_lic",
2078 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002079 "reciprocal"),
2080 matchResolution(
2081 "highest.apex.meta_lic",
2082 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002083 "notice"),
2084 matchResolution(
2085 "highest.apex.meta_lic",
2086 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002087 "reciprocal"),
2088 matchResolution(
2089 "lib/liba.so.meta_lic",
2090 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002091 "reciprocal"),
2092 matchResolution(
2093 "lib/libb.so.meta_lic",
2094 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002095 "notice"),
2096 },
2097 },
2098 {
2099 condition: "reciprocal",
2100 name: "container",
2101 roots: []string{"container.zip.meta_lic"},
2102 expectedOut: []getMatcher{
2103 matchTarget("testdata/reciprocal/bin/bin1.meta_lic"),
2104 matchTarget("testdata/reciprocal/lib/liba.so.meta_lic"),
2105 matchTarget("testdata/reciprocal/lib/libc.a.meta_lic"),
2106 matchTarget("testdata/reciprocal/bin/bin2.meta_lic"),
2107 matchTarget("testdata/reciprocal/container.zip.meta_lic"),
2108 matchTarget("testdata/reciprocal/lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002109 matchResolution(
2110 "testdata/reciprocal/bin/bin1.meta_lic",
2111 "testdata/reciprocal/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002112 "notice"),
2113 matchResolution(
2114 "testdata/reciprocal/bin/bin1.meta_lic",
2115 "testdata/reciprocal/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002116 "reciprocal"),
2117 matchResolution(
2118 "testdata/reciprocal/bin/bin1.meta_lic",
2119 "testdata/reciprocal/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002120 "reciprocal"),
2121 matchResolution(
2122 "testdata/reciprocal/bin/bin2.meta_lic",
2123 "testdata/reciprocal/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002124 "notice"),
2125 matchResolution(
2126 "testdata/reciprocal/container.zip.meta_lic",
2127 "testdata/reciprocal/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002128 "notice"),
2129 matchResolution(
2130 "testdata/reciprocal/container.zip.meta_lic",
2131 "testdata/reciprocal/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002132 "notice"),
2133 matchResolution(
2134 "testdata/reciprocal/container.zip.meta_lic",
2135 "testdata/reciprocal/container.zip.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002136 "notice"),
2137 matchResolution(
2138 "testdata/reciprocal/container.zip.meta_lic",
2139 "testdata/reciprocal/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002140 "reciprocal"),
2141 matchResolution(
2142 "testdata/reciprocal/container.zip.meta_lic",
2143 "testdata/reciprocal/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002144 "notice"),
2145 matchResolution(
2146 "testdata/reciprocal/container.zip.meta_lic",
2147 "testdata/reciprocal/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002148 "reciprocal"),
2149 matchResolution(
2150 "testdata/reciprocal/lib/liba.so.meta_lic",
2151 "testdata/reciprocal/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002152 "reciprocal"),
2153 matchResolution(
2154 "testdata/reciprocal/lib/libb.so.meta_lic",
2155 "testdata/reciprocal/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002156 "notice"),
2157 },
2158 },
2159 {
2160 condition: "reciprocal",
2161 name: "application",
2162 roots: []string{"application.meta_lic"},
2163 expectedOut: []getMatcher{
2164 matchTarget("testdata/reciprocal/application.meta_lic"),
2165 matchTarget("testdata/reciprocal/lib/liba.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002166 matchResolution(
2167 "testdata/reciprocal/application.meta_lic",
2168 "testdata/reciprocal/application.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002169 "notice"),
2170 matchResolution(
2171 "testdata/reciprocal/application.meta_lic",
2172 "testdata/reciprocal/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002173 "reciprocal"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002174 },
2175 },
2176 {
2177 condition: "reciprocal",
2178 name: "binary",
2179 roots: []string{"bin/bin1.meta_lic"},
2180 expectedOut: []getMatcher{
2181 matchTarget("testdata/reciprocal/bin/bin1.meta_lic"),
2182 matchTarget("testdata/reciprocal/lib/liba.so.meta_lic"),
2183 matchTarget("testdata/reciprocal/lib/libc.a.meta_lic"),
2184 matchResolution(
2185 "testdata/reciprocal/bin/bin1.meta_lic",
2186 "testdata/reciprocal/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002187 "notice"),
2188 matchResolution(
2189 "testdata/reciprocal/bin/bin1.meta_lic",
2190 "testdata/reciprocal/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002191 "reciprocal"),
2192 matchResolution(
2193 "testdata/reciprocal/bin/bin1.meta_lic",
2194 "testdata/reciprocal/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002195 "reciprocal"),
2196 },
2197 },
2198 {
2199 condition: "reciprocal",
2200 name: "library",
2201 roots: []string{"lib/libd.so.meta_lic"},
2202 expectedOut: []getMatcher{
2203 matchTarget("testdata/reciprocal/lib/libd.so.meta_lic"),
2204 matchResolution(
2205 "testdata/reciprocal/lib/libd.so.meta_lic",
2206 "testdata/reciprocal/lib/libd.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002207 "notice"),
2208 },
2209 },
2210 {
2211 condition: "restricted",
2212 name: "apex",
2213 roots: []string{"highest.apex.meta_lic"},
2214 expectedOut: []getMatcher{
2215 matchTarget("testdata/restricted/bin/bin1.meta_lic"),
2216 matchTarget("testdata/restricted/lib/liba.so.meta_lic"),
2217 matchTarget("testdata/restricted/lib/libc.a.meta_lic"),
2218 matchTarget("testdata/restricted/bin/bin2.meta_lic"),
2219 matchTarget("testdata/restricted/lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002220 matchTarget("testdata/restricted/highest.apex.meta_lic"),
2221 matchResolution(
2222 "testdata/restricted/bin/bin1.meta_lic",
2223 "testdata/restricted/bin/bin1.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002224 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002225 "notice"),
2226 matchResolution(
2227 "testdata/restricted/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002228 "testdata/restricted/lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002229 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002230 matchResolution(
2231 "testdata/restricted/bin/bin1.meta_lic",
2232 "testdata/restricted/lib/libc.a.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002233 "reciprocal",
2234 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002235 matchResolution(
2236 "testdata/restricted/bin/bin2.meta_lic",
2237 "testdata/restricted/bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002238 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002239 "notice"),
2240 matchResolution(
2241 "testdata/restricted/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002242 "testdata/restricted/lib/libb.so.meta_lic",
2243 "restricted"),
2244 matchResolution(
2245 "testdata/restricted/highest.apex.meta_lic",
2246 "testdata/restricted/bin/bin1.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002247 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002248 "notice"),
2249 matchResolution(
2250 "testdata/restricted/highest.apex.meta_lic",
2251 "testdata/restricted/bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002252 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002253 "notice"),
2254 matchResolution(
2255 "testdata/restricted/highest.apex.meta_lic",
2256 "testdata/restricted/highest.apex.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002257 "restricted",
2258 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002259 "notice"),
Bob Badour103eb0f2022-01-10 13:50:57 -08002260 matchResolution(
2261 "testdata/restricted/highest.apex.meta_lic",
2262 "testdata/restricted/lib/liba.so.meta_lic",
2263 "restricted_allows_dynamic_linking"),
2264 matchResolution(
2265 "testdata/restricted/highest.apex.meta_lic",
2266 "testdata/restricted/lib/libb.so.meta_lic",
2267 "restricted"),
2268 matchResolution(
2269 "testdata/restricted/highest.apex.meta_lic",
2270 "testdata/restricted/lib/libc.a.meta_lic",
2271 "reciprocal",
2272 "restricted_allows_dynamic_linking"),
2273 matchResolution(
2274 "testdata/restricted/lib/liba.so.meta_lic",
2275 "testdata/restricted/lib/liba.so.meta_lic",
2276 "restricted_allows_dynamic_linking"),
2277 matchResolution(
2278 "testdata/restricted/lib/libb.so.meta_lic",
2279 "testdata/restricted/lib/libb.so.meta_lic",
2280 "restricted"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002281 },
2282 },
2283 {
2284 condition: "restricted",
2285 name: "apex_trimmed",
2286 roots: []string{"highest.apex.meta_lic"},
2287 ctx: context{stripPrefix: "testdata/restricted/"},
2288 expectedOut: []getMatcher{
2289 matchTarget("bin/bin1.meta_lic"),
2290 matchTarget("lib/liba.so.meta_lic"),
2291 matchTarget("lib/libc.a.meta_lic"),
2292 matchTarget("bin/bin2.meta_lic"),
2293 matchTarget("lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002294 matchTarget("highest.apex.meta_lic"),
2295 matchResolution(
2296 "bin/bin1.meta_lic",
2297 "bin/bin1.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002298 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002299 "notice"),
2300 matchResolution(
2301 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002302 "lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002303 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002304 matchResolution(
2305 "bin/bin1.meta_lic",
2306 "lib/libc.a.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002307 "reciprocal",
2308 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002309 matchResolution(
2310 "bin/bin2.meta_lic",
2311 "bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002312 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002313 "notice"),
2314 matchResolution(
2315 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002316 "lib/libb.so.meta_lic",
2317 "restricted"),
2318 matchResolution(
2319 "highest.apex.meta_lic",
2320 "bin/bin1.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002321 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002322 "notice"),
2323 matchResolution(
2324 "highest.apex.meta_lic",
2325 "bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002326 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002327 "notice"),
2328 matchResolution(
2329 "highest.apex.meta_lic",
2330 "highest.apex.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002331 "restricted",
2332 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002333 "notice"),
Bob Badour103eb0f2022-01-10 13:50:57 -08002334 matchResolution(
2335 "highest.apex.meta_lic",
2336 "lib/liba.so.meta_lic",
2337 "restricted_allows_dynamic_linking"),
2338 matchResolution(
2339 "highest.apex.meta_lic",
2340 "lib/libb.so.meta_lic",
2341 "restricted"),
2342 matchResolution(
2343 "highest.apex.meta_lic",
2344 "lib/libc.a.meta_lic",
2345 "reciprocal",
2346 "restricted_allows_dynamic_linking"),
2347 matchResolution(
2348 "lib/liba.so.meta_lic",
2349 "lib/liba.so.meta_lic",
2350 "restricted_allows_dynamic_linking"),
2351 matchResolution(
2352 "lib/libb.so.meta_lic",
2353 "lib/libb.so.meta_lic",
2354 "restricted"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002355 },
2356 },
2357 {
2358 condition: "restricted",
2359 name: "apex_trimmed_notice",
2360 roots: []string{"highest.apex.meta_lic"},
2361 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08002362 conditions: []compliance.LicenseCondition{compliance.NoticeCondition},
Bob Badour1ded0a12021-12-03 17:16:14 -08002363 stripPrefix: "testdata/restricted/",
2364 },
2365 expectedOut: []getMatcher{
2366 matchTarget("bin/bin1.meta_lic"),
2367 matchTarget("bin/bin2.meta_lic"),
2368 matchTarget("highest.apex.meta_lic"),
2369 matchResolution(
2370 "bin/bin1.meta_lic",
2371 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002372 "notice"),
2373 matchResolution(
2374 "bin/bin2.meta_lic",
2375 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002376 "notice"),
2377 matchResolution(
2378 "highest.apex.meta_lic",
2379 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002380 "notice"),
2381 matchResolution(
2382 "highest.apex.meta_lic",
2383 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002384 "notice"),
2385 matchResolution(
2386 "highest.apex.meta_lic",
2387 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002388 "notice"),
2389 },
2390 },
2391 {
2392 condition: "restricted",
2393 name: "apex_trimmed_share",
2394 roots: []string{"highest.apex.meta_lic"},
2395 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08002396 conditions: compliance.ImpliesShared.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -08002397 stripPrefix: "testdata/restricted/",
2398 },
2399 expectedOut: []getMatcher{
2400 matchTarget("bin/bin1.meta_lic"),
2401 matchTarget("lib/liba.so.meta_lic"),
2402 matchTarget("lib/libc.a.meta_lic"),
2403 matchTarget("bin/bin2.meta_lic"),
2404 matchTarget("lib/libb.so.meta_lic"),
2405 matchTarget("highest.apex.meta_lic"),
2406 matchResolution(
2407 "bin/bin1.meta_lic",
2408 "bin/bin1.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002409 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002410 matchResolution(
2411 "bin/bin1.meta_lic",
2412 "lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002413 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002414 matchResolution(
2415 "bin/bin1.meta_lic",
2416 "lib/libc.a.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002417 "reciprocal",
2418 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002419 matchResolution(
2420 "bin/bin2.meta_lic",
2421 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002422 "restricted"),
2423 matchResolution(
2424 "bin/bin2.meta_lic",
2425 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002426 "restricted"),
2427 matchResolution(
2428 "highest.apex.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002429 "bin/bin1.meta_lic",
2430 "restricted_allows_dynamic_linking"),
2431 matchResolution(
Bob Badour1ded0a12021-12-03 17:16:14 -08002432 "highest.apex.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002433 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002434 "restricted"),
2435 matchResolution(
2436 "highest.apex.meta_lic",
2437 "highest.apex.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002438 "restricted",
2439 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002440 matchResolution(
2441 "highest.apex.meta_lic",
2442 "lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002443 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002444 matchResolution(
2445 "highest.apex.meta_lic",
2446 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002447 "restricted"),
2448 matchResolution(
2449 "highest.apex.meta_lic",
2450 "lib/libc.a.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002451 "reciprocal",
2452 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002453 matchResolution(
2454 "lib/liba.so.meta_lic",
2455 "lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002456 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002457 matchResolution(
2458 "lib/libb.so.meta_lic",
2459 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002460 "restricted"),
2461 },
2462 },
2463 {
2464 condition: "restricted",
2465 name: "apex_trimmed_private",
2466 roots: []string{"highest.apex.meta_lic"},
2467 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08002468 conditions: compliance.ImpliesPrivate.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -08002469 stripPrefix: "testdata/restricted/",
2470 },
2471 expectedOut: []getMatcher{},
2472 },
2473 {
2474 condition: "restricted",
2475 name: "apex_trimmed_share_private",
2476 roots: []string{"highest.apex.meta_lic"},
2477 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08002478 conditions: compliance.ImpliesShared.Union(compliance.ImpliesPrivate).AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -08002479 stripPrefix: "testdata/restricted/",
2480 },
2481 expectedOut: []getMatcher{
2482 matchTarget("bin/bin1.meta_lic"),
2483 matchTarget("lib/liba.so.meta_lic"),
2484 matchTarget("lib/libc.a.meta_lic"),
2485 matchTarget("bin/bin2.meta_lic"),
2486 matchTarget("lib/libb.so.meta_lic"),
2487 matchTarget("highest.apex.meta_lic"),
2488 matchResolution(
2489 "bin/bin1.meta_lic",
2490 "bin/bin1.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002491 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002492 matchResolution(
2493 "bin/bin1.meta_lic",
2494 "lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002495 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002496 matchResolution(
2497 "bin/bin1.meta_lic",
2498 "lib/libc.a.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002499 "reciprocal",
2500 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002501 matchResolution(
2502 "bin/bin2.meta_lic",
2503 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002504 "restricted"),
2505 matchResolution(
2506 "bin/bin2.meta_lic",
2507 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002508 "restricted"),
2509 matchResolution(
2510 "highest.apex.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002511 "bin/bin1.meta_lic",
2512 "restricted_allows_dynamic_linking"),
2513 matchResolution(
Bob Badour1ded0a12021-12-03 17:16:14 -08002514 "highest.apex.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002515 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002516 "restricted"),
2517 matchResolution(
2518 "highest.apex.meta_lic",
2519 "highest.apex.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002520 "restricted",
2521 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002522 matchResolution(
2523 "highest.apex.meta_lic",
2524 "lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002525 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002526 matchResolution(
2527 "highest.apex.meta_lic",
2528 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002529 "restricted"),
2530 matchResolution(
2531 "highest.apex.meta_lic",
2532 "lib/libc.a.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002533 "reciprocal",
2534 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002535 matchResolution(
2536 "lib/liba.so.meta_lic",
2537 "lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002538 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002539 matchResolution(
2540 "lib/libb.so.meta_lic",
2541 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002542 "restricted"),
2543 },
2544 },
2545 {
2546 condition: "restricted",
2547 name: "apex_trimmed_labelled",
2548 roots: []string{"highest.apex.meta_lic"},
2549 ctx: context{stripPrefix: "testdata/restricted/", labelConditions: true},
2550 expectedOut: []getMatcher{
2551 matchTarget("bin/bin1.meta_lic", "notice"),
Bob Badour103eb0f2022-01-10 13:50:57 -08002552 matchTarget("lib/liba.so.meta_lic", "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002553 matchTarget("lib/libc.a.meta_lic", "reciprocal"),
2554 matchTarget("bin/bin2.meta_lic", "notice"),
2555 matchTarget("lib/libb.so.meta_lic", "restricted"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002556 matchTarget("highest.apex.meta_lic", "notice"),
2557 matchResolution(
2558 "bin/bin1.meta_lic",
2559 "bin/bin1.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002560 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002561 "notice"),
2562 matchResolution(
2563 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002564 "lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002565 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002566 matchResolution(
2567 "bin/bin1.meta_lic",
2568 "lib/libc.a.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002569 "reciprocal",
2570 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002571 matchResolution(
2572 "bin/bin2.meta_lic",
2573 "bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002574 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002575 "notice"),
2576 matchResolution(
2577 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002578 "lib/libb.so.meta_lic",
2579 "restricted"),
2580 matchResolution(
2581 "highest.apex.meta_lic",
2582 "bin/bin1.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002583 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002584 "notice"),
2585 matchResolution(
2586 "highest.apex.meta_lic",
2587 "bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002588 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002589 "notice"),
2590 matchResolution(
2591 "highest.apex.meta_lic",
2592 "highest.apex.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002593 "restricted",
2594 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002595 "notice"),
Bob Badour103eb0f2022-01-10 13:50:57 -08002596 matchResolution(
2597 "highest.apex.meta_lic",
2598 "lib/liba.so.meta_lic",
2599 "restricted_allows_dynamic_linking"),
2600 matchResolution(
2601 "highest.apex.meta_lic",
2602 "lib/libb.so.meta_lic",
2603 "restricted"),
2604 matchResolution(
2605 "highest.apex.meta_lic",
2606 "lib/libc.a.meta_lic",
2607 "reciprocal",
2608 "restricted_allows_dynamic_linking"),
2609 matchResolution(
2610 "lib/liba.so.meta_lic",
2611 "lib/liba.so.meta_lic",
2612 "restricted_allows_dynamic_linking"),
2613 matchResolution(
2614 "lib/libb.so.meta_lic",
2615 "lib/libb.so.meta_lic",
2616 "restricted"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002617 },
2618 },
2619 {
2620 condition: "restricted",
2621 name: "container",
2622 roots: []string{"container.zip.meta_lic"},
2623 expectedOut: []getMatcher{
2624 matchTarget("testdata/restricted/bin/bin1.meta_lic"),
2625 matchTarget("testdata/restricted/lib/liba.so.meta_lic"),
2626 matchTarget("testdata/restricted/lib/libc.a.meta_lic"),
2627 matchTarget("testdata/restricted/bin/bin2.meta_lic"),
2628 matchTarget("testdata/restricted/lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002629 matchTarget("testdata/restricted/container.zip.meta_lic"),
2630 matchResolution(
2631 "testdata/restricted/bin/bin1.meta_lic",
2632 "testdata/restricted/bin/bin1.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002633 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002634 "notice"),
2635 matchResolution(
2636 "testdata/restricted/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002637 "testdata/restricted/lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002638 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002639 matchResolution(
2640 "testdata/restricted/bin/bin1.meta_lic",
2641 "testdata/restricted/lib/libc.a.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002642 "reciprocal",
2643 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002644 matchResolution(
2645 "testdata/restricted/bin/bin2.meta_lic",
2646 "testdata/restricted/bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002647 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002648 "notice"),
2649 matchResolution(
2650 "testdata/restricted/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002651 "testdata/restricted/lib/libb.so.meta_lic",
2652 "restricted"),
2653 matchResolution(
2654 "testdata/restricted/container.zip.meta_lic",
2655 "testdata/restricted/bin/bin1.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002656 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002657 "notice"),
2658 matchResolution(
2659 "testdata/restricted/container.zip.meta_lic",
2660 "testdata/restricted/bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002661 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002662 "notice"),
2663 matchResolution(
2664 "testdata/restricted/container.zip.meta_lic",
2665 "testdata/restricted/container.zip.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002666 "restricted",
2667 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002668 "notice"),
Bob Badour103eb0f2022-01-10 13:50:57 -08002669 matchResolution(
2670 "testdata/restricted/container.zip.meta_lic",
2671 "testdata/restricted/lib/liba.so.meta_lic",
2672 "restricted_allows_dynamic_linking"),
2673 matchResolution(
2674 "testdata/restricted/container.zip.meta_lic",
2675 "testdata/restricted/lib/libb.so.meta_lic",
2676 "restricted"),
2677 matchResolution(
2678 "testdata/restricted/container.zip.meta_lic",
2679 "testdata/restricted/lib/libc.a.meta_lic",
2680 "reciprocal",
2681 "restricted_allows_dynamic_linking"),
2682 matchResolution(
2683 "testdata/restricted/lib/liba.so.meta_lic",
2684 "testdata/restricted/lib/liba.so.meta_lic",
2685 "restricted_allows_dynamic_linking"),
2686 matchResolution(
2687 "testdata/restricted/lib/libb.so.meta_lic",
2688 "testdata/restricted/lib/libb.so.meta_lic",
2689 "restricted"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002690 },
2691 },
2692 {
2693 condition: "restricted",
2694 name: "application",
2695 roots: []string{"application.meta_lic"},
2696 expectedOut: []getMatcher{
2697 matchTarget("testdata/restricted/application.meta_lic"),
2698 matchTarget("testdata/restricted/lib/liba.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002699 matchResolution(
2700 "testdata/restricted/application.meta_lic",
2701 "testdata/restricted/application.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002702 "restricted",
2703 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002704 "notice"),
2705 matchResolution(
2706 "testdata/restricted/application.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002707 "testdata/restricted/lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002708 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002709 "restricted"),
2710 },
2711 },
2712 {
2713 condition: "restricted",
2714 name: "binary",
2715 roots: []string{"bin/bin1.meta_lic"},
2716 expectedOut: []getMatcher{
2717 matchTarget("testdata/restricted/bin/bin1.meta_lic"),
2718 matchTarget("testdata/restricted/lib/liba.so.meta_lic"),
2719 matchTarget("testdata/restricted/lib/libc.a.meta_lic"),
2720 matchResolution(
2721 "testdata/restricted/bin/bin1.meta_lic",
2722 "testdata/restricted/bin/bin1.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002723 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002724 "notice"),
2725 matchResolution(
2726 "testdata/restricted/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002727 "testdata/restricted/lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002728 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002729 matchResolution(
2730 "testdata/restricted/bin/bin1.meta_lic",
2731 "testdata/restricted/lib/libc.a.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002732 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002733 "reciprocal"),
2734 },
2735 },
2736 {
2737 condition: "restricted",
2738 name: "library",
2739 roots: []string{"lib/libd.so.meta_lic"},
2740 expectedOut: []getMatcher{
2741 matchTarget("testdata/restricted/lib/libd.so.meta_lic"),
2742 matchResolution(
2743 "testdata/restricted/lib/libd.so.meta_lic",
2744 "testdata/restricted/lib/libd.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002745 "notice"),
2746 },
2747 },
2748 {
2749 condition: "proprietary",
2750 name: "apex",
2751 roots: []string{"highest.apex.meta_lic"},
2752 expectedOut: []getMatcher{
2753 matchTarget("testdata/proprietary/bin/bin1.meta_lic"),
2754 matchTarget("testdata/proprietary/lib/liba.so.meta_lic"),
2755 matchTarget("testdata/proprietary/lib/libc.a.meta_lic"),
2756 matchTarget("testdata/proprietary/bin/bin2.meta_lic"),
2757 matchTarget("testdata/proprietary/lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002758 matchTarget("testdata/proprietary/highest.apex.meta_lic"),
2759 matchResolution(
2760 "testdata/proprietary/bin/bin1.meta_lic",
2761 "testdata/proprietary/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002762 "notice"),
2763 matchResolution(
2764 "testdata/proprietary/bin/bin1.meta_lic",
2765 "testdata/proprietary/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002766 "by_exception_only",
2767 "proprietary"),
2768 matchResolution(
2769 "testdata/proprietary/bin/bin1.meta_lic",
2770 "testdata/proprietary/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002771 "by_exception_only",
2772 "proprietary"),
2773 matchResolution(
2774 "testdata/proprietary/bin/bin2.meta_lic",
2775 "testdata/proprietary/bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002776 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002777 "by_exception_only",
2778 "proprietary"),
2779 matchResolution(
2780 "testdata/proprietary/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002781 "testdata/proprietary/lib/libb.so.meta_lic",
2782 "restricted"),
2783 matchResolution(
2784 "testdata/proprietary/highest.apex.meta_lic",
2785 "testdata/proprietary/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002786 "notice"),
2787 matchResolution(
2788 "testdata/proprietary/highest.apex.meta_lic",
2789 "testdata/proprietary/bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002790 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002791 "by_exception_only",
2792 "proprietary"),
2793 matchResolution(
2794 "testdata/proprietary/highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002795 "testdata/proprietary/highest.apex.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002796 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002797 "notice"),
2798 matchResolution(
2799 "testdata/proprietary/highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002800 "testdata/proprietary/lib/liba.so.meta_lic",
2801 "by_exception_only",
2802 "proprietary"),
2803 matchResolution(
2804 "testdata/proprietary/highest.apex.meta_lic",
2805 "testdata/proprietary/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002806 "restricted"),
2807 matchResolution(
2808 "testdata/proprietary/highest.apex.meta_lic",
2809 "testdata/proprietary/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002810 "by_exception_only",
2811 "proprietary"),
2812 matchResolution(
Bob Badour1ded0a12021-12-03 17:16:14 -08002813 "testdata/proprietary/lib/liba.so.meta_lic",
2814 "testdata/proprietary/lib/liba.so.meta_lic",
2815 "by_exception_only",
2816 "proprietary"),
2817 matchResolution(
2818 "testdata/proprietary/lib/libb.so.meta_lic",
2819 "testdata/proprietary/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002820 "restricted"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002821 },
2822 },
2823 {
2824 condition: "proprietary",
2825 name: "apex_trimmed",
2826 roots: []string{"highest.apex.meta_lic"},
2827 ctx: context{stripPrefix: "testdata/proprietary/"},
2828 expectedOut: []getMatcher{
2829 matchTarget("bin/bin1.meta_lic"),
2830 matchTarget("lib/liba.so.meta_lic"),
2831 matchTarget("lib/libc.a.meta_lic"),
2832 matchTarget("bin/bin2.meta_lic"),
2833 matchTarget("lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002834 matchTarget("highest.apex.meta_lic"),
2835 matchResolution(
2836 "bin/bin1.meta_lic",
2837 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002838 "notice"),
2839 matchResolution(
2840 "bin/bin1.meta_lic",
2841 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002842 "by_exception_only",
2843 "proprietary"),
2844 matchResolution(
2845 "bin/bin1.meta_lic",
2846 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002847 "by_exception_only",
2848 "proprietary"),
2849 matchResolution(
2850 "bin/bin2.meta_lic",
2851 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002852 "by_exception_only",
Bob Badour103eb0f2022-01-10 13:50:57 -08002853 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002854 "proprietary"),
2855 matchResolution(
2856 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002857 "lib/libb.so.meta_lic",
2858 "restricted"),
2859 matchResolution(
2860 "highest.apex.meta_lic",
2861 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002862 "notice"),
2863 matchResolution(
2864 "highest.apex.meta_lic",
2865 "bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002866 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002867 "by_exception_only",
2868 "proprietary"),
2869 matchResolution(
2870 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002871 "highest.apex.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002872 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002873 "notice"),
2874 matchResolution(
2875 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002876 "lib/liba.so.meta_lic",
2877 "by_exception_only",
2878 "proprietary"),
2879 matchResolution(
2880 "highest.apex.meta_lic",
2881 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002882 "restricted"),
2883 matchResolution(
2884 "highest.apex.meta_lic",
2885 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002886 "by_exception_only",
2887 "proprietary"),
2888 matchResolution(
Bob Badour1ded0a12021-12-03 17:16:14 -08002889 "lib/liba.so.meta_lic",
2890 "lib/liba.so.meta_lic",
2891 "by_exception_only",
2892 "proprietary"),
2893 matchResolution(
2894 "lib/libb.so.meta_lic",
2895 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002896 "restricted"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002897 },
2898 },
2899 {
2900 condition: "proprietary",
2901 name: "apex_trimmed_notice",
2902 roots: []string{"highest.apex.meta_lic"},
2903 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08002904 conditions: []compliance.LicenseCondition{compliance.NoticeCondition},
Bob Badour1ded0a12021-12-03 17:16:14 -08002905 stripPrefix: "testdata/proprietary/",
2906 },
2907 expectedOut: []getMatcher{
2908 matchTarget("bin/bin1.meta_lic"),
2909 matchTarget("highest.apex.meta_lic"),
2910 matchResolution(
2911 "bin/bin1.meta_lic",
2912 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002913 "notice"),
2914 matchResolution(
2915 "highest.apex.meta_lic",
2916 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002917 "notice"),
2918 matchResolution(
2919 "highest.apex.meta_lic",
2920 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002921 "notice"),
2922 },
2923 },
2924 {
2925 condition: "proprietary",
2926 name: "apex_trimmed_share",
2927 roots: []string{"highest.apex.meta_lic"},
2928 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08002929 conditions: compliance.ImpliesShared.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -08002930 stripPrefix: "testdata/proprietary/",
2931 },
2932 expectedOut: []getMatcher{
2933 matchTarget("bin/bin2.meta_lic"),
2934 matchTarget("lib/libb.so.meta_lic"),
2935 matchTarget("highest.apex.meta_lic"),
2936 matchResolution(
2937 "bin/bin2.meta_lic",
2938 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002939 "restricted"),
2940 matchResolution(
2941 "bin/bin2.meta_lic",
2942 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002943 "restricted"),
2944 matchResolution(
2945 "highest.apex.meta_lic",
2946 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002947 "restricted"),
2948 matchResolution(
2949 "highest.apex.meta_lic",
2950 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002951 "restricted"),
2952 matchResolution(
2953 "highest.apex.meta_lic",
2954 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002955 "restricted"),
2956 matchResolution(
2957 "lib/libb.so.meta_lic",
2958 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002959 "restricted"),
2960 },
2961 },
2962 {
2963 condition: "proprietary",
2964 name: "apex_trimmed_private",
2965 roots: []string{"highest.apex.meta_lic"},
2966 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08002967 conditions: compliance.ImpliesPrivate.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -08002968 stripPrefix: "testdata/proprietary/",
2969 },
2970 expectedOut: []getMatcher{
2971 matchTarget("bin/bin1.meta_lic"),
2972 matchTarget("lib/liba.so.meta_lic"),
2973 matchTarget("lib/libc.a.meta_lic"),
2974 matchTarget("bin/bin2.meta_lic"),
2975 matchTarget("highest.apex.meta_lic"),
2976 matchResolution(
2977 "bin/bin1.meta_lic",
2978 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002979 "proprietary"),
2980 matchResolution(
2981 "bin/bin1.meta_lic",
2982 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002983 "proprietary"),
2984 matchResolution(
2985 "bin/bin2.meta_lic",
2986 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002987 "proprietary"),
2988 matchResolution(
2989 "highest.apex.meta_lic",
2990 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002991 "proprietary"),
2992 matchResolution(
2993 "highest.apex.meta_lic",
2994 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002995 "proprietary"),
2996 matchResolution(
2997 "highest.apex.meta_lic",
2998 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002999 "proprietary"),
3000 matchResolution(
3001 "lib/liba.so.meta_lic",
3002 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003003 "proprietary"),
3004 },
3005 },
3006 {
3007 condition: "proprietary",
3008 name: "apex_trimmed_share_private",
3009 roots: []string{"highest.apex.meta_lic"},
3010 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08003011 conditions: compliance.ImpliesShared.Union(compliance.ImpliesPrivate).AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -08003012 stripPrefix: "testdata/proprietary/",
3013 },
3014 expectedOut: []getMatcher{
3015 matchTarget("bin/bin1.meta_lic"),
3016 matchTarget("lib/liba.so.meta_lic"),
3017 matchTarget("lib/libc.a.meta_lic"),
3018 matchTarget("bin/bin2.meta_lic"),
3019 matchTarget("lib/libb.so.meta_lic"),
3020 matchTarget("highest.apex.meta_lic"),
3021 matchResolution(
3022 "bin/bin1.meta_lic",
3023 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003024 "proprietary"),
3025 matchResolution(
3026 "bin/bin1.meta_lic",
3027 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003028 "proprietary"),
3029 matchResolution(
3030 "bin/bin2.meta_lic",
3031 "bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08003032 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08003033 "proprietary"),
3034 matchResolution(
3035 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003036 "lib/libb.so.meta_lic",
3037 "restricted"),
3038 matchResolution(
3039 "highest.apex.meta_lic",
3040 "bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08003041 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08003042 "proprietary"),
3043 matchResolution(
3044 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003045 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003046 "restricted"),
3047 matchResolution(
3048 "highest.apex.meta_lic",
3049 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003050 "proprietary"),
3051 matchResolution(
3052 "highest.apex.meta_lic",
3053 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003054 "restricted"),
3055 matchResolution(
3056 "highest.apex.meta_lic",
3057 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003058 "proprietary"),
3059 matchResolution(
3060 "lib/liba.so.meta_lic",
3061 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003062 "proprietary"),
3063 matchResolution(
3064 "lib/libb.so.meta_lic",
3065 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003066 "restricted"),
3067 },
3068 },
3069 {
3070 condition: "proprietary",
3071 name: "apex_trimmed_labelled",
3072 roots: []string{"highest.apex.meta_lic"},
3073 ctx: context{stripPrefix: "testdata/proprietary/", labelConditions: true},
3074 expectedOut: []getMatcher{
3075 matchTarget("bin/bin1.meta_lic", "notice"),
3076 matchTarget("lib/liba.so.meta_lic", "by_exception_only", "proprietary"),
3077 matchTarget("lib/libc.a.meta_lic", "by_exception_only", "proprietary"),
3078 matchTarget("bin/bin2.meta_lic", "by_exception_only", "proprietary"),
3079 matchTarget("lib/libb.so.meta_lic", "restricted"),
Bob Badour1ded0a12021-12-03 17:16:14 -08003080 matchTarget("highest.apex.meta_lic", "notice"),
3081 matchResolution(
3082 "bin/bin1.meta_lic",
3083 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003084 "notice"),
3085 matchResolution(
3086 "bin/bin1.meta_lic",
3087 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003088 "by_exception_only",
3089 "proprietary"),
3090 matchResolution(
3091 "bin/bin1.meta_lic",
3092 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003093 "by_exception_only",
3094 "proprietary"),
3095 matchResolution(
3096 "bin/bin2.meta_lic",
3097 "bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08003098 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08003099 "by_exception_only",
3100 "proprietary"),
3101 matchResolution(
3102 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003103 "lib/libb.so.meta_lic",
3104 "restricted"),
3105 matchResolution(
3106 "highest.apex.meta_lic",
3107 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003108 "notice"),
3109 matchResolution(
3110 "highest.apex.meta_lic",
3111 "bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08003112 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08003113 "by_exception_only",
3114 "proprietary"),
3115 matchResolution(
3116 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003117 "highest.apex.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08003118 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08003119 "notice"),
3120 matchResolution(
3121 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003122 "lib/liba.so.meta_lic",
3123 "by_exception_only",
3124 "proprietary"),
3125 matchResolution(
3126 "highest.apex.meta_lic",
3127 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003128 "restricted"),
3129 matchResolution(
3130 "highest.apex.meta_lic",
3131 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003132 "by_exception_only",
3133 "proprietary"),
3134 matchResolution(
Bob Badour1ded0a12021-12-03 17:16:14 -08003135 "lib/liba.so.meta_lic",
3136 "lib/liba.so.meta_lic",
3137 "by_exception_only",
3138 "proprietary"),
3139 matchResolution(
3140 "lib/libb.so.meta_lic",
3141 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003142 "restricted"),
Bob Badour1ded0a12021-12-03 17:16:14 -08003143 },
3144 },
3145 {
3146 condition: "proprietary",
3147 name: "container",
3148 roots: []string{"container.zip.meta_lic"},
3149 expectedOut: []getMatcher{
3150 matchTarget("testdata/proprietary/bin/bin1.meta_lic"),
3151 matchTarget("testdata/proprietary/lib/liba.so.meta_lic"),
3152 matchTarget("testdata/proprietary/lib/libc.a.meta_lic"),
3153 matchTarget("testdata/proprietary/bin/bin2.meta_lic"),
3154 matchTarget("testdata/proprietary/lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08003155 matchTarget("testdata/proprietary/container.zip.meta_lic"),
3156 matchResolution(
3157 "testdata/proprietary/bin/bin1.meta_lic",
3158 "testdata/proprietary/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003159 "notice"),
3160 matchResolution(
3161 "testdata/proprietary/bin/bin1.meta_lic",
3162 "testdata/proprietary/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003163 "by_exception_only",
3164 "proprietary"),
3165 matchResolution(
3166 "testdata/proprietary/bin/bin1.meta_lic",
3167 "testdata/proprietary/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003168 "by_exception_only",
3169 "proprietary"),
3170 matchResolution(
3171 "testdata/proprietary/bin/bin2.meta_lic",
3172 "testdata/proprietary/bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08003173 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08003174 "by_exception_only",
3175 "proprietary"),
3176 matchResolution(
3177 "testdata/proprietary/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003178 "testdata/proprietary/lib/libb.so.meta_lic",
3179 "restricted"),
3180 matchResolution(
3181 "testdata/proprietary/container.zip.meta_lic",
3182 "testdata/proprietary/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003183 "notice"),
3184 matchResolution(
3185 "testdata/proprietary/container.zip.meta_lic",
3186 "testdata/proprietary/bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08003187 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08003188 "by_exception_only",
3189 "proprietary"),
3190 matchResolution(
3191 "testdata/proprietary/container.zip.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003192 "testdata/proprietary/container.zip.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08003193 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08003194 "notice"),
3195 matchResolution(
3196 "testdata/proprietary/container.zip.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003197 "testdata/proprietary/lib/liba.so.meta_lic",
3198 "by_exception_only",
3199 "proprietary"),
3200 matchResolution(
3201 "testdata/proprietary/container.zip.meta_lic",
3202 "testdata/proprietary/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003203 "restricted"),
3204 matchResolution(
3205 "testdata/proprietary/container.zip.meta_lic",
3206 "testdata/proprietary/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003207 "by_exception_only",
3208 "proprietary"),
3209 matchResolution(
Bob Badour1ded0a12021-12-03 17:16:14 -08003210 "testdata/proprietary/lib/liba.so.meta_lic",
3211 "testdata/proprietary/lib/liba.so.meta_lic",
3212 "by_exception_only",
3213 "proprietary"),
3214 matchResolution(
3215 "testdata/proprietary/lib/libb.so.meta_lic",
3216 "testdata/proprietary/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003217 "restricted"),
Bob Badour1ded0a12021-12-03 17:16:14 -08003218 },
3219 },
3220 {
3221 condition: "proprietary",
3222 name: "application",
3223 roots: []string{"application.meta_lic"},
3224 expectedOut: []getMatcher{
3225 matchTarget("testdata/proprietary/application.meta_lic"),
3226 matchTarget("testdata/proprietary/lib/liba.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08003227 matchResolution(
3228 "testdata/proprietary/application.meta_lic",
3229 "testdata/proprietary/application.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08003230 "notice",
Bob Badour1ded0a12021-12-03 17:16:14 -08003231 "restricted"),
3232 matchResolution(
3233 "testdata/proprietary/application.meta_lic",
3234 "testdata/proprietary/lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08003235 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08003236 "by_exception_only",
3237 "proprietary"),
Bob Badour1ded0a12021-12-03 17:16:14 -08003238 },
3239 },
3240 {
3241 condition: "proprietary",
3242 name: "binary",
3243 roots: []string{"bin/bin1.meta_lic"},
3244 expectedOut: []getMatcher{
3245 matchTarget("testdata/proprietary/bin/bin1.meta_lic"),
3246 matchTarget("testdata/proprietary/lib/liba.so.meta_lic"),
3247 matchTarget("testdata/proprietary/lib/libc.a.meta_lic"),
3248 matchResolution(
3249 "testdata/proprietary/bin/bin1.meta_lic",
3250 "testdata/proprietary/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003251 "notice"),
3252 matchResolution(
3253 "testdata/proprietary/bin/bin1.meta_lic",
3254 "testdata/proprietary/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003255 "by_exception_only",
3256 "proprietary"),
3257 matchResolution(
3258 "testdata/proprietary/bin/bin1.meta_lic",
3259 "testdata/proprietary/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003260 "by_exception_only",
3261 "proprietary"),
3262 },
3263 },
3264 {
3265 condition: "proprietary",
3266 name: "library",
3267 roots: []string{"lib/libd.so.meta_lic"},
3268 expectedOut: []getMatcher{
3269 matchTarget("testdata/proprietary/lib/libd.so.meta_lic"),
3270 matchResolution(
3271 "testdata/proprietary/lib/libd.so.meta_lic",
3272 "testdata/proprietary/lib/libd.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003273 "notice"),
3274 },
3275 },
3276 }
3277 for _, tt := range tests {
3278 t.Run(tt.condition+" "+tt.name, func(t *testing.T) {
3279 ctx := &testContext{0, make(map[string]string)}
3280
Bob Badour1ded0a12021-12-03 17:16:14 -08003281 stdout := &bytes.Buffer{}
3282 stderr := &bytes.Buffer{}
3283
3284 rootFiles := make([]string, 0, len(tt.roots))
3285 for _, r := range tt.roots {
3286 rootFiles = append(rootFiles, "testdata/"+tt.condition+"/"+r)
3287 }
3288 tt.ctx.graphViz = true
Bob Badour103eb0f2022-01-10 13:50:57 -08003289 lg, err := dumpResolutions(&tt.ctx, stdout, stderr, rootFiles...)
Bob Badour1ded0a12021-12-03 17:16:14 -08003290 if err != nil {
3291 t.Fatalf("dumpresolutions: error = %v, stderr = %v", err, stderr)
3292 return
3293 }
3294 if stderr.Len() > 0 {
3295 t.Errorf("dumpresolutions: gotStderr = %v, want none", stderr)
3296 }
Bob Badour103eb0f2022-01-10 13:50:57 -08003297
3298 expectedOut := &bytes.Buffer{}
3299 for _, eo := range tt.expectedOut {
3300 m := eo(ctx)
3301 expectedOut.WriteString(m.matchString(ctx, lg))
3302 expectedOut.WriteString("\n")
3303 }
3304
Bob Badour1ded0a12021-12-03 17:16:14 -08003305 outList := strings.Split(stdout.String(), "\n")
3306 outLine := 0
3307 if outList[outLine] != "strict digraph {" {
3308 t.Errorf("dumpresolutions: got 1st line %v, want strict digraph {")
3309 }
3310 outLine++
3311 if strings.HasPrefix(strings.TrimLeft(outList[outLine], " \t"), "rankdir") {
3312 outLine++
3313 }
3314 endOut := len(outList)
3315 for endOut > 0 && strings.TrimLeft(outList[endOut-1], " \t") == "" {
3316 endOut--
3317 }
3318 if outList[endOut-1] != "}" {
3319 t.Errorf("dumpresolutions: got last line %v, want }", outList[endOut-1])
3320 }
3321 endOut--
3322 if strings.HasPrefix(strings.TrimLeft(outList[endOut-1], " \t"), "{rank=same") {
3323 endOut--
3324 }
3325 expectedList := strings.Split(expectedOut.String(), "\n")
3326 for len(expectedList) > 0 && expectedList[len(expectedList)-1] == "" {
3327 expectedList = expectedList[0 : len(expectedList)-1]
3328 }
3329 matchLine := 0
3330
3331 for outLine < endOut && matchLine < len(expectedList) && strings.TrimLeft(outList[outLine], " \t") == expectedList[matchLine] {
3332 outLine++
3333 matchLine++
3334 }
3335 if outLine < endOut || matchLine < len(expectedList) {
3336 if outLine >= endOut {
3337 t.Errorf("dumpresolutions: missing lines at end of graph, want %d lines %v", len(expectedList)-matchLine, strings.Join(expectedList[matchLine:], "\n"))
3338 } else if matchLine >= len(expectedList) {
3339 t.Errorf("dumpresolutions: unexpected lines at end of graph starting line %d, got %v, want nothing", outLine+1, strings.Join(outList[outLine:], "\n"))
3340 } else {
3341 t.Errorf("dumpresolutions: at line %d, got %v, want %v", outLine+1, strings.Join(outList[outLine:], "\n"), strings.Join(expectedList[matchLine:], "\n"))
3342 }
3343 }
3344 })
3345 }
3346}