blob: 50a631997e6296ded4a58ef9e9c6fce2ff0a17cb [file] [log] [blame]
Bob Badour1ded0a12021-12-03 17:16:14 -08001// Copyright 2021 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package main
16
17import (
18 "bytes"
19 "fmt"
20 "strings"
21 "testing"
Colin Cross38a61932022-01-27 15:26:49 -080022
23 "android/soong/tools/compliance"
Bob Badour1ded0a12021-12-03 17:16:14 -080024)
25
26func Test_plaintext(t *testing.T) {
27 tests := []struct {
28 condition string
29 name string
30 roots []string
31 ctx context
32 expectedOut []string
33 }{
34 {
35 condition: "firstparty",
36 name: "apex",
37 roots: []string{"highest.apex.meta_lic"},
38 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -080039 "testdata/firstparty/bin/bin1.meta_lic testdata/firstparty/bin/bin1.meta_lic notice",
40 "testdata/firstparty/bin/bin1.meta_lic testdata/firstparty/lib/liba.so.meta_lic notice",
41 "testdata/firstparty/bin/bin1.meta_lic testdata/firstparty/lib/libc.a.meta_lic notice",
42 "testdata/firstparty/bin/bin2.meta_lic testdata/firstparty/bin/bin2.meta_lic notice",
43 "testdata/firstparty/highest.apex.meta_lic testdata/firstparty/bin/bin1.meta_lic notice",
44 "testdata/firstparty/highest.apex.meta_lic testdata/firstparty/bin/bin2.meta_lic notice",
45 "testdata/firstparty/highest.apex.meta_lic testdata/firstparty/highest.apex.meta_lic notice",
46 "testdata/firstparty/highest.apex.meta_lic testdata/firstparty/lib/liba.so.meta_lic notice",
47 "testdata/firstparty/highest.apex.meta_lic testdata/firstparty/lib/libb.so.meta_lic notice",
48 "testdata/firstparty/highest.apex.meta_lic testdata/firstparty/lib/libc.a.meta_lic notice",
49 "testdata/firstparty/lib/liba.so.meta_lic testdata/firstparty/lib/liba.so.meta_lic notice",
50 "testdata/firstparty/lib/libb.so.meta_lic testdata/firstparty/lib/libb.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -080051 },
52 },
53 {
54 condition: "firstparty",
55 name: "apex_trimmed",
56 roots: []string{"highest.apex.meta_lic"},
57 ctx: context{stripPrefix: "testdata/firstparty/"},
58 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -080059 "bin/bin1.meta_lic bin/bin1.meta_lic notice",
60 "bin/bin1.meta_lic lib/liba.so.meta_lic notice",
61 "bin/bin1.meta_lic lib/libc.a.meta_lic notice",
62 "bin/bin2.meta_lic bin/bin2.meta_lic notice",
63 "highest.apex.meta_lic bin/bin1.meta_lic notice",
64 "highest.apex.meta_lic bin/bin2.meta_lic notice",
65 "highest.apex.meta_lic highest.apex.meta_lic notice",
66 "highest.apex.meta_lic lib/liba.so.meta_lic notice",
67 "highest.apex.meta_lic lib/libb.so.meta_lic notice",
68 "highest.apex.meta_lic lib/libc.a.meta_lic notice",
69 "lib/liba.so.meta_lic lib/liba.so.meta_lic notice",
70 "lib/libb.so.meta_lic lib/libb.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -080071 },
72 },
73 {
74 condition: "firstparty",
75 name: "apex_trimmed_notice",
76 roots: []string{"highest.apex.meta_lic"},
77 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -080078 conditions: []compliance.LicenseCondition{compliance.NoticeCondition},
Bob Badour1ded0a12021-12-03 17:16:14 -080079 stripPrefix: "testdata/firstparty/",
80 },
81 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -080082 "bin/bin1.meta_lic bin/bin1.meta_lic notice",
83 "bin/bin1.meta_lic lib/liba.so.meta_lic notice",
84 "bin/bin1.meta_lic lib/libc.a.meta_lic notice",
85 "bin/bin2.meta_lic bin/bin2.meta_lic notice",
86 "highest.apex.meta_lic bin/bin1.meta_lic notice",
87 "highest.apex.meta_lic bin/bin2.meta_lic notice",
88 "highest.apex.meta_lic highest.apex.meta_lic notice",
89 "highest.apex.meta_lic lib/liba.so.meta_lic notice",
90 "highest.apex.meta_lic lib/libb.so.meta_lic notice",
91 "highest.apex.meta_lic lib/libc.a.meta_lic notice",
92 "lib/liba.so.meta_lic lib/liba.so.meta_lic notice",
93 "lib/libb.so.meta_lic lib/libb.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -080094 },
95 },
96 {
97 condition: "firstparty",
98 name: "apex_trimmed_share",
99 roots: []string{"highest.apex.meta_lic"},
100 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800101 conditions: compliance.ImpliesShared.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -0800102 stripPrefix: "testdata/firstparty/",
103 },
104 expectedOut: []string{},
105 },
106 {
107 condition: "firstparty",
108 name: "apex_trimmed_private",
109 roots: []string{"highest.apex.meta_lic"},
110 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800111 conditions: compliance.ImpliesPrivate.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -0800112 stripPrefix: "testdata/firstparty/",
113 },
114 expectedOut: []string{},
115 },
116 {
117 condition: "firstparty",
118 name: "apex_trimmed_share_private",
119 roots: []string{"highest.apex.meta_lic"},
120 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800121 conditions: append(compliance.ImpliesPrivate.AsList(), compliance.ImpliesShared.AsList()...),
Bob Badour1ded0a12021-12-03 17:16:14 -0800122 stripPrefix: "testdata/firstparty/",
123 },
124 expectedOut: []string{},
125 },
126 {
127 condition: "firstparty",
128 name: "apex_trimmed_labelled",
129 roots: []string{"highest.apex.meta_lic"},
130 ctx: context{stripPrefix: "testdata/firstparty/", labelConditions: true},
131 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800132 "bin/bin1.meta_lic:notice bin/bin1.meta_lic:notice notice",
133 "bin/bin1.meta_lic:notice lib/liba.so.meta_lic:notice notice",
134 "bin/bin1.meta_lic:notice lib/libc.a.meta_lic:notice notice",
135 "bin/bin2.meta_lic:notice bin/bin2.meta_lic:notice notice",
136 "highest.apex.meta_lic:notice bin/bin1.meta_lic:notice notice",
137 "highest.apex.meta_lic:notice bin/bin2.meta_lic:notice notice",
138 "highest.apex.meta_lic:notice highest.apex.meta_lic:notice notice",
139 "highest.apex.meta_lic:notice lib/liba.so.meta_lic:notice notice",
140 "highest.apex.meta_lic:notice lib/libb.so.meta_lic:notice notice",
141 "highest.apex.meta_lic:notice lib/libc.a.meta_lic:notice notice",
142 "lib/liba.so.meta_lic:notice lib/liba.so.meta_lic:notice notice",
143 "lib/libb.so.meta_lic:notice lib/libb.so.meta_lic:notice notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800144 },
145 },
146 {
147 condition: "firstparty",
148 name: "container",
149 roots: []string{"container.zip.meta_lic"},
150 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800151 "testdata/firstparty/bin/bin1.meta_lic testdata/firstparty/bin/bin1.meta_lic notice",
152 "testdata/firstparty/bin/bin1.meta_lic testdata/firstparty/lib/liba.so.meta_lic notice",
153 "testdata/firstparty/bin/bin1.meta_lic testdata/firstparty/lib/libc.a.meta_lic notice",
154 "testdata/firstparty/bin/bin2.meta_lic testdata/firstparty/bin/bin2.meta_lic notice",
155 "testdata/firstparty/container.zip.meta_lic testdata/firstparty/bin/bin1.meta_lic notice",
156 "testdata/firstparty/container.zip.meta_lic testdata/firstparty/bin/bin2.meta_lic notice",
157 "testdata/firstparty/container.zip.meta_lic testdata/firstparty/container.zip.meta_lic notice",
158 "testdata/firstparty/container.zip.meta_lic testdata/firstparty/lib/liba.so.meta_lic notice",
159 "testdata/firstparty/container.zip.meta_lic testdata/firstparty/lib/libb.so.meta_lic notice",
160 "testdata/firstparty/container.zip.meta_lic testdata/firstparty/lib/libc.a.meta_lic notice",
161 "testdata/firstparty/lib/liba.so.meta_lic testdata/firstparty/lib/liba.so.meta_lic notice",
162 "testdata/firstparty/lib/libb.so.meta_lic testdata/firstparty/lib/libb.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800163 },
164 },
165 {
166 condition: "firstparty",
167 name: "application",
168 roots: []string{"application.meta_lic"},
169 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800170 "testdata/firstparty/application.meta_lic testdata/firstparty/application.meta_lic notice",
171 "testdata/firstparty/application.meta_lic testdata/firstparty/lib/liba.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800172 },
173 },
174 {
175 condition: "firstparty",
176 name: "binary",
177 roots: []string{"bin/bin1.meta_lic"},
178 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800179 "testdata/firstparty/bin/bin1.meta_lic testdata/firstparty/bin/bin1.meta_lic notice",
180 "testdata/firstparty/bin/bin1.meta_lic testdata/firstparty/lib/liba.so.meta_lic notice",
181 "testdata/firstparty/bin/bin1.meta_lic testdata/firstparty/lib/libc.a.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800182 },
183 },
184 {
185 condition: "firstparty",
186 name: "library",
187 roots: []string{"lib/libd.so.meta_lic"},
188 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800189 "testdata/firstparty/lib/libd.so.meta_lic testdata/firstparty/lib/libd.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800190 },
191 },
192 {
193 condition: "notice",
194 name: "apex",
195 roots: []string{"highest.apex.meta_lic"},
196 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800197 "testdata/notice/bin/bin1.meta_lic testdata/notice/bin/bin1.meta_lic notice",
198 "testdata/notice/bin/bin1.meta_lic testdata/notice/lib/liba.so.meta_lic notice",
199 "testdata/notice/bin/bin1.meta_lic testdata/notice/lib/libc.a.meta_lic notice",
200 "testdata/notice/bin/bin2.meta_lic testdata/notice/bin/bin2.meta_lic notice",
201 "testdata/notice/highest.apex.meta_lic testdata/notice/bin/bin1.meta_lic notice",
202 "testdata/notice/highest.apex.meta_lic testdata/notice/bin/bin2.meta_lic notice",
203 "testdata/notice/highest.apex.meta_lic testdata/notice/highest.apex.meta_lic notice",
204 "testdata/notice/highest.apex.meta_lic testdata/notice/lib/liba.so.meta_lic notice",
205 "testdata/notice/highest.apex.meta_lic testdata/notice/lib/libb.so.meta_lic notice",
206 "testdata/notice/highest.apex.meta_lic testdata/notice/lib/libc.a.meta_lic notice",
207 "testdata/notice/lib/liba.so.meta_lic testdata/notice/lib/liba.so.meta_lic notice",
208 "testdata/notice/lib/libb.so.meta_lic testdata/notice/lib/libb.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800209 },
210 },
211 {
212 condition: "notice",
213 name: "apex_trimmed",
214 roots: []string{"highest.apex.meta_lic"},
215 ctx: context{stripPrefix: "testdata/notice/"},
216 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800217 "bin/bin1.meta_lic bin/bin1.meta_lic notice",
218 "bin/bin1.meta_lic lib/liba.so.meta_lic notice",
219 "bin/bin1.meta_lic lib/libc.a.meta_lic notice",
220 "bin/bin2.meta_lic bin/bin2.meta_lic notice",
221 "highest.apex.meta_lic bin/bin1.meta_lic notice",
222 "highest.apex.meta_lic bin/bin2.meta_lic notice",
223 "highest.apex.meta_lic highest.apex.meta_lic notice",
224 "highest.apex.meta_lic lib/liba.so.meta_lic notice",
225 "highest.apex.meta_lic lib/libb.so.meta_lic notice",
226 "highest.apex.meta_lic lib/libc.a.meta_lic notice",
227 "lib/liba.so.meta_lic lib/liba.so.meta_lic notice",
228 "lib/libb.so.meta_lic lib/libb.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800229 },
230 },
231 {
232 condition: "notice",
233 name: "apex_trimmed_notice",
234 roots: []string{"highest.apex.meta_lic"},
235 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -0800236 conditions: []compliance.LicenseCondition{compliance.NoticeCondition},
Bob Badour1ded0a12021-12-03 17:16:14 -0800237 stripPrefix: "testdata/notice/",
238 },
239 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800240 "bin/bin1.meta_lic bin/bin1.meta_lic notice",
241 "bin/bin1.meta_lic lib/liba.so.meta_lic notice",
242 "bin/bin1.meta_lic lib/libc.a.meta_lic notice",
243 "bin/bin2.meta_lic bin/bin2.meta_lic notice",
244 "highest.apex.meta_lic bin/bin1.meta_lic notice",
245 "highest.apex.meta_lic bin/bin2.meta_lic notice",
246 "highest.apex.meta_lic highest.apex.meta_lic notice",
247 "highest.apex.meta_lic lib/liba.so.meta_lic notice",
248 "highest.apex.meta_lic lib/libb.so.meta_lic notice",
249 "highest.apex.meta_lic lib/libc.a.meta_lic notice",
250 "lib/liba.so.meta_lic lib/liba.so.meta_lic notice",
251 "lib/libb.so.meta_lic lib/libb.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800252 },
253 },
254 {
255 condition: "notice",
256 name: "apex_trimmed_share",
257 roots: []string{"highest.apex.meta_lic"},
258 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800259 conditions: compliance.ImpliesShared.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -0800260 stripPrefix: "testdata/notice/",
261 },
262 expectedOut: []string{},
263 },
264 {
265 condition: "notice",
266 name: "apex_trimmed_private",
267 roots: []string{"highest.apex.meta_lic"},
268 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800269 conditions: compliance.ImpliesPrivate.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -0800270 stripPrefix: "testdata/notice/",
271 },
272 expectedOut: []string{},
273 },
274 {
275 condition: "notice",
276 name: "apex_trimmed_share_private",
277 roots: []string{"highest.apex.meta_lic"},
278 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800279 conditions: append(compliance.ImpliesShared.AsList(), compliance.ImpliesPrivate.AsList()...),
Bob Badour1ded0a12021-12-03 17:16:14 -0800280 stripPrefix: "testdata/notice/",
281 },
282 expectedOut: []string{},
283 },
284 {
285 condition: "notice",
286 name: "apex_trimmed_labelled",
287 roots: []string{"highest.apex.meta_lic"},
288 ctx: context{stripPrefix: "testdata/notice/", labelConditions: true},
289 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800290 "bin/bin1.meta_lic:notice bin/bin1.meta_lic:notice notice",
291 "bin/bin1.meta_lic:notice lib/liba.so.meta_lic:notice notice",
292 "bin/bin1.meta_lic:notice lib/libc.a.meta_lic:notice notice",
293 "bin/bin2.meta_lic:notice bin/bin2.meta_lic:notice notice",
294 "highest.apex.meta_lic:notice bin/bin1.meta_lic:notice notice",
295 "highest.apex.meta_lic:notice bin/bin2.meta_lic:notice notice",
296 "highest.apex.meta_lic:notice highest.apex.meta_lic:notice notice",
297 "highest.apex.meta_lic:notice lib/liba.so.meta_lic:notice notice",
298 "highest.apex.meta_lic:notice lib/libb.so.meta_lic:notice notice",
299 "highest.apex.meta_lic:notice lib/libc.a.meta_lic:notice notice",
300 "lib/liba.so.meta_lic:notice lib/liba.so.meta_lic:notice notice",
301 "lib/libb.so.meta_lic:notice lib/libb.so.meta_lic:notice notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800302 },
303 },
304 {
305 condition: "notice",
306 name: "container",
307 roots: []string{"container.zip.meta_lic"},
308 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800309 "testdata/notice/bin/bin1.meta_lic testdata/notice/bin/bin1.meta_lic notice",
310 "testdata/notice/bin/bin1.meta_lic testdata/notice/lib/liba.so.meta_lic notice",
311 "testdata/notice/bin/bin1.meta_lic testdata/notice/lib/libc.a.meta_lic notice",
312 "testdata/notice/bin/bin2.meta_lic testdata/notice/bin/bin2.meta_lic notice",
313 "testdata/notice/container.zip.meta_lic testdata/notice/bin/bin1.meta_lic notice",
314 "testdata/notice/container.zip.meta_lic testdata/notice/bin/bin2.meta_lic notice",
315 "testdata/notice/container.zip.meta_lic testdata/notice/container.zip.meta_lic notice",
316 "testdata/notice/container.zip.meta_lic testdata/notice/lib/liba.so.meta_lic notice",
317 "testdata/notice/container.zip.meta_lic testdata/notice/lib/libb.so.meta_lic notice",
318 "testdata/notice/container.zip.meta_lic testdata/notice/lib/libc.a.meta_lic notice",
319 "testdata/notice/lib/liba.so.meta_lic testdata/notice/lib/liba.so.meta_lic notice",
320 "testdata/notice/lib/libb.so.meta_lic testdata/notice/lib/libb.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800321 },
322 },
323 {
324 condition: "notice",
325 name: "application",
326 roots: []string{"application.meta_lic"},
327 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800328 "testdata/notice/application.meta_lic testdata/notice/application.meta_lic notice",
329 "testdata/notice/application.meta_lic testdata/notice/lib/liba.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800330 },
331 },
332 {
333 condition: "notice",
334 name: "binary",
335 roots: []string{"bin/bin1.meta_lic"},
336 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800337 "testdata/notice/bin/bin1.meta_lic testdata/notice/bin/bin1.meta_lic notice",
338 "testdata/notice/bin/bin1.meta_lic testdata/notice/lib/liba.so.meta_lic notice",
339 "testdata/notice/bin/bin1.meta_lic testdata/notice/lib/libc.a.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800340 },
341 },
342 {
343 condition: "notice",
344 name: "library",
345 roots: []string{"lib/libd.so.meta_lic"},
346 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800347 "testdata/notice/lib/libd.so.meta_lic testdata/notice/lib/libd.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800348 },
349 },
350 {
351 condition: "reciprocal",
352 name: "apex",
353 roots: []string{"highest.apex.meta_lic"},
354 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800355 "testdata/reciprocal/bin/bin1.meta_lic testdata/reciprocal/bin/bin1.meta_lic notice",
356 "testdata/reciprocal/bin/bin1.meta_lic testdata/reciprocal/lib/liba.so.meta_lic reciprocal",
357 "testdata/reciprocal/bin/bin1.meta_lic testdata/reciprocal/lib/libc.a.meta_lic reciprocal",
358 "testdata/reciprocal/bin/bin2.meta_lic testdata/reciprocal/bin/bin2.meta_lic notice",
359 "testdata/reciprocal/highest.apex.meta_lic testdata/reciprocal/bin/bin1.meta_lic notice",
360 "testdata/reciprocal/highest.apex.meta_lic testdata/reciprocal/bin/bin2.meta_lic notice",
361 "testdata/reciprocal/highest.apex.meta_lic testdata/reciprocal/highest.apex.meta_lic notice",
362 "testdata/reciprocal/highest.apex.meta_lic testdata/reciprocal/lib/liba.so.meta_lic reciprocal",
363 "testdata/reciprocal/highest.apex.meta_lic testdata/reciprocal/lib/libb.so.meta_lic notice",
364 "testdata/reciprocal/highest.apex.meta_lic testdata/reciprocal/lib/libc.a.meta_lic reciprocal",
365 "testdata/reciprocal/lib/liba.so.meta_lic testdata/reciprocal/lib/liba.so.meta_lic reciprocal",
366 "testdata/reciprocal/lib/libb.so.meta_lic testdata/reciprocal/lib/libb.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800367 },
368 },
369 {
370 condition: "reciprocal",
371 name: "apex_trimmed",
372 roots: []string{"highest.apex.meta_lic"},
373 ctx: context{stripPrefix: "testdata/reciprocal/"},
374 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800375 "bin/bin1.meta_lic bin/bin1.meta_lic notice",
376 "bin/bin1.meta_lic lib/liba.so.meta_lic reciprocal",
377 "bin/bin1.meta_lic lib/libc.a.meta_lic reciprocal",
378 "bin/bin2.meta_lic bin/bin2.meta_lic notice",
379 "highest.apex.meta_lic bin/bin1.meta_lic notice",
380 "highest.apex.meta_lic bin/bin2.meta_lic notice",
381 "highest.apex.meta_lic highest.apex.meta_lic notice",
382 "highest.apex.meta_lic lib/liba.so.meta_lic reciprocal",
383 "highest.apex.meta_lic lib/libb.so.meta_lic notice",
384 "highest.apex.meta_lic lib/libc.a.meta_lic reciprocal",
385 "lib/liba.so.meta_lic lib/liba.so.meta_lic reciprocal",
386 "lib/libb.so.meta_lic lib/libb.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800387 },
388 },
389 {
390 condition: "reciprocal",
391 name: "apex_trimmed_notice",
392 roots: []string{"highest.apex.meta_lic"},
393 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -0800394 conditions: []compliance.LicenseCondition{compliance.NoticeCondition},
Bob Badour1ded0a12021-12-03 17:16:14 -0800395 stripPrefix: "testdata/reciprocal/",
396 },
397 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800398 "bin/bin1.meta_lic bin/bin1.meta_lic notice",
399 "bin/bin2.meta_lic bin/bin2.meta_lic notice",
400 "highest.apex.meta_lic bin/bin1.meta_lic notice",
401 "highest.apex.meta_lic bin/bin2.meta_lic notice",
402 "highest.apex.meta_lic highest.apex.meta_lic notice",
403 "highest.apex.meta_lic lib/libb.so.meta_lic notice",
404 "lib/libb.so.meta_lic lib/libb.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800405 },
406 },
407 {
408 condition: "reciprocal",
409 name: "apex_trimmed_share",
410 roots: []string{"highest.apex.meta_lic"},
411 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800412 conditions: compliance.ImpliesShared.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -0800413 stripPrefix: "testdata/reciprocal/",
414 },
415 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800416 "bin/bin1.meta_lic lib/liba.so.meta_lic reciprocal",
417 "bin/bin1.meta_lic lib/libc.a.meta_lic reciprocal",
418 "highest.apex.meta_lic lib/liba.so.meta_lic reciprocal",
419 "highest.apex.meta_lic lib/libc.a.meta_lic reciprocal",
420 "lib/liba.so.meta_lic lib/liba.so.meta_lic reciprocal",
Bob Badour1ded0a12021-12-03 17:16:14 -0800421 },
422 },
423 {
424 condition: "reciprocal",
425 name: "apex_trimmed_private",
426 roots: []string{"highest.apex.meta_lic"},
427 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800428 conditions: compliance.ImpliesPrivate.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -0800429 stripPrefix: "testdata/reciprocal/",
430 },
431 expectedOut: []string{},
432 },
433 {
434 condition: "reciprocal",
435 name: "apex_trimmed_share_private",
436 roots: []string{"highest.apex.meta_lic"},
437 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800438 conditions: append(compliance.ImpliesShared.AsList(), compliance.ImpliesPrivate.AsList()...),
Bob Badour1ded0a12021-12-03 17:16:14 -0800439 stripPrefix: "testdata/reciprocal/",
440 },
441 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800442 "bin/bin1.meta_lic lib/liba.so.meta_lic reciprocal",
443 "bin/bin1.meta_lic lib/libc.a.meta_lic reciprocal",
444 "highest.apex.meta_lic lib/liba.so.meta_lic reciprocal",
445 "highest.apex.meta_lic lib/libc.a.meta_lic reciprocal",
446 "lib/liba.so.meta_lic lib/liba.so.meta_lic reciprocal",
Bob Badour1ded0a12021-12-03 17:16:14 -0800447 },
448 },
449 {
450 condition: "reciprocal",
451 name: "apex_trimmed_labelled",
452 roots: []string{"highest.apex.meta_lic"},
453 ctx: context{stripPrefix: "testdata/reciprocal/", labelConditions: true},
454 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800455 "bin/bin1.meta_lic:notice bin/bin1.meta_lic:notice notice",
456 "bin/bin1.meta_lic:notice lib/liba.so.meta_lic:reciprocal reciprocal",
457 "bin/bin1.meta_lic:notice lib/libc.a.meta_lic:reciprocal reciprocal",
458 "bin/bin2.meta_lic:notice bin/bin2.meta_lic:notice notice",
459 "highest.apex.meta_lic:notice bin/bin1.meta_lic:notice notice",
460 "highest.apex.meta_lic:notice bin/bin2.meta_lic:notice notice",
461 "highest.apex.meta_lic:notice highest.apex.meta_lic:notice notice",
462 "highest.apex.meta_lic:notice lib/liba.so.meta_lic:reciprocal reciprocal",
463 "highest.apex.meta_lic:notice lib/libb.so.meta_lic:notice notice",
464 "highest.apex.meta_lic:notice lib/libc.a.meta_lic:reciprocal reciprocal",
465 "lib/liba.so.meta_lic:reciprocal lib/liba.so.meta_lic:reciprocal reciprocal",
466 "lib/libb.so.meta_lic:notice lib/libb.so.meta_lic:notice notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800467 },
468 },
469 {
470 condition: "reciprocal",
471 name: "container",
472 roots: []string{"container.zip.meta_lic"},
473 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800474 "testdata/reciprocal/bin/bin1.meta_lic testdata/reciprocal/bin/bin1.meta_lic notice",
475 "testdata/reciprocal/bin/bin1.meta_lic testdata/reciprocal/lib/liba.so.meta_lic reciprocal",
476 "testdata/reciprocal/bin/bin1.meta_lic testdata/reciprocal/lib/libc.a.meta_lic reciprocal",
477 "testdata/reciprocal/bin/bin2.meta_lic testdata/reciprocal/bin/bin2.meta_lic notice",
478 "testdata/reciprocal/container.zip.meta_lic testdata/reciprocal/bin/bin1.meta_lic notice",
479 "testdata/reciprocal/container.zip.meta_lic testdata/reciprocal/bin/bin2.meta_lic notice",
480 "testdata/reciprocal/container.zip.meta_lic testdata/reciprocal/container.zip.meta_lic notice",
481 "testdata/reciprocal/container.zip.meta_lic testdata/reciprocal/lib/liba.so.meta_lic reciprocal",
482 "testdata/reciprocal/container.zip.meta_lic testdata/reciprocal/lib/libb.so.meta_lic notice",
483 "testdata/reciprocal/container.zip.meta_lic testdata/reciprocal/lib/libc.a.meta_lic reciprocal",
484 "testdata/reciprocal/lib/liba.so.meta_lic testdata/reciprocal/lib/liba.so.meta_lic reciprocal",
485 "testdata/reciprocal/lib/libb.so.meta_lic testdata/reciprocal/lib/libb.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800486 },
487 },
488 {
489 condition: "reciprocal",
490 name: "application",
491 roots: []string{"application.meta_lic"},
492 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800493 "testdata/reciprocal/application.meta_lic testdata/reciprocal/application.meta_lic notice",
494 "testdata/reciprocal/application.meta_lic testdata/reciprocal/lib/liba.so.meta_lic reciprocal",
Bob Badour1ded0a12021-12-03 17:16:14 -0800495 },
496 },
497 {
498 condition: "reciprocal",
499 name: "binary",
500 roots: []string{"bin/bin1.meta_lic"},
501 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800502 "testdata/reciprocal/bin/bin1.meta_lic testdata/reciprocal/bin/bin1.meta_lic notice",
503 "testdata/reciprocal/bin/bin1.meta_lic testdata/reciprocal/lib/liba.so.meta_lic reciprocal",
504 "testdata/reciprocal/bin/bin1.meta_lic testdata/reciprocal/lib/libc.a.meta_lic reciprocal",
Bob Badour1ded0a12021-12-03 17:16:14 -0800505 },
506 },
507 {
508 condition: "reciprocal",
509 name: "library",
510 roots: []string{"lib/libd.so.meta_lic"},
511 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800512 "testdata/reciprocal/lib/libd.so.meta_lic testdata/reciprocal/lib/libd.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800513 },
514 },
515 {
516 condition: "restricted",
517 name: "apex",
518 roots: []string{"highest.apex.meta_lic"},
519 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800520 "testdata/restricted/bin/bin1.meta_lic testdata/restricted/bin/bin1.meta_lic notice:restricted_allows_dynamic_linking",
521 "testdata/restricted/bin/bin1.meta_lic testdata/restricted/lib/liba.so.meta_lic restricted_allows_dynamic_linking",
522 "testdata/restricted/bin/bin1.meta_lic testdata/restricted/lib/libc.a.meta_lic reciprocal:restricted_allows_dynamic_linking",
523 "testdata/restricted/bin/bin2.meta_lic testdata/restricted/bin/bin2.meta_lic notice:restricted",
524 "testdata/restricted/bin/bin2.meta_lic testdata/restricted/lib/libb.so.meta_lic restricted",
525 "testdata/restricted/highest.apex.meta_lic testdata/restricted/bin/bin1.meta_lic notice:restricted_allows_dynamic_linking",
526 "testdata/restricted/highest.apex.meta_lic testdata/restricted/bin/bin2.meta_lic notice:restricted",
527 "testdata/restricted/highest.apex.meta_lic testdata/restricted/highest.apex.meta_lic notice:restricted:restricted_allows_dynamic_linking",
528 "testdata/restricted/highest.apex.meta_lic testdata/restricted/lib/liba.so.meta_lic restricted_allows_dynamic_linking",
529 "testdata/restricted/highest.apex.meta_lic testdata/restricted/lib/libb.so.meta_lic restricted",
530 "testdata/restricted/highest.apex.meta_lic testdata/restricted/lib/libc.a.meta_lic reciprocal:restricted_allows_dynamic_linking",
531 "testdata/restricted/lib/liba.so.meta_lic testdata/restricted/lib/liba.so.meta_lic restricted_allows_dynamic_linking",
532 "testdata/restricted/lib/libb.so.meta_lic testdata/restricted/lib/libb.so.meta_lic restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -0800533 },
534 },
535 {
536 condition: "restricted",
537 name: "apex_trimmed",
538 roots: []string{"highest.apex.meta_lic"},
539 ctx: context{stripPrefix: "testdata/restricted/"},
540 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800541 "bin/bin1.meta_lic bin/bin1.meta_lic notice:restricted_allows_dynamic_linking",
542 "bin/bin1.meta_lic lib/liba.so.meta_lic restricted_allows_dynamic_linking",
543 "bin/bin1.meta_lic lib/libc.a.meta_lic reciprocal:restricted_allows_dynamic_linking",
544 "bin/bin2.meta_lic bin/bin2.meta_lic notice:restricted",
545 "bin/bin2.meta_lic lib/libb.so.meta_lic restricted",
546 "highest.apex.meta_lic bin/bin1.meta_lic notice:restricted_allows_dynamic_linking",
547 "highest.apex.meta_lic bin/bin2.meta_lic notice:restricted",
548 "highest.apex.meta_lic highest.apex.meta_lic notice:restricted:restricted_allows_dynamic_linking",
549 "highest.apex.meta_lic lib/liba.so.meta_lic restricted_allows_dynamic_linking",
550 "highest.apex.meta_lic lib/libb.so.meta_lic restricted",
551 "highest.apex.meta_lic lib/libc.a.meta_lic reciprocal:restricted_allows_dynamic_linking",
552 "lib/liba.so.meta_lic lib/liba.so.meta_lic restricted_allows_dynamic_linking",
553 "lib/libb.so.meta_lic lib/libb.so.meta_lic restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -0800554 },
555 },
556 {
557 condition: "restricted",
558 name: "apex_trimmed_notice",
559 roots: []string{"highest.apex.meta_lic"},
560 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -0800561 conditions: []compliance.LicenseCondition{compliance.NoticeCondition},
Bob Badour1ded0a12021-12-03 17:16:14 -0800562 stripPrefix: "testdata/restricted/",
563 },
564 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800565 "bin/bin1.meta_lic bin/bin1.meta_lic notice",
566 "bin/bin2.meta_lic bin/bin2.meta_lic notice",
567 "highest.apex.meta_lic bin/bin1.meta_lic notice",
568 "highest.apex.meta_lic bin/bin2.meta_lic notice",
569 "highest.apex.meta_lic highest.apex.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800570 },
571 },
572 {
573 condition: "restricted",
574 name: "apex_trimmed_share",
575 roots: []string{"highest.apex.meta_lic"},
576 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800577 conditions: compliance.ImpliesShared.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -0800578 stripPrefix: "testdata/restricted/",
579 },
580 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800581 "bin/bin1.meta_lic bin/bin1.meta_lic restricted_allows_dynamic_linking",
582 "bin/bin1.meta_lic lib/liba.so.meta_lic restricted_allows_dynamic_linking",
583 "bin/bin1.meta_lic lib/libc.a.meta_lic reciprocal:restricted_allows_dynamic_linking",
584 "bin/bin2.meta_lic bin/bin2.meta_lic restricted",
585 "bin/bin2.meta_lic lib/libb.so.meta_lic restricted",
586 "highest.apex.meta_lic bin/bin1.meta_lic restricted_allows_dynamic_linking",
587 "highest.apex.meta_lic bin/bin2.meta_lic restricted",
588 "highest.apex.meta_lic highest.apex.meta_lic restricted:restricted_allows_dynamic_linking",
589 "highest.apex.meta_lic lib/liba.so.meta_lic restricted_allows_dynamic_linking",
590 "highest.apex.meta_lic lib/libb.so.meta_lic restricted",
591 "highest.apex.meta_lic lib/libc.a.meta_lic reciprocal:restricted_allows_dynamic_linking",
592 "lib/liba.so.meta_lic lib/liba.so.meta_lic restricted_allows_dynamic_linking",
593 "lib/libb.so.meta_lic lib/libb.so.meta_lic restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -0800594 },
595 },
596 {
597 condition: "restricted",
598 name: "apex_trimmed_private",
599 roots: []string{"highest.apex.meta_lic"},
600 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800601 conditions: compliance.ImpliesPrivate.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -0800602 stripPrefix: "testdata/restricted/",
603 },
604 expectedOut: []string{},
605 },
606 {
607 condition: "restricted",
608 name: "apex_trimmed_share_private",
609 roots: []string{"highest.apex.meta_lic"},
610 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800611 conditions: append(compliance.ImpliesShared.AsList(), compliance.ImpliesPrivate.AsList()...),
Bob Badour1ded0a12021-12-03 17:16:14 -0800612 stripPrefix: "testdata/restricted/",
613 },
614 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800615 "bin/bin1.meta_lic bin/bin1.meta_lic restricted_allows_dynamic_linking",
616 "bin/bin1.meta_lic lib/liba.so.meta_lic restricted_allows_dynamic_linking",
617 "bin/bin1.meta_lic lib/libc.a.meta_lic reciprocal:restricted_allows_dynamic_linking",
618 "bin/bin2.meta_lic bin/bin2.meta_lic restricted",
619 "bin/bin2.meta_lic lib/libb.so.meta_lic restricted",
620 "highest.apex.meta_lic bin/bin1.meta_lic restricted_allows_dynamic_linking",
621 "highest.apex.meta_lic bin/bin2.meta_lic restricted",
622 "highest.apex.meta_lic highest.apex.meta_lic restricted:restricted_allows_dynamic_linking",
623 "highest.apex.meta_lic lib/liba.so.meta_lic restricted_allows_dynamic_linking",
624 "highest.apex.meta_lic lib/libb.so.meta_lic restricted",
625 "highest.apex.meta_lic lib/libc.a.meta_lic reciprocal:restricted_allows_dynamic_linking",
626 "lib/liba.so.meta_lic lib/liba.so.meta_lic restricted_allows_dynamic_linking",
627 "lib/libb.so.meta_lic lib/libb.so.meta_lic restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -0800628 },
629 },
630 {
631 condition: "restricted",
632 name: "apex_trimmed_labelled",
633 roots: []string{"highest.apex.meta_lic"},
634 ctx: context{stripPrefix: "testdata/restricted/", labelConditions: true},
635 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800636 "bin/bin1.meta_lic:notice bin/bin1.meta_lic:notice notice:restricted_allows_dynamic_linking",
637 "bin/bin1.meta_lic:notice lib/liba.so.meta_lic:restricted_allows_dynamic_linking restricted_allows_dynamic_linking",
638 "bin/bin1.meta_lic:notice lib/libc.a.meta_lic:reciprocal reciprocal:restricted_allows_dynamic_linking",
639 "bin/bin2.meta_lic:notice bin/bin2.meta_lic:notice notice:restricted",
640 "bin/bin2.meta_lic:notice lib/libb.so.meta_lic:restricted restricted",
641 "highest.apex.meta_lic:notice bin/bin1.meta_lic:notice notice:restricted_allows_dynamic_linking",
642 "highest.apex.meta_lic:notice bin/bin2.meta_lic:notice notice:restricted",
643 "highest.apex.meta_lic:notice highest.apex.meta_lic:notice notice:restricted:restricted_allows_dynamic_linking",
644 "highest.apex.meta_lic:notice lib/liba.so.meta_lic:restricted_allows_dynamic_linking restricted_allows_dynamic_linking",
645 "highest.apex.meta_lic:notice lib/libb.so.meta_lic:restricted restricted",
646 "highest.apex.meta_lic:notice lib/libc.a.meta_lic:reciprocal reciprocal:restricted_allows_dynamic_linking",
647 "lib/liba.so.meta_lic:restricted_allows_dynamic_linking lib/liba.so.meta_lic:restricted_allows_dynamic_linking restricted_allows_dynamic_linking",
648 "lib/libb.so.meta_lic:restricted lib/libb.so.meta_lic:restricted restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -0800649 },
650 },
651 {
652 condition: "restricted",
653 name: "container",
654 roots: []string{"container.zip.meta_lic"},
655 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800656 "testdata/restricted/bin/bin1.meta_lic testdata/restricted/bin/bin1.meta_lic notice:restricted_allows_dynamic_linking",
657 "testdata/restricted/bin/bin1.meta_lic testdata/restricted/lib/liba.so.meta_lic restricted_allows_dynamic_linking",
658 "testdata/restricted/bin/bin1.meta_lic testdata/restricted/lib/libc.a.meta_lic reciprocal:restricted_allows_dynamic_linking",
659 "testdata/restricted/bin/bin2.meta_lic testdata/restricted/bin/bin2.meta_lic notice:restricted",
660 "testdata/restricted/bin/bin2.meta_lic testdata/restricted/lib/libb.so.meta_lic restricted",
661 "testdata/restricted/container.zip.meta_lic testdata/restricted/bin/bin1.meta_lic notice:restricted_allows_dynamic_linking",
662 "testdata/restricted/container.zip.meta_lic testdata/restricted/bin/bin2.meta_lic notice:restricted",
663 "testdata/restricted/container.zip.meta_lic testdata/restricted/container.zip.meta_lic notice:restricted:restricted_allows_dynamic_linking",
664 "testdata/restricted/container.zip.meta_lic testdata/restricted/lib/liba.so.meta_lic restricted_allows_dynamic_linking",
665 "testdata/restricted/container.zip.meta_lic testdata/restricted/lib/libb.so.meta_lic restricted",
666 "testdata/restricted/container.zip.meta_lic testdata/restricted/lib/libc.a.meta_lic reciprocal:restricted_allows_dynamic_linking",
667 "testdata/restricted/lib/liba.so.meta_lic testdata/restricted/lib/liba.so.meta_lic restricted_allows_dynamic_linking",
668 "testdata/restricted/lib/libb.so.meta_lic testdata/restricted/lib/libb.so.meta_lic restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -0800669 },
670 },
671 {
672 condition: "restricted",
673 name: "application",
674 roots: []string{"application.meta_lic"},
675 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800676 "testdata/restricted/application.meta_lic testdata/restricted/application.meta_lic notice:restricted:restricted_allows_dynamic_linking",
677 "testdata/restricted/application.meta_lic testdata/restricted/lib/liba.so.meta_lic restricted:restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -0800678 },
679 },
680 {
681 condition: "restricted",
682 name: "binary",
683 roots: []string{"bin/bin1.meta_lic"},
684 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800685 "testdata/restricted/bin/bin1.meta_lic testdata/restricted/bin/bin1.meta_lic notice:restricted_allows_dynamic_linking",
686 "testdata/restricted/bin/bin1.meta_lic testdata/restricted/lib/liba.so.meta_lic restricted_allows_dynamic_linking",
687 "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 -0800688 },
689 },
690 {
691 condition: "restricted",
692 name: "library",
693 roots: []string{"lib/libd.so.meta_lic"},
694 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800695 "testdata/restricted/lib/libd.so.meta_lic testdata/restricted/lib/libd.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800696 },
697 },
698 {
699 condition: "proprietary",
700 name: "apex",
701 roots: []string{"highest.apex.meta_lic"},
702 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800703 "testdata/proprietary/bin/bin1.meta_lic testdata/proprietary/bin/bin1.meta_lic notice",
704 "testdata/proprietary/bin/bin1.meta_lic testdata/proprietary/lib/liba.so.meta_lic proprietary:by_exception_only",
705 "testdata/proprietary/bin/bin1.meta_lic testdata/proprietary/lib/libc.a.meta_lic proprietary:by_exception_only",
706 "testdata/proprietary/bin/bin2.meta_lic testdata/proprietary/bin/bin2.meta_lic restricted:proprietary:by_exception_only",
707 "testdata/proprietary/bin/bin2.meta_lic testdata/proprietary/lib/libb.so.meta_lic restricted",
708 "testdata/proprietary/highest.apex.meta_lic testdata/proprietary/bin/bin1.meta_lic notice",
709 "testdata/proprietary/highest.apex.meta_lic testdata/proprietary/bin/bin2.meta_lic restricted:proprietary:by_exception_only",
710 "testdata/proprietary/highest.apex.meta_lic testdata/proprietary/highest.apex.meta_lic notice:restricted",
711 "testdata/proprietary/highest.apex.meta_lic testdata/proprietary/lib/liba.so.meta_lic proprietary:by_exception_only",
712 "testdata/proprietary/highest.apex.meta_lic testdata/proprietary/lib/libb.so.meta_lic restricted",
713 "testdata/proprietary/highest.apex.meta_lic testdata/proprietary/lib/libc.a.meta_lic proprietary:by_exception_only",
714 "testdata/proprietary/lib/liba.so.meta_lic testdata/proprietary/lib/liba.so.meta_lic proprietary:by_exception_only",
715 "testdata/proprietary/lib/libb.so.meta_lic testdata/proprietary/lib/libb.so.meta_lic restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -0800716 },
717 },
718 {
719 condition: "proprietary",
720 name: "apex_trimmed",
721 roots: []string{"highest.apex.meta_lic"},
722 ctx: context{stripPrefix: "testdata/proprietary/"},
723 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800724 "bin/bin1.meta_lic bin/bin1.meta_lic notice",
725 "bin/bin1.meta_lic lib/liba.so.meta_lic proprietary:by_exception_only",
726 "bin/bin1.meta_lic lib/libc.a.meta_lic proprietary:by_exception_only",
727 "bin/bin2.meta_lic bin/bin2.meta_lic restricted:proprietary:by_exception_only",
728 "bin/bin2.meta_lic lib/libb.so.meta_lic restricted",
729 "highest.apex.meta_lic bin/bin1.meta_lic notice",
730 "highest.apex.meta_lic bin/bin2.meta_lic restricted:proprietary:by_exception_only",
731 "highest.apex.meta_lic highest.apex.meta_lic notice:restricted",
732 "highest.apex.meta_lic lib/liba.so.meta_lic proprietary:by_exception_only",
733 "highest.apex.meta_lic lib/libb.so.meta_lic restricted",
734 "highest.apex.meta_lic lib/libc.a.meta_lic proprietary:by_exception_only",
735 "lib/liba.so.meta_lic lib/liba.so.meta_lic proprietary:by_exception_only",
736 "lib/libb.so.meta_lic lib/libb.so.meta_lic restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -0800737 },
738 },
739 {
740 condition: "proprietary",
741 name: "apex_trimmed_notice",
742 roots: []string{"highest.apex.meta_lic"},
743 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -0800744 conditions: []compliance.LicenseCondition{compliance.NoticeCondition},
Bob Badour1ded0a12021-12-03 17:16:14 -0800745 stripPrefix: "testdata/proprietary/",
746 },
747 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800748 "bin/bin1.meta_lic bin/bin1.meta_lic notice",
749 "highest.apex.meta_lic bin/bin1.meta_lic notice",
750 "highest.apex.meta_lic highest.apex.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800751 },
752 },
753 {
754 condition: "proprietary",
755 name: "apex_trimmed_share",
756 roots: []string{"highest.apex.meta_lic"},
757 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800758 conditions: compliance.ImpliesShared.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -0800759 stripPrefix: "testdata/proprietary/",
760 },
761 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800762 "bin/bin2.meta_lic bin/bin2.meta_lic restricted",
763 "bin/bin2.meta_lic lib/libb.so.meta_lic restricted",
764 "highest.apex.meta_lic bin/bin2.meta_lic restricted",
765 "highest.apex.meta_lic highest.apex.meta_lic restricted",
766 "highest.apex.meta_lic lib/libb.so.meta_lic restricted",
767 "lib/libb.so.meta_lic lib/libb.so.meta_lic restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -0800768 },
769 },
770 {
771 condition: "proprietary",
772 name: "apex_trimmed_private",
773 roots: []string{"highest.apex.meta_lic"},
774 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800775 conditions: compliance.ImpliesPrivate.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -0800776 stripPrefix: "testdata/proprietary/",
777 },
778 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800779 "bin/bin1.meta_lic lib/liba.so.meta_lic proprietary",
780 "bin/bin1.meta_lic lib/libc.a.meta_lic proprietary",
781 "bin/bin2.meta_lic bin/bin2.meta_lic proprietary",
782 "highest.apex.meta_lic bin/bin2.meta_lic proprietary",
783 "highest.apex.meta_lic lib/liba.so.meta_lic proprietary",
784 "highest.apex.meta_lic lib/libc.a.meta_lic proprietary",
785 "lib/liba.so.meta_lic lib/liba.so.meta_lic proprietary",
Bob Badour1ded0a12021-12-03 17:16:14 -0800786 },
787 },
788 {
789 condition: "proprietary",
790 name: "apex_trimmed_share_private",
791 roots: []string{"highest.apex.meta_lic"},
792 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800793 conditions: append(compliance.ImpliesShared.AsList(), compliance.ImpliesPrivate.AsList()...),
Bob Badour1ded0a12021-12-03 17:16:14 -0800794 stripPrefix: "testdata/proprietary/",
795 },
796 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800797 "bin/bin1.meta_lic lib/liba.so.meta_lic proprietary",
798 "bin/bin1.meta_lic lib/libc.a.meta_lic proprietary",
799 "bin/bin2.meta_lic bin/bin2.meta_lic restricted:proprietary",
800 "bin/bin2.meta_lic lib/libb.so.meta_lic restricted",
801 "highest.apex.meta_lic bin/bin2.meta_lic restricted:proprietary",
802 "highest.apex.meta_lic highest.apex.meta_lic restricted",
803 "highest.apex.meta_lic lib/liba.so.meta_lic proprietary",
804 "highest.apex.meta_lic lib/libb.so.meta_lic restricted",
805 "highest.apex.meta_lic lib/libc.a.meta_lic proprietary",
806 "lib/liba.so.meta_lic lib/liba.so.meta_lic proprietary",
807 "lib/libb.so.meta_lic lib/libb.so.meta_lic restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -0800808 },
809 },
810 {
811 condition: "proprietary",
812 name: "apex_trimmed_labelled",
813 roots: []string{"highest.apex.meta_lic"},
814 ctx: context{stripPrefix: "testdata/proprietary/", labelConditions: true},
815 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800816 "bin/bin1.meta_lic:notice bin/bin1.meta_lic:notice notice",
817 "bin/bin1.meta_lic:notice lib/liba.so.meta_lic:proprietary:by_exception_only proprietary:by_exception_only",
818 "bin/bin1.meta_lic:notice lib/libc.a.meta_lic:proprietary:by_exception_only proprietary:by_exception_only",
819 "bin/bin2.meta_lic:proprietary:by_exception_only bin/bin2.meta_lic:proprietary:by_exception_only restricted:proprietary:by_exception_only",
820 "bin/bin2.meta_lic:proprietary:by_exception_only lib/libb.so.meta_lic:restricted restricted",
821 "highest.apex.meta_lic:notice bin/bin1.meta_lic:notice notice",
822 "highest.apex.meta_lic:notice bin/bin2.meta_lic:proprietary:by_exception_only restricted:proprietary:by_exception_only",
823 "highest.apex.meta_lic:notice highest.apex.meta_lic:notice notice:restricted",
824 "highest.apex.meta_lic:notice lib/liba.so.meta_lic:proprietary:by_exception_only proprietary:by_exception_only",
825 "highest.apex.meta_lic:notice lib/libb.so.meta_lic:restricted restricted",
826 "highest.apex.meta_lic:notice lib/libc.a.meta_lic:proprietary:by_exception_only proprietary:by_exception_only",
827 "lib/liba.so.meta_lic:proprietary:by_exception_only lib/liba.so.meta_lic:proprietary:by_exception_only proprietary:by_exception_only",
828 "lib/libb.so.meta_lic:restricted lib/libb.so.meta_lic:restricted restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -0800829 },
830 },
831 {
832 condition: "proprietary",
833 name: "container",
834 roots: []string{"container.zip.meta_lic"},
835 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800836 "testdata/proprietary/bin/bin1.meta_lic testdata/proprietary/bin/bin1.meta_lic notice",
837 "testdata/proprietary/bin/bin1.meta_lic testdata/proprietary/lib/liba.so.meta_lic proprietary:by_exception_only",
838 "testdata/proprietary/bin/bin1.meta_lic testdata/proprietary/lib/libc.a.meta_lic proprietary:by_exception_only",
839 "testdata/proprietary/bin/bin2.meta_lic testdata/proprietary/bin/bin2.meta_lic restricted:proprietary:by_exception_only",
840 "testdata/proprietary/bin/bin2.meta_lic testdata/proprietary/lib/libb.so.meta_lic restricted",
841 "testdata/proprietary/container.zip.meta_lic testdata/proprietary/bin/bin1.meta_lic notice",
842 "testdata/proprietary/container.zip.meta_lic testdata/proprietary/bin/bin2.meta_lic restricted:proprietary:by_exception_only",
843 "testdata/proprietary/container.zip.meta_lic testdata/proprietary/container.zip.meta_lic notice:restricted",
844 "testdata/proprietary/container.zip.meta_lic testdata/proprietary/lib/liba.so.meta_lic proprietary:by_exception_only",
845 "testdata/proprietary/container.zip.meta_lic testdata/proprietary/lib/libb.so.meta_lic restricted",
846 "testdata/proprietary/container.zip.meta_lic testdata/proprietary/lib/libc.a.meta_lic proprietary:by_exception_only",
847 "testdata/proprietary/lib/liba.so.meta_lic testdata/proprietary/lib/liba.so.meta_lic proprietary:by_exception_only",
848 "testdata/proprietary/lib/libb.so.meta_lic testdata/proprietary/lib/libb.so.meta_lic restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -0800849 },
850 },
851 {
852 condition: "proprietary",
853 name: "application",
854 roots: []string{"application.meta_lic"},
855 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800856 "testdata/proprietary/application.meta_lic testdata/proprietary/application.meta_lic notice:restricted",
857 "testdata/proprietary/application.meta_lic testdata/proprietary/lib/liba.so.meta_lic restricted:proprietary:by_exception_only",
Bob Badour1ded0a12021-12-03 17:16:14 -0800858 },
859 },
860 {
861 condition: "proprietary",
862 name: "binary",
863 roots: []string{"bin/bin1.meta_lic"},
864 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800865 "testdata/proprietary/bin/bin1.meta_lic testdata/proprietary/bin/bin1.meta_lic notice",
866 "testdata/proprietary/bin/bin1.meta_lic testdata/proprietary/lib/liba.so.meta_lic proprietary:by_exception_only",
867 "testdata/proprietary/bin/bin1.meta_lic testdata/proprietary/lib/libc.a.meta_lic proprietary:by_exception_only",
Bob Badour1ded0a12021-12-03 17:16:14 -0800868 },
869 },
870 {
871 condition: "proprietary",
872 name: "library",
873 roots: []string{"lib/libd.so.meta_lic"},
874 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800875 "testdata/proprietary/lib/libd.so.meta_lic testdata/proprietary/lib/libd.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800876 },
877 },
878 }
879 for _, tt := range tests {
880 t.Run(tt.condition+" "+tt.name, func(t *testing.T) {
881 expectedOut := &bytes.Buffer{}
882 for _, eo := range tt.expectedOut {
883 expectedOut.WriteString(eo)
884 expectedOut.WriteString("\n")
885 }
886
887 stdout := &bytes.Buffer{}
888 stderr := &bytes.Buffer{}
889
890 rootFiles := make([]string, 0, len(tt.roots))
891 for _, r := range tt.roots {
892 rootFiles = append(rootFiles, "testdata/"+tt.condition+"/"+r)
893 }
Bob Badour103eb0f2022-01-10 13:50:57 -0800894 _, err := dumpResolutions(&tt.ctx, stdout, stderr, rootFiles...)
Bob Badour1ded0a12021-12-03 17:16:14 -0800895 if err != nil {
896 t.Fatalf("dumpresolutions: error = %v, stderr = %v", err, stderr)
897 return
898 }
899 if stderr.Len() > 0 {
900 t.Errorf("dumpresolutions: gotStderr = %v, want none", stderr)
901 }
902 out := stdout.String()
903 expected := expectedOut.String()
904 if out != expected {
905 outList := strings.Split(out, "\n")
906 expectedList := strings.Split(expected, "\n")
907 startLine := 0
908 for len(outList) > startLine && len(expectedList) > startLine && outList[startLine] == expectedList[startLine] {
909 startLine++
910 }
911 t.Errorf("listshare: gotStdout = %v, want %v, somewhere near line %d Stdout = %v, want %v",
912 out, expected, startLine+1, outList[startLine], expectedList[startLine])
913 }
914 })
915 }
916}
917
918type testContext struct {
919 nextNode int
920 nodes map[string]string
921}
922
923type matcher interface {
Bob Badour103eb0f2022-01-10 13:50:57 -0800924 matchString(*testContext, *compliance.LicenseGraph) string
Bob Badour1ded0a12021-12-03 17:16:14 -0800925 typeString() string
926}
927
928type targetMatcher struct {
929 target string
930 conditions []string
931}
932
Bob Badour103eb0f2022-01-10 13:50:57 -0800933// newTestCondition constructs a test license condition in the license graph.
Colin Cross35f79c32022-01-27 15:18:52 -0800934func newTestCondition(lg *compliance.LicenseGraph, conditionName ...string) compliance.LicenseConditionSet {
Bob Badour103eb0f2022-01-10 13:50:57 -0800935 cs := compliance.NewLicenseConditionSet()
936 for _, name := range conditionName {
937 cs = cs.Plus(compliance.RecognizedConditionNames[name])
938 }
939 if cs.IsEmpty() && len(conditionName) != 0 {
940 panic(fmt.Errorf("attempt to create unrecognized condition: %q", conditionName))
941 }
942 return cs
943}
944
945func (tm *targetMatcher) matchString(ctx *testContext, lg *compliance.LicenseGraph) string {
946 cs := newTestCondition(lg, tm.conditions...)
Bob Badour1ded0a12021-12-03 17:16:14 -0800947 m := tm.target
Bob Badour103eb0f2022-01-10 13:50:57 -0800948 if !cs.IsEmpty() {
949 m += "\\n" + strings.Join(cs.Names(), "\\n")
Bob Badour1ded0a12021-12-03 17:16:14 -0800950 }
951 m = ctx.nodes[tm.target] + " [label=\"" + m + "\"];"
952 return m
953}
954
955func (tm *targetMatcher) typeString() string {
956 return "target"
957}
958
959type resolutionMatcher struct {
960 appliesTo string
961 actsOn string
Bob Badour1ded0a12021-12-03 17:16:14 -0800962 conditions []string
963}
964
Bob Badour103eb0f2022-01-10 13:50:57 -0800965func (rm *resolutionMatcher) matchString(ctx *testContext, lg *compliance.LicenseGraph) string {
966 cs := newTestCondition(lg, rm.conditions...)
967 return ctx.nodes[rm.appliesTo] + " -> " + ctx.nodes[rm.actsOn] +
968 " [label=\"" + strings.Join(cs.Names(), "\\n") + "\"];"
Bob Badour1ded0a12021-12-03 17:16:14 -0800969}
970
971func (rm *resolutionMatcher) typeString() string {
972 return "resolution"
973}
974
975type getMatcher func(*testContext) matcher
976
977func matchTarget(target string, conditions ...string) getMatcher {
978 return func(ctx *testContext) matcher {
979 ctx.nodes[target] = fmt.Sprintf("n%d", ctx.nextNode)
980 ctx.nextNode++
981 return &targetMatcher{target, append([]string{}, conditions...)}
982 }
983}
984
Bob Badour103eb0f2022-01-10 13:50:57 -0800985func matchResolution(appliesTo, actsOn string, conditions ...string) getMatcher {
Bob Badour1ded0a12021-12-03 17:16:14 -0800986 return func(ctx *testContext) matcher {
987 if _, ok := ctx.nodes[appliesTo]; !ok {
988 ctx.nodes[appliesTo] = fmt.Sprintf("unknown%d", ctx.nextNode)
989 ctx.nextNode++
990 }
991 if _, ok := ctx.nodes[actsOn]; !ok {
992 ctx.nodes[actsOn] = fmt.Sprintf("unknown%d", ctx.nextNode)
993 ctx.nextNode++
994 }
Bob Badour103eb0f2022-01-10 13:50:57 -0800995 return &resolutionMatcher{appliesTo, actsOn, append([]string{}, conditions...)}
Bob Badour1ded0a12021-12-03 17:16:14 -0800996 }
997}
998
999func Test_graphviz(t *testing.T) {
1000 tests := []struct {
1001 condition string
1002 name string
1003 roots []string
1004 ctx context
1005 expectedOut []getMatcher
1006 }{
1007 {
1008 condition: "firstparty",
1009 name: "apex",
1010 roots: []string{"highest.apex.meta_lic"},
1011 expectedOut: []getMatcher{
1012 matchTarget("testdata/firstparty/bin/bin1.meta_lic"),
1013 matchTarget("testdata/firstparty/lib/liba.so.meta_lic"),
1014 matchTarget("testdata/firstparty/lib/libc.a.meta_lic"),
1015 matchTarget("testdata/firstparty/bin/bin2.meta_lic"),
1016 matchTarget("testdata/firstparty/highest.apex.meta_lic"),
1017 matchTarget("testdata/firstparty/lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08001018 matchResolution(
1019 "testdata/firstparty/bin/bin1.meta_lic",
1020 "testdata/firstparty/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001021 "notice"),
1022 matchResolution(
1023 "testdata/firstparty/bin/bin1.meta_lic",
1024 "testdata/firstparty/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001025 "notice"),
1026 matchResolution(
1027 "testdata/firstparty/bin/bin1.meta_lic",
1028 "testdata/firstparty/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001029 "notice"),
1030 matchResolution(
1031 "testdata/firstparty/bin/bin2.meta_lic",
1032 "testdata/firstparty/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001033 "notice"),
1034 matchResolution(
1035 "testdata/firstparty/highest.apex.meta_lic",
1036 "testdata/firstparty/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001037 "notice"),
1038 matchResolution(
1039 "testdata/firstparty/highest.apex.meta_lic",
1040 "testdata/firstparty/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001041 "notice"),
1042 matchResolution(
1043 "testdata/firstparty/highest.apex.meta_lic",
1044 "testdata/firstparty/highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001045 "notice"),
1046 matchResolution(
1047 "testdata/firstparty/highest.apex.meta_lic",
1048 "testdata/firstparty/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001049 "notice"),
1050 matchResolution(
1051 "testdata/firstparty/highest.apex.meta_lic",
1052 "testdata/firstparty/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001053 "notice"),
1054 matchResolution(
1055 "testdata/firstparty/highest.apex.meta_lic",
1056 "testdata/firstparty/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001057 "notice"),
1058 matchResolution(
1059 "testdata/firstparty/lib/liba.so.meta_lic",
1060 "testdata/firstparty/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001061 "notice"),
1062 matchResolution(
1063 "testdata/firstparty/lib/libb.so.meta_lic",
1064 "testdata/firstparty/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001065 "notice"),
1066 },
1067 },
1068 {
1069 condition: "firstparty",
1070 name: "apex_trimmed",
1071 roots: []string{"highest.apex.meta_lic"},
1072 ctx: context{stripPrefix: "testdata/firstparty/"},
1073 expectedOut: []getMatcher{
1074 matchTarget("bin/bin1.meta_lic"),
1075 matchTarget("lib/liba.so.meta_lic"),
1076 matchTarget("lib/libc.a.meta_lic"),
1077 matchTarget("bin/bin2.meta_lic"),
1078 matchTarget("highest.apex.meta_lic"),
1079 matchTarget("lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08001080 matchResolution(
1081 "bin/bin1.meta_lic",
1082 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001083 "notice"),
1084 matchResolution(
1085 "bin/bin1.meta_lic",
1086 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001087 "notice"),
1088 matchResolution(
1089 "bin/bin1.meta_lic",
1090 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001091 "notice"),
1092 matchResolution(
1093 "bin/bin2.meta_lic",
1094 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001095 "notice"),
1096 matchResolution(
1097 "highest.apex.meta_lic",
1098 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001099 "notice"),
1100 matchResolution(
1101 "highest.apex.meta_lic",
1102 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001103 "notice"),
1104 matchResolution(
1105 "highest.apex.meta_lic",
1106 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001107 "notice"),
1108 matchResolution(
1109 "highest.apex.meta_lic",
1110 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001111 "notice"),
1112 matchResolution(
1113 "highest.apex.meta_lic",
1114 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001115 "notice"),
1116 matchResolution(
1117 "highest.apex.meta_lic",
1118 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001119 "notice"),
1120 matchResolution(
1121 "lib/liba.so.meta_lic",
1122 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001123 "notice"),
1124 matchResolution(
1125 "lib/libb.so.meta_lic",
1126 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001127 "notice"),
1128 },
1129 },
1130 {
1131 condition: "firstparty",
1132 name: "apex_trimmed_notice",
1133 roots: []string{"highest.apex.meta_lic"},
1134 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08001135 conditions: []compliance.LicenseCondition{compliance.NoticeCondition},
Bob Badour1ded0a12021-12-03 17:16:14 -08001136 stripPrefix: "testdata/firstparty/",
1137 },
1138 expectedOut: []getMatcher{
1139 matchTarget("bin/bin1.meta_lic"),
1140 matchTarget("lib/liba.so.meta_lic"),
1141 matchTarget("lib/libc.a.meta_lic"),
1142 matchTarget("bin/bin2.meta_lic"),
1143 matchTarget("highest.apex.meta_lic"),
1144 matchTarget("lib/libb.so.meta_lic"),
1145 matchResolution(
1146 "bin/bin1.meta_lic",
1147 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001148 "notice"),
1149 matchResolution(
1150 "bin/bin1.meta_lic",
1151 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001152 "notice"),
1153 matchResolution(
1154 "bin/bin1.meta_lic",
1155 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001156 "notice"),
1157 matchResolution(
1158 "bin/bin2.meta_lic",
1159 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001160 "notice"),
1161 matchResolution(
1162 "highest.apex.meta_lic",
1163 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001164 "notice"),
1165 matchResolution(
1166 "highest.apex.meta_lic",
1167 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001168 "notice"),
1169 matchResolution(
1170 "highest.apex.meta_lic",
1171 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001172 "notice"),
1173 matchResolution(
1174 "highest.apex.meta_lic",
1175 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001176 "notice"),
1177 matchResolution(
1178 "highest.apex.meta_lic",
1179 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001180 "notice"),
1181 matchResolution(
1182 "highest.apex.meta_lic",
1183 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001184 "notice"),
1185 matchResolution(
1186 "lib/liba.so.meta_lic",
1187 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001188 "notice"),
1189 matchResolution(
1190 "lib/libb.so.meta_lic",
1191 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001192 "notice"),
1193 },
1194 },
1195 {
1196 condition: "firstparty",
1197 name: "apex_trimmed_share",
1198 roots: []string{"highest.apex.meta_lic"},
1199 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08001200 conditions: compliance.ImpliesShared.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -08001201 stripPrefix: "testdata/firstparty/",
1202 },
1203 expectedOut: []getMatcher{},
1204 },
1205 {
1206 condition: "firstparty",
1207 name: "apex_trimmed_private",
1208 roots: []string{"highest.apex.meta_lic"},
1209 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08001210 conditions: compliance.ImpliesPrivate.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -08001211 stripPrefix: "testdata/firstparty/",
1212 },
1213 expectedOut: []getMatcher{},
1214 },
1215 {
1216 condition: "firstparty",
1217 name: "apex_trimmed_share_private",
1218 roots: []string{"highest.apex.meta_lic"},
1219 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08001220 conditions: compliance.ImpliesShared.Union(compliance.ImpliesPrivate).AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -08001221 stripPrefix: "testdata/firstparty/",
1222 },
1223 expectedOut: []getMatcher{},
1224 },
1225 {
1226 condition: "firstparty",
1227 name: "apex_trimmed_labelled",
1228 roots: []string{"highest.apex.meta_lic"},
1229 ctx: context{stripPrefix: "testdata/firstparty/", labelConditions: true},
1230 expectedOut: []getMatcher{
1231 matchTarget("bin/bin1.meta_lic", "notice"),
1232 matchTarget("lib/liba.so.meta_lic", "notice"),
1233 matchTarget("lib/libc.a.meta_lic", "notice"),
1234 matchTarget("bin/bin2.meta_lic", "notice"),
1235 matchTarget("highest.apex.meta_lic", "notice"),
1236 matchTarget("lib/libb.so.meta_lic", "notice"),
Bob Badour1ded0a12021-12-03 17:16:14 -08001237 matchResolution(
1238 "bin/bin1.meta_lic",
1239 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001240 "notice"),
1241 matchResolution(
1242 "bin/bin1.meta_lic",
1243 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001244 "notice"),
1245 matchResolution(
1246 "bin/bin1.meta_lic",
1247 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001248 "notice"),
1249 matchResolution(
1250 "bin/bin2.meta_lic",
1251 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001252 "notice"),
1253 matchResolution(
1254 "highest.apex.meta_lic",
1255 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001256 "notice"),
1257 matchResolution(
1258 "highest.apex.meta_lic",
1259 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001260 "notice"),
1261 matchResolution(
1262 "highest.apex.meta_lic",
1263 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001264 "notice"),
1265 matchResolution(
1266 "highest.apex.meta_lic",
1267 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001268 "notice"),
1269 matchResolution(
1270 "highest.apex.meta_lic",
1271 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001272 "notice"),
1273 matchResolution(
1274 "highest.apex.meta_lic",
1275 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001276 "notice"),
1277 matchResolution(
1278 "lib/liba.so.meta_lic",
1279 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001280 "notice"),
1281 matchResolution(
1282 "lib/libb.so.meta_lic",
1283 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001284 "notice"),
1285 },
1286 },
1287 {
1288 condition: "firstparty",
1289 name: "container",
1290 roots: []string{"container.zip.meta_lic"},
1291 expectedOut: []getMatcher{
1292 matchTarget("testdata/firstparty/bin/bin1.meta_lic"),
1293 matchTarget("testdata/firstparty/lib/liba.so.meta_lic"),
1294 matchTarget("testdata/firstparty/lib/libc.a.meta_lic"),
1295 matchTarget("testdata/firstparty/bin/bin2.meta_lic"),
1296 matchTarget("testdata/firstparty/container.zip.meta_lic"),
1297 matchTarget("testdata/firstparty/lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08001298 matchResolution(
1299 "testdata/firstparty/bin/bin1.meta_lic",
1300 "testdata/firstparty/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001301 "notice"),
1302 matchResolution(
1303 "testdata/firstparty/bin/bin1.meta_lic",
1304 "testdata/firstparty/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001305 "notice"),
1306 matchResolution(
1307 "testdata/firstparty/bin/bin1.meta_lic",
1308 "testdata/firstparty/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001309 "notice"),
1310 matchResolution(
1311 "testdata/firstparty/bin/bin2.meta_lic",
1312 "testdata/firstparty/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001313 "notice"),
1314 matchResolution(
1315 "testdata/firstparty/container.zip.meta_lic",
1316 "testdata/firstparty/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001317 "notice"),
1318 matchResolution(
1319 "testdata/firstparty/container.zip.meta_lic",
1320 "testdata/firstparty/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001321 "notice"),
1322 matchResolution(
1323 "testdata/firstparty/container.zip.meta_lic",
1324 "testdata/firstparty/container.zip.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001325 "notice"),
1326 matchResolution(
1327 "testdata/firstparty/container.zip.meta_lic",
1328 "testdata/firstparty/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001329 "notice"),
1330 matchResolution(
1331 "testdata/firstparty/container.zip.meta_lic",
1332 "testdata/firstparty/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001333 "notice"),
1334 matchResolution(
1335 "testdata/firstparty/container.zip.meta_lic",
1336 "testdata/firstparty/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001337 "notice"),
1338 matchResolution(
1339 "testdata/firstparty/lib/liba.so.meta_lic",
1340 "testdata/firstparty/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001341 "notice"),
1342 matchResolution(
1343 "testdata/firstparty/lib/libb.so.meta_lic",
1344 "testdata/firstparty/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001345 "notice"),
1346 },
1347 },
1348 {
1349 condition: "firstparty",
1350 name: "application",
1351 roots: []string{"application.meta_lic"},
1352 expectedOut: []getMatcher{
1353 matchTarget("testdata/firstparty/application.meta_lic"),
1354 matchTarget("testdata/firstparty/lib/liba.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08001355 matchResolution(
1356 "testdata/firstparty/application.meta_lic",
1357 "testdata/firstparty/application.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001358 "notice"),
1359 matchResolution(
1360 "testdata/firstparty/application.meta_lic",
1361 "testdata/firstparty/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001362 "notice"),
1363 },
1364 },
1365 {
1366 condition: "firstparty",
1367 name: "binary",
1368 roots: []string{"bin/bin1.meta_lic"},
1369 expectedOut: []getMatcher{
1370 matchTarget("testdata/firstparty/bin/bin1.meta_lic"),
1371 matchTarget("testdata/firstparty/lib/liba.so.meta_lic"),
1372 matchTarget("testdata/firstparty/lib/libc.a.meta_lic"),
1373 matchResolution(
1374 "testdata/firstparty/bin/bin1.meta_lic",
1375 "testdata/firstparty/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001376 "notice"),
1377 matchResolution(
1378 "testdata/firstparty/bin/bin1.meta_lic",
1379 "testdata/firstparty/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001380 "notice"),
1381 matchResolution(
1382 "testdata/firstparty/bin/bin1.meta_lic",
1383 "testdata/firstparty/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001384 "notice"),
1385 },
1386 },
1387 {
1388 condition: "firstparty",
1389 name: "library",
1390 roots: []string{"lib/libd.so.meta_lic"},
1391 expectedOut: []getMatcher{
1392 matchTarget("testdata/firstparty/lib/libd.so.meta_lic"),
1393 matchResolution(
1394 "testdata/firstparty/lib/libd.so.meta_lic",
1395 "testdata/firstparty/lib/libd.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001396 "notice"),
1397 },
1398 },
1399 {
1400 condition: "notice",
1401 name: "apex",
1402 roots: []string{"highest.apex.meta_lic"},
1403 expectedOut: []getMatcher{
1404 matchTarget("testdata/notice/bin/bin1.meta_lic"),
1405 matchTarget("testdata/notice/lib/liba.so.meta_lic"),
1406 matchTarget("testdata/notice/lib/libc.a.meta_lic"),
1407 matchTarget("testdata/notice/bin/bin2.meta_lic"),
1408 matchTarget("testdata/notice/highest.apex.meta_lic"),
1409 matchTarget("testdata/notice/lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08001410 matchResolution(
1411 "testdata/notice/bin/bin1.meta_lic",
1412 "testdata/notice/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001413 "notice"),
1414 matchResolution(
1415 "testdata/notice/bin/bin1.meta_lic",
1416 "testdata/notice/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001417 "notice"),
1418 matchResolution(
1419 "testdata/notice/bin/bin1.meta_lic",
1420 "testdata/notice/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001421 "notice"),
1422 matchResolution(
1423 "testdata/notice/bin/bin2.meta_lic",
1424 "testdata/notice/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001425 "notice"),
1426 matchResolution(
1427 "testdata/notice/highest.apex.meta_lic",
1428 "testdata/notice/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001429 "notice"),
1430 matchResolution(
1431 "testdata/notice/highest.apex.meta_lic",
1432 "testdata/notice/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001433 "notice"),
1434 matchResolution(
1435 "testdata/notice/highest.apex.meta_lic",
1436 "testdata/notice/highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001437 "notice"),
1438 matchResolution(
1439 "testdata/notice/highest.apex.meta_lic",
1440 "testdata/notice/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001441 "notice"),
1442 matchResolution(
1443 "testdata/notice/highest.apex.meta_lic",
1444 "testdata/notice/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001445 "notice"),
1446 matchResolution(
1447 "testdata/notice/highest.apex.meta_lic",
1448 "testdata/notice/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001449 "notice"),
1450 matchResolution(
1451 "testdata/notice/lib/liba.so.meta_lic",
1452 "testdata/notice/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001453 "notice"),
1454 matchResolution(
1455 "testdata/notice/lib/libb.so.meta_lic",
1456 "testdata/notice/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001457 "notice"),
1458 },
1459 },
1460 {
1461 condition: "notice",
1462 name: "apex_trimmed",
1463 roots: []string{"highest.apex.meta_lic"},
1464 ctx: context{stripPrefix: "testdata/notice/"},
1465 expectedOut: []getMatcher{
1466 matchTarget("bin/bin1.meta_lic"),
1467 matchTarget("lib/liba.so.meta_lic"),
1468 matchTarget("lib/libc.a.meta_lic"),
1469 matchTarget("bin/bin2.meta_lic"),
1470 matchTarget("highest.apex.meta_lic"),
1471 matchTarget("lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08001472 matchResolution(
1473 "bin/bin1.meta_lic",
1474 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001475 "notice"),
1476 matchResolution(
1477 "bin/bin1.meta_lic",
1478 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001479 "notice"),
1480 matchResolution(
1481 "bin/bin1.meta_lic",
1482 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001483 "notice"),
1484 matchResolution(
1485 "bin/bin2.meta_lic",
1486 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001487 "notice"),
1488 matchResolution(
1489 "highest.apex.meta_lic",
1490 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001491 "notice"),
1492 matchResolution(
1493 "highest.apex.meta_lic",
1494 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001495 "notice"),
1496 matchResolution(
1497 "highest.apex.meta_lic",
1498 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001499 "notice"),
1500 matchResolution(
1501 "highest.apex.meta_lic",
1502 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001503 "notice"),
1504 matchResolution(
1505 "highest.apex.meta_lic",
1506 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001507 "notice"),
1508 matchResolution(
1509 "highest.apex.meta_lic",
1510 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001511 "notice"),
1512 matchResolution(
1513 "lib/liba.so.meta_lic",
1514 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001515 "notice"),
1516 matchResolution(
1517 "lib/libb.so.meta_lic",
1518 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001519 "notice"),
1520 },
1521 },
1522 {
1523 condition: "notice",
1524 name: "apex_trimmed_notice",
1525 roots: []string{"highest.apex.meta_lic"},
1526 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08001527 conditions: []compliance.LicenseCondition{compliance.NoticeCondition},
Bob Badour1ded0a12021-12-03 17:16:14 -08001528 stripPrefix: "testdata/notice/",
1529 },
1530 expectedOut: []getMatcher{
1531 matchTarget("bin/bin1.meta_lic"),
1532 matchTarget("lib/liba.so.meta_lic"),
1533 matchTarget("lib/libc.a.meta_lic"),
1534 matchTarget("bin/bin2.meta_lic"),
1535 matchTarget("highest.apex.meta_lic"),
1536 matchTarget("lib/libb.so.meta_lic"),
1537 matchResolution(
1538 "bin/bin1.meta_lic",
1539 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001540 "notice"),
1541 matchResolution(
1542 "bin/bin1.meta_lic",
1543 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001544 "notice"),
1545 matchResolution(
1546 "bin/bin1.meta_lic",
1547 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001548 "notice"),
1549 matchResolution(
1550 "bin/bin2.meta_lic",
1551 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001552 "notice"),
1553 matchResolution(
1554 "highest.apex.meta_lic",
1555 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001556 "notice"),
1557 matchResolution(
1558 "highest.apex.meta_lic",
1559 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001560 "notice"),
1561 matchResolution(
1562 "highest.apex.meta_lic",
1563 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001564 "notice"),
1565 matchResolution(
1566 "highest.apex.meta_lic",
1567 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001568 "notice"),
1569 matchResolution(
1570 "highest.apex.meta_lic",
1571 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001572 "notice"),
1573 matchResolution(
1574 "highest.apex.meta_lic",
1575 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001576 "notice"),
1577 matchResolution(
1578 "lib/liba.so.meta_lic",
1579 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001580 "notice"),
1581 matchResolution(
1582 "lib/libb.so.meta_lic",
1583 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001584 "notice"),
1585 },
1586 },
1587 {
1588 condition: "notice",
1589 name: "apex_trimmed_share",
1590 roots: []string{"highest.apex.meta_lic"},
1591 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08001592 conditions: compliance.ImpliesShared.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -08001593 stripPrefix: "testdata/notice/",
1594 },
1595 expectedOut: []getMatcher{},
1596 },
1597 {
1598 condition: "notice",
1599 name: "apex_trimmed_private",
1600 roots: []string{"highest.apex.meta_lic"},
1601 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08001602 conditions: compliance.ImpliesPrivate.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -08001603 stripPrefix: "testdata/notice/",
1604 },
1605 expectedOut: []getMatcher{},
1606 },
1607 {
1608 condition: "notice",
1609 name: "apex_trimmed_share_private",
1610 roots: []string{"highest.apex.meta_lic"},
1611 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08001612 conditions: compliance.ImpliesShared.Union(compliance.ImpliesPrivate).AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -08001613 stripPrefix: "testdata/notice/",
1614 },
1615 expectedOut: []getMatcher{},
1616 },
1617 {
1618 condition: "notice",
1619 name: "apex_trimmed_labelled",
1620 roots: []string{"highest.apex.meta_lic"},
1621 ctx: context{stripPrefix: "testdata/notice/", labelConditions: true},
1622 expectedOut: []getMatcher{
1623 matchTarget("bin/bin1.meta_lic", "notice"),
1624 matchTarget("lib/liba.so.meta_lic", "notice"),
1625 matchTarget("lib/libc.a.meta_lic", "notice"),
1626 matchTarget("bin/bin2.meta_lic", "notice"),
1627 matchTarget("highest.apex.meta_lic", "notice"),
1628 matchTarget("lib/libb.so.meta_lic", "notice"),
Bob Badour1ded0a12021-12-03 17:16:14 -08001629 matchResolution(
1630 "bin/bin1.meta_lic",
1631 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001632 "notice"),
1633 matchResolution(
1634 "bin/bin1.meta_lic",
1635 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001636 "notice"),
1637 matchResolution(
1638 "bin/bin1.meta_lic",
1639 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001640 "notice"),
1641 matchResolution(
1642 "bin/bin2.meta_lic",
1643 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001644 "notice"),
1645 matchResolution(
1646 "highest.apex.meta_lic",
1647 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001648 "notice"),
1649 matchResolution(
1650 "highest.apex.meta_lic",
1651 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001652 "notice"),
1653 matchResolution(
1654 "highest.apex.meta_lic",
1655 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001656 "notice"),
1657 matchResolution(
1658 "highest.apex.meta_lic",
1659 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001660 "notice"),
1661 matchResolution(
1662 "highest.apex.meta_lic",
1663 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001664 "notice"),
1665 matchResolution(
1666 "highest.apex.meta_lic",
1667 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001668 "notice"),
1669 matchResolution(
1670 "lib/liba.so.meta_lic",
1671 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001672 "notice"),
1673 matchResolution(
1674 "lib/libb.so.meta_lic",
1675 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001676 "notice"),
1677 },
1678 },
1679 {
1680 condition: "notice",
1681 name: "container",
1682 roots: []string{"container.zip.meta_lic"},
1683 expectedOut: []getMatcher{
1684 matchTarget("testdata/notice/bin/bin1.meta_lic"),
1685 matchTarget("testdata/notice/lib/liba.so.meta_lic"),
1686 matchTarget("testdata/notice/lib/libc.a.meta_lic"),
1687 matchTarget("testdata/notice/bin/bin2.meta_lic"),
1688 matchTarget("testdata/notice/container.zip.meta_lic"),
1689 matchTarget("testdata/notice/lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08001690 matchResolution(
1691 "testdata/notice/bin/bin1.meta_lic",
1692 "testdata/notice/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001693 "notice"),
1694 matchResolution(
1695 "testdata/notice/bin/bin1.meta_lic",
1696 "testdata/notice/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001697 "notice"),
1698 matchResolution(
1699 "testdata/notice/bin/bin1.meta_lic",
1700 "testdata/notice/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001701 "notice"),
1702 matchResolution(
1703 "testdata/notice/bin/bin2.meta_lic",
1704 "testdata/notice/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001705 "notice"),
1706 matchResolution(
1707 "testdata/notice/container.zip.meta_lic",
1708 "testdata/notice/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001709 "notice"),
1710 matchResolution(
1711 "testdata/notice/container.zip.meta_lic",
1712 "testdata/notice/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001713 "notice"),
1714 matchResolution(
1715 "testdata/notice/container.zip.meta_lic",
1716 "testdata/notice/container.zip.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001717 "notice"),
1718 matchResolution(
1719 "testdata/notice/container.zip.meta_lic",
1720 "testdata/notice/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001721 "notice"),
1722 matchResolution(
1723 "testdata/notice/container.zip.meta_lic",
1724 "testdata/notice/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001725 "notice"),
1726 matchResolution(
1727 "testdata/notice/container.zip.meta_lic",
1728 "testdata/notice/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001729 "notice"),
1730 matchResolution(
1731 "testdata/notice/lib/liba.so.meta_lic",
1732 "testdata/notice/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001733 "notice"),
1734 matchResolution(
1735 "testdata/notice/lib/libb.so.meta_lic",
1736 "testdata/notice/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001737 "notice"),
1738 },
1739 },
1740 {
1741 condition: "notice",
1742 name: "application",
1743 roots: []string{"application.meta_lic"},
1744 expectedOut: []getMatcher{
1745 matchTarget("testdata/notice/application.meta_lic"),
1746 matchTarget("testdata/notice/lib/liba.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08001747 matchResolution(
1748 "testdata/notice/application.meta_lic",
1749 "testdata/notice/application.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001750 "notice"),
1751 matchResolution(
1752 "testdata/notice/application.meta_lic",
1753 "testdata/notice/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001754 "notice"),
1755 },
1756 },
1757 {
1758 condition: "notice",
1759 name: "binary",
1760 roots: []string{"bin/bin1.meta_lic"},
1761 expectedOut: []getMatcher{
1762 matchTarget("testdata/notice/bin/bin1.meta_lic"),
1763 matchTarget("testdata/notice/lib/liba.so.meta_lic"),
1764 matchTarget("testdata/notice/lib/libc.a.meta_lic"),
1765 matchResolution(
1766 "testdata/notice/bin/bin1.meta_lic",
1767 "testdata/notice/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001768 "notice"),
1769 matchResolution(
1770 "testdata/notice/bin/bin1.meta_lic",
1771 "testdata/notice/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001772 "notice"),
1773 matchResolution(
1774 "testdata/notice/bin/bin1.meta_lic",
1775 "testdata/notice/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001776 "notice"),
1777 },
1778 },
1779 {
1780 condition: "notice",
1781 name: "library",
1782 roots: []string{"lib/libd.so.meta_lic"},
1783 expectedOut: []getMatcher{
1784 matchTarget("testdata/notice/lib/libd.so.meta_lic"),
1785 matchResolution(
1786 "testdata/notice/lib/libd.so.meta_lic",
1787 "testdata/notice/lib/libd.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001788 "notice"),
1789 },
1790 },
1791 {
1792 condition: "reciprocal",
1793 name: "apex",
1794 roots: []string{"highest.apex.meta_lic"},
1795 expectedOut: []getMatcher{
1796 matchTarget("testdata/reciprocal/bin/bin1.meta_lic"),
1797 matchTarget("testdata/reciprocal/lib/liba.so.meta_lic"),
1798 matchTarget("testdata/reciprocal/lib/libc.a.meta_lic"),
1799 matchTarget("testdata/reciprocal/bin/bin2.meta_lic"),
1800 matchTarget("testdata/reciprocal/highest.apex.meta_lic"),
1801 matchTarget("testdata/reciprocal/lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08001802 matchResolution(
1803 "testdata/reciprocal/bin/bin1.meta_lic",
1804 "testdata/reciprocal/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001805 "notice"),
1806 matchResolution(
1807 "testdata/reciprocal/bin/bin1.meta_lic",
1808 "testdata/reciprocal/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001809 "reciprocal"),
1810 matchResolution(
1811 "testdata/reciprocal/bin/bin1.meta_lic",
1812 "testdata/reciprocal/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001813 "reciprocal"),
1814 matchResolution(
1815 "testdata/reciprocal/bin/bin2.meta_lic",
1816 "testdata/reciprocal/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001817 "notice"),
1818 matchResolution(
1819 "testdata/reciprocal/highest.apex.meta_lic",
1820 "testdata/reciprocal/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001821 "notice"),
1822 matchResolution(
1823 "testdata/reciprocal/highest.apex.meta_lic",
1824 "testdata/reciprocal/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001825 "notice"),
1826 matchResolution(
1827 "testdata/reciprocal/highest.apex.meta_lic",
1828 "testdata/reciprocal/highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001829 "notice"),
1830 matchResolution(
1831 "testdata/reciprocal/highest.apex.meta_lic",
1832 "testdata/reciprocal/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001833 "reciprocal"),
1834 matchResolution(
1835 "testdata/reciprocal/highest.apex.meta_lic",
1836 "testdata/reciprocal/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001837 "notice"),
1838 matchResolution(
1839 "testdata/reciprocal/highest.apex.meta_lic",
1840 "testdata/reciprocal/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001841 "reciprocal"),
1842 matchResolution(
1843 "testdata/reciprocal/lib/liba.so.meta_lic",
1844 "testdata/reciprocal/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001845 "reciprocal"),
1846 matchResolution(
1847 "testdata/reciprocal/lib/libb.so.meta_lic",
1848 "testdata/reciprocal/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001849 "notice"),
1850 },
1851 },
1852 {
1853 condition: "reciprocal",
1854 name: "apex_trimmed",
1855 roots: []string{"highest.apex.meta_lic"},
1856 ctx: context{stripPrefix: "testdata/reciprocal/"},
1857 expectedOut: []getMatcher{
1858 matchTarget("bin/bin1.meta_lic"),
1859 matchTarget("lib/liba.so.meta_lic"),
1860 matchTarget("lib/libc.a.meta_lic"),
1861 matchTarget("bin/bin2.meta_lic"),
1862 matchTarget("highest.apex.meta_lic"),
1863 matchTarget("lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08001864 matchResolution(
1865 "bin/bin1.meta_lic",
1866 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001867 "notice"),
1868 matchResolution(
1869 "bin/bin1.meta_lic",
1870 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001871 "reciprocal"),
1872 matchResolution(
1873 "bin/bin1.meta_lic",
1874 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001875 "reciprocal"),
1876 matchResolution(
1877 "bin/bin2.meta_lic",
1878 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001879 "notice"),
1880 matchResolution(
1881 "highest.apex.meta_lic",
1882 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001883 "notice"),
1884 matchResolution(
1885 "highest.apex.meta_lic",
1886 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001887 "notice"),
1888 matchResolution(
1889 "highest.apex.meta_lic",
1890 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001891 "notice"),
1892 matchResolution(
1893 "highest.apex.meta_lic",
1894 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001895 "reciprocal"),
1896 matchResolution(
1897 "highest.apex.meta_lic",
1898 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001899 "notice"),
1900 matchResolution(
1901 "highest.apex.meta_lic",
1902 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001903 "reciprocal"),
1904 matchResolution(
1905 "lib/liba.so.meta_lic",
1906 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001907 "reciprocal"),
1908 matchResolution(
1909 "lib/libb.so.meta_lic",
1910 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001911 "notice"),
1912 },
1913 },
1914 {
1915 condition: "reciprocal",
1916 name: "apex_trimmed_notice",
1917 roots: []string{"highest.apex.meta_lic"},
1918 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08001919 conditions: []compliance.LicenseCondition{compliance.NoticeCondition},
Bob Badour1ded0a12021-12-03 17:16:14 -08001920 stripPrefix: "testdata/reciprocal/",
1921 },
1922 expectedOut: []getMatcher{
1923 matchTarget("bin/bin1.meta_lic"),
1924 matchTarget("bin/bin2.meta_lic"),
1925 matchTarget("highest.apex.meta_lic"),
1926 matchTarget("lib/libb.so.meta_lic"),
1927 matchResolution(
1928 "bin/bin1.meta_lic",
1929 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001930 "notice"),
1931 matchResolution(
1932 "bin/bin2.meta_lic",
1933 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001934 "notice"),
1935 matchResolution(
1936 "highest.apex.meta_lic",
1937 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001938 "notice"),
1939 matchResolution(
1940 "highest.apex.meta_lic",
1941 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001942 "notice"),
1943 matchResolution(
1944 "highest.apex.meta_lic",
1945 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001946 "notice"),
1947 matchResolution(
1948 "highest.apex.meta_lic",
1949 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001950 "notice"),
1951 matchResolution(
1952 "lib/libb.so.meta_lic",
1953 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001954 "notice"),
1955 },
1956 },
1957 {
1958 condition: "reciprocal",
1959 name: "apex_trimmed_share",
1960 roots: []string{"highest.apex.meta_lic"},
1961 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08001962 conditions: compliance.ImpliesShared.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -08001963 stripPrefix: "testdata/reciprocal/",
1964 },
1965 expectedOut: []getMatcher{
1966 matchTarget("bin/bin1.meta_lic"),
1967 matchTarget("lib/liba.so.meta_lic"),
1968 matchTarget("lib/libc.a.meta_lic"),
1969 matchTarget("highest.apex.meta_lic"),
1970 matchResolution(
1971 "bin/bin1.meta_lic",
1972 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001973 "reciprocal"),
1974 matchResolution(
1975 "bin/bin1.meta_lic",
1976 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001977 "reciprocal"),
1978 matchResolution(
1979 "highest.apex.meta_lic",
1980 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001981 "reciprocal"),
1982 matchResolution(
1983 "highest.apex.meta_lic",
1984 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001985 "reciprocal"),
1986 matchResolution(
1987 "lib/liba.so.meta_lic",
1988 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001989 "reciprocal"),
1990 },
1991 },
1992 {
1993 condition: "reciprocal",
1994 name: "apex_trimmed_private",
1995 roots: []string{"highest.apex.meta_lic"},
1996 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08001997 conditions: compliance.ImpliesPrivate.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -08001998 stripPrefix: "testdata/reciprocal/",
1999 },
2000 expectedOut: []getMatcher{},
2001 },
2002 {
2003 condition: "reciprocal",
2004 name: "apex_trimmed_share_private",
2005 roots: []string{"highest.apex.meta_lic"},
2006 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08002007 conditions: compliance.ImpliesShared.Union(compliance.ImpliesPrivate).AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -08002008 stripPrefix: "testdata/reciprocal/",
2009 },
2010 expectedOut: []getMatcher{
2011 matchTarget("bin/bin1.meta_lic"),
2012 matchTarget("lib/liba.so.meta_lic"),
2013 matchTarget("lib/libc.a.meta_lic"),
2014 matchTarget("highest.apex.meta_lic"),
2015 matchResolution(
2016 "bin/bin1.meta_lic",
2017 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002018 "reciprocal"),
2019 matchResolution(
2020 "bin/bin1.meta_lic",
2021 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002022 "reciprocal"),
2023 matchResolution(
2024 "highest.apex.meta_lic",
2025 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002026 "reciprocal"),
2027 matchResolution(
2028 "highest.apex.meta_lic",
2029 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002030 "reciprocal"),
2031 matchResolution(
2032 "lib/liba.so.meta_lic",
2033 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002034 "reciprocal"),
2035 },
2036 },
2037 {
2038 condition: "reciprocal",
2039 name: "apex_trimmed_labelled",
2040 roots: []string{"highest.apex.meta_lic"},
2041 ctx: context{stripPrefix: "testdata/reciprocal/", labelConditions: true},
2042 expectedOut: []getMatcher{
2043 matchTarget("bin/bin1.meta_lic", "notice"),
2044 matchTarget("lib/liba.so.meta_lic", "reciprocal"),
2045 matchTarget("lib/libc.a.meta_lic", "reciprocal"),
2046 matchTarget("bin/bin2.meta_lic", "notice"),
2047 matchTarget("highest.apex.meta_lic", "notice"),
2048 matchTarget("lib/libb.so.meta_lic", "notice"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002049 matchResolution(
2050 "bin/bin1.meta_lic",
2051 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002052 "notice"),
2053 matchResolution(
2054 "bin/bin1.meta_lic",
2055 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002056 "reciprocal"),
2057 matchResolution(
2058 "bin/bin1.meta_lic",
2059 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002060 "reciprocal"),
2061 matchResolution(
2062 "bin/bin2.meta_lic",
2063 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002064 "notice"),
2065 matchResolution(
2066 "highest.apex.meta_lic",
2067 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002068 "notice"),
2069 matchResolution(
2070 "highest.apex.meta_lic",
2071 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002072 "notice"),
2073 matchResolution(
2074 "highest.apex.meta_lic",
2075 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002076 "notice"),
2077 matchResolution(
2078 "highest.apex.meta_lic",
2079 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002080 "reciprocal"),
2081 matchResolution(
2082 "highest.apex.meta_lic",
2083 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002084 "notice"),
2085 matchResolution(
2086 "highest.apex.meta_lic",
2087 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002088 "reciprocal"),
2089 matchResolution(
2090 "lib/liba.so.meta_lic",
2091 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002092 "reciprocal"),
2093 matchResolution(
2094 "lib/libb.so.meta_lic",
2095 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002096 "notice"),
2097 },
2098 },
2099 {
2100 condition: "reciprocal",
2101 name: "container",
2102 roots: []string{"container.zip.meta_lic"},
2103 expectedOut: []getMatcher{
2104 matchTarget("testdata/reciprocal/bin/bin1.meta_lic"),
2105 matchTarget("testdata/reciprocal/lib/liba.so.meta_lic"),
2106 matchTarget("testdata/reciprocal/lib/libc.a.meta_lic"),
2107 matchTarget("testdata/reciprocal/bin/bin2.meta_lic"),
2108 matchTarget("testdata/reciprocal/container.zip.meta_lic"),
2109 matchTarget("testdata/reciprocal/lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002110 matchResolution(
2111 "testdata/reciprocal/bin/bin1.meta_lic",
2112 "testdata/reciprocal/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002113 "notice"),
2114 matchResolution(
2115 "testdata/reciprocal/bin/bin1.meta_lic",
2116 "testdata/reciprocal/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002117 "reciprocal"),
2118 matchResolution(
2119 "testdata/reciprocal/bin/bin1.meta_lic",
2120 "testdata/reciprocal/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002121 "reciprocal"),
2122 matchResolution(
2123 "testdata/reciprocal/bin/bin2.meta_lic",
2124 "testdata/reciprocal/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002125 "notice"),
2126 matchResolution(
2127 "testdata/reciprocal/container.zip.meta_lic",
2128 "testdata/reciprocal/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002129 "notice"),
2130 matchResolution(
2131 "testdata/reciprocal/container.zip.meta_lic",
2132 "testdata/reciprocal/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002133 "notice"),
2134 matchResolution(
2135 "testdata/reciprocal/container.zip.meta_lic",
2136 "testdata/reciprocal/container.zip.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002137 "notice"),
2138 matchResolution(
2139 "testdata/reciprocal/container.zip.meta_lic",
2140 "testdata/reciprocal/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002141 "reciprocal"),
2142 matchResolution(
2143 "testdata/reciprocal/container.zip.meta_lic",
2144 "testdata/reciprocal/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002145 "notice"),
2146 matchResolution(
2147 "testdata/reciprocal/container.zip.meta_lic",
2148 "testdata/reciprocal/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002149 "reciprocal"),
2150 matchResolution(
2151 "testdata/reciprocal/lib/liba.so.meta_lic",
2152 "testdata/reciprocal/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002153 "reciprocal"),
2154 matchResolution(
2155 "testdata/reciprocal/lib/libb.so.meta_lic",
2156 "testdata/reciprocal/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002157 "notice"),
2158 },
2159 },
2160 {
2161 condition: "reciprocal",
2162 name: "application",
2163 roots: []string{"application.meta_lic"},
2164 expectedOut: []getMatcher{
2165 matchTarget("testdata/reciprocal/application.meta_lic"),
2166 matchTarget("testdata/reciprocal/lib/liba.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002167 matchResolution(
2168 "testdata/reciprocal/application.meta_lic",
2169 "testdata/reciprocal/application.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002170 "notice"),
2171 matchResolution(
2172 "testdata/reciprocal/application.meta_lic",
2173 "testdata/reciprocal/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002174 "reciprocal"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002175 },
2176 },
2177 {
2178 condition: "reciprocal",
2179 name: "binary",
2180 roots: []string{"bin/bin1.meta_lic"},
2181 expectedOut: []getMatcher{
2182 matchTarget("testdata/reciprocal/bin/bin1.meta_lic"),
2183 matchTarget("testdata/reciprocal/lib/liba.so.meta_lic"),
2184 matchTarget("testdata/reciprocal/lib/libc.a.meta_lic"),
2185 matchResolution(
2186 "testdata/reciprocal/bin/bin1.meta_lic",
2187 "testdata/reciprocal/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002188 "notice"),
2189 matchResolution(
2190 "testdata/reciprocal/bin/bin1.meta_lic",
2191 "testdata/reciprocal/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002192 "reciprocal"),
2193 matchResolution(
2194 "testdata/reciprocal/bin/bin1.meta_lic",
2195 "testdata/reciprocal/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002196 "reciprocal"),
2197 },
2198 },
2199 {
2200 condition: "reciprocal",
2201 name: "library",
2202 roots: []string{"lib/libd.so.meta_lic"},
2203 expectedOut: []getMatcher{
2204 matchTarget("testdata/reciprocal/lib/libd.so.meta_lic"),
2205 matchResolution(
2206 "testdata/reciprocal/lib/libd.so.meta_lic",
2207 "testdata/reciprocal/lib/libd.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002208 "notice"),
2209 },
2210 },
2211 {
2212 condition: "restricted",
2213 name: "apex",
2214 roots: []string{"highest.apex.meta_lic"},
2215 expectedOut: []getMatcher{
2216 matchTarget("testdata/restricted/bin/bin1.meta_lic"),
2217 matchTarget("testdata/restricted/lib/liba.so.meta_lic"),
2218 matchTarget("testdata/restricted/lib/libc.a.meta_lic"),
2219 matchTarget("testdata/restricted/bin/bin2.meta_lic"),
2220 matchTarget("testdata/restricted/lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002221 matchTarget("testdata/restricted/highest.apex.meta_lic"),
2222 matchResolution(
2223 "testdata/restricted/bin/bin1.meta_lic",
2224 "testdata/restricted/bin/bin1.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002225 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002226 "notice"),
2227 matchResolution(
2228 "testdata/restricted/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002229 "testdata/restricted/lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002230 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002231 matchResolution(
2232 "testdata/restricted/bin/bin1.meta_lic",
2233 "testdata/restricted/lib/libc.a.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002234 "reciprocal",
2235 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002236 matchResolution(
2237 "testdata/restricted/bin/bin2.meta_lic",
2238 "testdata/restricted/bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002239 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002240 "notice"),
2241 matchResolution(
2242 "testdata/restricted/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002243 "testdata/restricted/lib/libb.so.meta_lic",
2244 "restricted"),
2245 matchResolution(
2246 "testdata/restricted/highest.apex.meta_lic",
2247 "testdata/restricted/bin/bin1.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002248 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002249 "notice"),
2250 matchResolution(
2251 "testdata/restricted/highest.apex.meta_lic",
2252 "testdata/restricted/bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002253 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002254 "notice"),
2255 matchResolution(
2256 "testdata/restricted/highest.apex.meta_lic",
2257 "testdata/restricted/highest.apex.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002258 "restricted",
2259 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002260 "notice"),
Bob Badour103eb0f2022-01-10 13:50:57 -08002261 matchResolution(
2262 "testdata/restricted/highest.apex.meta_lic",
2263 "testdata/restricted/lib/liba.so.meta_lic",
2264 "restricted_allows_dynamic_linking"),
2265 matchResolution(
2266 "testdata/restricted/highest.apex.meta_lic",
2267 "testdata/restricted/lib/libb.so.meta_lic",
2268 "restricted"),
2269 matchResolution(
2270 "testdata/restricted/highest.apex.meta_lic",
2271 "testdata/restricted/lib/libc.a.meta_lic",
2272 "reciprocal",
2273 "restricted_allows_dynamic_linking"),
2274 matchResolution(
2275 "testdata/restricted/lib/liba.so.meta_lic",
2276 "testdata/restricted/lib/liba.so.meta_lic",
2277 "restricted_allows_dynamic_linking"),
2278 matchResolution(
2279 "testdata/restricted/lib/libb.so.meta_lic",
2280 "testdata/restricted/lib/libb.so.meta_lic",
2281 "restricted"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002282 },
2283 },
2284 {
2285 condition: "restricted",
2286 name: "apex_trimmed",
2287 roots: []string{"highest.apex.meta_lic"},
2288 ctx: context{stripPrefix: "testdata/restricted/"},
2289 expectedOut: []getMatcher{
2290 matchTarget("bin/bin1.meta_lic"),
2291 matchTarget("lib/liba.so.meta_lic"),
2292 matchTarget("lib/libc.a.meta_lic"),
2293 matchTarget("bin/bin2.meta_lic"),
2294 matchTarget("lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002295 matchTarget("highest.apex.meta_lic"),
2296 matchResolution(
2297 "bin/bin1.meta_lic",
2298 "bin/bin1.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002299 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002300 "notice"),
2301 matchResolution(
2302 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002303 "lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002304 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002305 matchResolution(
2306 "bin/bin1.meta_lic",
2307 "lib/libc.a.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002308 "reciprocal",
2309 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002310 matchResolution(
2311 "bin/bin2.meta_lic",
2312 "bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002313 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002314 "notice"),
2315 matchResolution(
2316 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002317 "lib/libb.so.meta_lic",
2318 "restricted"),
2319 matchResolution(
2320 "highest.apex.meta_lic",
2321 "bin/bin1.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002322 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002323 "notice"),
2324 matchResolution(
2325 "highest.apex.meta_lic",
2326 "bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002327 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002328 "notice"),
2329 matchResolution(
2330 "highest.apex.meta_lic",
2331 "highest.apex.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002332 "restricted",
2333 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002334 "notice"),
Bob Badour103eb0f2022-01-10 13:50:57 -08002335 matchResolution(
2336 "highest.apex.meta_lic",
2337 "lib/liba.so.meta_lic",
2338 "restricted_allows_dynamic_linking"),
2339 matchResolution(
2340 "highest.apex.meta_lic",
2341 "lib/libb.so.meta_lic",
2342 "restricted"),
2343 matchResolution(
2344 "highest.apex.meta_lic",
2345 "lib/libc.a.meta_lic",
2346 "reciprocal",
2347 "restricted_allows_dynamic_linking"),
2348 matchResolution(
2349 "lib/liba.so.meta_lic",
2350 "lib/liba.so.meta_lic",
2351 "restricted_allows_dynamic_linking"),
2352 matchResolution(
2353 "lib/libb.so.meta_lic",
2354 "lib/libb.so.meta_lic",
2355 "restricted"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002356 },
2357 },
2358 {
2359 condition: "restricted",
2360 name: "apex_trimmed_notice",
2361 roots: []string{"highest.apex.meta_lic"},
2362 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08002363 conditions: []compliance.LicenseCondition{compliance.NoticeCondition},
Bob Badour1ded0a12021-12-03 17:16:14 -08002364 stripPrefix: "testdata/restricted/",
2365 },
2366 expectedOut: []getMatcher{
2367 matchTarget("bin/bin1.meta_lic"),
2368 matchTarget("bin/bin2.meta_lic"),
2369 matchTarget("highest.apex.meta_lic"),
2370 matchResolution(
2371 "bin/bin1.meta_lic",
2372 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002373 "notice"),
2374 matchResolution(
2375 "bin/bin2.meta_lic",
2376 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002377 "notice"),
2378 matchResolution(
2379 "highest.apex.meta_lic",
2380 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002381 "notice"),
2382 matchResolution(
2383 "highest.apex.meta_lic",
2384 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002385 "notice"),
2386 matchResolution(
2387 "highest.apex.meta_lic",
2388 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002389 "notice"),
2390 },
2391 },
2392 {
2393 condition: "restricted",
2394 name: "apex_trimmed_share",
2395 roots: []string{"highest.apex.meta_lic"},
2396 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08002397 conditions: compliance.ImpliesShared.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -08002398 stripPrefix: "testdata/restricted/",
2399 },
2400 expectedOut: []getMatcher{
2401 matchTarget("bin/bin1.meta_lic"),
2402 matchTarget("lib/liba.so.meta_lic"),
2403 matchTarget("lib/libc.a.meta_lic"),
2404 matchTarget("bin/bin2.meta_lic"),
2405 matchTarget("lib/libb.so.meta_lic"),
2406 matchTarget("highest.apex.meta_lic"),
2407 matchResolution(
2408 "bin/bin1.meta_lic",
2409 "bin/bin1.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002410 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002411 matchResolution(
2412 "bin/bin1.meta_lic",
2413 "lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002414 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002415 matchResolution(
2416 "bin/bin1.meta_lic",
2417 "lib/libc.a.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002418 "reciprocal",
2419 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002420 matchResolution(
2421 "bin/bin2.meta_lic",
2422 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002423 "restricted"),
2424 matchResolution(
2425 "bin/bin2.meta_lic",
2426 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002427 "restricted"),
2428 matchResolution(
2429 "highest.apex.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002430 "bin/bin1.meta_lic",
2431 "restricted_allows_dynamic_linking"),
2432 matchResolution(
Bob Badour1ded0a12021-12-03 17:16:14 -08002433 "highest.apex.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002434 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002435 "restricted"),
2436 matchResolution(
2437 "highest.apex.meta_lic",
2438 "highest.apex.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002439 "restricted",
2440 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002441 matchResolution(
2442 "highest.apex.meta_lic",
2443 "lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002444 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002445 matchResolution(
2446 "highest.apex.meta_lic",
2447 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002448 "restricted"),
2449 matchResolution(
2450 "highest.apex.meta_lic",
2451 "lib/libc.a.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002452 "reciprocal",
2453 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002454 matchResolution(
2455 "lib/liba.so.meta_lic",
2456 "lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002457 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002458 matchResolution(
2459 "lib/libb.so.meta_lic",
2460 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002461 "restricted"),
2462 },
2463 },
2464 {
2465 condition: "restricted",
2466 name: "apex_trimmed_private",
2467 roots: []string{"highest.apex.meta_lic"},
2468 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08002469 conditions: compliance.ImpliesPrivate.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -08002470 stripPrefix: "testdata/restricted/",
2471 },
2472 expectedOut: []getMatcher{},
2473 },
2474 {
2475 condition: "restricted",
2476 name: "apex_trimmed_share_private",
2477 roots: []string{"highest.apex.meta_lic"},
2478 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08002479 conditions: compliance.ImpliesShared.Union(compliance.ImpliesPrivate).AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -08002480 stripPrefix: "testdata/restricted/",
2481 },
2482 expectedOut: []getMatcher{
2483 matchTarget("bin/bin1.meta_lic"),
2484 matchTarget("lib/liba.so.meta_lic"),
2485 matchTarget("lib/libc.a.meta_lic"),
2486 matchTarget("bin/bin2.meta_lic"),
2487 matchTarget("lib/libb.so.meta_lic"),
2488 matchTarget("highest.apex.meta_lic"),
2489 matchResolution(
2490 "bin/bin1.meta_lic",
2491 "bin/bin1.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002492 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002493 matchResolution(
2494 "bin/bin1.meta_lic",
2495 "lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002496 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002497 matchResolution(
2498 "bin/bin1.meta_lic",
2499 "lib/libc.a.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002500 "reciprocal",
2501 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002502 matchResolution(
2503 "bin/bin2.meta_lic",
2504 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002505 "restricted"),
2506 matchResolution(
2507 "bin/bin2.meta_lic",
2508 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002509 "restricted"),
2510 matchResolution(
2511 "highest.apex.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002512 "bin/bin1.meta_lic",
2513 "restricted_allows_dynamic_linking"),
2514 matchResolution(
Bob Badour1ded0a12021-12-03 17:16:14 -08002515 "highest.apex.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002516 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002517 "restricted"),
2518 matchResolution(
2519 "highest.apex.meta_lic",
2520 "highest.apex.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002521 "restricted",
2522 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002523 matchResolution(
2524 "highest.apex.meta_lic",
2525 "lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002526 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002527 matchResolution(
2528 "highest.apex.meta_lic",
2529 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002530 "restricted"),
2531 matchResolution(
2532 "highest.apex.meta_lic",
2533 "lib/libc.a.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002534 "reciprocal",
2535 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002536 matchResolution(
2537 "lib/liba.so.meta_lic",
2538 "lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002539 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002540 matchResolution(
2541 "lib/libb.so.meta_lic",
2542 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002543 "restricted"),
2544 },
2545 },
2546 {
2547 condition: "restricted",
2548 name: "apex_trimmed_labelled",
2549 roots: []string{"highest.apex.meta_lic"},
2550 ctx: context{stripPrefix: "testdata/restricted/", labelConditions: true},
2551 expectedOut: []getMatcher{
2552 matchTarget("bin/bin1.meta_lic", "notice"),
Bob Badour103eb0f2022-01-10 13:50:57 -08002553 matchTarget("lib/liba.so.meta_lic", "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002554 matchTarget("lib/libc.a.meta_lic", "reciprocal"),
2555 matchTarget("bin/bin2.meta_lic", "notice"),
2556 matchTarget("lib/libb.so.meta_lic", "restricted"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002557 matchTarget("highest.apex.meta_lic", "notice"),
2558 matchResolution(
2559 "bin/bin1.meta_lic",
2560 "bin/bin1.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002561 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002562 "notice"),
2563 matchResolution(
2564 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002565 "lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002566 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002567 matchResolution(
2568 "bin/bin1.meta_lic",
2569 "lib/libc.a.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002570 "reciprocal",
2571 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002572 matchResolution(
2573 "bin/bin2.meta_lic",
2574 "bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002575 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002576 "notice"),
2577 matchResolution(
2578 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002579 "lib/libb.so.meta_lic",
2580 "restricted"),
2581 matchResolution(
2582 "highest.apex.meta_lic",
2583 "bin/bin1.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002584 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002585 "notice"),
2586 matchResolution(
2587 "highest.apex.meta_lic",
2588 "bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002589 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002590 "notice"),
2591 matchResolution(
2592 "highest.apex.meta_lic",
2593 "highest.apex.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002594 "restricted",
2595 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002596 "notice"),
Bob Badour103eb0f2022-01-10 13:50:57 -08002597 matchResolution(
2598 "highest.apex.meta_lic",
2599 "lib/liba.so.meta_lic",
2600 "restricted_allows_dynamic_linking"),
2601 matchResolution(
2602 "highest.apex.meta_lic",
2603 "lib/libb.so.meta_lic",
2604 "restricted"),
2605 matchResolution(
2606 "highest.apex.meta_lic",
2607 "lib/libc.a.meta_lic",
2608 "reciprocal",
2609 "restricted_allows_dynamic_linking"),
2610 matchResolution(
2611 "lib/liba.so.meta_lic",
2612 "lib/liba.so.meta_lic",
2613 "restricted_allows_dynamic_linking"),
2614 matchResolution(
2615 "lib/libb.so.meta_lic",
2616 "lib/libb.so.meta_lic",
2617 "restricted"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002618 },
2619 },
2620 {
2621 condition: "restricted",
2622 name: "container",
2623 roots: []string{"container.zip.meta_lic"},
2624 expectedOut: []getMatcher{
2625 matchTarget("testdata/restricted/bin/bin1.meta_lic"),
2626 matchTarget("testdata/restricted/lib/liba.so.meta_lic"),
2627 matchTarget("testdata/restricted/lib/libc.a.meta_lic"),
2628 matchTarget("testdata/restricted/bin/bin2.meta_lic"),
2629 matchTarget("testdata/restricted/lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002630 matchTarget("testdata/restricted/container.zip.meta_lic"),
2631 matchResolution(
2632 "testdata/restricted/bin/bin1.meta_lic",
2633 "testdata/restricted/bin/bin1.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002634 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002635 "notice"),
2636 matchResolution(
2637 "testdata/restricted/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002638 "testdata/restricted/lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002639 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002640 matchResolution(
2641 "testdata/restricted/bin/bin1.meta_lic",
2642 "testdata/restricted/lib/libc.a.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002643 "reciprocal",
2644 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002645 matchResolution(
2646 "testdata/restricted/bin/bin2.meta_lic",
2647 "testdata/restricted/bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002648 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002649 "notice"),
2650 matchResolution(
2651 "testdata/restricted/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002652 "testdata/restricted/lib/libb.so.meta_lic",
2653 "restricted"),
2654 matchResolution(
2655 "testdata/restricted/container.zip.meta_lic",
2656 "testdata/restricted/bin/bin1.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002657 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002658 "notice"),
2659 matchResolution(
2660 "testdata/restricted/container.zip.meta_lic",
2661 "testdata/restricted/bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002662 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002663 "notice"),
2664 matchResolution(
2665 "testdata/restricted/container.zip.meta_lic",
2666 "testdata/restricted/container.zip.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002667 "restricted",
2668 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002669 "notice"),
Bob Badour103eb0f2022-01-10 13:50:57 -08002670 matchResolution(
2671 "testdata/restricted/container.zip.meta_lic",
2672 "testdata/restricted/lib/liba.so.meta_lic",
2673 "restricted_allows_dynamic_linking"),
2674 matchResolution(
2675 "testdata/restricted/container.zip.meta_lic",
2676 "testdata/restricted/lib/libb.so.meta_lic",
2677 "restricted"),
2678 matchResolution(
2679 "testdata/restricted/container.zip.meta_lic",
2680 "testdata/restricted/lib/libc.a.meta_lic",
2681 "reciprocal",
2682 "restricted_allows_dynamic_linking"),
2683 matchResolution(
2684 "testdata/restricted/lib/liba.so.meta_lic",
2685 "testdata/restricted/lib/liba.so.meta_lic",
2686 "restricted_allows_dynamic_linking"),
2687 matchResolution(
2688 "testdata/restricted/lib/libb.so.meta_lic",
2689 "testdata/restricted/lib/libb.so.meta_lic",
2690 "restricted"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002691 },
2692 },
2693 {
2694 condition: "restricted",
2695 name: "application",
2696 roots: []string{"application.meta_lic"},
2697 expectedOut: []getMatcher{
2698 matchTarget("testdata/restricted/application.meta_lic"),
2699 matchTarget("testdata/restricted/lib/liba.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002700 matchResolution(
2701 "testdata/restricted/application.meta_lic",
2702 "testdata/restricted/application.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002703 "restricted",
2704 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002705 "notice"),
2706 matchResolution(
2707 "testdata/restricted/application.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002708 "testdata/restricted/lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002709 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002710 "restricted"),
2711 },
2712 },
2713 {
2714 condition: "restricted",
2715 name: "binary",
2716 roots: []string{"bin/bin1.meta_lic"},
2717 expectedOut: []getMatcher{
2718 matchTarget("testdata/restricted/bin/bin1.meta_lic"),
2719 matchTarget("testdata/restricted/lib/liba.so.meta_lic"),
2720 matchTarget("testdata/restricted/lib/libc.a.meta_lic"),
2721 matchResolution(
2722 "testdata/restricted/bin/bin1.meta_lic",
2723 "testdata/restricted/bin/bin1.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002724 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002725 "notice"),
2726 matchResolution(
2727 "testdata/restricted/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002728 "testdata/restricted/lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002729 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002730 matchResolution(
2731 "testdata/restricted/bin/bin1.meta_lic",
2732 "testdata/restricted/lib/libc.a.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002733 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002734 "reciprocal"),
2735 },
2736 },
2737 {
2738 condition: "restricted",
2739 name: "library",
2740 roots: []string{"lib/libd.so.meta_lic"},
2741 expectedOut: []getMatcher{
2742 matchTarget("testdata/restricted/lib/libd.so.meta_lic"),
2743 matchResolution(
2744 "testdata/restricted/lib/libd.so.meta_lic",
2745 "testdata/restricted/lib/libd.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002746 "notice"),
2747 },
2748 },
2749 {
2750 condition: "proprietary",
2751 name: "apex",
2752 roots: []string{"highest.apex.meta_lic"},
2753 expectedOut: []getMatcher{
2754 matchTarget("testdata/proprietary/bin/bin1.meta_lic"),
2755 matchTarget("testdata/proprietary/lib/liba.so.meta_lic"),
2756 matchTarget("testdata/proprietary/lib/libc.a.meta_lic"),
2757 matchTarget("testdata/proprietary/bin/bin2.meta_lic"),
2758 matchTarget("testdata/proprietary/lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002759 matchTarget("testdata/proprietary/highest.apex.meta_lic"),
2760 matchResolution(
2761 "testdata/proprietary/bin/bin1.meta_lic",
2762 "testdata/proprietary/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002763 "notice"),
2764 matchResolution(
2765 "testdata/proprietary/bin/bin1.meta_lic",
2766 "testdata/proprietary/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002767 "by_exception_only",
2768 "proprietary"),
2769 matchResolution(
2770 "testdata/proprietary/bin/bin1.meta_lic",
2771 "testdata/proprietary/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002772 "by_exception_only",
2773 "proprietary"),
2774 matchResolution(
2775 "testdata/proprietary/bin/bin2.meta_lic",
2776 "testdata/proprietary/bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002777 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002778 "by_exception_only",
2779 "proprietary"),
2780 matchResolution(
2781 "testdata/proprietary/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002782 "testdata/proprietary/lib/libb.so.meta_lic",
2783 "restricted"),
2784 matchResolution(
2785 "testdata/proprietary/highest.apex.meta_lic",
2786 "testdata/proprietary/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002787 "notice"),
2788 matchResolution(
2789 "testdata/proprietary/highest.apex.meta_lic",
2790 "testdata/proprietary/bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002791 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002792 "by_exception_only",
2793 "proprietary"),
2794 matchResolution(
2795 "testdata/proprietary/highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002796 "testdata/proprietary/highest.apex.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002797 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002798 "notice"),
2799 matchResolution(
2800 "testdata/proprietary/highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002801 "testdata/proprietary/lib/liba.so.meta_lic",
2802 "by_exception_only",
2803 "proprietary"),
2804 matchResolution(
2805 "testdata/proprietary/highest.apex.meta_lic",
2806 "testdata/proprietary/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002807 "restricted"),
2808 matchResolution(
2809 "testdata/proprietary/highest.apex.meta_lic",
2810 "testdata/proprietary/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002811 "by_exception_only",
2812 "proprietary"),
2813 matchResolution(
Bob Badour1ded0a12021-12-03 17:16:14 -08002814 "testdata/proprietary/lib/liba.so.meta_lic",
2815 "testdata/proprietary/lib/liba.so.meta_lic",
2816 "by_exception_only",
2817 "proprietary"),
2818 matchResolution(
2819 "testdata/proprietary/lib/libb.so.meta_lic",
2820 "testdata/proprietary/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002821 "restricted"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002822 },
2823 },
2824 {
2825 condition: "proprietary",
2826 name: "apex_trimmed",
2827 roots: []string{"highest.apex.meta_lic"},
2828 ctx: context{stripPrefix: "testdata/proprietary/"},
2829 expectedOut: []getMatcher{
2830 matchTarget("bin/bin1.meta_lic"),
2831 matchTarget("lib/liba.so.meta_lic"),
2832 matchTarget("lib/libc.a.meta_lic"),
2833 matchTarget("bin/bin2.meta_lic"),
2834 matchTarget("lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002835 matchTarget("highest.apex.meta_lic"),
2836 matchResolution(
2837 "bin/bin1.meta_lic",
2838 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002839 "notice"),
2840 matchResolution(
2841 "bin/bin1.meta_lic",
2842 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002843 "by_exception_only",
2844 "proprietary"),
2845 matchResolution(
2846 "bin/bin1.meta_lic",
2847 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002848 "by_exception_only",
2849 "proprietary"),
2850 matchResolution(
2851 "bin/bin2.meta_lic",
2852 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002853 "by_exception_only",
Bob Badour103eb0f2022-01-10 13:50:57 -08002854 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002855 "proprietary"),
2856 matchResolution(
2857 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002858 "lib/libb.so.meta_lic",
2859 "restricted"),
2860 matchResolution(
2861 "highest.apex.meta_lic",
2862 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002863 "notice"),
2864 matchResolution(
2865 "highest.apex.meta_lic",
2866 "bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002867 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002868 "by_exception_only",
2869 "proprietary"),
2870 matchResolution(
2871 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002872 "highest.apex.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002873 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002874 "notice"),
2875 matchResolution(
2876 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002877 "lib/liba.so.meta_lic",
2878 "by_exception_only",
2879 "proprietary"),
2880 matchResolution(
2881 "highest.apex.meta_lic",
2882 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002883 "restricted"),
2884 matchResolution(
2885 "highest.apex.meta_lic",
2886 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002887 "by_exception_only",
2888 "proprietary"),
2889 matchResolution(
Bob Badour1ded0a12021-12-03 17:16:14 -08002890 "lib/liba.so.meta_lic",
2891 "lib/liba.so.meta_lic",
2892 "by_exception_only",
2893 "proprietary"),
2894 matchResolution(
2895 "lib/libb.so.meta_lic",
2896 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002897 "restricted"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002898 },
2899 },
2900 {
2901 condition: "proprietary",
2902 name: "apex_trimmed_notice",
2903 roots: []string{"highest.apex.meta_lic"},
2904 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08002905 conditions: []compliance.LicenseCondition{compliance.NoticeCondition},
Bob Badour1ded0a12021-12-03 17:16:14 -08002906 stripPrefix: "testdata/proprietary/",
2907 },
2908 expectedOut: []getMatcher{
2909 matchTarget("bin/bin1.meta_lic"),
2910 matchTarget("highest.apex.meta_lic"),
2911 matchResolution(
2912 "bin/bin1.meta_lic",
2913 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002914 "notice"),
2915 matchResolution(
2916 "highest.apex.meta_lic",
2917 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002918 "notice"),
2919 matchResolution(
2920 "highest.apex.meta_lic",
2921 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002922 "notice"),
2923 },
2924 },
2925 {
2926 condition: "proprietary",
2927 name: "apex_trimmed_share",
2928 roots: []string{"highest.apex.meta_lic"},
2929 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08002930 conditions: compliance.ImpliesShared.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -08002931 stripPrefix: "testdata/proprietary/",
2932 },
2933 expectedOut: []getMatcher{
2934 matchTarget("bin/bin2.meta_lic"),
2935 matchTarget("lib/libb.so.meta_lic"),
2936 matchTarget("highest.apex.meta_lic"),
2937 matchResolution(
2938 "bin/bin2.meta_lic",
2939 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002940 "restricted"),
2941 matchResolution(
2942 "bin/bin2.meta_lic",
2943 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002944 "restricted"),
2945 matchResolution(
2946 "highest.apex.meta_lic",
2947 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002948 "restricted"),
2949 matchResolution(
2950 "highest.apex.meta_lic",
2951 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002952 "restricted"),
2953 matchResolution(
2954 "highest.apex.meta_lic",
2955 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002956 "restricted"),
2957 matchResolution(
2958 "lib/libb.so.meta_lic",
2959 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002960 "restricted"),
2961 },
2962 },
2963 {
2964 condition: "proprietary",
2965 name: "apex_trimmed_private",
2966 roots: []string{"highest.apex.meta_lic"},
2967 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08002968 conditions: compliance.ImpliesPrivate.AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -08002969 stripPrefix: "testdata/proprietary/",
2970 },
2971 expectedOut: []getMatcher{
2972 matchTarget("bin/bin1.meta_lic"),
2973 matchTarget("lib/liba.so.meta_lic"),
2974 matchTarget("lib/libc.a.meta_lic"),
2975 matchTarget("bin/bin2.meta_lic"),
2976 matchTarget("highest.apex.meta_lic"),
2977 matchResolution(
2978 "bin/bin1.meta_lic",
2979 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002980 "proprietary"),
2981 matchResolution(
2982 "bin/bin1.meta_lic",
2983 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002984 "proprietary"),
2985 matchResolution(
2986 "bin/bin2.meta_lic",
2987 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002988 "proprietary"),
2989 matchResolution(
2990 "highest.apex.meta_lic",
2991 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002992 "proprietary"),
2993 matchResolution(
2994 "highest.apex.meta_lic",
2995 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002996 "proprietary"),
2997 matchResolution(
2998 "highest.apex.meta_lic",
2999 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003000 "proprietary"),
3001 matchResolution(
3002 "lib/liba.so.meta_lic",
3003 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003004 "proprietary"),
3005 },
3006 },
3007 {
3008 condition: "proprietary",
3009 name: "apex_trimmed_share_private",
3010 roots: []string{"highest.apex.meta_lic"},
3011 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08003012 conditions: compliance.ImpliesShared.Union(compliance.ImpliesPrivate).AsList(),
Bob Badour1ded0a12021-12-03 17:16:14 -08003013 stripPrefix: "testdata/proprietary/",
3014 },
3015 expectedOut: []getMatcher{
3016 matchTarget("bin/bin1.meta_lic"),
3017 matchTarget("lib/liba.so.meta_lic"),
3018 matchTarget("lib/libc.a.meta_lic"),
3019 matchTarget("bin/bin2.meta_lic"),
3020 matchTarget("lib/libb.so.meta_lic"),
3021 matchTarget("highest.apex.meta_lic"),
3022 matchResolution(
3023 "bin/bin1.meta_lic",
3024 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003025 "proprietary"),
3026 matchResolution(
3027 "bin/bin1.meta_lic",
3028 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003029 "proprietary"),
3030 matchResolution(
3031 "bin/bin2.meta_lic",
3032 "bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08003033 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08003034 "proprietary"),
3035 matchResolution(
3036 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003037 "lib/libb.so.meta_lic",
3038 "restricted"),
3039 matchResolution(
3040 "highest.apex.meta_lic",
3041 "bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08003042 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08003043 "proprietary"),
3044 matchResolution(
3045 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003046 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003047 "restricted"),
3048 matchResolution(
3049 "highest.apex.meta_lic",
3050 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003051 "proprietary"),
3052 matchResolution(
3053 "highest.apex.meta_lic",
3054 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003055 "restricted"),
3056 matchResolution(
3057 "highest.apex.meta_lic",
3058 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003059 "proprietary"),
3060 matchResolution(
3061 "lib/liba.so.meta_lic",
3062 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003063 "proprietary"),
3064 matchResolution(
3065 "lib/libb.so.meta_lic",
3066 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003067 "restricted"),
3068 },
3069 },
3070 {
3071 condition: "proprietary",
3072 name: "apex_trimmed_labelled",
3073 roots: []string{"highest.apex.meta_lic"},
3074 ctx: context{stripPrefix: "testdata/proprietary/", labelConditions: true},
3075 expectedOut: []getMatcher{
3076 matchTarget("bin/bin1.meta_lic", "notice"),
3077 matchTarget("lib/liba.so.meta_lic", "by_exception_only", "proprietary"),
3078 matchTarget("lib/libc.a.meta_lic", "by_exception_only", "proprietary"),
3079 matchTarget("bin/bin2.meta_lic", "by_exception_only", "proprietary"),
3080 matchTarget("lib/libb.so.meta_lic", "restricted"),
Bob Badour1ded0a12021-12-03 17:16:14 -08003081 matchTarget("highest.apex.meta_lic", "notice"),
3082 matchResolution(
3083 "bin/bin1.meta_lic",
3084 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003085 "notice"),
3086 matchResolution(
3087 "bin/bin1.meta_lic",
3088 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003089 "by_exception_only",
3090 "proprietary"),
3091 matchResolution(
3092 "bin/bin1.meta_lic",
3093 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003094 "by_exception_only",
3095 "proprietary"),
3096 matchResolution(
3097 "bin/bin2.meta_lic",
3098 "bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08003099 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08003100 "by_exception_only",
3101 "proprietary"),
3102 matchResolution(
3103 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003104 "lib/libb.so.meta_lic",
3105 "restricted"),
3106 matchResolution(
3107 "highest.apex.meta_lic",
3108 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003109 "notice"),
3110 matchResolution(
3111 "highest.apex.meta_lic",
3112 "bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08003113 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08003114 "by_exception_only",
3115 "proprietary"),
3116 matchResolution(
3117 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003118 "highest.apex.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08003119 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08003120 "notice"),
3121 matchResolution(
3122 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003123 "lib/liba.so.meta_lic",
3124 "by_exception_only",
3125 "proprietary"),
3126 matchResolution(
3127 "highest.apex.meta_lic",
3128 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003129 "restricted"),
3130 matchResolution(
3131 "highest.apex.meta_lic",
3132 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003133 "by_exception_only",
3134 "proprietary"),
3135 matchResolution(
Bob Badour1ded0a12021-12-03 17:16:14 -08003136 "lib/liba.so.meta_lic",
3137 "lib/liba.so.meta_lic",
3138 "by_exception_only",
3139 "proprietary"),
3140 matchResolution(
3141 "lib/libb.so.meta_lic",
3142 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003143 "restricted"),
Bob Badour1ded0a12021-12-03 17:16:14 -08003144 },
3145 },
3146 {
3147 condition: "proprietary",
3148 name: "container",
3149 roots: []string{"container.zip.meta_lic"},
3150 expectedOut: []getMatcher{
3151 matchTarget("testdata/proprietary/bin/bin1.meta_lic"),
3152 matchTarget("testdata/proprietary/lib/liba.so.meta_lic"),
3153 matchTarget("testdata/proprietary/lib/libc.a.meta_lic"),
3154 matchTarget("testdata/proprietary/bin/bin2.meta_lic"),
3155 matchTarget("testdata/proprietary/lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08003156 matchTarget("testdata/proprietary/container.zip.meta_lic"),
3157 matchResolution(
3158 "testdata/proprietary/bin/bin1.meta_lic",
3159 "testdata/proprietary/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003160 "notice"),
3161 matchResolution(
3162 "testdata/proprietary/bin/bin1.meta_lic",
3163 "testdata/proprietary/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003164 "by_exception_only",
3165 "proprietary"),
3166 matchResolution(
3167 "testdata/proprietary/bin/bin1.meta_lic",
3168 "testdata/proprietary/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003169 "by_exception_only",
3170 "proprietary"),
3171 matchResolution(
3172 "testdata/proprietary/bin/bin2.meta_lic",
3173 "testdata/proprietary/bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08003174 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08003175 "by_exception_only",
3176 "proprietary"),
3177 matchResolution(
3178 "testdata/proprietary/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003179 "testdata/proprietary/lib/libb.so.meta_lic",
3180 "restricted"),
3181 matchResolution(
3182 "testdata/proprietary/container.zip.meta_lic",
3183 "testdata/proprietary/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003184 "notice"),
3185 matchResolution(
3186 "testdata/proprietary/container.zip.meta_lic",
3187 "testdata/proprietary/bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08003188 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08003189 "by_exception_only",
3190 "proprietary"),
3191 matchResolution(
3192 "testdata/proprietary/container.zip.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003193 "testdata/proprietary/container.zip.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08003194 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08003195 "notice"),
3196 matchResolution(
3197 "testdata/proprietary/container.zip.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003198 "testdata/proprietary/lib/liba.so.meta_lic",
3199 "by_exception_only",
3200 "proprietary"),
3201 matchResolution(
3202 "testdata/proprietary/container.zip.meta_lic",
3203 "testdata/proprietary/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003204 "restricted"),
3205 matchResolution(
3206 "testdata/proprietary/container.zip.meta_lic",
3207 "testdata/proprietary/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003208 "by_exception_only",
3209 "proprietary"),
3210 matchResolution(
Bob Badour1ded0a12021-12-03 17:16:14 -08003211 "testdata/proprietary/lib/liba.so.meta_lic",
3212 "testdata/proprietary/lib/liba.so.meta_lic",
3213 "by_exception_only",
3214 "proprietary"),
3215 matchResolution(
3216 "testdata/proprietary/lib/libb.so.meta_lic",
3217 "testdata/proprietary/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003218 "restricted"),
Bob Badour1ded0a12021-12-03 17:16:14 -08003219 },
3220 },
3221 {
3222 condition: "proprietary",
3223 name: "application",
3224 roots: []string{"application.meta_lic"},
3225 expectedOut: []getMatcher{
3226 matchTarget("testdata/proprietary/application.meta_lic"),
3227 matchTarget("testdata/proprietary/lib/liba.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08003228 matchResolution(
3229 "testdata/proprietary/application.meta_lic",
3230 "testdata/proprietary/application.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08003231 "notice",
Bob Badour1ded0a12021-12-03 17:16:14 -08003232 "restricted"),
3233 matchResolution(
3234 "testdata/proprietary/application.meta_lic",
3235 "testdata/proprietary/lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08003236 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08003237 "by_exception_only",
3238 "proprietary"),
Bob Badour1ded0a12021-12-03 17:16:14 -08003239 },
3240 },
3241 {
3242 condition: "proprietary",
3243 name: "binary",
3244 roots: []string{"bin/bin1.meta_lic"},
3245 expectedOut: []getMatcher{
3246 matchTarget("testdata/proprietary/bin/bin1.meta_lic"),
3247 matchTarget("testdata/proprietary/lib/liba.so.meta_lic"),
3248 matchTarget("testdata/proprietary/lib/libc.a.meta_lic"),
3249 matchResolution(
3250 "testdata/proprietary/bin/bin1.meta_lic",
3251 "testdata/proprietary/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003252 "notice"),
3253 matchResolution(
3254 "testdata/proprietary/bin/bin1.meta_lic",
3255 "testdata/proprietary/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003256 "by_exception_only",
3257 "proprietary"),
3258 matchResolution(
3259 "testdata/proprietary/bin/bin1.meta_lic",
3260 "testdata/proprietary/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003261 "by_exception_only",
3262 "proprietary"),
3263 },
3264 },
3265 {
3266 condition: "proprietary",
3267 name: "library",
3268 roots: []string{"lib/libd.so.meta_lic"},
3269 expectedOut: []getMatcher{
3270 matchTarget("testdata/proprietary/lib/libd.so.meta_lic"),
3271 matchResolution(
3272 "testdata/proprietary/lib/libd.so.meta_lic",
3273 "testdata/proprietary/lib/libd.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003274 "notice"),
3275 },
3276 },
3277 }
3278 for _, tt := range tests {
3279 t.Run(tt.condition+" "+tt.name, func(t *testing.T) {
3280 ctx := &testContext{0, make(map[string]string)}
3281
Bob Badour1ded0a12021-12-03 17:16:14 -08003282 stdout := &bytes.Buffer{}
3283 stderr := &bytes.Buffer{}
3284
3285 rootFiles := make([]string, 0, len(tt.roots))
3286 for _, r := range tt.roots {
3287 rootFiles = append(rootFiles, "testdata/"+tt.condition+"/"+r)
3288 }
3289 tt.ctx.graphViz = true
Bob Badour103eb0f2022-01-10 13:50:57 -08003290 lg, err := dumpResolutions(&tt.ctx, stdout, stderr, rootFiles...)
Bob Badour1ded0a12021-12-03 17:16:14 -08003291 if err != nil {
3292 t.Fatalf("dumpresolutions: error = %v, stderr = %v", err, stderr)
3293 return
3294 }
3295 if stderr.Len() > 0 {
3296 t.Errorf("dumpresolutions: gotStderr = %v, want none", stderr)
3297 }
Bob Badour103eb0f2022-01-10 13:50:57 -08003298
3299 expectedOut := &bytes.Buffer{}
3300 for _, eo := range tt.expectedOut {
3301 m := eo(ctx)
3302 expectedOut.WriteString(m.matchString(ctx, lg))
3303 expectedOut.WriteString("\n")
3304 }
3305
Bob Badour1ded0a12021-12-03 17:16:14 -08003306 outList := strings.Split(stdout.String(), "\n")
3307 outLine := 0
3308 if outList[outLine] != "strict digraph {" {
Colin Cross179ec3e2022-01-27 15:47:09 -08003309 t.Errorf("dumpresolutions: got 1st line %v, want strict digraph {", outList[outLine])
Bob Badour1ded0a12021-12-03 17:16:14 -08003310 }
3311 outLine++
3312 if strings.HasPrefix(strings.TrimLeft(outList[outLine], " \t"), "rankdir") {
3313 outLine++
3314 }
3315 endOut := len(outList)
3316 for endOut > 0 && strings.TrimLeft(outList[endOut-1], " \t") == "" {
3317 endOut--
3318 }
3319 if outList[endOut-1] != "}" {
3320 t.Errorf("dumpresolutions: got last line %v, want }", outList[endOut-1])
3321 }
3322 endOut--
3323 if strings.HasPrefix(strings.TrimLeft(outList[endOut-1], " \t"), "{rank=same") {
3324 endOut--
3325 }
3326 expectedList := strings.Split(expectedOut.String(), "\n")
3327 for len(expectedList) > 0 && expectedList[len(expectedList)-1] == "" {
3328 expectedList = expectedList[0 : len(expectedList)-1]
3329 }
3330 matchLine := 0
3331
3332 for outLine < endOut && matchLine < len(expectedList) && strings.TrimLeft(outList[outLine], " \t") == expectedList[matchLine] {
3333 outLine++
3334 matchLine++
3335 }
3336 if outLine < endOut || matchLine < len(expectedList) {
3337 if outLine >= endOut {
3338 t.Errorf("dumpresolutions: missing lines at end of graph, want %d lines %v", len(expectedList)-matchLine, strings.Join(expectedList[matchLine:], "\n"))
3339 } else if matchLine >= len(expectedList) {
3340 t.Errorf("dumpresolutions: unexpected lines at end of graph starting line %d, got %v, want nothing", outLine+1, strings.Join(outList[outLine:], "\n"))
3341 } else {
3342 t.Errorf("dumpresolutions: at line %d, got %v, want %v", outLine+1, strings.Join(outList[outLine:], "\n"), strings.Join(expectedList[matchLine:], "\n"))
3343 }
3344 }
3345 })
3346 }
3347}