blob: 63fd157f58e0382c9f0815395a66e051e4aa327c [file] [log] [blame]
Bob Badour1ded0a12021-12-03 17:16:14 -08001// Copyright 2021 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package main
16
17import (
18 "bytes"
19 "fmt"
Colin Crossd0f05c92022-01-27 15:40:29 -080020 "os"
Bob Badour1ded0a12021-12-03 17:16:14 -080021 "strings"
22 "testing"
Colin Cross38a61932022-01-27 15:26:49 -080023
24 "android/soong/tools/compliance"
Bob Badour1ded0a12021-12-03 17:16:14 -080025)
26
Colin Crossd0f05c92022-01-27 15:40:29 -080027func TestMain(m *testing.M) {
28 // Change into the parent directory before running the tests
29 // so they can find the testdata directory.
30 if err := os.Chdir(".."); err != nil {
31 fmt.Printf("failed to change to testdata directory: %s\n", err)
32 os.Exit(1)
33 }
34 os.Exit(m.Run())
35}
36
Bob Badour1ded0a12021-12-03 17:16:14 -080037func Test_plaintext(t *testing.T) {
38 tests := []struct {
39 condition string
40 name string
Bob Badourc778e4c2022-03-22 13:05:19 -070041 outDir string
Bob Badour1ded0a12021-12-03 17:16:14 -080042 roots []string
43 ctx context
44 expectedOut []string
45 }{
46 {
47 condition: "firstparty",
48 name: "apex",
49 roots: []string{"highest.apex.meta_lic"},
50 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -080051 "testdata/firstparty/bin/bin1.meta_lic testdata/firstparty/bin/bin1.meta_lic notice",
52 "testdata/firstparty/bin/bin1.meta_lic testdata/firstparty/lib/liba.so.meta_lic notice",
53 "testdata/firstparty/bin/bin1.meta_lic testdata/firstparty/lib/libc.a.meta_lic notice",
54 "testdata/firstparty/bin/bin2.meta_lic testdata/firstparty/bin/bin2.meta_lic notice",
55 "testdata/firstparty/highest.apex.meta_lic testdata/firstparty/bin/bin1.meta_lic notice",
56 "testdata/firstparty/highest.apex.meta_lic testdata/firstparty/bin/bin2.meta_lic notice",
57 "testdata/firstparty/highest.apex.meta_lic testdata/firstparty/highest.apex.meta_lic notice",
58 "testdata/firstparty/highest.apex.meta_lic testdata/firstparty/lib/liba.so.meta_lic notice",
59 "testdata/firstparty/highest.apex.meta_lic testdata/firstparty/lib/libb.so.meta_lic notice",
60 "testdata/firstparty/highest.apex.meta_lic testdata/firstparty/lib/libc.a.meta_lic notice",
61 "testdata/firstparty/lib/liba.so.meta_lic testdata/firstparty/lib/liba.so.meta_lic notice",
62 "testdata/firstparty/lib/libb.so.meta_lic testdata/firstparty/lib/libb.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -080063 },
64 },
65 {
66 condition: "firstparty",
67 name: "apex_trimmed",
68 roots: []string{"highest.apex.meta_lic"},
Bob Badour682e1ba2022-02-02 15:15:56 -080069 ctx: context{stripPrefix: []string{"testdata/firstparty/"}},
Bob Badour1ded0a12021-12-03 17:16:14 -080070 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -080071 "bin/bin1.meta_lic bin/bin1.meta_lic notice",
72 "bin/bin1.meta_lic lib/liba.so.meta_lic notice",
73 "bin/bin1.meta_lic lib/libc.a.meta_lic notice",
74 "bin/bin2.meta_lic bin/bin2.meta_lic notice",
75 "highest.apex.meta_lic bin/bin1.meta_lic notice",
76 "highest.apex.meta_lic bin/bin2.meta_lic notice",
77 "highest.apex.meta_lic highest.apex.meta_lic notice",
78 "highest.apex.meta_lic lib/liba.so.meta_lic notice",
79 "highest.apex.meta_lic lib/libb.so.meta_lic notice",
80 "highest.apex.meta_lic lib/libc.a.meta_lic notice",
81 "lib/liba.so.meta_lic lib/liba.so.meta_lic notice",
82 "lib/libb.so.meta_lic lib/libb.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -080083 },
84 },
85 {
86 condition: "firstparty",
87 name: "apex_trimmed_notice",
88 roots: []string{"highest.apex.meta_lic"},
89 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -080090 conditions: []compliance.LicenseCondition{compliance.NoticeCondition},
Bob Badour682e1ba2022-02-02 15:15:56 -080091 stripPrefix: []string{"testdata/firstparty/"},
Bob Badour1ded0a12021-12-03 17:16:14 -080092 },
93 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -080094 "bin/bin1.meta_lic bin/bin1.meta_lic notice",
95 "bin/bin1.meta_lic lib/liba.so.meta_lic notice",
96 "bin/bin1.meta_lic lib/libc.a.meta_lic notice",
97 "bin/bin2.meta_lic bin/bin2.meta_lic notice",
98 "highest.apex.meta_lic bin/bin1.meta_lic notice",
99 "highest.apex.meta_lic bin/bin2.meta_lic notice",
100 "highest.apex.meta_lic highest.apex.meta_lic notice",
101 "highest.apex.meta_lic lib/liba.so.meta_lic notice",
102 "highest.apex.meta_lic lib/libb.so.meta_lic notice",
103 "highest.apex.meta_lic lib/libc.a.meta_lic notice",
104 "lib/liba.so.meta_lic lib/liba.so.meta_lic notice",
105 "lib/libb.so.meta_lic lib/libb.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800106 },
107 },
108 {
109 condition: "firstparty",
110 name: "apex_trimmed_share",
111 roots: []string{"highest.apex.meta_lic"},
112 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800113 conditions: compliance.ImpliesShared.AsList(),
Bob Badour682e1ba2022-02-02 15:15:56 -0800114 stripPrefix: []string{"testdata/firstparty/"},
Bob Badour1ded0a12021-12-03 17:16:14 -0800115 },
116 expectedOut: []string{},
117 },
118 {
119 condition: "firstparty",
120 name: "apex_trimmed_private",
121 roots: []string{"highest.apex.meta_lic"},
122 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800123 conditions: compliance.ImpliesPrivate.AsList(),
Bob Badour682e1ba2022-02-02 15:15:56 -0800124 stripPrefix: []string{"testdata/firstparty/"},
Bob Badour1ded0a12021-12-03 17:16:14 -0800125 },
126 expectedOut: []string{},
127 },
128 {
129 condition: "firstparty",
130 name: "apex_trimmed_share_private",
131 roots: []string{"highest.apex.meta_lic"},
132 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800133 conditions: append(compliance.ImpliesPrivate.AsList(), compliance.ImpliesShared.AsList()...),
Bob Badour682e1ba2022-02-02 15:15:56 -0800134 stripPrefix: []string{"testdata/firstparty/"},
Bob Badour1ded0a12021-12-03 17:16:14 -0800135 },
136 expectedOut: []string{},
137 },
138 {
139 condition: "firstparty",
140 name: "apex_trimmed_labelled",
141 roots: []string{"highest.apex.meta_lic"},
Bob Badour682e1ba2022-02-02 15:15:56 -0800142 ctx: context{stripPrefix: []string{"testdata/firstparty/"}, labelConditions: true},
Bob Badour1ded0a12021-12-03 17:16:14 -0800143 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800144 "bin/bin1.meta_lic:notice bin/bin1.meta_lic:notice notice",
145 "bin/bin1.meta_lic:notice lib/liba.so.meta_lic:notice notice",
146 "bin/bin1.meta_lic:notice lib/libc.a.meta_lic:notice notice",
147 "bin/bin2.meta_lic:notice bin/bin2.meta_lic:notice notice",
148 "highest.apex.meta_lic:notice bin/bin1.meta_lic:notice notice",
149 "highest.apex.meta_lic:notice bin/bin2.meta_lic:notice notice",
150 "highest.apex.meta_lic:notice highest.apex.meta_lic:notice notice",
151 "highest.apex.meta_lic:notice lib/liba.so.meta_lic:notice notice",
152 "highest.apex.meta_lic:notice lib/libb.so.meta_lic:notice notice",
153 "highest.apex.meta_lic:notice lib/libc.a.meta_lic:notice notice",
154 "lib/liba.so.meta_lic:notice lib/liba.so.meta_lic:notice notice",
155 "lib/libb.so.meta_lic:notice lib/libb.so.meta_lic:notice notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800156 },
157 },
158 {
159 condition: "firstparty",
160 name: "container",
161 roots: []string{"container.zip.meta_lic"},
162 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800163 "testdata/firstparty/bin/bin1.meta_lic testdata/firstparty/bin/bin1.meta_lic notice",
164 "testdata/firstparty/bin/bin1.meta_lic testdata/firstparty/lib/liba.so.meta_lic notice",
165 "testdata/firstparty/bin/bin1.meta_lic testdata/firstparty/lib/libc.a.meta_lic notice",
166 "testdata/firstparty/bin/bin2.meta_lic testdata/firstparty/bin/bin2.meta_lic notice",
167 "testdata/firstparty/container.zip.meta_lic testdata/firstparty/bin/bin1.meta_lic notice",
168 "testdata/firstparty/container.zip.meta_lic testdata/firstparty/bin/bin2.meta_lic notice",
169 "testdata/firstparty/container.zip.meta_lic testdata/firstparty/container.zip.meta_lic notice",
170 "testdata/firstparty/container.zip.meta_lic testdata/firstparty/lib/liba.so.meta_lic notice",
171 "testdata/firstparty/container.zip.meta_lic testdata/firstparty/lib/libb.so.meta_lic notice",
172 "testdata/firstparty/container.zip.meta_lic testdata/firstparty/lib/libc.a.meta_lic notice",
173 "testdata/firstparty/lib/liba.so.meta_lic testdata/firstparty/lib/liba.so.meta_lic notice",
174 "testdata/firstparty/lib/libb.so.meta_lic testdata/firstparty/lib/libb.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800175 },
176 },
177 {
178 condition: "firstparty",
179 name: "application",
180 roots: []string{"application.meta_lic"},
181 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800182 "testdata/firstparty/application.meta_lic testdata/firstparty/application.meta_lic notice",
183 "testdata/firstparty/application.meta_lic testdata/firstparty/lib/liba.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800184 },
185 },
186 {
187 condition: "firstparty",
188 name: "binary",
189 roots: []string{"bin/bin1.meta_lic"},
190 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800191 "testdata/firstparty/bin/bin1.meta_lic testdata/firstparty/bin/bin1.meta_lic notice",
192 "testdata/firstparty/bin/bin1.meta_lic testdata/firstparty/lib/liba.so.meta_lic notice",
193 "testdata/firstparty/bin/bin1.meta_lic testdata/firstparty/lib/libc.a.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800194 },
195 },
196 {
197 condition: "firstparty",
198 name: "library",
199 roots: []string{"lib/libd.so.meta_lic"},
200 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800201 "testdata/firstparty/lib/libd.so.meta_lic testdata/firstparty/lib/libd.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800202 },
203 },
204 {
205 condition: "notice",
206 name: "apex",
207 roots: []string{"highest.apex.meta_lic"},
208 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800209 "testdata/notice/bin/bin1.meta_lic testdata/notice/bin/bin1.meta_lic notice",
210 "testdata/notice/bin/bin1.meta_lic testdata/notice/lib/liba.so.meta_lic notice",
211 "testdata/notice/bin/bin1.meta_lic testdata/notice/lib/libc.a.meta_lic notice",
212 "testdata/notice/bin/bin2.meta_lic testdata/notice/bin/bin2.meta_lic notice",
213 "testdata/notice/highest.apex.meta_lic testdata/notice/bin/bin1.meta_lic notice",
214 "testdata/notice/highest.apex.meta_lic testdata/notice/bin/bin2.meta_lic notice",
215 "testdata/notice/highest.apex.meta_lic testdata/notice/highest.apex.meta_lic notice",
216 "testdata/notice/highest.apex.meta_lic testdata/notice/lib/liba.so.meta_lic notice",
217 "testdata/notice/highest.apex.meta_lic testdata/notice/lib/libb.so.meta_lic notice",
218 "testdata/notice/highest.apex.meta_lic testdata/notice/lib/libc.a.meta_lic notice",
219 "testdata/notice/lib/liba.so.meta_lic testdata/notice/lib/liba.so.meta_lic notice",
220 "testdata/notice/lib/libb.so.meta_lic testdata/notice/lib/libb.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800221 },
222 },
223 {
224 condition: "notice",
225 name: "apex_trimmed",
226 roots: []string{"highest.apex.meta_lic"},
Bob Badour682e1ba2022-02-02 15:15:56 -0800227 ctx: context{stripPrefix: []string{"testdata/notice/"}},
Bob Badour1ded0a12021-12-03 17:16:14 -0800228 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800229 "bin/bin1.meta_lic bin/bin1.meta_lic notice",
230 "bin/bin1.meta_lic lib/liba.so.meta_lic notice",
231 "bin/bin1.meta_lic lib/libc.a.meta_lic notice",
232 "bin/bin2.meta_lic bin/bin2.meta_lic notice",
233 "highest.apex.meta_lic bin/bin1.meta_lic notice",
234 "highest.apex.meta_lic bin/bin2.meta_lic notice",
235 "highest.apex.meta_lic highest.apex.meta_lic notice",
236 "highest.apex.meta_lic lib/liba.so.meta_lic notice",
237 "highest.apex.meta_lic lib/libb.so.meta_lic notice",
238 "highest.apex.meta_lic lib/libc.a.meta_lic notice",
239 "lib/liba.so.meta_lic lib/liba.so.meta_lic notice",
240 "lib/libb.so.meta_lic lib/libb.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800241 },
242 },
243 {
244 condition: "notice",
245 name: "apex_trimmed_notice",
246 roots: []string{"highest.apex.meta_lic"},
247 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -0800248 conditions: []compliance.LicenseCondition{compliance.NoticeCondition},
Bob Badour682e1ba2022-02-02 15:15:56 -0800249 stripPrefix: []string{"testdata/notice/"},
Bob Badour1ded0a12021-12-03 17:16:14 -0800250 },
251 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800252 "bin/bin1.meta_lic bin/bin1.meta_lic notice",
253 "bin/bin1.meta_lic lib/liba.so.meta_lic notice",
254 "bin/bin1.meta_lic lib/libc.a.meta_lic notice",
255 "bin/bin2.meta_lic bin/bin2.meta_lic notice",
256 "highest.apex.meta_lic bin/bin1.meta_lic notice",
257 "highest.apex.meta_lic bin/bin2.meta_lic notice",
258 "highest.apex.meta_lic highest.apex.meta_lic notice",
259 "highest.apex.meta_lic lib/liba.so.meta_lic notice",
260 "highest.apex.meta_lic lib/libb.so.meta_lic notice",
261 "highest.apex.meta_lic lib/libc.a.meta_lic notice",
262 "lib/liba.so.meta_lic lib/liba.so.meta_lic notice",
263 "lib/libb.so.meta_lic lib/libb.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800264 },
265 },
266 {
267 condition: "notice",
268 name: "apex_trimmed_share",
269 roots: []string{"highest.apex.meta_lic"},
270 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800271 conditions: compliance.ImpliesShared.AsList(),
Bob Badour682e1ba2022-02-02 15:15:56 -0800272 stripPrefix: []string{"testdata/notice/"},
Bob Badour1ded0a12021-12-03 17:16:14 -0800273 },
274 expectedOut: []string{},
275 },
276 {
277 condition: "notice",
278 name: "apex_trimmed_private",
279 roots: []string{"highest.apex.meta_lic"},
280 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800281 conditions: compliance.ImpliesPrivate.AsList(),
Bob Badour682e1ba2022-02-02 15:15:56 -0800282 stripPrefix: []string{"testdata/notice/"},
Bob Badour1ded0a12021-12-03 17:16:14 -0800283 },
284 expectedOut: []string{},
285 },
286 {
287 condition: "notice",
288 name: "apex_trimmed_share_private",
289 roots: []string{"highest.apex.meta_lic"},
290 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800291 conditions: append(compliance.ImpliesShared.AsList(), compliance.ImpliesPrivate.AsList()...),
Bob Badour682e1ba2022-02-02 15:15:56 -0800292 stripPrefix: []string{"testdata/notice/"},
Bob Badour1ded0a12021-12-03 17:16:14 -0800293 },
294 expectedOut: []string{},
295 },
296 {
297 condition: "notice",
298 name: "apex_trimmed_labelled",
299 roots: []string{"highest.apex.meta_lic"},
Bob Badour682e1ba2022-02-02 15:15:56 -0800300 ctx: context{stripPrefix: []string{"testdata/notice/"}, labelConditions: true},
Bob Badour1ded0a12021-12-03 17:16:14 -0800301 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800302 "bin/bin1.meta_lic:notice bin/bin1.meta_lic:notice notice",
303 "bin/bin1.meta_lic:notice lib/liba.so.meta_lic:notice notice",
304 "bin/bin1.meta_lic:notice lib/libc.a.meta_lic:notice notice",
305 "bin/bin2.meta_lic:notice bin/bin2.meta_lic:notice notice",
306 "highest.apex.meta_lic:notice bin/bin1.meta_lic:notice notice",
307 "highest.apex.meta_lic:notice bin/bin2.meta_lic:notice notice",
308 "highest.apex.meta_lic:notice highest.apex.meta_lic:notice notice",
309 "highest.apex.meta_lic:notice lib/liba.so.meta_lic:notice notice",
310 "highest.apex.meta_lic:notice lib/libb.so.meta_lic:notice notice",
311 "highest.apex.meta_lic:notice lib/libc.a.meta_lic:notice notice",
312 "lib/liba.so.meta_lic:notice lib/liba.so.meta_lic:notice notice",
313 "lib/libb.so.meta_lic:notice lib/libb.so.meta_lic:notice notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800314 },
315 },
316 {
317 condition: "notice",
318 name: "container",
319 roots: []string{"container.zip.meta_lic"},
320 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800321 "testdata/notice/bin/bin1.meta_lic testdata/notice/bin/bin1.meta_lic notice",
322 "testdata/notice/bin/bin1.meta_lic testdata/notice/lib/liba.so.meta_lic notice",
323 "testdata/notice/bin/bin1.meta_lic testdata/notice/lib/libc.a.meta_lic notice",
324 "testdata/notice/bin/bin2.meta_lic testdata/notice/bin/bin2.meta_lic notice",
325 "testdata/notice/container.zip.meta_lic testdata/notice/bin/bin1.meta_lic notice",
326 "testdata/notice/container.zip.meta_lic testdata/notice/bin/bin2.meta_lic notice",
327 "testdata/notice/container.zip.meta_lic testdata/notice/container.zip.meta_lic notice",
328 "testdata/notice/container.zip.meta_lic testdata/notice/lib/liba.so.meta_lic notice",
329 "testdata/notice/container.zip.meta_lic testdata/notice/lib/libb.so.meta_lic notice",
330 "testdata/notice/container.zip.meta_lic testdata/notice/lib/libc.a.meta_lic notice",
331 "testdata/notice/lib/liba.so.meta_lic testdata/notice/lib/liba.so.meta_lic notice",
332 "testdata/notice/lib/libb.so.meta_lic testdata/notice/lib/libb.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800333 },
334 },
335 {
336 condition: "notice",
337 name: "application",
338 roots: []string{"application.meta_lic"},
339 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800340 "testdata/notice/application.meta_lic testdata/notice/application.meta_lic notice",
341 "testdata/notice/application.meta_lic testdata/notice/lib/liba.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800342 },
343 },
344 {
345 condition: "notice",
346 name: "binary",
347 roots: []string{"bin/bin1.meta_lic"},
348 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800349 "testdata/notice/bin/bin1.meta_lic testdata/notice/bin/bin1.meta_lic notice",
350 "testdata/notice/bin/bin1.meta_lic testdata/notice/lib/liba.so.meta_lic notice",
351 "testdata/notice/bin/bin1.meta_lic testdata/notice/lib/libc.a.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800352 },
353 },
354 {
355 condition: "notice",
356 name: "library",
357 roots: []string{"lib/libd.so.meta_lic"},
358 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800359 "testdata/notice/lib/libd.so.meta_lic testdata/notice/lib/libd.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800360 },
361 },
362 {
363 condition: "reciprocal",
364 name: "apex",
365 roots: []string{"highest.apex.meta_lic"},
366 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800367 "testdata/reciprocal/bin/bin1.meta_lic testdata/reciprocal/bin/bin1.meta_lic notice",
368 "testdata/reciprocal/bin/bin1.meta_lic testdata/reciprocal/lib/liba.so.meta_lic reciprocal",
369 "testdata/reciprocal/bin/bin1.meta_lic testdata/reciprocal/lib/libc.a.meta_lic reciprocal",
370 "testdata/reciprocal/bin/bin2.meta_lic testdata/reciprocal/bin/bin2.meta_lic notice",
371 "testdata/reciprocal/highest.apex.meta_lic testdata/reciprocal/bin/bin1.meta_lic notice",
372 "testdata/reciprocal/highest.apex.meta_lic testdata/reciprocal/bin/bin2.meta_lic notice",
373 "testdata/reciprocal/highest.apex.meta_lic testdata/reciprocal/highest.apex.meta_lic notice",
374 "testdata/reciprocal/highest.apex.meta_lic testdata/reciprocal/lib/liba.so.meta_lic reciprocal",
375 "testdata/reciprocal/highest.apex.meta_lic testdata/reciprocal/lib/libb.so.meta_lic notice",
376 "testdata/reciprocal/highest.apex.meta_lic testdata/reciprocal/lib/libc.a.meta_lic reciprocal",
377 "testdata/reciprocal/lib/liba.so.meta_lic testdata/reciprocal/lib/liba.so.meta_lic reciprocal",
378 "testdata/reciprocal/lib/libb.so.meta_lic testdata/reciprocal/lib/libb.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800379 },
380 },
381 {
382 condition: "reciprocal",
383 name: "apex_trimmed",
384 roots: []string{"highest.apex.meta_lic"},
Bob Badour682e1ba2022-02-02 15:15:56 -0800385 ctx: context{stripPrefix: []string{"testdata/reciprocal/"}},
Bob Badour1ded0a12021-12-03 17:16:14 -0800386 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800387 "bin/bin1.meta_lic bin/bin1.meta_lic notice",
388 "bin/bin1.meta_lic lib/liba.so.meta_lic reciprocal",
389 "bin/bin1.meta_lic lib/libc.a.meta_lic reciprocal",
390 "bin/bin2.meta_lic bin/bin2.meta_lic notice",
391 "highest.apex.meta_lic bin/bin1.meta_lic notice",
392 "highest.apex.meta_lic bin/bin2.meta_lic notice",
393 "highest.apex.meta_lic highest.apex.meta_lic notice",
394 "highest.apex.meta_lic lib/liba.so.meta_lic reciprocal",
395 "highest.apex.meta_lic lib/libb.so.meta_lic notice",
396 "highest.apex.meta_lic lib/libc.a.meta_lic reciprocal",
397 "lib/liba.so.meta_lic lib/liba.so.meta_lic reciprocal",
398 "lib/libb.so.meta_lic lib/libb.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800399 },
400 },
401 {
402 condition: "reciprocal",
403 name: "apex_trimmed_notice",
404 roots: []string{"highest.apex.meta_lic"},
405 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -0800406 conditions: []compliance.LicenseCondition{compliance.NoticeCondition},
Bob Badour682e1ba2022-02-02 15:15:56 -0800407 stripPrefix: []string{"testdata/reciprocal/"},
Bob Badour1ded0a12021-12-03 17:16:14 -0800408 },
409 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800410 "bin/bin1.meta_lic bin/bin1.meta_lic notice",
411 "bin/bin2.meta_lic bin/bin2.meta_lic notice",
412 "highest.apex.meta_lic bin/bin1.meta_lic notice",
413 "highest.apex.meta_lic bin/bin2.meta_lic notice",
414 "highest.apex.meta_lic highest.apex.meta_lic notice",
415 "highest.apex.meta_lic lib/libb.so.meta_lic notice",
416 "lib/libb.so.meta_lic lib/libb.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800417 },
418 },
419 {
420 condition: "reciprocal",
421 name: "apex_trimmed_share",
422 roots: []string{"highest.apex.meta_lic"},
423 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800424 conditions: compliance.ImpliesShared.AsList(),
Bob Badour682e1ba2022-02-02 15:15:56 -0800425 stripPrefix: []string{"testdata/reciprocal/"},
Bob Badour1ded0a12021-12-03 17:16:14 -0800426 },
427 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800428 "bin/bin1.meta_lic lib/liba.so.meta_lic reciprocal",
429 "bin/bin1.meta_lic lib/libc.a.meta_lic reciprocal",
430 "highest.apex.meta_lic lib/liba.so.meta_lic reciprocal",
431 "highest.apex.meta_lic lib/libc.a.meta_lic reciprocal",
432 "lib/liba.so.meta_lic lib/liba.so.meta_lic reciprocal",
Bob Badour1ded0a12021-12-03 17:16:14 -0800433 },
434 },
435 {
436 condition: "reciprocal",
437 name: "apex_trimmed_private",
438 roots: []string{"highest.apex.meta_lic"},
439 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800440 conditions: compliance.ImpliesPrivate.AsList(),
Bob Badour682e1ba2022-02-02 15:15:56 -0800441 stripPrefix: []string{"testdata/reciprocal/"},
Bob Badour1ded0a12021-12-03 17:16:14 -0800442 },
443 expectedOut: []string{},
444 },
445 {
446 condition: "reciprocal",
447 name: "apex_trimmed_share_private",
448 roots: []string{"highest.apex.meta_lic"},
449 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800450 conditions: append(compliance.ImpliesShared.AsList(), compliance.ImpliesPrivate.AsList()...),
Bob Badour682e1ba2022-02-02 15:15:56 -0800451 stripPrefix: []string{"testdata/reciprocal/"},
Bob Badour1ded0a12021-12-03 17:16:14 -0800452 },
453 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800454 "bin/bin1.meta_lic lib/liba.so.meta_lic reciprocal",
455 "bin/bin1.meta_lic lib/libc.a.meta_lic reciprocal",
456 "highest.apex.meta_lic lib/liba.so.meta_lic reciprocal",
457 "highest.apex.meta_lic lib/libc.a.meta_lic reciprocal",
458 "lib/liba.so.meta_lic lib/liba.so.meta_lic reciprocal",
Bob Badour1ded0a12021-12-03 17:16:14 -0800459 },
460 },
461 {
462 condition: "reciprocal",
463 name: "apex_trimmed_labelled",
464 roots: []string{"highest.apex.meta_lic"},
Bob Badour682e1ba2022-02-02 15:15:56 -0800465 ctx: context{stripPrefix: []string{"testdata/reciprocal/"}, labelConditions: true},
Bob Badour1ded0a12021-12-03 17:16:14 -0800466 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800467 "bin/bin1.meta_lic:notice bin/bin1.meta_lic:notice notice",
468 "bin/bin1.meta_lic:notice lib/liba.so.meta_lic:reciprocal reciprocal",
469 "bin/bin1.meta_lic:notice lib/libc.a.meta_lic:reciprocal reciprocal",
470 "bin/bin2.meta_lic:notice bin/bin2.meta_lic:notice notice",
471 "highest.apex.meta_lic:notice bin/bin1.meta_lic:notice notice",
472 "highest.apex.meta_lic:notice bin/bin2.meta_lic:notice notice",
473 "highest.apex.meta_lic:notice highest.apex.meta_lic:notice notice",
474 "highest.apex.meta_lic:notice lib/liba.so.meta_lic:reciprocal reciprocal",
475 "highest.apex.meta_lic:notice lib/libb.so.meta_lic:notice notice",
476 "highest.apex.meta_lic:notice lib/libc.a.meta_lic:reciprocal reciprocal",
477 "lib/liba.so.meta_lic:reciprocal lib/liba.so.meta_lic:reciprocal reciprocal",
478 "lib/libb.so.meta_lic:notice lib/libb.so.meta_lic:notice notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800479 },
480 },
481 {
482 condition: "reciprocal",
483 name: "container",
484 roots: []string{"container.zip.meta_lic"},
485 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800486 "testdata/reciprocal/bin/bin1.meta_lic testdata/reciprocal/bin/bin1.meta_lic notice",
487 "testdata/reciprocal/bin/bin1.meta_lic testdata/reciprocal/lib/liba.so.meta_lic reciprocal",
488 "testdata/reciprocal/bin/bin1.meta_lic testdata/reciprocal/lib/libc.a.meta_lic reciprocal",
489 "testdata/reciprocal/bin/bin2.meta_lic testdata/reciprocal/bin/bin2.meta_lic notice",
490 "testdata/reciprocal/container.zip.meta_lic testdata/reciprocal/bin/bin1.meta_lic notice",
491 "testdata/reciprocal/container.zip.meta_lic testdata/reciprocal/bin/bin2.meta_lic notice",
492 "testdata/reciprocal/container.zip.meta_lic testdata/reciprocal/container.zip.meta_lic notice",
493 "testdata/reciprocal/container.zip.meta_lic testdata/reciprocal/lib/liba.so.meta_lic reciprocal",
494 "testdata/reciprocal/container.zip.meta_lic testdata/reciprocal/lib/libb.so.meta_lic notice",
495 "testdata/reciprocal/container.zip.meta_lic testdata/reciprocal/lib/libc.a.meta_lic reciprocal",
496 "testdata/reciprocal/lib/liba.so.meta_lic testdata/reciprocal/lib/liba.so.meta_lic reciprocal",
497 "testdata/reciprocal/lib/libb.so.meta_lic testdata/reciprocal/lib/libb.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800498 },
499 },
500 {
501 condition: "reciprocal",
502 name: "application",
503 roots: []string{"application.meta_lic"},
504 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800505 "testdata/reciprocal/application.meta_lic testdata/reciprocal/application.meta_lic notice",
506 "testdata/reciprocal/application.meta_lic testdata/reciprocal/lib/liba.so.meta_lic reciprocal",
Bob Badour1ded0a12021-12-03 17:16:14 -0800507 },
508 },
509 {
510 condition: "reciprocal",
511 name: "binary",
512 roots: []string{"bin/bin1.meta_lic"},
513 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800514 "testdata/reciprocal/bin/bin1.meta_lic testdata/reciprocal/bin/bin1.meta_lic notice",
515 "testdata/reciprocal/bin/bin1.meta_lic testdata/reciprocal/lib/liba.so.meta_lic reciprocal",
516 "testdata/reciprocal/bin/bin1.meta_lic testdata/reciprocal/lib/libc.a.meta_lic reciprocal",
Bob Badour1ded0a12021-12-03 17:16:14 -0800517 },
518 },
519 {
520 condition: "reciprocal",
521 name: "library",
522 roots: []string{"lib/libd.so.meta_lic"},
523 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800524 "testdata/reciprocal/lib/libd.so.meta_lic testdata/reciprocal/lib/libd.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800525 },
526 },
527 {
528 condition: "restricted",
529 name: "apex",
530 roots: []string{"highest.apex.meta_lic"},
531 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800532 "testdata/restricted/bin/bin1.meta_lic testdata/restricted/bin/bin1.meta_lic notice:restricted_allows_dynamic_linking",
533 "testdata/restricted/bin/bin1.meta_lic testdata/restricted/lib/liba.so.meta_lic restricted_allows_dynamic_linking",
534 "testdata/restricted/bin/bin1.meta_lic testdata/restricted/lib/libc.a.meta_lic reciprocal:restricted_allows_dynamic_linking",
535 "testdata/restricted/bin/bin2.meta_lic testdata/restricted/bin/bin2.meta_lic notice:restricted",
536 "testdata/restricted/bin/bin2.meta_lic testdata/restricted/lib/libb.so.meta_lic restricted",
537 "testdata/restricted/highest.apex.meta_lic testdata/restricted/bin/bin1.meta_lic notice:restricted_allows_dynamic_linking",
538 "testdata/restricted/highest.apex.meta_lic testdata/restricted/bin/bin2.meta_lic notice:restricted",
539 "testdata/restricted/highest.apex.meta_lic testdata/restricted/highest.apex.meta_lic notice:restricted:restricted_allows_dynamic_linking",
540 "testdata/restricted/highest.apex.meta_lic testdata/restricted/lib/liba.so.meta_lic restricted_allows_dynamic_linking",
541 "testdata/restricted/highest.apex.meta_lic testdata/restricted/lib/libb.so.meta_lic restricted",
542 "testdata/restricted/highest.apex.meta_lic testdata/restricted/lib/libc.a.meta_lic reciprocal:restricted_allows_dynamic_linking",
543 "testdata/restricted/lib/liba.so.meta_lic testdata/restricted/lib/liba.so.meta_lic restricted_allows_dynamic_linking",
544 "testdata/restricted/lib/libb.so.meta_lic testdata/restricted/lib/libb.so.meta_lic restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -0800545 },
546 },
547 {
548 condition: "restricted",
549 name: "apex_trimmed",
550 roots: []string{"highest.apex.meta_lic"},
Bob Badour682e1ba2022-02-02 15:15:56 -0800551 ctx: context{stripPrefix: []string{"testdata/restricted/"}},
Bob Badour1ded0a12021-12-03 17:16:14 -0800552 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800553 "bin/bin1.meta_lic bin/bin1.meta_lic notice:restricted_allows_dynamic_linking",
554 "bin/bin1.meta_lic lib/liba.so.meta_lic restricted_allows_dynamic_linking",
555 "bin/bin1.meta_lic lib/libc.a.meta_lic reciprocal:restricted_allows_dynamic_linking",
556 "bin/bin2.meta_lic bin/bin2.meta_lic notice:restricted",
557 "bin/bin2.meta_lic lib/libb.so.meta_lic restricted",
558 "highest.apex.meta_lic bin/bin1.meta_lic notice:restricted_allows_dynamic_linking",
559 "highest.apex.meta_lic bin/bin2.meta_lic notice:restricted",
560 "highest.apex.meta_lic highest.apex.meta_lic notice:restricted:restricted_allows_dynamic_linking",
561 "highest.apex.meta_lic lib/liba.so.meta_lic restricted_allows_dynamic_linking",
562 "highest.apex.meta_lic lib/libb.so.meta_lic restricted",
563 "highest.apex.meta_lic lib/libc.a.meta_lic reciprocal:restricted_allows_dynamic_linking",
564 "lib/liba.so.meta_lic lib/liba.so.meta_lic restricted_allows_dynamic_linking",
565 "lib/libb.so.meta_lic lib/libb.so.meta_lic restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -0800566 },
567 },
568 {
569 condition: "restricted",
570 name: "apex_trimmed_notice",
571 roots: []string{"highest.apex.meta_lic"},
572 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -0800573 conditions: []compliance.LicenseCondition{compliance.NoticeCondition},
Bob Badour682e1ba2022-02-02 15:15:56 -0800574 stripPrefix: []string{"testdata/restricted/"},
Bob Badour1ded0a12021-12-03 17:16:14 -0800575 },
576 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800577 "bin/bin1.meta_lic bin/bin1.meta_lic notice",
578 "bin/bin2.meta_lic bin/bin2.meta_lic notice",
579 "highest.apex.meta_lic bin/bin1.meta_lic notice",
580 "highest.apex.meta_lic bin/bin2.meta_lic notice",
581 "highest.apex.meta_lic highest.apex.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800582 },
583 },
584 {
585 condition: "restricted",
586 name: "apex_trimmed_share",
587 roots: []string{"highest.apex.meta_lic"},
588 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800589 conditions: compliance.ImpliesShared.AsList(),
Bob Badour682e1ba2022-02-02 15:15:56 -0800590 stripPrefix: []string{"testdata/restricted/"},
Bob Badour1ded0a12021-12-03 17:16:14 -0800591 },
592 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800593 "bin/bin1.meta_lic bin/bin1.meta_lic restricted_allows_dynamic_linking",
594 "bin/bin1.meta_lic lib/liba.so.meta_lic restricted_allows_dynamic_linking",
595 "bin/bin1.meta_lic lib/libc.a.meta_lic reciprocal:restricted_allows_dynamic_linking",
596 "bin/bin2.meta_lic bin/bin2.meta_lic restricted",
597 "bin/bin2.meta_lic lib/libb.so.meta_lic restricted",
598 "highest.apex.meta_lic bin/bin1.meta_lic restricted_allows_dynamic_linking",
599 "highest.apex.meta_lic bin/bin2.meta_lic restricted",
600 "highest.apex.meta_lic highest.apex.meta_lic restricted:restricted_allows_dynamic_linking",
601 "highest.apex.meta_lic lib/liba.so.meta_lic restricted_allows_dynamic_linking",
602 "highest.apex.meta_lic lib/libb.so.meta_lic restricted",
603 "highest.apex.meta_lic lib/libc.a.meta_lic reciprocal:restricted_allows_dynamic_linking",
604 "lib/liba.so.meta_lic lib/liba.so.meta_lic restricted_allows_dynamic_linking",
605 "lib/libb.so.meta_lic lib/libb.so.meta_lic restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -0800606 },
607 },
608 {
609 condition: "restricted",
610 name: "apex_trimmed_private",
611 roots: []string{"highest.apex.meta_lic"},
612 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800613 conditions: compliance.ImpliesPrivate.AsList(),
Bob Badour682e1ba2022-02-02 15:15:56 -0800614 stripPrefix: []string{"testdata/restricted/"},
Bob Badour1ded0a12021-12-03 17:16:14 -0800615 },
616 expectedOut: []string{},
617 },
618 {
619 condition: "restricted",
620 name: "apex_trimmed_share_private",
621 roots: []string{"highest.apex.meta_lic"},
622 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800623 conditions: append(compliance.ImpliesShared.AsList(), compliance.ImpliesPrivate.AsList()...),
Bob Badour682e1ba2022-02-02 15:15:56 -0800624 stripPrefix: []string{"testdata/restricted/"},
Bob Badour1ded0a12021-12-03 17:16:14 -0800625 },
626 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800627 "bin/bin1.meta_lic bin/bin1.meta_lic restricted_allows_dynamic_linking",
628 "bin/bin1.meta_lic lib/liba.so.meta_lic restricted_allows_dynamic_linking",
629 "bin/bin1.meta_lic lib/libc.a.meta_lic reciprocal:restricted_allows_dynamic_linking",
630 "bin/bin2.meta_lic bin/bin2.meta_lic restricted",
631 "bin/bin2.meta_lic lib/libb.so.meta_lic restricted",
632 "highest.apex.meta_lic bin/bin1.meta_lic restricted_allows_dynamic_linking",
633 "highest.apex.meta_lic bin/bin2.meta_lic restricted",
634 "highest.apex.meta_lic highest.apex.meta_lic restricted:restricted_allows_dynamic_linking",
635 "highest.apex.meta_lic lib/liba.so.meta_lic restricted_allows_dynamic_linking",
636 "highest.apex.meta_lic lib/libb.so.meta_lic restricted",
637 "highest.apex.meta_lic lib/libc.a.meta_lic reciprocal:restricted_allows_dynamic_linking",
638 "lib/liba.so.meta_lic lib/liba.so.meta_lic restricted_allows_dynamic_linking",
639 "lib/libb.so.meta_lic lib/libb.so.meta_lic restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -0800640 },
641 },
642 {
643 condition: "restricted",
644 name: "apex_trimmed_labelled",
645 roots: []string{"highest.apex.meta_lic"},
Bob Badour682e1ba2022-02-02 15:15:56 -0800646 ctx: context{stripPrefix: []string{"testdata/restricted/"}, labelConditions: true},
Bob Badour1ded0a12021-12-03 17:16:14 -0800647 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800648 "bin/bin1.meta_lic:notice bin/bin1.meta_lic:notice notice:restricted_allows_dynamic_linking",
649 "bin/bin1.meta_lic:notice lib/liba.so.meta_lic:restricted_allows_dynamic_linking restricted_allows_dynamic_linking",
650 "bin/bin1.meta_lic:notice lib/libc.a.meta_lic:reciprocal reciprocal:restricted_allows_dynamic_linking",
651 "bin/bin2.meta_lic:notice bin/bin2.meta_lic:notice notice:restricted",
652 "bin/bin2.meta_lic:notice lib/libb.so.meta_lic:restricted restricted",
653 "highest.apex.meta_lic:notice bin/bin1.meta_lic:notice notice:restricted_allows_dynamic_linking",
654 "highest.apex.meta_lic:notice bin/bin2.meta_lic:notice notice:restricted",
655 "highest.apex.meta_lic:notice highest.apex.meta_lic:notice notice:restricted:restricted_allows_dynamic_linking",
656 "highest.apex.meta_lic:notice lib/liba.so.meta_lic:restricted_allows_dynamic_linking restricted_allows_dynamic_linking",
657 "highest.apex.meta_lic:notice lib/libb.so.meta_lic:restricted restricted",
658 "highest.apex.meta_lic:notice lib/libc.a.meta_lic:reciprocal reciprocal:restricted_allows_dynamic_linking",
659 "lib/liba.so.meta_lic:restricted_allows_dynamic_linking lib/liba.so.meta_lic:restricted_allows_dynamic_linking restricted_allows_dynamic_linking",
660 "lib/libb.so.meta_lic:restricted lib/libb.so.meta_lic:restricted restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -0800661 },
662 },
663 {
664 condition: "restricted",
665 name: "container",
666 roots: []string{"container.zip.meta_lic"},
667 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800668 "testdata/restricted/bin/bin1.meta_lic testdata/restricted/bin/bin1.meta_lic notice:restricted_allows_dynamic_linking",
669 "testdata/restricted/bin/bin1.meta_lic testdata/restricted/lib/liba.so.meta_lic restricted_allows_dynamic_linking",
670 "testdata/restricted/bin/bin1.meta_lic testdata/restricted/lib/libc.a.meta_lic reciprocal:restricted_allows_dynamic_linking",
671 "testdata/restricted/bin/bin2.meta_lic testdata/restricted/bin/bin2.meta_lic notice:restricted",
672 "testdata/restricted/bin/bin2.meta_lic testdata/restricted/lib/libb.so.meta_lic restricted",
673 "testdata/restricted/container.zip.meta_lic testdata/restricted/bin/bin1.meta_lic notice:restricted_allows_dynamic_linking",
674 "testdata/restricted/container.zip.meta_lic testdata/restricted/bin/bin2.meta_lic notice:restricted",
675 "testdata/restricted/container.zip.meta_lic testdata/restricted/container.zip.meta_lic notice:restricted:restricted_allows_dynamic_linking",
676 "testdata/restricted/container.zip.meta_lic testdata/restricted/lib/liba.so.meta_lic restricted_allows_dynamic_linking",
677 "testdata/restricted/container.zip.meta_lic testdata/restricted/lib/libb.so.meta_lic restricted",
678 "testdata/restricted/container.zip.meta_lic testdata/restricted/lib/libc.a.meta_lic reciprocal:restricted_allows_dynamic_linking",
679 "testdata/restricted/lib/liba.so.meta_lic testdata/restricted/lib/liba.so.meta_lic restricted_allows_dynamic_linking",
680 "testdata/restricted/lib/libb.so.meta_lic testdata/restricted/lib/libb.so.meta_lic restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -0800681 },
682 },
683 {
684 condition: "restricted",
685 name: "application",
686 roots: []string{"application.meta_lic"},
687 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800688 "testdata/restricted/application.meta_lic testdata/restricted/application.meta_lic notice:restricted:restricted_allows_dynamic_linking",
689 "testdata/restricted/application.meta_lic testdata/restricted/lib/liba.so.meta_lic restricted:restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -0800690 },
691 },
692 {
693 condition: "restricted",
694 name: "binary",
695 roots: []string{"bin/bin1.meta_lic"},
696 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800697 "testdata/restricted/bin/bin1.meta_lic testdata/restricted/bin/bin1.meta_lic notice:restricted_allows_dynamic_linking",
698 "testdata/restricted/bin/bin1.meta_lic testdata/restricted/lib/liba.so.meta_lic restricted_allows_dynamic_linking",
699 "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 -0800700 },
701 },
702 {
703 condition: "restricted",
704 name: "library",
705 roots: []string{"lib/libd.so.meta_lic"},
706 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800707 "testdata/restricted/lib/libd.so.meta_lic testdata/restricted/lib/libd.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800708 },
709 },
710 {
711 condition: "proprietary",
712 name: "apex",
713 roots: []string{"highest.apex.meta_lic"},
714 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800715 "testdata/proprietary/bin/bin1.meta_lic testdata/proprietary/bin/bin1.meta_lic notice",
716 "testdata/proprietary/bin/bin1.meta_lic testdata/proprietary/lib/liba.so.meta_lic proprietary:by_exception_only",
717 "testdata/proprietary/bin/bin1.meta_lic testdata/proprietary/lib/libc.a.meta_lic proprietary:by_exception_only",
718 "testdata/proprietary/bin/bin2.meta_lic testdata/proprietary/bin/bin2.meta_lic restricted:proprietary:by_exception_only",
719 "testdata/proprietary/bin/bin2.meta_lic testdata/proprietary/lib/libb.so.meta_lic restricted",
720 "testdata/proprietary/highest.apex.meta_lic testdata/proprietary/bin/bin1.meta_lic notice",
721 "testdata/proprietary/highest.apex.meta_lic testdata/proprietary/bin/bin2.meta_lic restricted:proprietary:by_exception_only",
722 "testdata/proprietary/highest.apex.meta_lic testdata/proprietary/highest.apex.meta_lic notice:restricted",
723 "testdata/proprietary/highest.apex.meta_lic testdata/proprietary/lib/liba.so.meta_lic proprietary:by_exception_only",
724 "testdata/proprietary/highest.apex.meta_lic testdata/proprietary/lib/libb.so.meta_lic restricted",
725 "testdata/proprietary/highest.apex.meta_lic testdata/proprietary/lib/libc.a.meta_lic proprietary:by_exception_only",
726 "testdata/proprietary/lib/liba.so.meta_lic testdata/proprietary/lib/liba.so.meta_lic proprietary:by_exception_only",
727 "testdata/proprietary/lib/libb.so.meta_lic testdata/proprietary/lib/libb.so.meta_lic restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -0800728 },
729 },
730 {
731 condition: "proprietary",
732 name: "apex_trimmed",
733 roots: []string{"highest.apex.meta_lic"},
Bob Badour682e1ba2022-02-02 15:15:56 -0800734 ctx: context{stripPrefix: []string{"testdata/proprietary/"}},
Bob Badour1ded0a12021-12-03 17:16:14 -0800735 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800736 "bin/bin1.meta_lic bin/bin1.meta_lic notice",
737 "bin/bin1.meta_lic lib/liba.so.meta_lic proprietary:by_exception_only",
738 "bin/bin1.meta_lic lib/libc.a.meta_lic proprietary:by_exception_only",
739 "bin/bin2.meta_lic bin/bin2.meta_lic restricted:proprietary:by_exception_only",
740 "bin/bin2.meta_lic lib/libb.so.meta_lic restricted",
741 "highest.apex.meta_lic bin/bin1.meta_lic notice",
742 "highest.apex.meta_lic bin/bin2.meta_lic restricted:proprietary:by_exception_only",
743 "highest.apex.meta_lic highest.apex.meta_lic notice:restricted",
744 "highest.apex.meta_lic lib/liba.so.meta_lic proprietary:by_exception_only",
745 "highest.apex.meta_lic lib/libb.so.meta_lic restricted",
746 "highest.apex.meta_lic lib/libc.a.meta_lic proprietary:by_exception_only",
747 "lib/liba.so.meta_lic lib/liba.so.meta_lic proprietary:by_exception_only",
748 "lib/libb.so.meta_lic lib/libb.so.meta_lic restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -0800749 },
750 },
751 {
752 condition: "proprietary",
753 name: "apex_trimmed_notice",
754 roots: []string{"highest.apex.meta_lic"},
755 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -0800756 conditions: []compliance.LicenseCondition{compliance.NoticeCondition},
Bob Badour682e1ba2022-02-02 15:15:56 -0800757 stripPrefix: []string{"testdata/proprietary/"},
Bob Badour1ded0a12021-12-03 17:16:14 -0800758 },
759 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800760 "bin/bin1.meta_lic bin/bin1.meta_lic notice",
761 "highest.apex.meta_lic bin/bin1.meta_lic notice",
762 "highest.apex.meta_lic highest.apex.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800763 },
764 },
765 {
766 condition: "proprietary",
767 name: "apex_trimmed_share",
768 roots: []string{"highest.apex.meta_lic"},
769 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800770 conditions: compliance.ImpliesShared.AsList(),
Bob Badour682e1ba2022-02-02 15:15:56 -0800771 stripPrefix: []string{"testdata/proprietary/"},
Bob Badour1ded0a12021-12-03 17:16:14 -0800772 },
773 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800774 "bin/bin2.meta_lic bin/bin2.meta_lic restricted",
775 "bin/bin2.meta_lic lib/libb.so.meta_lic restricted",
776 "highest.apex.meta_lic bin/bin2.meta_lic restricted",
777 "highest.apex.meta_lic highest.apex.meta_lic restricted",
778 "highest.apex.meta_lic lib/libb.so.meta_lic restricted",
779 "lib/libb.so.meta_lic lib/libb.so.meta_lic restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -0800780 },
781 },
782 {
783 condition: "proprietary",
784 name: "apex_trimmed_private",
785 roots: []string{"highest.apex.meta_lic"},
786 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800787 conditions: compliance.ImpliesPrivate.AsList(),
Bob Badour682e1ba2022-02-02 15:15:56 -0800788 stripPrefix: []string{"testdata/proprietary/"},
Bob Badour1ded0a12021-12-03 17:16:14 -0800789 },
790 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800791 "bin/bin1.meta_lic lib/liba.so.meta_lic proprietary",
792 "bin/bin1.meta_lic lib/libc.a.meta_lic proprietary",
793 "bin/bin2.meta_lic bin/bin2.meta_lic proprietary",
794 "highest.apex.meta_lic bin/bin2.meta_lic proprietary",
795 "highest.apex.meta_lic lib/liba.so.meta_lic proprietary",
796 "highest.apex.meta_lic lib/libc.a.meta_lic proprietary",
797 "lib/liba.so.meta_lic lib/liba.so.meta_lic proprietary",
Bob Badour1ded0a12021-12-03 17:16:14 -0800798 },
799 },
800 {
801 condition: "proprietary",
802 name: "apex_trimmed_share_private",
803 roots: []string{"highest.apex.meta_lic"},
804 ctx: context{
Colin Cross35f79c32022-01-27 15:18:52 -0800805 conditions: append(compliance.ImpliesShared.AsList(), compliance.ImpliesPrivate.AsList()...),
Bob Badour682e1ba2022-02-02 15:15:56 -0800806 stripPrefix: []string{"testdata/proprietary/"},
Bob Badour1ded0a12021-12-03 17:16:14 -0800807 },
808 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800809 "bin/bin1.meta_lic lib/liba.so.meta_lic proprietary",
810 "bin/bin1.meta_lic lib/libc.a.meta_lic proprietary",
811 "bin/bin2.meta_lic bin/bin2.meta_lic restricted:proprietary",
812 "bin/bin2.meta_lic lib/libb.so.meta_lic restricted",
813 "highest.apex.meta_lic bin/bin2.meta_lic restricted:proprietary",
814 "highest.apex.meta_lic highest.apex.meta_lic restricted",
815 "highest.apex.meta_lic lib/liba.so.meta_lic proprietary",
816 "highest.apex.meta_lic lib/libb.so.meta_lic restricted",
817 "highest.apex.meta_lic lib/libc.a.meta_lic proprietary",
818 "lib/liba.so.meta_lic lib/liba.so.meta_lic proprietary",
819 "lib/libb.so.meta_lic lib/libb.so.meta_lic restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -0800820 },
821 },
822 {
823 condition: "proprietary",
824 name: "apex_trimmed_labelled",
825 roots: []string{"highest.apex.meta_lic"},
Bob Badour682e1ba2022-02-02 15:15:56 -0800826 ctx: context{stripPrefix: []string{"testdata/proprietary/"}, labelConditions: true},
Bob Badour1ded0a12021-12-03 17:16:14 -0800827 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800828 "bin/bin1.meta_lic:notice bin/bin1.meta_lic:notice notice",
829 "bin/bin1.meta_lic:notice lib/liba.so.meta_lic:proprietary:by_exception_only proprietary:by_exception_only",
830 "bin/bin1.meta_lic:notice lib/libc.a.meta_lic:proprietary:by_exception_only proprietary:by_exception_only",
831 "bin/bin2.meta_lic:proprietary:by_exception_only bin/bin2.meta_lic:proprietary:by_exception_only restricted:proprietary:by_exception_only",
832 "bin/bin2.meta_lic:proprietary:by_exception_only lib/libb.so.meta_lic:restricted restricted",
833 "highest.apex.meta_lic:notice bin/bin1.meta_lic:notice notice",
834 "highest.apex.meta_lic:notice bin/bin2.meta_lic:proprietary:by_exception_only restricted:proprietary:by_exception_only",
835 "highest.apex.meta_lic:notice highest.apex.meta_lic:notice notice:restricted",
836 "highest.apex.meta_lic:notice lib/liba.so.meta_lic:proprietary:by_exception_only proprietary:by_exception_only",
837 "highest.apex.meta_lic:notice lib/libb.so.meta_lic:restricted restricted",
838 "highest.apex.meta_lic:notice lib/libc.a.meta_lic:proprietary:by_exception_only proprietary:by_exception_only",
839 "lib/liba.so.meta_lic:proprietary:by_exception_only lib/liba.so.meta_lic:proprietary:by_exception_only proprietary:by_exception_only",
840 "lib/libb.so.meta_lic:restricted lib/libb.so.meta_lic:restricted restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -0800841 },
842 },
843 {
844 condition: "proprietary",
845 name: "container",
846 roots: []string{"container.zip.meta_lic"},
847 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800848 "testdata/proprietary/bin/bin1.meta_lic testdata/proprietary/bin/bin1.meta_lic notice",
849 "testdata/proprietary/bin/bin1.meta_lic testdata/proprietary/lib/liba.so.meta_lic proprietary:by_exception_only",
850 "testdata/proprietary/bin/bin1.meta_lic testdata/proprietary/lib/libc.a.meta_lic proprietary:by_exception_only",
851 "testdata/proprietary/bin/bin2.meta_lic testdata/proprietary/bin/bin2.meta_lic restricted:proprietary:by_exception_only",
852 "testdata/proprietary/bin/bin2.meta_lic testdata/proprietary/lib/libb.so.meta_lic restricted",
853 "testdata/proprietary/container.zip.meta_lic testdata/proprietary/bin/bin1.meta_lic notice",
854 "testdata/proprietary/container.zip.meta_lic testdata/proprietary/bin/bin2.meta_lic restricted:proprietary:by_exception_only",
855 "testdata/proprietary/container.zip.meta_lic testdata/proprietary/container.zip.meta_lic notice:restricted",
856 "testdata/proprietary/container.zip.meta_lic testdata/proprietary/lib/liba.so.meta_lic proprietary:by_exception_only",
857 "testdata/proprietary/container.zip.meta_lic testdata/proprietary/lib/libb.so.meta_lic restricted",
858 "testdata/proprietary/container.zip.meta_lic testdata/proprietary/lib/libc.a.meta_lic proprietary:by_exception_only",
859 "testdata/proprietary/lib/liba.so.meta_lic testdata/proprietary/lib/liba.so.meta_lic proprietary:by_exception_only",
860 "testdata/proprietary/lib/libb.so.meta_lic testdata/proprietary/lib/libb.so.meta_lic restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -0800861 },
862 },
863 {
864 condition: "proprietary",
865 name: "application",
866 roots: []string{"application.meta_lic"},
867 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800868 "testdata/proprietary/application.meta_lic testdata/proprietary/application.meta_lic notice:restricted",
869 "testdata/proprietary/application.meta_lic testdata/proprietary/lib/liba.so.meta_lic restricted:proprietary:by_exception_only",
Bob Badour1ded0a12021-12-03 17:16:14 -0800870 },
871 },
872 {
873 condition: "proprietary",
874 name: "binary",
875 roots: []string{"bin/bin1.meta_lic"},
876 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800877 "testdata/proprietary/bin/bin1.meta_lic testdata/proprietary/bin/bin1.meta_lic notice",
878 "testdata/proprietary/bin/bin1.meta_lic testdata/proprietary/lib/liba.so.meta_lic proprietary:by_exception_only",
879 "testdata/proprietary/bin/bin1.meta_lic testdata/proprietary/lib/libc.a.meta_lic proprietary:by_exception_only",
Bob Badour1ded0a12021-12-03 17:16:14 -0800880 },
881 },
882 {
883 condition: "proprietary",
884 name: "library",
885 roots: []string{"lib/libd.so.meta_lic"},
886 expectedOut: []string{
Bob Badour103eb0f2022-01-10 13:50:57 -0800887 "testdata/proprietary/lib/libd.so.meta_lic testdata/proprietary/lib/libd.so.meta_lic notice",
Bob Badour1ded0a12021-12-03 17:16:14 -0800888 },
889 },
890 }
891 for _, tt := range tests {
892 t.Run(tt.condition+" "+tt.name, func(t *testing.T) {
893 expectedOut := &bytes.Buffer{}
894 for _, eo := range tt.expectedOut {
895 expectedOut.WriteString(eo)
896 expectedOut.WriteString("\n")
897 }
898
899 stdout := &bytes.Buffer{}
900 stderr := &bytes.Buffer{}
901
902 rootFiles := make([]string, 0, len(tt.roots))
903 for _, r := range tt.roots {
904 rootFiles = append(rootFiles, "testdata/"+tt.condition+"/"+r)
905 }
Bob Badourc778e4c2022-03-22 13:05:19 -0700906 _, err := dumpResolutions(&tt.ctx, stdout, stderr, compliance.GetFS(tt.outDir), rootFiles...)
Bob Badour1ded0a12021-12-03 17:16:14 -0800907 if err != nil {
908 t.Fatalf("dumpresolutions: error = %v, stderr = %v", err, stderr)
909 return
910 }
911 if stderr.Len() > 0 {
912 t.Errorf("dumpresolutions: gotStderr = %v, want none", stderr)
913 }
914 out := stdout.String()
915 expected := expectedOut.String()
916 if out != expected {
917 outList := strings.Split(out, "\n")
918 expectedList := strings.Split(expected, "\n")
919 startLine := 0
920 for len(outList) > startLine && len(expectedList) > startLine && outList[startLine] == expectedList[startLine] {
921 startLine++
922 }
Bob Badour91af68b2022-01-31 13:11:11 -0800923 t.Errorf("dumpresoliutions: gotStdout = %v, want %v, somewhere near line %d Stdout = %v, want %v",
Bob Badour1ded0a12021-12-03 17:16:14 -0800924 out, expected, startLine+1, outList[startLine], expectedList[startLine])
925 }
926 })
927 }
928}
929
930type testContext struct {
931 nextNode int
932 nodes map[string]string
933}
934
935type matcher interface {
Bob Badour103eb0f2022-01-10 13:50:57 -0800936 matchString(*testContext, *compliance.LicenseGraph) string
Bob Badour1ded0a12021-12-03 17:16:14 -0800937 typeString() string
938}
939
940type targetMatcher struct {
941 target string
942 conditions []string
943}
944
Bob Badour103eb0f2022-01-10 13:50:57 -0800945// newTestCondition constructs a test license condition in the license graph.
Colin Cross35f79c32022-01-27 15:18:52 -0800946func newTestCondition(lg *compliance.LicenseGraph, conditionName ...string) compliance.LicenseConditionSet {
Bob Badour103eb0f2022-01-10 13:50:57 -0800947 cs := compliance.NewLicenseConditionSet()
948 for _, name := range conditionName {
949 cs = cs.Plus(compliance.RecognizedConditionNames[name])
950 }
951 if cs.IsEmpty() && len(conditionName) != 0 {
952 panic(fmt.Errorf("attempt to create unrecognized condition: %q", conditionName))
953 }
954 return cs
955}
956
957func (tm *targetMatcher) matchString(ctx *testContext, lg *compliance.LicenseGraph) string {
958 cs := newTestCondition(lg, tm.conditions...)
Bob Badour1ded0a12021-12-03 17:16:14 -0800959 m := tm.target
Bob Badour103eb0f2022-01-10 13:50:57 -0800960 if !cs.IsEmpty() {
961 m += "\\n" + strings.Join(cs.Names(), "\\n")
Bob Badour1ded0a12021-12-03 17:16:14 -0800962 }
963 m = ctx.nodes[tm.target] + " [label=\"" + m + "\"];"
964 return m
965}
966
967func (tm *targetMatcher) typeString() string {
968 return "target"
969}
970
971type resolutionMatcher struct {
972 appliesTo string
973 actsOn string
Bob Badour1ded0a12021-12-03 17:16:14 -0800974 conditions []string
975}
976
Bob Badour103eb0f2022-01-10 13:50:57 -0800977func (rm *resolutionMatcher) matchString(ctx *testContext, lg *compliance.LicenseGraph) string {
978 cs := newTestCondition(lg, rm.conditions...)
979 return ctx.nodes[rm.appliesTo] + " -> " + ctx.nodes[rm.actsOn] +
980 " [label=\"" + strings.Join(cs.Names(), "\\n") + "\"];"
Bob Badour1ded0a12021-12-03 17:16:14 -0800981}
982
983func (rm *resolutionMatcher) typeString() string {
984 return "resolution"
985}
986
987type getMatcher func(*testContext) matcher
988
989func matchTarget(target string, conditions ...string) getMatcher {
990 return func(ctx *testContext) matcher {
991 ctx.nodes[target] = fmt.Sprintf("n%d", ctx.nextNode)
992 ctx.nextNode++
993 return &targetMatcher{target, append([]string{}, conditions...)}
994 }
995}
996
Bob Badour103eb0f2022-01-10 13:50:57 -0800997func matchResolution(appliesTo, actsOn string, conditions ...string) getMatcher {
Bob Badour1ded0a12021-12-03 17:16:14 -0800998 return func(ctx *testContext) matcher {
999 if _, ok := ctx.nodes[appliesTo]; !ok {
1000 ctx.nodes[appliesTo] = fmt.Sprintf("unknown%d", ctx.nextNode)
1001 ctx.nextNode++
1002 }
1003 if _, ok := ctx.nodes[actsOn]; !ok {
1004 ctx.nodes[actsOn] = fmt.Sprintf("unknown%d", ctx.nextNode)
1005 ctx.nextNode++
1006 }
Bob Badour103eb0f2022-01-10 13:50:57 -08001007 return &resolutionMatcher{appliesTo, actsOn, append([]string{}, conditions...)}
Bob Badour1ded0a12021-12-03 17:16:14 -08001008 }
1009}
1010
1011func Test_graphviz(t *testing.T) {
1012 tests := []struct {
1013 condition string
1014 name string
Bob Badourc778e4c2022-03-22 13:05:19 -07001015 outDir string
Bob Badour1ded0a12021-12-03 17:16:14 -08001016 roots []string
1017 ctx context
1018 expectedOut []getMatcher
1019 }{
1020 {
1021 condition: "firstparty",
1022 name: "apex",
1023 roots: []string{"highest.apex.meta_lic"},
1024 expectedOut: []getMatcher{
1025 matchTarget("testdata/firstparty/bin/bin1.meta_lic"),
1026 matchTarget("testdata/firstparty/lib/liba.so.meta_lic"),
1027 matchTarget("testdata/firstparty/lib/libc.a.meta_lic"),
1028 matchTarget("testdata/firstparty/bin/bin2.meta_lic"),
1029 matchTarget("testdata/firstparty/highest.apex.meta_lic"),
1030 matchTarget("testdata/firstparty/lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08001031 matchResolution(
1032 "testdata/firstparty/bin/bin1.meta_lic",
1033 "testdata/firstparty/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001034 "notice"),
1035 matchResolution(
1036 "testdata/firstparty/bin/bin1.meta_lic",
1037 "testdata/firstparty/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001038 "notice"),
1039 matchResolution(
1040 "testdata/firstparty/bin/bin1.meta_lic",
1041 "testdata/firstparty/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001042 "notice"),
1043 matchResolution(
1044 "testdata/firstparty/bin/bin2.meta_lic",
1045 "testdata/firstparty/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001046 "notice"),
1047 matchResolution(
1048 "testdata/firstparty/highest.apex.meta_lic",
1049 "testdata/firstparty/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001050 "notice"),
1051 matchResolution(
1052 "testdata/firstparty/highest.apex.meta_lic",
1053 "testdata/firstparty/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001054 "notice"),
1055 matchResolution(
1056 "testdata/firstparty/highest.apex.meta_lic",
1057 "testdata/firstparty/highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001058 "notice"),
1059 matchResolution(
1060 "testdata/firstparty/highest.apex.meta_lic",
1061 "testdata/firstparty/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001062 "notice"),
1063 matchResolution(
1064 "testdata/firstparty/highest.apex.meta_lic",
1065 "testdata/firstparty/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001066 "notice"),
1067 matchResolution(
1068 "testdata/firstparty/highest.apex.meta_lic",
1069 "testdata/firstparty/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001070 "notice"),
1071 matchResolution(
1072 "testdata/firstparty/lib/liba.so.meta_lic",
1073 "testdata/firstparty/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001074 "notice"),
1075 matchResolution(
1076 "testdata/firstparty/lib/libb.so.meta_lic",
1077 "testdata/firstparty/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001078 "notice"),
1079 },
1080 },
1081 {
1082 condition: "firstparty",
1083 name: "apex_trimmed",
1084 roots: []string{"highest.apex.meta_lic"},
Bob Badour682e1ba2022-02-02 15:15:56 -08001085 ctx: context{stripPrefix: []string{"testdata/firstparty/"}},
Bob Badour1ded0a12021-12-03 17:16:14 -08001086 expectedOut: []getMatcher{
1087 matchTarget("bin/bin1.meta_lic"),
1088 matchTarget("lib/liba.so.meta_lic"),
1089 matchTarget("lib/libc.a.meta_lic"),
1090 matchTarget("bin/bin2.meta_lic"),
1091 matchTarget("highest.apex.meta_lic"),
1092 matchTarget("lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08001093 matchResolution(
1094 "bin/bin1.meta_lic",
1095 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001096 "notice"),
1097 matchResolution(
1098 "bin/bin1.meta_lic",
1099 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001100 "notice"),
1101 matchResolution(
1102 "bin/bin1.meta_lic",
1103 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001104 "notice"),
1105 matchResolution(
1106 "bin/bin2.meta_lic",
1107 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001108 "notice"),
1109 matchResolution(
1110 "highest.apex.meta_lic",
1111 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001112 "notice"),
1113 matchResolution(
1114 "highest.apex.meta_lic",
1115 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001116 "notice"),
1117 matchResolution(
1118 "highest.apex.meta_lic",
1119 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001120 "notice"),
1121 matchResolution(
1122 "highest.apex.meta_lic",
1123 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001124 "notice"),
1125 matchResolution(
1126 "highest.apex.meta_lic",
1127 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001128 "notice"),
1129 matchResolution(
1130 "highest.apex.meta_lic",
1131 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001132 "notice"),
1133 matchResolution(
1134 "lib/liba.so.meta_lic",
1135 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001136 "notice"),
1137 matchResolution(
1138 "lib/libb.so.meta_lic",
1139 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001140 "notice"),
1141 },
1142 },
1143 {
1144 condition: "firstparty",
1145 name: "apex_trimmed_notice",
1146 roots: []string{"highest.apex.meta_lic"},
1147 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08001148 conditions: []compliance.LicenseCondition{compliance.NoticeCondition},
Bob Badour682e1ba2022-02-02 15:15:56 -08001149 stripPrefix: []string{"testdata/firstparty/"},
Bob Badour1ded0a12021-12-03 17:16:14 -08001150 },
1151 expectedOut: []getMatcher{
1152 matchTarget("bin/bin1.meta_lic"),
1153 matchTarget("lib/liba.so.meta_lic"),
1154 matchTarget("lib/libc.a.meta_lic"),
1155 matchTarget("bin/bin2.meta_lic"),
1156 matchTarget("highest.apex.meta_lic"),
1157 matchTarget("lib/libb.so.meta_lic"),
1158 matchResolution(
1159 "bin/bin1.meta_lic",
1160 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001161 "notice"),
1162 matchResolution(
1163 "bin/bin1.meta_lic",
1164 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001165 "notice"),
1166 matchResolution(
1167 "bin/bin1.meta_lic",
1168 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001169 "notice"),
1170 matchResolution(
1171 "bin/bin2.meta_lic",
1172 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001173 "notice"),
1174 matchResolution(
1175 "highest.apex.meta_lic",
1176 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001177 "notice"),
1178 matchResolution(
1179 "highest.apex.meta_lic",
1180 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001181 "notice"),
1182 matchResolution(
1183 "highest.apex.meta_lic",
1184 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001185 "notice"),
1186 matchResolution(
1187 "highest.apex.meta_lic",
1188 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001189 "notice"),
1190 matchResolution(
1191 "highest.apex.meta_lic",
1192 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001193 "notice"),
1194 matchResolution(
1195 "highest.apex.meta_lic",
1196 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001197 "notice"),
1198 matchResolution(
1199 "lib/liba.so.meta_lic",
1200 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001201 "notice"),
1202 matchResolution(
1203 "lib/libb.so.meta_lic",
1204 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001205 "notice"),
1206 },
1207 },
1208 {
1209 condition: "firstparty",
1210 name: "apex_trimmed_share",
1211 roots: []string{"highest.apex.meta_lic"},
1212 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08001213 conditions: compliance.ImpliesShared.AsList(),
Bob Badour682e1ba2022-02-02 15:15:56 -08001214 stripPrefix: []string{"testdata/firstparty/"},
Bob Badour1ded0a12021-12-03 17:16:14 -08001215 },
1216 expectedOut: []getMatcher{},
1217 },
1218 {
1219 condition: "firstparty",
1220 name: "apex_trimmed_private",
1221 roots: []string{"highest.apex.meta_lic"},
1222 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08001223 conditions: compliance.ImpliesPrivate.AsList(),
Bob Badour682e1ba2022-02-02 15:15:56 -08001224 stripPrefix: []string{"testdata/firstparty/"},
Bob Badour1ded0a12021-12-03 17:16:14 -08001225 },
1226 expectedOut: []getMatcher{},
1227 },
1228 {
1229 condition: "firstparty",
1230 name: "apex_trimmed_share_private",
1231 roots: []string{"highest.apex.meta_lic"},
1232 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08001233 conditions: compliance.ImpliesShared.Union(compliance.ImpliesPrivate).AsList(),
Bob Badour682e1ba2022-02-02 15:15:56 -08001234 stripPrefix: []string{"testdata/firstparty/"},
Bob Badour1ded0a12021-12-03 17:16:14 -08001235 },
1236 expectedOut: []getMatcher{},
1237 },
1238 {
1239 condition: "firstparty",
1240 name: "apex_trimmed_labelled",
1241 roots: []string{"highest.apex.meta_lic"},
Bob Badour682e1ba2022-02-02 15:15:56 -08001242 ctx: context{stripPrefix: []string{"testdata/firstparty/"}, labelConditions: true},
Bob Badour1ded0a12021-12-03 17:16:14 -08001243 expectedOut: []getMatcher{
1244 matchTarget("bin/bin1.meta_lic", "notice"),
1245 matchTarget("lib/liba.so.meta_lic", "notice"),
1246 matchTarget("lib/libc.a.meta_lic", "notice"),
1247 matchTarget("bin/bin2.meta_lic", "notice"),
1248 matchTarget("highest.apex.meta_lic", "notice"),
1249 matchTarget("lib/libb.so.meta_lic", "notice"),
Bob Badour1ded0a12021-12-03 17:16:14 -08001250 matchResolution(
1251 "bin/bin1.meta_lic",
1252 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001253 "notice"),
1254 matchResolution(
1255 "bin/bin1.meta_lic",
1256 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001257 "notice"),
1258 matchResolution(
1259 "bin/bin1.meta_lic",
1260 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001261 "notice"),
1262 matchResolution(
1263 "bin/bin2.meta_lic",
1264 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001265 "notice"),
1266 matchResolution(
1267 "highest.apex.meta_lic",
1268 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001269 "notice"),
1270 matchResolution(
1271 "highest.apex.meta_lic",
1272 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001273 "notice"),
1274 matchResolution(
1275 "highest.apex.meta_lic",
1276 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001277 "notice"),
1278 matchResolution(
1279 "highest.apex.meta_lic",
1280 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001281 "notice"),
1282 matchResolution(
1283 "highest.apex.meta_lic",
1284 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001285 "notice"),
1286 matchResolution(
1287 "highest.apex.meta_lic",
1288 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001289 "notice"),
1290 matchResolution(
1291 "lib/liba.so.meta_lic",
1292 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001293 "notice"),
1294 matchResolution(
1295 "lib/libb.so.meta_lic",
1296 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001297 "notice"),
1298 },
1299 },
1300 {
1301 condition: "firstparty",
1302 name: "container",
1303 roots: []string{"container.zip.meta_lic"},
1304 expectedOut: []getMatcher{
1305 matchTarget("testdata/firstparty/bin/bin1.meta_lic"),
1306 matchTarget("testdata/firstparty/lib/liba.so.meta_lic"),
1307 matchTarget("testdata/firstparty/lib/libc.a.meta_lic"),
1308 matchTarget("testdata/firstparty/bin/bin2.meta_lic"),
1309 matchTarget("testdata/firstparty/container.zip.meta_lic"),
1310 matchTarget("testdata/firstparty/lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08001311 matchResolution(
1312 "testdata/firstparty/bin/bin1.meta_lic",
1313 "testdata/firstparty/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001314 "notice"),
1315 matchResolution(
1316 "testdata/firstparty/bin/bin1.meta_lic",
1317 "testdata/firstparty/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001318 "notice"),
1319 matchResolution(
1320 "testdata/firstparty/bin/bin1.meta_lic",
1321 "testdata/firstparty/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001322 "notice"),
1323 matchResolution(
1324 "testdata/firstparty/bin/bin2.meta_lic",
1325 "testdata/firstparty/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001326 "notice"),
1327 matchResolution(
1328 "testdata/firstparty/container.zip.meta_lic",
1329 "testdata/firstparty/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001330 "notice"),
1331 matchResolution(
1332 "testdata/firstparty/container.zip.meta_lic",
1333 "testdata/firstparty/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001334 "notice"),
1335 matchResolution(
1336 "testdata/firstparty/container.zip.meta_lic",
1337 "testdata/firstparty/container.zip.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001338 "notice"),
1339 matchResolution(
1340 "testdata/firstparty/container.zip.meta_lic",
1341 "testdata/firstparty/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001342 "notice"),
1343 matchResolution(
1344 "testdata/firstparty/container.zip.meta_lic",
1345 "testdata/firstparty/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001346 "notice"),
1347 matchResolution(
1348 "testdata/firstparty/container.zip.meta_lic",
1349 "testdata/firstparty/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001350 "notice"),
1351 matchResolution(
1352 "testdata/firstparty/lib/liba.so.meta_lic",
1353 "testdata/firstparty/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001354 "notice"),
1355 matchResolution(
1356 "testdata/firstparty/lib/libb.so.meta_lic",
1357 "testdata/firstparty/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001358 "notice"),
1359 },
1360 },
1361 {
1362 condition: "firstparty",
1363 name: "application",
1364 roots: []string{"application.meta_lic"},
1365 expectedOut: []getMatcher{
1366 matchTarget("testdata/firstparty/application.meta_lic"),
1367 matchTarget("testdata/firstparty/lib/liba.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08001368 matchResolution(
1369 "testdata/firstparty/application.meta_lic",
1370 "testdata/firstparty/application.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001371 "notice"),
1372 matchResolution(
1373 "testdata/firstparty/application.meta_lic",
1374 "testdata/firstparty/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001375 "notice"),
1376 },
1377 },
1378 {
1379 condition: "firstparty",
1380 name: "binary",
1381 roots: []string{"bin/bin1.meta_lic"},
1382 expectedOut: []getMatcher{
1383 matchTarget("testdata/firstparty/bin/bin1.meta_lic"),
1384 matchTarget("testdata/firstparty/lib/liba.so.meta_lic"),
1385 matchTarget("testdata/firstparty/lib/libc.a.meta_lic"),
1386 matchResolution(
1387 "testdata/firstparty/bin/bin1.meta_lic",
1388 "testdata/firstparty/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001389 "notice"),
1390 matchResolution(
1391 "testdata/firstparty/bin/bin1.meta_lic",
1392 "testdata/firstparty/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001393 "notice"),
1394 matchResolution(
1395 "testdata/firstparty/bin/bin1.meta_lic",
1396 "testdata/firstparty/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001397 "notice"),
1398 },
1399 },
1400 {
1401 condition: "firstparty",
1402 name: "library",
1403 roots: []string{"lib/libd.so.meta_lic"},
1404 expectedOut: []getMatcher{
1405 matchTarget("testdata/firstparty/lib/libd.so.meta_lic"),
1406 matchResolution(
1407 "testdata/firstparty/lib/libd.so.meta_lic",
1408 "testdata/firstparty/lib/libd.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001409 "notice"),
1410 },
1411 },
1412 {
1413 condition: "notice",
1414 name: "apex",
1415 roots: []string{"highest.apex.meta_lic"},
1416 expectedOut: []getMatcher{
1417 matchTarget("testdata/notice/bin/bin1.meta_lic"),
1418 matchTarget("testdata/notice/lib/liba.so.meta_lic"),
1419 matchTarget("testdata/notice/lib/libc.a.meta_lic"),
1420 matchTarget("testdata/notice/bin/bin2.meta_lic"),
1421 matchTarget("testdata/notice/highest.apex.meta_lic"),
1422 matchTarget("testdata/notice/lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08001423 matchResolution(
1424 "testdata/notice/bin/bin1.meta_lic",
1425 "testdata/notice/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001426 "notice"),
1427 matchResolution(
1428 "testdata/notice/bin/bin1.meta_lic",
1429 "testdata/notice/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001430 "notice"),
1431 matchResolution(
1432 "testdata/notice/bin/bin1.meta_lic",
1433 "testdata/notice/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001434 "notice"),
1435 matchResolution(
1436 "testdata/notice/bin/bin2.meta_lic",
1437 "testdata/notice/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001438 "notice"),
1439 matchResolution(
1440 "testdata/notice/highest.apex.meta_lic",
1441 "testdata/notice/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001442 "notice"),
1443 matchResolution(
1444 "testdata/notice/highest.apex.meta_lic",
1445 "testdata/notice/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001446 "notice"),
1447 matchResolution(
1448 "testdata/notice/highest.apex.meta_lic",
1449 "testdata/notice/highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001450 "notice"),
1451 matchResolution(
1452 "testdata/notice/highest.apex.meta_lic",
1453 "testdata/notice/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001454 "notice"),
1455 matchResolution(
1456 "testdata/notice/highest.apex.meta_lic",
1457 "testdata/notice/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001458 "notice"),
1459 matchResolution(
1460 "testdata/notice/highest.apex.meta_lic",
1461 "testdata/notice/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001462 "notice"),
1463 matchResolution(
1464 "testdata/notice/lib/liba.so.meta_lic",
1465 "testdata/notice/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001466 "notice"),
1467 matchResolution(
1468 "testdata/notice/lib/libb.so.meta_lic",
1469 "testdata/notice/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001470 "notice"),
1471 },
1472 },
1473 {
1474 condition: "notice",
1475 name: "apex_trimmed",
1476 roots: []string{"highest.apex.meta_lic"},
Bob Badour682e1ba2022-02-02 15:15:56 -08001477 ctx: context{stripPrefix: []string{"testdata/notice/"}},
Bob Badour1ded0a12021-12-03 17:16:14 -08001478 expectedOut: []getMatcher{
1479 matchTarget("bin/bin1.meta_lic"),
1480 matchTarget("lib/liba.so.meta_lic"),
1481 matchTarget("lib/libc.a.meta_lic"),
1482 matchTarget("bin/bin2.meta_lic"),
1483 matchTarget("highest.apex.meta_lic"),
1484 matchTarget("lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08001485 matchResolution(
1486 "bin/bin1.meta_lic",
1487 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001488 "notice"),
1489 matchResolution(
1490 "bin/bin1.meta_lic",
1491 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001492 "notice"),
1493 matchResolution(
1494 "bin/bin1.meta_lic",
1495 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001496 "notice"),
1497 matchResolution(
1498 "bin/bin2.meta_lic",
1499 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001500 "notice"),
1501 matchResolution(
1502 "highest.apex.meta_lic",
1503 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001504 "notice"),
1505 matchResolution(
1506 "highest.apex.meta_lic",
1507 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001508 "notice"),
1509 matchResolution(
1510 "highest.apex.meta_lic",
1511 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001512 "notice"),
1513 matchResolution(
1514 "highest.apex.meta_lic",
1515 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001516 "notice"),
1517 matchResolution(
1518 "highest.apex.meta_lic",
1519 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001520 "notice"),
1521 matchResolution(
1522 "highest.apex.meta_lic",
1523 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001524 "notice"),
1525 matchResolution(
1526 "lib/liba.so.meta_lic",
1527 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001528 "notice"),
1529 matchResolution(
1530 "lib/libb.so.meta_lic",
1531 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001532 "notice"),
1533 },
1534 },
1535 {
1536 condition: "notice",
1537 name: "apex_trimmed_notice",
1538 roots: []string{"highest.apex.meta_lic"},
1539 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08001540 conditions: []compliance.LicenseCondition{compliance.NoticeCondition},
Bob Badour682e1ba2022-02-02 15:15:56 -08001541 stripPrefix: []string{"testdata/notice/"},
Bob Badour1ded0a12021-12-03 17:16:14 -08001542 },
1543 expectedOut: []getMatcher{
1544 matchTarget("bin/bin1.meta_lic"),
1545 matchTarget("lib/liba.so.meta_lic"),
1546 matchTarget("lib/libc.a.meta_lic"),
1547 matchTarget("bin/bin2.meta_lic"),
1548 matchTarget("highest.apex.meta_lic"),
1549 matchTarget("lib/libb.so.meta_lic"),
1550 matchResolution(
1551 "bin/bin1.meta_lic",
1552 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001553 "notice"),
1554 matchResolution(
1555 "bin/bin1.meta_lic",
1556 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001557 "notice"),
1558 matchResolution(
1559 "bin/bin1.meta_lic",
1560 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001561 "notice"),
1562 matchResolution(
1563 "bin/bin2.meta_lic",
1564 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001565 "notice"),
1566 matchResolution(
1567 "highest.apex.meta_lic",
1568 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001569 "notice"),
1570 matchResolution(
1571 "highest.apex.meta_lic",
1572 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001573 "notice"),
1574 matchResolution(
1575 "highest.apex.meta_lic",
1576 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001577 "notice"),
1578 matchResolution(
1579 "highest.apex.meta_lic",
1580 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001581 "notice"),
1582 matchResolution(
1583 "highest.apex.meta_lic",
1584 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001585 "notice"),
1586 matchResolution(
1587 "highest.apex.meta_lic",
1588 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001589 "notice"),
1590 matchResolution(
1591 "lib/liba.so.meta_lic",
1592 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001593 "notice"),
1594 matchResolution(
1595 "lib/libb.so.meta_lic",
1596 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001597 "notice"),
1598 },
1599 },
1600 {
1601 condition: "notice",
1602 name: "apex_trimmed_share",
1603 roots: []string{"highest.apex.meta_lic"},
1604 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08001605 conditions: compliance.ImpliesShared.AsList(),
Bob Badour682e1ba2022-02-02 15:15:56 -08001606 stripPrefix: []string{"testdata/notice/"},
Bob Badour1ded0a12021-12-03 17:16:14 -08001607 },
1608 expectedOut: []getMatcher{},
1609 },
1610 {
1611 condition: "notice",
1612 name: "apex_trimmed_private",
1613 roots: []string{"highest.apex.meta_lic"},
1614 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08001615 conditions: compliance.ImpliesPrivate.AsList(),
Bob Badour682e1ba2022-02-02 15:15:56 -08001616 stripPrefix: []string{"testdata/notice/"},
Bob Badour1ded0a12021-12-03 17:16:14 -08001617 },
1618 expectedOut: []getMatcher{},
1619 },
1620 {
1621 condition: "notice",
1622 name: "apex_trimmed_share_private",
1623 roots: []string{"highest.apex.meta_lic"},
1624 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08001625 conditions: compliance.ImpliesShared.Union(compliance.ImpliesPrivate).AsList(),
Bob Badour682e1ba2022-02-02 15:15:56 -08001626 stripPrefix: []string{"testdata/notice/"},
Bob Badour1ded0a12021-12-03 17:16:14 -08001627 },
1628 expectedOut: []getMatcher{},
1629 },
1630 {
1631 condition: "notice",
1632 name: "apex_trimmed_labelled",
1633 roots: []string{"highest.apex.meta_lic"},
Bob Badour682e1ba2022-02-02 15:15:56 -08001634 ctx: context{stripPrefix: []string{"testdata/notice/"}, labelConditions: true},
Bob Badour1ded0a12021-12-03 17:16:14 -08001635 expectedOut: []getMatcher{
1636 matchTarget("bin/bin1.meta_lic", "notice"),
1637 matchTarget("lib/liba.so.meta_lic", "notice"),
1638 matchTarget("lib/libc.a.meta_lic", "notice"),
1639 matchTarget("bin/bin2.meta_lic", "notice"),
1640 matchTarget("highest.apex.meta_lic", "notice"),
1641 matchTarget("lib/libb.so.meta_lic", "notice"),
Bob Badour1ded0a12021-12-03 17:16:14 -08001642 matchResolution(
1643 "bin/bin1.meta_lic",
1644 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001645 "notice"),
1646 matchResolution(
1647 "bin/bin1.meta_lic",
1648 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001649 "notice"),
1650 matchResolution(
1651 "bin/bin1.meta_lic",
1652 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001653 "notice"),
1654 matchResolution(
1655 "bin/bin2.meta_lic",
1656 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001657 "notice"),
1658 matchResolution(
1659 "highest.apex.meta_lic",
1660 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001661 "notice"),
1662 matchResolution(
1663 "highest.apex.meta_lic",
1664 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001665 "notice"),
1666 matchResolution(
1667 "highest.apex.meta_lic",
1668 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001669 "notice"),
1670 matchResolution(
1671 "highest.apex.meta_lic",
1672 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001673 "notice"),
1674 matchResolution(
1675 "highest.apex.meta_lic",
1676 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001677 "notice"),
1678 matchResolution(
1679 "highest.apex.meta_lic",
1680 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001681 "notice"),
1682 matchResolution(
1683 "lib/liba.so.meta_lic",
1684 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001685 "notice"),
1686 matchResolution(
1687 "lib/libb.so.meta_lic",
1688 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001689 "notice"),
1690 },
1691 },
1692 {
1693 condition: "notice",
1694 name: "container",
1695 roots: []string{"container.zip.meta_lic"},
1696 expectedOut: []getMatcher{
1697 matchTarget("testdata/notice/bin/bin1.meta_lic"),
1698 matchTarget("testdata/notice/lib/liba.so.meta_lic"),
1699 matchTarget("testdata/notice/lib/libc.a.meta_lic"),
1700 matchTarget("testdata/notice/bin/bin2.meta_lic"),
1701 matchTarget("testdata/notice/container.zip.meta_lic"),
1702 matchTarget("testdata/notice/lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08001703 matchResolution(
1704 "testdata/notice/bin/bin1.meta_lic",
1705 "testdata/notice/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001706 "notice"),
1707 matchResolution(
1708 "testdata/notice/bin/bin1.meta_lic",
1709 "testdata/notice/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001710 "notice"),
1711 matchResolution(
1712 "testdata/notice/bin/bin1.meta_lic",
1713 "testdata/notice/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001714 "notice"),
1715 matchResolution(
1716 "testdata/notice/bin/bin2.meta_lic",
1717 "testdata/notice/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001718 "notice"),
1719 matchResolution(
1720 "testdata/notice/container.zip.meta_lic",
1721 "testdata/notice/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001722 "notice"),
1723 matchResolution(
1724 "testdata/notice/container.zip.meta_lic",
1725 "testdata/notice/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001726 "notice"),
1727 matchResolution(
1728 "testdata/notice/container.zip.meta_lic",
1729 "testdata/notice/container.zip.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001730 "notice"),
1731 matchResolution(
1732 "testdata/notice/container.zip.meta_lic",
1733 "testdata/notice/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001734 "notice"),
1735 matchResolution(
1736 "testdata/notice/container.zip.meta_lic",
1737 "testdata/notice/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001738 "notice"),
1739 matchResolution(
1740 "testdata/notice/container.zip.meta_lic",
1741 "testdata/notice/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001742 "notice"),
1743 matchResolution(
1744 "testdata/notice/lib/liba.so.meta_lic",
1745 "testdata/notice/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001746 "notice"),
1747 matchResolution(
1748 "testdata/notice/lib/libb.so.meta_lic",
1749 "testdata/notice/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001750 "notice"),
1751 },
1752 },
1753 {
1754 condition: "notice",
1755 name: "application",
1756 roots: []string{"application.meta_lic"},
1757 expectedOut: []getMatcher{
1758 matchTarget("testdata/notice/application.meta_lic"),
1759 matchTarget("testdata/notice/lib/liba.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08001760 matchResolution(
1761 "testdata/notice/application.meta_lic",
1762 "testdata/notice/application.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001763 "notice"),
1764 matchResolution(
1765 "testdata/notice/application.meta_lic",
1766 "testdata/notice/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001767 "notice"),
1768 },
1769 },
1770 {
1771 condition: "notice",
1772 name: "binary",
1773 roots: []string{"bin/bin1.meta_lic"},
1774 expectedOut: []getMatcher{
1775 matchTarget("testdata/notice/bin/bin1.meta_lic"),
1776 matchTarget("testdata/notice/lib/liba.so.meta_lic"),
1777 matchTarget("testdata/notice/lib/libc.a.meta_lic"),
1778 matchResolution(
1779 "testdata/notice/bin/bin1.meta_lic",
1780 "testdata/notice/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001781 "notice"),
1782 matchResolution(
1783 "testdata/notice/bin/bin1.meta_lic",
1784 "testdata/notice/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001785 "notice"),
1786 matchResolution(
1787 "testdata/notice/bin/bin1.meta_lic",
1788 "testdata/notice/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001789 "notice"),
1790 },
1791 },
1792 {
1793 condition: "notice",
1794 name: "library",
1795 roots: []string{"lib/libd.so.meta_lic"},
1796 expectedOut: []getMatcher{
1797 matchTarget("testdata/notice/lib/libd.so.meta_lic"),
1798 matchResolution(
1799 "testdata/notice/lib/libd.so.meta_lic",
1800 "testdata/notice/lib/libd.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001801 "notice"),
1802 },
1803 },
1804 {
1805 condition: "reciprocal",
1806 name: "apex",
1807 roots: []string{"highest.apex.meta_lic"},
1808 expectedOut: []getMatcher{
1809 matchTarget("testdata/reciprocal/bin/bin1.meta_lic"),
1810 matchTarget("testdata/reciprocal/lib/liba.so.meta_lic"),
1811 matchTarget("testdata/reciprocal/lib/libc.a.meta_lic"),
1812 matchTarget("testdata/reciprocal/bin/bin2.meta_lic"),
1813 matchTarget("testdata/reciprocal/highest.apex.meta_lic"),
1814 matchTarget("testdata/reciprocal/lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08001815 matchResolution(
1816 "testdata/reciprocal/bin/bin1.meta_lic",
1817 "testdata/reciprocal/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001818 "notice"),
1819 matchResolution(
1820 "testdata/reciprocal/bin/bin1.meta_lic",
1821 "testdata/reciprocal/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001822 "reciprocal"),
1823 matchResolution(
1824 "testdata/reciprocal/bin/bin1.meta_lic",
1825 "testdata/reciprocal/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001826 "reciprocal"),
1827 matchResolution(
1828 "testdata/reciprocal/bin/bin2.meta_lic",
1829 "testdata/reciprocal/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001830 "notice"),
1831 matchResolution(
1832 "testdata/reciprocal/highest.apex.meta_lic",
1833 "testdata/reciprocal/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001834 "notice"),
1835 matchResolution(
1836 "testdata/reciprocal/highest.apex.meta_lic",
1837 "testdata/reciprocal/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001838 "notice"),
1839 matchResolution(
1840 "testdata/reciprocal/highest.apex.meta_lic",
1841 "testdata/reciprocal/highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001842 "notice"),
1843 matchResolution(
1844 "testdata/reciprocal/highest.apex.meta_lic",
1845 "testdata/reciprocal/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001846 "reciprocal"),
1847 matchResolution(
1848 "testdata/reciprocal/highest.apex.meta_lic",
1849 "testdata/reciprocal/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001850 "notice"),
1851 matchResolution(
1852 "testdata/reciprocal/highest.apex.meta_lic",
1853 "testdata/reciprocal/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001854 "reciprocal"),
1855 matchResolution(
1856 "testdata/reciprocal/lib/liba.so.meta_lic",
1857 "testdata/reciprocal/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001858 "reciprocal"),
1859 matchResolution(
1860 "testdata/reciprocal/lib/libb.so.meta_lic",
1861 "testdata/reciprocal/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001862 "notice"),
1863 },
1864 },
1865 {
1866 condition: "reciprocal",
1867 name: "apex_trimmed",
1868 roots: []string{"highest.apex.meta_lic"},
Bob Badour682e1ba2022-02-02 15:15:56 -08001869 ctx: context{stripPrefix: []string{"testdata/reciprocal/"}},
Bob Badour1ded0a12021-12-03 17:16:14 -08001870 expectedOut: []getMatcher{
1871 matchTarget("bin/bin1.meta_lic"),
1872 matchTarget("lib/liba.so.meta_lic"),
1873 matchTarget("lib/libc.a.meta_lic"),
1874 matchTarget("bin/bin2.meta_lic"),
1875 matchTarget("highest.apex.meta_lic"),
1876 matchTarget("lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08001877 matchResolution(
1878 "bin/bin1.meta_lic",
1879 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001880 "notice"),
1881 matchResolution(
1882 "bin/bin1.meta_lic",
1883 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001884 "reciprocal"),
1885 matchResolution(
1886 "bin/bin1.meta_lic",
1887 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001888 "reciprocal"),
1889 matchResolution(
1890 "bin/bin2.meta_lic",
1891 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001892 "notice"),
1893 matchResolution(
1894 "highest.apex.meta_lic",
1895 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001896 "notice"),
1897 matchResolution(
1898 "highest.apex.meta_lic",
1899 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001900 "notice"),
1901 matchResolution(
1902 "highest.apex.meta_lic",
1903 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001904 "notice"),
1905 matchResolution(
1906 "highest.apex.meta_lic",
1907 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001908 "reciprocal"),
1909 matchResolution(
1910 "highest.apex.meta_lic",
1911 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001912 "notice"),
1913 matchResolution(
1914 "highest.apex.meta_lic",
1915 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001916 "reciprocal"),
1917 matchResolution(
1918 "lib/liba.so.meta_lic",
1919 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001920 "reciprocal"),
1921 matchResolution(
1922 "lib/libb.so.meta_lic",
1923 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001924 "notice"),
1925 },
1926 },
1927 {
1928 condition: "reciprocal",
1929 name: "apex_trimmed_notice",
1930 roots: []string{"highest.apex.meta_lic"},
1931 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08001932 conditions: []compliance.LicenseCondition{compliance.NoticeCondition},
Bob Badour682e1ba2022-02-02 15:15:56 -08001933 stripPrefix: []string{"testdata/reciprocal/"},
Bob Badour1ded0a12021-12-03 17:16:14 -08001934 },
1935 expectedOut: []getMatcher{
1936 matchTarget("bin/bin1.meta_lic"),
1937 matchTarget("bin/bin2.meta_lic"),
1938 matchTarget("highest.apex.meta_lic"),
1939 matchTarget("lib/libb.so.meta_lic"),
1940 matchResolution(
1941 "bin/bin1.meta_lic",
1942 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001943 "notice"),
1944 matchResolution(
1945 "bin/bin2.meta_lic",
1946 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001947 "notice"),
1948 matchResolution(
1949 "highest.apex.meta_lic",
1950 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001951 "notice"),
1952 matchResolution(
1953 "highest.apex.meta_lic",
1954 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001955 "notice"),
1956 matchResolution(
1957 "highest.apex.meta_lic",
1958 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001959 "notice"),
1960 matchResolution(
1961 "highest.apex.meta_lic",
1962 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001963 "notice"),
1964 matchResolution(
1965 "lib/libb.so.meta_lic",
1966 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001967 "notice"),
1968 },
1969 },
1970 {
1971 condition: "reciprocal",
1972 name: "apex_trimmed_share",
1973 roots: []string{"highest.apex.meta_lic"},
1974 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08001975 conditions: compliance.ImpliesShared.AsList(),
Bob Badour682e1ba2022-02-02 15:15:56 -08001976 stripPrefix: []string{"testdata/reciprocal/"},
Bob Badour1ded0a12021-12-03 17:16:14 -08001977 },
1978 expectedOut: []getMatcher{
1979 matchTarget("bin/bin1.meta_lic"),
1980 matchTarget("lib/liba.so.meta_lic"),
1981 matchTarget("lib/libc.a.meta_lic"),
1982 matchTarget("highest.apex.meta_lic"),
1983 matchResolution(
1984 "bin/bin1.meta_lic",
1985 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001986 "reciprocal"),
1987 matchResolution(
1988 "bin/bin1.meta_lic",
1989 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001990 "reciprocal"),
1991 matchResolution(
1992 "highest.apex.meta_lic",
1993 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001994 "reciprocal"),
1995 matchResolution(
1996 "highest.apex.meta_lic",
1997 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08001998 "reciprocal"),
1999 matchResolution(
2000 "lib/liba.so.meta_lic",
2001 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002002 "reciprocal"),
2003 },
2004 },
2005 {
2006 condition: "reciprocal",
2007 name: "apex_trimmed_private",
2008 roots: []string{"highest.apex.meta_lic"},
2009 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08002010 conditions: compliance.ImpliesPrivate.AsList(),
Bob Badour682e1ba2022-02-02 15:15:56 -08002011 stripPrefix: []string{"testdata/reciprocal/"},
Bob Badour1ded0a12021-12-03 17:16:14 -08002012 },
2013 expectedOut: []getMatcher{},
2014 },
2015 {
2016 condition: "reciprocal",
2017 name: "apex_trimmed_share_private",
2018 roots: []string{"highest.apex.meta_lic"},
2019 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08002020 conditions: compliance.ImpliesShared.Union(compliance.ImpliesPrivate).AsList(),
Bob Badour682e1ba2022-02-02 15:15:56 -08002021 stripPrefix: []string{"testdata/reciprocal/"},
Bob Badour1ded0a12021-12-03 17:16:14 -08002022 },
2023 expectedOut: []getMatcher{
2024 matchTarget("bin/bin1.meta_lic"),
2025 matchTarget("lib/liba.so.meta_lic"),
2026 matchTarget("lib/libc.a.meta_lic"),
2027 matchTarget("highest.apex.meta_lic"),
2028 matchResolution(
2029 "bin/bin1.meta_lic",
2030 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002031 "reciprocal"),
2032 matchResolution(
2033 "bin/bin1.meta_lic",
2034 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002035 "reciprocal"),
2036 matchResolution(
2037 "highest.apex.meta_lic",
2038 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002039 "reciprocal"),
2040 matchResolution(
2041 "highest.apex.meta_lic",
2042 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002043 "reciprocal"),
2044 matchResolution(
2045 "lib/liba.so.meta_lic",
2046 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002047 "reciprocal"),
2048 },
2049 },
2050 {
2051 condition: "reciprocal",
2052 name: "apex_trimmed_labelled",
2053 roots: []string{"highest.apex.meta_lic"},
Bob Badour682e1ba2022-02-02 15:15:56 -08002054 ctx: context{stripPrefix: []string{"testdata/reciprocal/"}, labelConditions: true},
Bob Badour1ded0a12021-12-03 17:16:14 -08002055 expectedOut: []getMatcher{
2056 matchTarget("bin/bin1.meta_lic", "notice"),
2057 matchTarget("lib/liba.so.meta_lic", "reciprocal"),
2058 matchTarget("lib/libc.a.meta_lic", "reciprocal"),
2059 matchTarget("bin/bin2.meta_lic", "notice"),
2060 matchTarget("highest.apex.meta_lic", "notice"),
2061 matchTarget("lib/libb.so.meta_lic", "notice"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002062 matchResolution(
2063 "bin/bin1.meta_lic",
2064 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002065 "notice"),
2066 matchResolution(
2067 "bin/bin1.meta_lic",
2068 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002069 "reciprocal"),
2070 matchResolution(
2071 "bin/bin1.meta_lic",
2072 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002073 "reciprocal"),
2074 matchResolution(
2075 "bin/bin2.meta_lic",
2076 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002077 "notice"),
2078 matchResolution(
2079 "highest.apex.meta_lic",
2080 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002081 "notice"),
2082 matchResolution(
2083 "highest.apex.meta_lic",
2084 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002085 "notice"),
2086 matchResolution(
2087 "highest.apex.meta_lic",
2088 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002089 "notice"),
2090 matchResolution(
2091 "highest.apex.meta_lic",
2092 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002093 "reciprocal"),
2094 matchResolution(
2095 "highest.apex.meta_lic",
2096 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002097 "notice"),
2098 matchResolution(
2099 "highest.apex.meta_lic",
2100 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002101 "reciprocal"),
2102 matchResolution(
2103 "lib/liba.so.meta_lic",
2104 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002105 "reciprocal"),
2106 matchResolution(
2107 "lib/libb.so.meta_lic",
2108 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002109 "notice"),
2110 },
2111 },
2112 {
2113 condition: "reciprocal",
2114 name: "container",
2115 roots: []string{"container.zip.meta_lic"},
2116 expectedOut: []getMatcher{
2117 matchTarget("testdata/reciprocal/bin/bin1.meta_lic"),
2118 matchTarget("testdata/reciprocal/lib/liba.so.meta_lic"),
2119 matchTarget("testdata/reciprocal/lib/libc.a.meta_lic"),
2120 matchTarget("testdata/reciprocal/bin/bin2.meta_lic"),
2121 matchTarget("testdata/reciprocal/container.zip.meta_lic"),
2122 matchTarget("testdata/reciprocal/lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002123 matchResolution(
2124 "testdata/reciprocal/bin/bin1.meta_lic",
2125 "testdata/reciprocal/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002126 "notice"),
2127 matchResolution(
2128 "testdata/reciprocal/bin/bin1.meta_lic",
2129 "testdata/reciprocal/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002130 "reciprocal"),
2131 matchResolution(
2132 "testdata/reciprocal/bin/bin1.meta_lic",
2133 "testdata/reciprocal/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002134 "reciprocal"),
2135 matchResolution(
2136 "testdata/reciprocal/bin/bin2.meta_lic",
2137 "testdata/reciprocal/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002138 "notice"),
2139 matchResolution(
2140 "testdata/reciprocal/container.zip.meta_lic",
2141 "testdata/reciprocal/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002142 "notice"),
2143 matchResolution(
2144 "testdata/reciprocal/container.zip.meta_lic",
2145 "testdata/reciprocal/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002146 "notice"),
2147 matchResolution(
2148 "testdata/reciprocal/container.zip.meta_lic",
2149 "testdata/reciprocal/container.zip.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002150 "notice"),
2151 matchResolution(
2152 "testdata/reciprocal/container.zip.meta_lic",
2153 "testdata/reciprocal/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002154 "reciprocal"),
2155 matchResolution(
2156 "testdata/reciprocal/container.zip.meta_lic",
2157 "testdata/reciprocal/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002158 "notice"),
2159 matchResolution(
2160 "testdata/reciprocal/container.zip.meta_lic",
2161 "testdata/reciprocal/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002162 "reciprocal"),
2163 matchResolution(
2164 "testdata/reciprocal/lib/liba.so.meta_lic",
2165 "testdata/reciprocal/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002166 "reciprocal"),
2167 matchResolution(
2168 "testdata/reciprocal/lib/libb.so.meta_lic",
2169 "testdata/reciprocal/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002170 "notice"),
2171 },
2172 },
2173 {
2174 condition: "reciprocal",
2175 name: "application",
2176 roots: []string{"application.meta_lic"},
2177 expectedOut: []getMatcher{
2178 matchTarget("testdata/reciprocal/application.meta_lic"),
2179 matchTarget("testdata/reciprocal/lib/liba.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002180 matchResolution(
2181 "testdata/reciprocal/application.meta_lic",
2182 "testdata/reciprocal/application.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002183 "notice"),
2184 matchResolution(
2185 "testdata/reciprocal/application.meta_lic",
2186 "testdata/reciprocal/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002187 "reciprocal"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002188 },
2189 },
2190 {
2191 condition: "reciprocal",
2192 name: "binary",
2193 roots: []string{"bin/bin1.meta_lic"},
2194 expectedOut: []getMatcher{
2195 matchTarget("testdata/reciprocal/bin/bin1.meta_lic"),
2196 matchTarget("testdata/reciprocal/lib/liba.so.meta_lic"),
2197 matchTarget("testdata/reciprocal/lib/libc.a.meta_lic"),
2198 matchResolution(
2199 "testdata/reciprocal/bin/bin1.meta_lic",
2200 "testdata/reciprocal/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002201 "notice"),
2202 matchResolution(
2203 "testdata/reciprocal/bin/bin1.meta_lic",
2204 "testdata/reciprocal/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002205 "reciprocal"),
2206 matchResolution(
2207 "testdata/reciprocal/bin/bin1.meta_lic",
2208 "testdata/reciprocal/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002209 "reciprocal"),
2210 },
2211 },
2212 {
2213 condition: "reciprocal",
2214 name: "library",
2215 roots: []string{"lib/libd.so.meta_lic"},
2216 expectedOut: []getMatcher{
2217 matchTarget("testdata/reciprocal/lib/libd.so.meta_lic"),
2218 matchResolution(
2219 "testdata/reciprocal/lib/libd.so.meta_lic",
2220 "testdata/reciprocal/lib/libd.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002221 "notice"),
2222 },
2223 },
2224 {
2225 condition: "restricted",
2226 name: "apex",
2227 roots: []string{"highest.apex.meta_lic"},
2228 expectedOut: []getMatcher{
2229 matchTarget("testdata/restricted/bin/bin1.meta_lic"),
2230 matchTarget("testdata/restricted/lib/liba.so.meta_lic"),
2231 matchTarget("testdata/restricted/lib/libc.a.meta_lic"),
2232 matchTarget("testdata/restricted/bin/bin2.meta_lic"),
2233 matchTarget("testdata/restricted/lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002234 matchTarget("testdata/restricted/highest.apex.meta_lic"),
2235 matchResolution(
2236 "testdata/restricted/bin/bin1.meta_lic",
2237 "testdata/restricted/bin/bin1.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002238 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002239 "notice"),
2240 matchResolution(
2241 "testdata/restricted/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002242 "testdata/restricted/lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002243 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002244 matchResolution(
2245 "testdata/restricted/bin/bin1.meta_lic",
2246 "testdata/restricted/lib/libc.a.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002247 "reciprocal",
2248 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002249 matchResolution(
2250 "testdata/restricted/bin/bin2.meta_lic",
2251 "testdata/restricted/bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002252 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002253 "notice"),
2254 matchResolution(
2255 "testdata/restricted/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002256 "testdata/restricted/lib/libb.so.meta_lic",
2257 "restricted"),
2258 matchResolution(
2259 "testdata/restricted/highest.apex.meta_lic",
2260 "testdata/restricted/bin/bin1.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002261 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002262 "notice"),
2263 matchResolution(
2264 "testdata/restricted/highest.apex.meta_lic",
2265 "testdata/restricted/bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002266 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002267 "notice"),
2268 matchResolution(
2269 "testdata/restricted/highest.apex.meta_lic",
2270 "testdata/restricted/highest.apex.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002271 "restricted",
2272 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002273 "notice"),
Bob Badour103eb0f2022-01-10 13:50:57 -08002274 matchResolution(
2275 "testdata/restricted/highest.apex.meta_lic",
2276 "testdata/restricted/lib/liba.so.meta_lic",
2277 "restricted_allows_dynamic_linking"),
2278 matchResolution(
2279 "testdata/restricted/highest.apex.meta_lic",
2280 "testdata/restricted/lib/libb.so.meta_lic",
2281 "restricted"),
2282 matchResolution(
2283 "testdata/restricted/highest.apex.meta_lic",
2284 "testdata/restricted/lib/libc.a.meta_lic",
2285 "reciprocal",
2286 "restricted_allows_dynamic_linking"),
2287 matchResolution(
2288 "testdata/restricted/lib/liba.so.meta_lic",
2289 "testdata/restricted/lib/liba.so.meta_lic",
2290 "restricted_allows_dynamic_linking"),
2291 matchResolution(
2292 "testdata/restricted/lib/libb.so.meta_lic",
2293 "testdata/restricted/lib/libb.so.meta_lic",
2294 "restricted"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002295 },
2296 },
2297 {
2298 condition: "restricted",
2299 name: "apex_trimmed",
2300 roots: []string{"highest.apex.meta_lic"},
Bob Badour682e1ba2022-02-02 15:15:56 -08002301 ctx: context{stripPrefix: []string{"testdata/restricted/"}},
Bob Badour1ded0a12021-12-03 17:16:14 -08002302 expectedOut: []getMatcher{
2303 matchTarget("bin/bin1.meta_lic"),
2304 matchTarget("lib/liba.so.meta_lic"),
2305 matchTarget("lib/libc.a.meta_lic"),
2306 matchTarget("bin/bin2.meta_lic"),
2307 matchTarget("lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002308 matchTarget("highest.apex.meta_lic"),
2309 matchResolution(
2310 "bin/bin1.meta_lic",
2311 "bin/bin1.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002312 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002313 "notice"),
2314 matchResolution(
2315 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002316 "lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002317 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002318 matchResolution(
2319 "bin/bin1.meta_lic",
2320 "lib/libc.a.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002321 "reciprocal",
2322 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002323 matchResolution(
2324 "bin/bin2.meta_lic",
2325 "bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002326 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002327 "notice"),
2328 matchResolution(
2329 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002330 "lib/libb.so.meta_lic",
2331 "restricted"),
2332 matchResolution(
2333 "highest.apex.meta_lic",
2334 "bin/bin1.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002335 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002336 "notice"),
2337 matchResolution(
2338 "highest.apex.meta_lic",
2339 "bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002340 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002341 "notice"),
2342 matchResolution(
2343 "highest.apex.meta_lic",
2344 "highest.apex.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002345 "restricted",
2346 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002347 "notice"),
Bob Badour103eb0f2022-01-10 13:50:57 -08002348 matchResolution(
2349 "highest.apex.meta_lic",
2350 "lib/liba.so.meta_lic",
2351 "restricted_allows_dynamic_linking"),
2352 matchResolution(
2353 "highest.apex.meta_lic",
2354 "lib/libb.so.meta_lic",
2355 "restricted"),
2356 matchResolution(
2357 "highest.apex.meta_lic",
2358 "lib/libc.a.meta_lic",
2359 "reciprocal",
2360 "restricted_allows_dynamic_linking"),
2361 matchResolution(
2362 "lib/liba.so.meta_lic",
2363 "lib/liba.so.meta_lic",
2364 "restricted_allows_dynamic_linking"),
2365 matchResolution(
2366 "lib/libb.so.meta_lic",
2367 "lib/libb.so.meta_lic",
2368 "restricted"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002369 },
2370 },
2371 {
2372 condition: "restricted",
2373 name: "apex_trimmed_notice",
2374 roots: []string{"highest.apex.meta_lic"},
2375 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08002376 conditions: []compliance.LicenseCondition{compliance.NoticeCondition},
Bob Badour682e1ba2022-02-02 15:15:56 -08002377 stripPrefix: []string{"testdata/restricted/"},
Bob Badour1ded0a12021-12-03 17:16:14 -08002378 },
2379 expectedOut: []getMatcher{
2380 matchTarget("bin/bin1.meta_lic"),
2381 matchTarget("bin/bin2.meta_lic"),
2382 matchTarget("highest.apex.meta_lic"),
2383 matchResolution(
2384 "bin/bin1.meta_lic",
2385 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002386 "notice"),
2387 matchResolution(
2388 "bin/bin2.meta_lic",
2389 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002390 "notice"),
2391 matchResolution(
2392 "highest.apex.meta_lic",
2393 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002394 "notice"),
2395 matchResolution(
2396 "highest.apex.meta_lic",
2397 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002398 "notice"),
2399 matchResolution(
2400 "highest.apex.meta_lic",
2401 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002402 "notice"),
2403 },
2404 },
2405 {
2406 condition: "restricted",
2407 name: "apex_trimmed_share",
2408 roots: []string{"highest.apex.meta_lic"},
2409 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08002410 conditions: compliance.ImpliesShared.AsList(),
Bob Badour682e1ba2022-02-02 15:15:56 -08002411 stripPrefix: []string{"testdata/restricted/"},
Bob Badour1ded0a12021-12-03 17:16:14 -08002412 },
2413 expectedOut: []getMatcher{
2414 matchTarget("bin/bin1.meta_lic"),
2415 matchTarget("lib/liba.so.meta_lic"),
2416 matchTarget("lib/libc.a.meta_lic"),
2417 matchTarget("bin/bin2.meta_lic"),
2418 matchTarget("lib/libb.so.meta_lic"),
2419 matchTarget("highest.apex.meta_lic"),
2420 matchResolution(
2421 "bin/bin1.meta_lic",
2422 "bin/bin1.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002423 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002424 matchResolution(
2425 "bin/bin1.meta_lic",
2426 "lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002427 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002428 matchResolution(
2429 "bin/bin1.meta_lic",
2430 "lib/libc.a.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002431 "reciprocal",
2432 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002433 matchResolution(
2434 "bin/bin2.meta_lic",
2435 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002436 "restricted"),
2437 matchResolution(
2438 "bin/bin2.meta_lic",
2439 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002440 "restricted"),
2441 matchResolution(
2442 "highest.apex.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002443 "bin/bin1.meta_lic",
2444 "restricted_allows_dynamic_linking"),
2445 matchResolution(
Bob Badour1ded0a12021-12-03 17:16:14 -08002446 "highest.apex.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002447 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002448 "restricted"),
2449 matchResolution(
2450 "highest.apex.meta_lic",
2451 "highest.apex.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002452 "restricted",
2453 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002454 matchResolution(
2455 "highest.apex.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 "highest.apex.meta_lic",
2460 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002461 "restricted"),
2462 matchResolution(
2463 "highest.apex.meta_lic",
2464 "lib/libc.a.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002465 "reciprocal",
2466 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002467 matchResolution(
2468 "lib/liba.so.meta_lic",
2469 "lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002470 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002471 matchResolution(
2472 "lib/libb.so.meta_lic",
2473 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002474 "restricted"),
2475 },
2476 },
2477 {
2478 condition: "restricted",
2479 name: "apex_trimmed_private",
2480 roots: []string{"highest.apex.meta_lic"},
2481 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08002482 conditions: compliance.ImpliesPrivate.AsList(),
Bob Badour682e1ba2022-02-02 15:15:56 -08002483 stripPrefix: []string{"testdata/restricted/"},
Bob Badour1ded0a12021-12-03 17:16:14 -08002484 },
2485 expectedOut: []getMatcher{},
2486 },
2487 {
2488 condition: "restricted",
2489 name: "apex_trimmed_share_private",
2490 roots: []string{"highest.apex.meta_lic"},
2491 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08002492 conditions: compliance.ImpliesShared.Union(compliance.ImpliesPrivate).AsList(),
Bob Badour682e1ba2022-02-02 15:15:56 -08002493 stripPrefix: []string{"testdata/restricted/"},
Bob Badour1ded0a12021-12-03 17:16:14 -08002494 },
2495 expectedOut: []getMatcher{
2496 matchTarget("bin/bin1.meta_lic"),
2497 matchTarget("lib/liba.so.meta_lic"),
2498 matchTarget("lib/libc.a.meta_lic"),
2499 matchTarget("bin/bin2.meta_lic"),
2500 matchTarget("lib/libb.so.meta_lic"),
2501 matchTarget("highest.apex.meta_lic"),
2502 matchResolution(
2503 "bin/bin1.meta_lic",
2504 "bin/bin1.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002505 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002506 matchResolution(
2507 "bin/bin1.meta_lic",
2508 "lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002509 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002510 matchResolution(
2511 "bin/bin1.meta_lic",
2512 "lib/libc.a.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002513 "reciprocal",
2514 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002515 matchResolution(
2516 "bin/bin2.meta_lic",
2517 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002518 "restricted"),
2519 matchResolution(
2520 "bin/bin2.meta_lic",
2521 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002522 "restricted"),
2523 matchResolution(
2524 "highest.apex.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002525 "bin/bin1.meta_lic",
2526 "restricted_allows_dynamic_linking"),
2527 matchResolution(
Bob Badour1ded0a12021-12-03 17:16:14 -08002528 "highest.apex.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002529 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002530 "restricted"),
2531 matchResolution(
2532 "highest.apex.meta_lic",
2533 "highest.apex.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002534 "restricted",
2535 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002536 matchResolution(
2537 "highest.apex.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 "highest.apex.meta_lic",
2542 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002543 "restricted"),
2544 matchResolution(
2545 "highest.apex.meta_lic",
2546 "lib/libc.a.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002547 "reciprocal",
2548 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002549 matchResolution(
2550 "lib/liba.so.meta_lic",
2551 "lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002552 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002553 matchResolution(
2554 "lib/libb.so.meta_lic",
2555 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002556 "restricted"),
2557 },
2558 },
2559 {
2560 condition: "restricted",
2561 name: "apex_trimmed_labelled",
2562 roots: []string{"highest.apex.meta_lic"},
Bob Badour682e1ba2022-02-02 15:15:56 -08002563 ctx: context{stripPrefix: []string{"testdata/restricted/"}, labelConditions: true},
Bob Badour1ded0a12021-12-03 17:16:14 -08002564 expectedOut: []getMatcher{
2565 matchTarget("bin/bin1.meta_lic", "notice"),
Bob Badour103eb0f2022-01-10 13:50:57 -08002566 matchTarget("lib/liba.so.meta_lic", "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002567 matchTarget("lib/libc.a.meta_lic", "reciprocal"),
2568 matchTarget("bin/bin2.meta_lic", "notice"),
2569 matchTarget("lib/libb.so.meta_lic", "restricted"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002570 matchTarget("highest.apex.meta_lic", "notice"),
2571 matchResolution(
2572 "bin/bin1.meta_lic",
2573 "bin/bin1.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002574 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002575 "notice"),
2576 matchResolution(
2577 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002578 "lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002579 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002580 matchResolution(
2581 "bin/bin1.meta_lic",
2582 "lib/libc.a.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002583 "reciprocal",
2584 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002585 matchResolution(
2586 "bin/bin2.meta_lic",
2587 "bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002588 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002589 "notice"),
2590 matchResolution(
2591 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002592 "lib/libb.so.meta_lic",
2593 "restricted"),
2594 matchResolution(
2595 "highest.apex.meta_lic",
2596 "bin/bin1.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002597 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002598 "notice"),
2599 matchResolution(
2600 "highest.apex.meta_lic",
2601 "bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002602 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002603 "notice"),
2604 matchResolution(
2605 "highest.apex.meta_lic",
2606 "highest.apex.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002607 "restricted",
2608 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002609 "notice"),
Bob Badour103eb0f2022-01-10 13:50:57 -08002610 matchResolution(
2611 "highest.apex.meta_lic",
2612 "lib/liba.so.meta_lic",
2613 "restricted_allows_dynamic_linking"),
2614 matchResolution(
2615 "highest.apex.meta_lic",
2616 "lib/libb.so.meta_lic",
2617 "restricted"),
2618 matchResolution(
2619 "highest.apex.meta_lic",
2620 "lib/libc.a.meta_lic",
2621 "reciprocal",
2622 "restricted_allows_dynamic_linking"),
2623 matchResolution(
2624 "lib/liba.so.meta_lic",
2625 "lib/liba.so.meta_lic",
2626 "restricted_allows_dynamic_linking"),
2627 matchResolution(
2628 "lib/libb.so.meta_lic",
2629 "lib/libb.so.meta_lic",
2630 "restricted"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002631 },
2632 },
2633 {
2634 condition: "restricted",
2635 name: "container",
2636 roots: []string{"container.zip.meta_lic"},
2637 expectedOut: []getMatcher{
2638 matchTarget("testdata/restricted/bin/bin1.meta_lic"),
2639 matchTarget("testdata/restricted/lib/liba.so.meta_lic"),
2640 matchTarget("testdata/restricted/lib/libc.a.meta_lic"),
2641 matchTarget("testdata/restricted/bin/bin2.meta_lic"),
2642 matchTarget("testdata/restricted/lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002643 matchTarget("testdata/restricted/container.zip.meta_lic"),
2644 matchResolution(
2645 "testdata/restricted/bin/bin1.meta_lic",
2646 "testdata/restricted/bin/bin1.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002647 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002648 "notice"),
2649 matchResolution(
2650 "testdata/restricted/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002651 "testdata/restricted/lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002652 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002653 matchResolution(
2654 "testdata/restricted/bin/bin1.meta_lic",
2655 "testdata/restricted/lib/libc.a.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002656 "reciprocal",
2657 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002658 matchResolution(
2659 "testdata/restricted/bin/bin2.meta_lic",
2660 "testdata/restricted/bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002661 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002662 "notice"),
2663 matchResolution(
2664 "testdata/restricted/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002665 "testdata/restricted/lib/libb.so.meta_lic",
2666 "restricted"),
2667 matchResolution(
2668 "testdata/restricted/container.zip.meta_lic",
2669 "testdata/restricted/bin/bin1.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002670 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002671 "notice"),
2672 matchResolution(
2673 "testdata/restricted/container.zip.meta_lic",
2674 "testdata/restricted/bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002675 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002676 "notice"),
2677 matchResolution(
2678 "testdata/restricted/container.zip.meta_lic",
2679 "testdata/restricted/container.zip.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002680 "restricted",
2681 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002682 "notice"),
Bob Badour103eb0f2022-01-10 13:50:57 -08002683 matchResolution(
2684 "testdata/restricted/container.zip.meta_lic",
2685 "testdata/restricted/lib/liba.so.meta_lic",
2686 "restricted_allows_dynamic_linking"),
2687 matchResolution(
2688 "testdata/restricted/container.zip.meta_lic",
2689 "testdata/restricted/lib/libb.so.meta_lic",
2690 "restricted"),
2691 matchResolution(
2692 "testdata/restricted/container.zip.meta_lic",
2693 "testdata/restricted/lib/libc.a.meta_lic",
2694 "reciprocal",
2695 "restricted_allows_dynamic_linking"),
2696 matchResolution(
2697 "testdata/restricted/lib/liba.so.meta_lic",
2698 "testdata/restricted/lib/liba.so.meta_lic",
2699 "restricted_allows_dynamic_linking"),
2700 matchResolution(
2701 "testdata/restricted/lib/libb.so.meta_lic",
2702 "testdata/restricted/lib/libb.so.meta_lic",
2703 "restricted"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002704 },
2705 },
2706 {
2707 condition: "restricted",
2708 name: "application",
2709 roots: []string{"application.meta_lic"},
2710 expectedOut: []getMatcher{
2711 matchTarget("testdata/restricted/application.meta_lic"),
2712 matchTarget("testdata/restricted/lib/liba.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002713 matchResolution(
2714 "testdata/restricted/application.meta_lic",
2715 "testdata/restricted/application.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002716 "restricted",
2717 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002718 "notice"),
2719 matchResolution(
2720 "testdata/restricted/application.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002721 "testdata/restricted/lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002722 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002723 "restricted"),
2724 },
2725 },
2726 {
2727 condition: "restricted",
2728 name: "binary",
2729 roots: []string{"bin/bin1.meta_lic"},
2730 expectedOut: []getMatcher{
2731 matchTarget("testdata/restricted/bin/bin1.meta_lic"),
2732 matchTarget("testdata/restricted/lib/liba.so.meta_lic"),
2733 matchTarget("testdata/restricted/lib/libc.a.meta_lic"),
2734 matchResolution(
2735 "testdata/restricted/bin/bin1.meta_lic",
2736 "testdata/restricted/bin/bin1.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002737 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002738 "notice"),
2739 matchResolution(
2740 "testdata/restricted/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002741 "testdata/restricted/lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002742 "restricted_allows_dynamic_linking"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002743 matchResolution(
2744 "testdata/restricted/bin/bin1.meta_lic",
2745 "testdata/restricted/lib/libc.a.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002746 "restricted_allows_dynamic_linking",
Bob Badour1ded0a12021-12-03 17:16:14 -08002747 "reciprocal"),
2748 },
2749 },
2750 {
2751 condition: "restricted",
2752 name: "library",
2753 roots: []string{"lib/libd.so.meta_lic"},
2754 expectedOut: []getMatcher{
2755 matchTarget("testdata/restricted/lib/libd.so.meta_lic"),
2756 matchResolution(
2757 "testdata/restricted/lib/libd.so.meta_lic",
2758 "testdata/restricted/lib/libd.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002759 "notice"),
2760 },
2761 },
2762 {
2763 condition: "proprietary",
2764 name: "apex",
2765 roots: []string{"highest.apex.meta_lic"},
2766 expectedOut: []getMatcher{
2767 matchTarget("testdata/proprietary/bin/bin1.meta_lic"),
2768 matchTarget("testdata/proprietary/lib/liba.so.meta_lic"),
2769 matchTarget("testdata/proprietary/lib/libc.a.meta_lic"),
2770 matchTarget("testdata/proprietary/bin/bin2.meta_lic"),
2771 matchTarget("testdata/proprietary/lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002772 matchTarget("testdata/proprietary/highest.apex.meta_lic"),
2773 matchResolution(
2774 "testdata/proprietary/bin/bin1.meta_lic",
2775 "testdata/proprietary/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002776 "notice"),
2777 matchResolution(
2778 "testdata/proprietary/bin/bin1.meta_lic",
2779 "testdata/proprietary/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002780 "by_exception_only",
2781 "proprietary"),
2782 matchResolution(
2783 "testdata/proprietary/bin/bin1.meta_lic",
2784 "testdata/proprietary/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002785 "by_exception_only",
2786 "proprietary"),
2787 matchResolution(
2788 "testdata/proprietary/bin/bin2.meta_lic",
2789 "testdata/proprietary/bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002790 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002791 "by_exception_only",
2792 "proprietary"),
2793 matchResolution(
2794 "testdata/proprietary/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002795 "testdata/proprietary/lib/libb.so.meta_lic",
2796 "restricted"),
2797 matchResolution(
2798 "testdata/proprietary/highest.apex.meta_lic",
2799 "testdata/proprietary/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002800 "notice"),
2801 matchResolution(
2802 "testdata/proprietary/highest.apex.meta_lic",
2803 "testdata/proprietary/bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002804 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002805 "by_exception_only",
2806 "proprietary"),
2807 matchResolution(
2808 "testdata/proprietary/highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002809 "testdata/proprietary/highest.apex.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002810 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002811 "notice"),
2812 matchResolution(
2813 "testdata/proprietary/highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002814 "testdata/proprietary/lib/liba.so.meta_lic",
2815 "by_exception_only",
2816 "proprietary"),
2817 matchResolution(
2818 "testdata/proprietary/highest.apex.meta_lic",
2819 "testdata/proprietary/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002820 "restricted"),
2821 matchResolution(
2822 "testdata/proprietary/highest.apex.meta_lic",
2823 "testdata/proprietary/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002824 "by_exception_only",
2825 "proprietary"),
2826 matchResolution(
Bob Badour1ded0a12021-12-03 17:16:14 -08002827 "testdata/proprietary/lib/liba.so.meta_lic",
2828 "testdata/proprietary/lib/liba.so.meta_lic",
2829 "by_exception_only",
2830 "proprietary"),
2831 matchResolution(
2832 "testdata/proprietary/lib/libb.so.meta_lic",
2833 "testdata/proprietary/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002834 "restricted"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002835 },
2836 },
2837 {
2838 condition: "proprietary",
2839 name: "apex_trimmed",
2840 roots: []string{"highest.apex.meta_lic"},
Bob Badour682e1ba2022-02-02 15:15:56 -08002841 ctx: context{stripPrefix: []string{"testdata/proprietary/"}},
Bob Badour1ded0a12021-12-03 17:16:14 -08002842 expectedOut: []getMatcher{
2843 matchTarget("bin/bin1.meta_lic"),
2844 matchTarget("lib/liba.so.meta_lic"),
2845 matchTarget("lib/libc.a.meta_lic"),
2846 matchTarget("bin/bin2.meta_lic"),
2847 matchTarget("lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002848 matchTarget("highest.apex.meta_lic"),
2849 matchResolution(
2850 "bin/bin1.meta_lic",
2851 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002852 "notice"),
2853 matchResolution(
2854 "bin/bin1.meta_lic",
2855 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002856 "by_exception_only",
2857 "proprietary"),
2858 matchResolution(
2859 "bin/bin1.meta_lic",
2860 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002861 "by_exception_only",
2862 "proprietary"),
2863 matchResolution(
2864 "bin/bin2.meta_lic",
2865 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002866 "by_exception_only",
Bob Badour103eb0f2022-01-10 13:50:57 -08002867 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002868 "proprietary"),
2869 matchResolution(
2870 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002871 "lib/libb.so.meta_lic",
2872 "restricted"),
2873 matchResolution(
2874 "highest.apex.meta_lic",
2875 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002876 "notice"),
2877 matchResolution(
2878 "highest.apex.meta_lic",
2879 "bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002880 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002881 "by_exception_only",
2882 "proprietary"),
2883 matchResolution(
2884 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002885 "highest.apex.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08002886 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08002887 "notice"),
2888 matchResolution(
2889 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002890 "lib/liba.so.meta_lic",
2891 "by_exception_only",
2892 "proprietary"),
2893 matchResolution(
2894 "highest.apex.meta_lic",
2895 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002896 "restricted"),
2897 matchResolution(
2898 "highest.apex.meta_lic",
2899 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002900 "by_exception_only",
2901 "proprietary"),
2902 matchResolution(
Bob Badour1ded0a12021-12-03 17:16:14 -08002903 "lib/liba.so.meta_lic",
2904 "lib/liba.so.meta_lic",
2905 "by_exception_only",
2906 "proprietary"),
2907 matchResolution(
2908 "lib/libb.so.meta_lic",
2909 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002910 "restricted"),
Bob Badour1ded0a12021-12-03 17:16:14 -08002911 },
2912 },
2913 {
2914 condition: "proprietary",
2915 name: "apex_trimmed_notice",
2916 roots: []string{"highest.apex.meta_lic"},
2917 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08002918 conditions: []compliance.LicenseCondition{compliance.NoticeCondition},
Bob Badour682e1ba2022-02-02 15:15:56 -08002919 stripPrefix: []string{"testdata/proprietary/"},
Bob Badour1ded0a12021-12-03 17:16:14 -08002920 },
2921 expectedOut: []getMatcher{
2922 matchTarget("bin/bin1.meta_lic"),
2923 matchTarget("highest.apex.meta_lic"),
2924 matchResolution(
2925 "bin/bin1.meta_lic",
2926 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002927 "notice"),
2928 matchResolution(
2929 "highest.apex.meta_lic",
2930 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002931 "notice"),
2932 matchResolution(
2933 "highest.apex.meta_lic",
2934 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002935 "notice"),
2936 },
2937 },
2938 {
2939 condition: "proprietary",
2940 name: "apex_trimmed_share",
2941 roots: []string{"highest.apex.meta_lic"},
2942 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08002943 conditions: compliance.ImpliesShared.AsList(),
Bob Badour682e1ba2022-02-02 15:15:56 -08002944 stripPrefix: []string{"testdata/proprietary/"},
Bob Badour1ded0a12021-12-03 17:16:14 -08002945 },
2946 expectedOut: []getMatcher{
2947 matchTarget("bin/bin2.meta_lic"),
2948 matchTarget("lib/libb.so.meta_lic"),
2949 matchTarget("highest.apex.meta_lic"),
2950 matchResolution(
2951 "bin/bin2.meta_lic",
2952 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002953 "restricted"),
2954 matchResolution(
2955 "bin/bin2.meta_lic",
2956 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002957 "restricted"),
2958 matchResolution(
2959 "highest.apex.meta_lic",
2960 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002961 "restricted"),
2962 matchResolution(
2963 "highest.apex.meta_lic",
2964 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002965 "restricted"),
2966 matchResolution(
2967 "highest.apex.meta_lic",
2968 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002969 "restricted"),
2970 matchResolution(
2971 "lib/libb.so.meta_lic",
2972 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002973 "restricted"),
2974 },
2975 },
2976 {
2977 condition: "proprietary",
2978 name: "apex_trimmed_private",
2979 roots: []string{"highest.apex.meta_lic"},
2980 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08002981 conditions: compliance.ImpliesPrivate.AsList(),
Bob Badour682e1ba2022-02-02 15:15:56 -08002982 stripPrefix: []string{"testdata/proprietary/"},
Bob Badour1ded0a12021-12-03 17:16:14 -08002983 },
2984 expectedOut: []getMatcher{
2985 matchTarget("bin/bin1.meta_lic"),
2986 matchTarget("lib/liba.so.meta_lic"),
2987 matchTarget("lib/libc.a.meta_lic"),
2988 matchTarget("bin/bin2.meta_lic"),
2989 matchTarget("highest.apex.meta_lic"),
2990 matchResolution(
2991 "bin/bin1.meta_lic",
2992 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002993 "proprietary"),
2994 matchResolution(
2995 "bin/bin1.meta_lic",
2996 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08002997 "proprietary"),
2998 matchResolution(
2999 "bin/bin2.meta_lic",
3000 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003001 "proprietary"),
3002 matchResolution(
3003 "highest.apex.meta_lic",
3004 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003005 "proprietary"),
3006 matchResolution(
3007 "highest.apex.meta_lic",
3008 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003009 "proprietary"),
3010 matchResolution(
3011 "highest.apex.meta_lic",
3012 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003013 "proprietary"),
3014 matchResolution(
3015 "lib/liba.so.meta_lic",
3016 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003017 "proprietary"),
3018 },
3019 },
3020 {
3021 condition: "proprietary",
3022 name: "apex_trimmed_share_private",
3023 roots: []string{"highest.apex.meta_lic"},
3024 ctx: context{
Bob Badour103eb0f2022-01-10 13:50:57 -08003025 conditions: compliance.ImpliesShared.Union(compliance.ImpliesPrivate).AsList(),
Bob Badour682e1ba2022-02-02 15:15:56 -08003026 stripPrefix: []string{"testdata/proprietary/"},
Bob Badour1ded0a12021-12-03 17:16:14 -08003027 },
3028 expectedOut: []getMatcher{
3029 matchTarget("bin/bin1.meta_lic"),
3030 matchTarget("lib/liba.so.meta_lic"),
3031 matchTarget("lib/libc.a.meta_lic"),
3032 matchTarget("bin/bin2.meta_lic"),
3033 matchTarget("lib/libb.so.meta_lic"),
3034 matchTarget("highest.apex.meta_lic"),
3035 matchResolution(
3036 "bin/bin1.meta_lic",
3037 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003038 "proprietary"),
3039 matchResolution(
3040 "bin/bin1.meta_lic",
3041 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003042 "proprietary"),
3043 matchResolution(
3044 "bin/bin2.meta_lic",
3045 "bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08003046 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08003047 "proprietary"),
3048 matchResolution(
3049 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003050 "lib/libb.so.meta_lic",
3051 "restricted"),
3052 matchResolution(
3053 "highest.apex.meta_lic",
3054 "bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08003055 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08003056 "proprietary"),
3057 matchResolution(
3058 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003059 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003060 "restricted"),
3061 matchResolution(
3062 "highest.apex.meta_lic",
3063 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003064 "proprietary"),
3065 matchResolution(
3066 "highest.apex.meta_lic",
3067 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003068 "restricted"),
3069 matchResolution(
3070 "highest.apex.meta_lic",
3071 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003072 "proprietary"),
3073 matchResolution(
3074 "lib/liba.so.meta_lic",
3075 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003076 "proprietary"),
3077 matchResolution(
3078 "lib/libb.so.meta_lic",
3079 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003080 "restricted"),
3081 },
3082 },
3083 {
3084 condition: "proprietary",
3085 name: "apex_trimmed_labelled",
3086 roots: []string{"highest.apex.meta_lic"},
Bob Badour682e1ba2022-02-02 15:15:56 -08003087 ctx: context{stripPrefix: []string{"testdata/proprietary/"}, labelConditions: true},
Bob Badour1ded0a12021-12-03 17:16:14 -08003088 expectedOut: []getMatcher{
3089 matchTarget("bin/bin1.meta_lic", "notice"),
3090 matchTarget("lib/liba.so.meta_lic", "by_exception_only", "proprietary"),
3091 matchTarget("lib/libc.a.meta_lic", "by_exception_only", "proprietary"),
3092 matchTarget("bin/bin2.meta_lic", "by_exception_only", "proprietary"),
3093 matchTarget("lib/libb.so.meta_lic", "restricted"),
Bob Badour1ded0a12021-12-03 17:16:14 -08003094 matchTarget("highest.apex.meta_lic", "notice"),
3095 matchResolution(
3096 "bin/bin1.meta_lic",
3097 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003098 "notice"),
3099 matchResolution(
3100 "bin/bin1.meta_lic",
3101 "lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003102 "by_exception_only",
3103 "proprietary"),
3104 matchResolution(
3105 "bin/bin1.meta_lic",
3106 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003107 "by_exception_only",
3108 "proprietary"),
3109 matchResolution(
3110 "bin/bin2.meta_lic",
3111 "bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08003112 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08003113 "by_exception_only",
3114 "proprietary"),
3115 matchResolution(
3116 "bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003117 "lib/libb.so.meta_lic",
3118 "restricted"),
3119 matchResolution(
3120 "highest.apex.meta_lic",
3121 "bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003122 "notice"),
3123 matchResolution(
3124 "highest.apex.meta_lic",
3125 "bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08003126 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08003127 "by_exception_only",
3128 "proprietary"),
3129 matchResolution(
3130 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003131 "highest.apex.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08003132 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08003133 "notice"),
3134 matchResolution(
3135 "highest.apex.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003136 "lib/liba.so.meta_lic",
3137 "by_exception_only",
3138 "proprietary"),
3139 matchResolution(
3140 "highest.apex.meta_lic",
3141 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003142 "restricted"),
3143 matchResolution(
3144 "highest.apex.meta_lic",
3145 "lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003146 "by_exception_only",
3147 "proprietary"),
3148 matchResolution(
Bob Badour1ded0a12021-12-03 17:16:14 -08003149 "lib/liba.so.meta_lic",
3150 "lib/liba.so.meta_lic",
3151 "by_exception_only",
3152 "proprietary"),
3153 matchResolution(
3154 "lib/libb.so.meta_lic",
3155 "lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003156 "restricted"),
Bob Badour1ded0a12021-12-03 17:16:14 -08003157 },
3158 },
3159 {
3160 condition: "proprietary",
3161 name: "container",
3162 roots: []string{"container.zip.meta_lic"},
3163 expectedOut: []getMatcher{
3164 matchTarget("testdata/proprietary/bin/bin1.meta_lic"),
3165 matchTarget("testdata/proprietary/lib/liba.so.meta_lic"),
3166 matchTarget("testdata/proprietary/lib/libc.a.meta_lic"),
3167 matchTarget("testdata/proprietary/bin/bin2.meta_lic"),
3168 matchTarget("testdata/proprietary/lib/libb.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08003169 matchTarget("testdata/proprietary/container.zip.meta_lic"),
3170 matchResolution(
3171 "testdata/proprietary/bin/bin1.meta_lic",
3172 "testdata/proprietary/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003173 "notice"),
3174 matchResolution(
3175 "testdata/proprietary/bin/bin1.meta_lic",
3176 "testdata/proprietary/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003177 "by_exception_only",
3178 "proprietary"),
3179 matchResolution(
3180 "testdata/proprietary/bin/bin1.meta_lic",
3181 "testdata/proprietary/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003182 "by_exception_only",
3183 "proprietary"),
3184 matchResolution(
3185 "testdata/proprietary/bin/bin2.meta_lic",
3186 "testdata/proprietary/bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08003187 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08003188 "by_exception_only",
3189 "proprietary"),
3190 matchResolution(
3191 "testdata/proprietary/bin/bin2.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003192 "testdata/proprietary/lib/libb.so.meta_lic",
3193 "restricted"),
3194 matchResolution(
3195 "testdata/proprietary/container.zip.meta_lic",
3196 "testdata/proprietary/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003197 "notice"),
3198 matchResolution(
3199 "testdata/proprietary/container.zip.meta_lic",
3200 "testdata/proprietary/bin/bin2.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08003201 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08003202 "by_exception_only",
3203 "proprietary"),
3204 matchResolution(
3205 "testdata/proprietary/container.zip.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003206 "testdata/proprietary/container.zip.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08003207 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08003208 "notice"),
3209 matchResolution(
3210 "testdata/proprietary/container.zip.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003211 "testdata/proprietary/lib/liba.so.meta_lic",
3212 "by_exception_only",
3213 "proprietary"),
3214 matchResolution(
3215 "testdata/proprietary/container.zip.meta_lic",
3216 "testdata/proprietary/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003217 "restricted"),
3218 matchResolution(
3219 "testdata/proprietary/container.zip.meta_lic",
3220 "testdata/proprietary/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003221 "by_exception_only",
3222 "proprietary"),
3223 matchResolution(
Bob Badour1ded0a12021-12-03 17:16:14 -08003224 "testdata/proprietary/lib/liba.so.meta_lic",
3225 "testdata/proprietary/lib/liba.so.meta_lic",
3226 "by_exception_only",
3227 "proprietary"),
3228 matchResolution(
3229 "testdata/proprietary/lib/libb.so.meta_lic",
3230 "testdata/proprietary/lib/libb.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003231 "restricted"),
Bob Badour1ded0a12021-12-03 17:16:14 -08003232 },
3233 },
3234 {
3235 condition: "proprietary",
3236 name: "application",
3237 roots: []string{"application.meta_lic"},
3238 expectedOut: []getMatcher{
3239 matchTarget("testdata/proprietary/application.meta_lic"),
3240 matchTarget("testdata/proprietary/lib/liba.so.meta_lic"),
Bob Badour1ded0a12021-12-03 17:16:14 -08003241 matchResolution(
3242 "testdata/proprietary/application.meta_lic",
3243 "testdata/proprietary/application.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08003244 "notice",
Bob Badour1ded0a12021-12-03 17:16:14 -08003245 "restricted"),
3246 matchResolution(
3247 "testdata/proprietary/application.meta_lic",
3248 "testdata/proprietary/lib/liba.so.meta_lic",
Bob Badour103eb0f2022-01-10 13:50:57 -08003249 "restricted",
Bob Badour1ded0a12021-12-03 17:16:14 -08003250 "by_exception_only",
3251 "proprietary"),
Bob Badour1ded0a12021-12-03 17:16:14 -08003252 },
3253 },
3254 {
3255 condition: "proprietary",
3256 name: "binary",
3257 roots: []string{"bin/bin1.meta_lic"},
3258 expectedOut: []getMatcher{
3259 matchTarget("testdata/proprietary/bin/bin1.meta_lic"),
3260 matchTarget("testdata/proprietary/lib/liba.so.meta_lic"),
3261 matchTarget("testdata/proprietary/lib/libc.a.meta_lic"),
3262 matchResolution(
3263 "testdata/proprietary/bin/bin1.meta_lic",
3264 "testdata/proprietary/bin/bin1.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003265 "notice"),
3266 matchResolution(
3267 "testdata/proprietary/bin/bin1.meta_lic",
3268 "testdata/proprietary/lib/liba.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003269 "by_exception_only",
3270 "proprietary"),
3271 matchResolution(
3272 "testdata/proprietary/bin/bin1.meta_lic",
3273 "testdata/proprietary/lib/libc.a.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003274 "by_exception_only",
3275 "proprietary"),
3276 },
3277 },
3278 {
3279 condition: "proprietary",
3280 name: "library",
3281 roots: []string{"lib/libd.so.meta_lic"},
3282 expectedOut: []getMatcher{
3283 matchTarget("testdata/proprietary/lib/libd.so.meta_lic"),
3284 matchResolution(
3285 "testdata/proprietary/lib/libd.so.meta_lic",
3286 "testdata/proprietary/lib/libd.so.meta_lic",
Bob Badour1ded0a12021-12-03 17:16:14 -08003287 "notice"),
3288 },
3289 },
3290 }
3291 for _, tt := range tests {
3292 t.Run(tt.condition+" "+tt.name, func(t *testing.T) {
3293 ctx := &testContext{0, make(map[string]string)}
3294
Bob Badour1ded0a12021-12-03 17:16:14 -08003295 stdout := &bytes.Buffer{}
3296 stderr := &bytes.Buffer{}
3297
3298 rootFiles := make([]string, 0, len(tt.roots))
3299 for _, r := range tt.roots {
3300 rootFiles = append(rootFiles, "testdata/"+tt.condition+"/"+r)
3301 }
3302 tt.ctx.graphViz = true
Bob Badourc778e4c2022-03-22 13:05:19 -07003303 lg, err := dumpResolutions(&tt.ctx, stdout, stderr, compliance.GetFS(tt.outDir), rootFiles...)
Bob Badour1ded0a12021-12-03 17:16:14 -08003304 if err != nil {
3305 t.Fatalf("dumpresolutions: error = %v, stderr = %v", err, stderr)
3306 return
3307 }
3308 if stderr.Len() > 0 {
3309 t.Errorf("dumpresolutions: gotStderr = %v, want none", stderr)
3310 }
Bob Badour103eb0f2022-01-10 13:50:57 -08003311
3312 expectedOut := &bytes.Buffer{}
3313 for _, eo := range tt.expectedOut {
3314 m := eo(ctx)
3315 expectedOut.WriteString(m.matchString(ctx, lg))
3316 expectedOut.WriteString("\n")
3317 }
3318
Bob Badour1ded0a12021-12-03 17:16:14 -08003319 outList := strings.Split(stdout.String(), "\n")
3320 outLine := 0
3321 if outList[outLine] != "strict digraph {" {
Colin Cross179ec3e2022-01-27 15:47:09 -08003322 t.Errorf("dumpresolutions: got 1st line %v, want strict digraph {", outList[outLine])
Bob Badour1ded0a12021-12-03 17:16:14 -08003323 }
3324 outLine++
3325 if strings.HasPrefix(strings.TrimLeft(outList[outLine], " \t"), "rankdir") {
3326 outLine++
3327 }
3328 endOut := len(outList)
3329 for endOut > 0 && strings.TrimLeft(outList[endOut-1], " \t") == "" {
3330 endOut--
3331 }
3332 if outList[endOut-1] != "}" {
3333 t.Errorf("dumpresolutions: got last line %v, want }", outList[endOut-1])
3334 }
3335 endOut--
3336 if strings.HasPrefix(strings.TrimLeft(outList[endOut-1], " \t"), "{rank=same") {
3337 endOut--
3338 }
3339 expectedList := strings.Split(expectedOut.String(), "\n")
3340 for len(expectedList) > 0 && expectedList[len(expectedList)-1] == "" {
3341 expectedList = expectedList[0 : len(expectedList)-1]
3342 }
3343 matchLine := 0
3344
3345 for outLine < endOut && matchLine < len(expectedList) && strings.TrimLeft(outList[outLine], " \t") == expectedList[matchLine] {
3346 outLine++
3347 matchLine++
3348 }
3349 if outLine < endOut || matchLine < len(expectedList) {
3350 if outLine >= endOut {
3351 t.Errorf("dumpresolutions: missing lines at end of graph, want %d lines %v", len(expectedList)-matchLine, strings.Join(expectedList[matchLine:], "\n"))
3352 } else if matchLine >= len(expectedList) {
3353 t.Errorf("dumpresolutions: unexpected lines at end of graph starting line %d, got %v, want nothing", outLine+1, strings.Join(outList[outLine:], "\n"))
3354 } else {
3355 t.Errorf("dumpresolutions: at line %d, got %v, want %v", outLine+1, strings.Join(outList[outLine:], "\n"), strings.Join(expectedList[matchLine:], "\n"))
3356 }
3357 }
3358 })
3359 }
3360}