• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2022 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	"encoding/json"
20	"fmt"
21	"os"
22	"reflect"
23	"strings"
24	"testing"
25	"time"
26
27	"android/soong/tools/compliance"
28	"github.com/spdx/tools-golang/builder/builder2v2"
29	"github.com/spdx/tools-golang/spdx/common"
30	spdx "github.com/spdx/tools-golang/spdx/v2_2"
31)
32
33func TestMain(m *testing.M) {
34	// Change into the parent directory before running the tests
35	// so they can find the testdata directory.
36	if err := os.Chdir(".."); err != nil {
37		fmt.Printf("failed to change to testdata directory: %s\n", err)
38		os.Exit(1)
39	}
40	os.Exit(m.Run())
41}
42
43func Test(t *testing.T) {
44	tests := []struct {
45		condition    string
46		name         string
47		outDir       string
48		roots        []string
49		stripPrefix  string
50		expectedOut  *spdx.Document
51		expectedDeps []string
52	}{
53		{
54			condition: "firstparty",
55			name:      "apex",
56			roots:     []string{"highest.apex.meta_lic"},
57			expectedOut: &spdx.Document{
58				SPDXVersion:       "SPDX-2.2",
59				DataLicense:       "CC0-1.0",
60				SPDXIdentifier:    "DOCUMENT",
61				DocumentName:      "testdata-firstparty-highest.apex",
62				DocumentNamespace: generateSPDXNamespace("1970-01-01T00:00:00Z"),
63				CreationInfo:      getCreationInfo(t),
64				Packages: []*spdx.Package{
65					{
66						PackageName:             "testdata-firstparty-highest.apex.meta_lic",
67						PackageVersion:          "NOASSERTION",
68						PackageDownloadLocation: "NOASSERTION",
69						PackageSPDXIdentifier:   common.ElementID("testdata-firstparty-highest.apex.meta_lic"),
70						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
71					},
72					{
73						PackageName:             "testdata-firstparty-bin-bin1.meta_lic",
74						PackageVersion:          "NOASSERTION",
75						PackageDownloadLocation: "NOASSERTION",
76						PackageSPDXIdentifier:   common.ElementID("testdata-firstparty-bin-bin1.meta_lic"),
77						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
78					},
79					{
80						PackageName:             "testdata-firstparty-bin-bin2.meta_lic",
81						PackageVersion:          "NOASSERTION",
82						PackageDownloadLocation: "NOASSERTION",
83						PackageSPDXIdentifier:   common.ElementID("testdata-firstparty-bin-bin2.meta_lic"),
84						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
85					},
86					{
87						PackageName:             "testdata-firstparty-lib-liba.so.meta_lic",
88						PackageVersion:          "NOASSERTION",
89						PackageDownloadLocation: "NOASSERTION",
90						PackageSPDXIdentifier:   common.ElementID("testdata-firstparty-lib-liba.so.meta_lic"),
91						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
92					},
93					{
94						PackageName:             "testdata-firstparty-lib-libb.so.meta_lic",
95						PackageVersion:          "NOASSERTION",
96						PackageDownloadLocation: "NOASSERTION",
97						PackageSPDXIdentifier:   common.ElementID("testdata-firstparty-lib-libb.so.meta_lic"),
98						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
99					},
100					{
101						PackageName:             "testdata-firstparty-lib-libc.a.meta_lic",
102						PackageVersion:          "NOASSERTION",
103						PackageDownloadLocation: "NOASSERTION",
104						PackageSPDXIdentifier:   common.ElementID("testdata-firstparty-lib-libc.a.meta_lic"),
105						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
106					},
107					{
108						PackageName:             "testdata-firstparty-lib-libd.so.meta_lic",
109						PackageVersion:          "NOASSERTION",
110						PackageDownloadLocation: "NOASSERTION",
111						PackageSPDXIdentifier:   common.ElementID("testdata-firstparty-lib-libd.so.meta_lic"),
112						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
113					},
114				},
115				Relationships: []*spdx.Relationship{
116					{
117						RefA:         common.MakeDocElementID("", "DOCUMENT"),
118						RefB:         common.MakeDocElementID("", "testdata-firstparty-highest.apex.meta_lic"),
119						Relationship: "DESCRIBES",
120					},
121					{
122						RefA:         common.MakeDocElementID("", "testdata-firstparty-highest.apex.meta_lic"),
123						RefB:         common.MakeDocElementID("", "testdata-firstparty-bin-bin1.meta_lic"),
124						Relationship: "CONTAINS",
125					},
126					{
127						RefA:         common.MakeDocElementID("", "testdata-firstparty-highest.apex.meta_lic"),
128						RefB:         common.MakeDocElementID("", "testdata-firstparty-bin-bin2.meta_lic"),
129						Relationship: "CONTAINS",
130					},
131					{
132						RefA:         common.MakeDocElementID("", "testdata-firstparty-highest.apex.meta_lic"),
133						RefB:         common.MakeDocElementID("", "testdata-firstparty-lib-liba.so.meta_lic"),
134						Relationship: "CONTAINS",
135					},
136					{
137						RefA:         common.MakeDocElementID("", "testdata-firstparty-highest.apex.meta_lic"),
138						RefB:         common.MakeDocElementID("", "testdata-firstparty-lib-libb.so.meta_lic"),
139						Relationship: "CONTAINS",
140					},
141					{
142						RefA:         common.MakeDocElementID("", "testdata-firstparty-bin-bin1.meta_lic"),
143						RefB:         common.MakeDocElementID("", "testdata-firstparty-lib-liba.so.meta_lic"),
144						Relationship: "CONTAINS",
145					},
146					{
147						RefA:         common.MakeDocElementID("", "testdata-firstparty-bin-bin1.meta_lic"),
148						RefB:         common.MakeDocElementID("", "testdata-firstparty-lib-libc.a.meta_lic"),
149						Relationship: "CONTAINS",
150					},
151					{
152						RefA:         common.MakeDocElementID("", "testdata-firstparty-lib-libb.so.meta_lic"),
153						RefB:         common.MakeDocElementID("", "testdata-firstparty-bin-bin2.meta_lic"),
154						Relationship: "RUNTIME_DEPENDENCY_OF",
155					},
156					{
157						RefA:         common.MakeDocElementID("", "testdata-firstparty-lib-libd.so.meta_lic"),
158						RefB:         common.MakeDocElementID("", "testdata-firstparty-bin-bin2.meta_lic"),
159						Relationship: "RUNTIME_DEPENDENCY_OF",
160					},
161				},
162				OtherLicenses: []*spdx.OtherLicense{
163					{
164						LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
165						ExtractedText:     "&&&First Party License&&&\n",
166						LicenseName:       "testdata-firstparty-FIRST_PARTY_LICENSE",
167					},
168				},
169			},
170			expectedDeps: []string{
171				"testdata/firstparty/FIRST_PARTY_LICENSE",
172				"testdata/firstparty/bin/bin1.meta_lic",
173				"testdata/firstparty/bin/bin2.meta_lic",
174				"testdata/firstparty/highest.apex.meta_lic",
175				"testdata/firstparty/lib/liba.so.meta_lic",
176				"testdata/firstparty/lib/libb.so.meta_lic",
177				"testdata/firstparty/lib/libc.a.meta_lic",
178				"testdata/firstparty/lib/libd.so.meta_lic",
179			},
180		},
181		{
182			condition: "firstparty",
183			name:      "application",
184			roots:     []string{"application.meta_lic"},
185			expectedOut: &spdx.Document{
186				SPDXVersion:       "SPDX-2.2",
187				DataLicense:       "CC0-1.0",
188				SPDXIdentifier:    "DOCUMENT",
189				DocumentName:      "testdata-firstparty-application",
190				DocumentNamespace: generateSPDXNamespace("1970-01-01T00:00:00Z"),
191				CreationInfo:      getCreationInfo(t),
192				Packages: []*spdx.Package{
193					{
194						PackageName:             "testdata-firstparty-application.meta_lic",
195						PackageVersion:          "NOASSERTION",
196						PackageDownloadLocation: "NOASSERTION",
197						PackageSPDXIdentifier:   common.ElementID("testdata-firstparty-application.meta_lic"),
198						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
199					},
200					{
201						PackageName:             "testdata-firstparty-bin-bin3.meta_lic",
202						PackageVersion:          "NOASSERTION",
203						PackageDownloadLocation: "NOASSERTION",
204						PackageSPDXIdentifier:   common.ElementID("testdata-firstparty-bin-bin3.meta_lic"),
205						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
206					},
207					{
208						PackageName:             "testdata-firstparty-lib-liba.so.meta_lic",
209						PackageVersion:          "NOASSERTION",
210						PackageDownloadLocation: "NOASSERTION",
211						PackageSPDXIdentifier:   common.ElementID("testdata-firstparty-lib-liba.so.meta_lic"),
212						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
213					},
214					{
215						PackageName:             "testdata-firstparty-lib-libb.so.meta_lic",
216						PackageVersion:          "NOASSERTION",
217						PackageDownloadLocation: "NOASSERTION",
218						PackageSPDXIdentifier:   common.ElementID("testdata-firstparty-lib-libb.so.meta_lic"),
219						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
220					},
221				},
222				Relationships: []*spdx.Relationship{
223					{
224						RefA:         common.MakeDocElementID("", "DOCUMENT"),
225						RefB:         common.MakeDocElementID("", "testdata-firstparty-application.meta_lic"),
226						Relationship: "DESCRIBES",
227					},
228					{
229						RefA:         common.MakeDocElementID("", "testdata-firstparty-bin-bin3.meta_lic"),
230						RefB:         common.MakeDocElementID("", "testdata-firstparty-application.meta_lic"),
231						Relationship: "BUILD_TOOL_OF",
232					},
233					{
234						RefA:         common.MakeDocElementID("", "testdata-firstparty-application.meta_lic"),
235						RefB:         common.MakeDocElementID("", "testdata-firstparty-lib-liba.so.meta_lic"),
236						Relationship: "CONTAINS",
237					},
238					{
239						RefA:         common.MakeDocElementID("", "testdata-firstparty-lib-libb.so.meta_lic"),
240						RefB:         common.MakeDocElementID("", "testdata-firstparty-application.meta_lic"),
241						Relationship: "RUNTIME_DEPENDENCY_OF",
242					},
243				},
244				OtherLicenses: []*spdx.OtherLicense{
245					{
246						LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
247						ExtractedText:     "&&&First Party License&&&\n",
248						LicenseName:       "testdata-firstparty-FIRST_PARTY_LICENSE",
249					},
250				},
251			},
252			expectedDeps: []string{
253				"testdata/firstparty/FIRST_PARTY_LICENSE",
254				"testdata/firstparty/application.meta_lic",
255				"testdata/firstparty/bin/bin3.meta_lic",
256				"testdata/firstparty/lib/liba.so.meta_lic",
257				"testdata/firstparty/lib/libb.so.meta_lic",
258			},
259		},
260		{
261			condition: "firstparty",
262			name:      "container",
263			roots:     []string{"container.zip.meta_lic"},
264			expectedOut: &spdx.Document{
265				SPDXVersion:       "SPDX-2.2",
266				DataLicense:       "CC0-1.0",
267				SPDXIdentifier:    "DOCUMENT",
268				DocumentName:      "testdata-firstparty-container.zip",
269				DocumentNamespace: generateSPDXNamespace("1970-01-01T00:00:00Z"),
270				CreationInfo:      getCreationInfo(t),
271				Packages: []*spdx.Package{
272					{
273						PackageName:             "testdata-firstparty-container.zip.meta_lic",
274						PackageVersion:          "NOASSERTION",
275						PackageDownloadLocation: "NOASSERTION",
276						PackageSPDXIdentifier:   common.ElementID("testdata-firstparty-container.zip.meta_lic"),
277						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
278					},
279					{
280						PackageName:             "testdata-firstparty-bin-bin1.meta_lic",
281						PackageVersion:          "NOASSERTION",
282						PackageDownloadLocation: "NOASSERTION",
283						PackageSPDXIdentifier:   common.ElementID("testdata-firstparty-bin-bin1.meta_lic"),
284						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
285					},
286					{
287						PackageName:             "testdata-firstparty-bin-bin2.meta_lic",
288						PackageVersion:          "NOASSERTION",
289						PackageDownloadLocation: "NOASSERTION",
290						PackageSPDXIdentifier:   common.ElementID("testdata-firstparty-bin-bin2.meta_lic"),
291						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
292					},
293					{
294						PackageName:             "testdata-firstparty-lib-liba.so.meta_lic",
295						PackageVersion:          "NOASSERTION",
296						PackageDownloadLocation: "NOASSERTION",
297						PackageSPDXIdentifier:   common.ElementID("testdata-firstparty-lib-liba.so.meta_lic"),
298						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
299					},
300					{
301						PackageName:             "testdata-firstparty-lib-libb.so.meta_lic",
302						PackageVersion:          "NOASSERTION",
303						PackageDownloadLocation: "NOASSERTION",
304						PackageSPDXIdentifier:   common.ElementID("testdata-firstparty-lib-libb.so.meta_lic"),
305						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
306					},
307					{
308						PackageName:             "testdata-firstparty-lib-libc.a.meta_lic",
309						PackageVersion:          "NOASSERTION",
310						PackageDownloadLocation: "NOASSERTION",
311						PackageSPDXIdentifier:   common.ElementID("testdata-firstparty-lib-libc.a.meta_lic"),
312						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
313					},
314					{
315						PackageName:             "testdata-firstparty-lib-libd.so.meta_lic",
316						PackageVersion:          "NOASSERTION",
317						PackageDownloadLocation: "NOASSERTION",
318						PackageSPDXIdentifier:   common.ElementID("testdata-firstparty-lib-libd.so.meta_lic"),
319						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
320					},
321				},
322				Relationships: []*spdx.Relationship{
323					{
324						RefA:         common.MakeDocElementID("", "DOCUMENT"),
325						RefB:         common.MakeDocElementID("", "testdata-firstparty-container.zip.meta_lic"),
326						Relationship: "DESCRIBES",
327					},
328					{
329						RefA:         common.MakeDocElementID("", "testdata-firstparty-container.zip.meta_lic"),
330						RefB:         common.MakeDocElementID("", "testdata-firstparty-bin-bin1.meta_lic"),
331						Relationship: "CONTAINS",
332					},
333					{
334						RefA:         common.MakeDocElementID("", "testdata-firstparty-container.zip.meta_lic"),
335						RefB:         common.MakeDocElementID("", "testdata-firstparty-bin-bin2.meta_lic"),
336						Relationship: "CONTAINS",
337					},
338					{
339						RefA:         common.MakeDocElementID("", "testdata-firstparty-container.zip.meta_lic"),
340						RefB:         common.MakeDocElementID("", "testdata-firstparty-lib-liba.so.meta_lic"),
341						Relationship: "CONTAINS",
342					},
343					{
344						RefA:         common.MakeDocElementID("", "testdata-firstparty-container.zip.meta_lic"),
345						RefB:         common.MakeDocElementID("", "testdata-firstparty-lib-libb.so.meta_lic"),
346						Relationship: "CONTAINS",
347					},
348					{
349						RefA:         common.MakeDocElementID("", "testdata-firstparty-bin-bin1.meta_lic"),
350						RefB:         common.MakeDocElementID("", "testdata-firstparty-lib-liba.so.meta_lic"),
351						Relationship: "CONTAINS",
352					},
353					{
354						RefA:         common.MakeDocElementID("", "testdata-firstparty-bin-bin1.meta_lic"),
355						RefB:         common.MakeDocElementID("", "testdata-firstparty-lib-libc.a.meta_lic"),
356						Relationship: "CONTAINS",
357					},
358					{
359						RefA:         common.MakeDocElementID("", "testdata-firstparty-lib-libb.so.meta_lic"),
360						RefB:         common.MakeDocElementID("", "testdata-firstparty-bin-bin2.meta_lic"),
361						Relationship: "RUNTIME_DEPENDENCY_OF",
362					},
363					{
364						RefA:         common.MakeDocElementID("", "testdata-firstparty-lib-libd.so.meta_lic"),
365						RefB:         common.MakeDocElementID("", "testdata-firstparty-bin-bin2.meta_lic"),
366						Relationship: "RUNTIME_DEPENDENCY_OF",
367					},
368				},
369				OtherLicenses: []*spdx.OtherLicense{
370					{
371						LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
372						ExtractedText:     "&&&First Party License&&&\n",
373						LicenseName:       "testdata-firstparty-FIRST_PARTY_LICENSE",
374					},
375				},
376			},
377			expectedDeps: []string{
378				"testdata/firstparty/FIRST_PARTY_LICENSE",
379				"testdata/firstparty/bin/bin1.meta_lic",
380				"testdata/firstparty/bin/bin2.meta_lic",
381				"testdata/firstparty/container.zip.meta_lic",
382				"testdata/firstparty/lib/liba.so.meta_lic",
383				"testdata/firstparty/lib/libb.so.meta_lic",
384				"testdata/firstparty/lib/libc.a.meta_lic",
385				"testdata/firstparty/lib/libd.so.meta_lic",
386			},
387		},
388		{
389			condition: "firstparty",
390			name:      "binary",
391			roots:     []string{"bin/bin1.meta_lic"},
392			expectedOut: &spdx.Document{
393				SPDXVersion:       "SPDX-2.2",
394				DataLicense:       "CC0-1.0",
395				SPDXIdentifier:    "DOCUMENT",
396				DocumentName:      "testdata-firstparty-bin-bin1",
397				DocumentNamespace: generateSPDXNamespace("1970-01-01T00:00:00Z"),
398				CreationInfo:      getCreationInfo(t),
399				Packages: []*spdx.Package{
400					{
401						PackageName:             "testdata-firstparty-bin-bin1.meta_lic",
402						PackageVersion:          "NOASSERTION",
403						PackageDownloadLocation: "NOASSERTION",
404						PackageSPDXIdentifier:   common.ElementID("testdata-firstparty-bin-bin1.meta_lic"),
405						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
406					},
407					{
408						PackageName:             "testdata-firstparty-lib-liba.so.meta_lic",
409						PackageVersion:          "NOASSERTION",
410						PackageDownloadLocation: "NOASSERTION",
411						PackageSPDXIdentifier:   common.ElementID("testdata-firstparty-lib-liba.so.meta_lic"),
412						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
413					},
414					{
415						PackageName:             "testdata-firstparty-lib-libc.a.meta_lic",
416						PackageVersion:          "NOASSERTION",
417						PackageDownloadLocation: "NOASSERTION",
418						PackageSPDXIdentifier:   common.ElementID("testdata-firstparty-lib-libc.a.meta_lic"),
419						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
420					},
421				},
422				Relationships: []*spdx.Relationship{
423					{
424						RefA:         common.MakeDocElementID("", "DOCUMENT"),
425						RefB:         common.MakeDocElementID("", "testdata-firstparty-bin-bin1.meta_lic"),
426						Relationship: "DESCRIBES",
427					},
428					{
429						RefA:         common.MakeDocElementID("", "testdata-firstparty-bin-bin1.meta_lic"),
430						RefB:         common.MakeDocElementID("", "testdata-firstparty-lib-liba.so.meta_lic"),
431						Relationship: "CONTAINS",
432					},
433					{
434						RefA:         common.MakeDocElementID("", "testdata-firstparty-bin-bin1.meta_lic"),
435						RefB:         common.MakeDocElementID("", "testdata-firstparty-lib-libc.a.meta_lic"),
436						Relationship: "CONTAINS",
437					},
438				},
439				OtherLicenses: []*spdx.OtherLicense{
440					{
441						LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
442						ExtractedText:     "&&&First Party License&&&\n",
443						LicenseName:       "testdata-firstparty-FIRST_PARTY_LICENSE",
444					},
445				},
446			},
447			expectedDeps: []string{
448				"testdata/firstparty/FIRST_PARTY_LICENSE",
449				"testdata/firstparty/bin/bin1.meta_lic",
450				"testdata/firstparty/lib/liba.so.meta_lic",
451				"testdata/firstparty/lib/libc.a.meta_lic",
452			},
453		},
454		{
455			condition: "firstparty",
456			name:      "library",
457			roots:     []string{"lib/libd.so.meta_lic"},
458			expectedOut: &spdx.Document{
459				SPDXVersion:       "SPDX-2.2",
460				DataLicense:       "CC0-1.0",
461				SPDXIdentifier:    "DOCUMENT",
462				DocumentName:      "testdata-firstparty-lib-libd.so",
463				DocumentNamespace: generateSPDXNamespace("1970-01-01T00:00:00Z"),
464				CreationInfo:      getCreationInfo(t),
465				Packages: []*spdx.Package{
466					{
467						PackageName:             "testdata-firstparty-lib-libd.so.meta_lic",
468						PackageVersion:          "NOASSERTION",
469						PackageDownloadLocation: "NOASSERTION",
470						PackageSPDXIdentifier:   common.ElementID("testdata-firstparty-lib-libd.so.meta_lic"),
471						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
472					},
473				},
474				Relationships: []*spdx.Relationship{
475					{
476						RefA:         common.MakeDocElementID("", "DOCUMENT"),
477						RefB:         common.MakeDocElementID("", "testdata-firstparty-lib-libd.so.meta_lic"),
478						Relationship: "DESCRIBES",
479					},
480				},
481				OtherLicenses: []*spdx.OtherLicense{
482					{
483						LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
484						ExtractedText:     "&&&First Party License&&&\n",
485						LicenseName:       "testdata-firstparty-FIRST_PARTY_LICENSE",
486					},
487				},
488			},
489			expectedDeps: []string{
490				"testdata/firstparty/FIRST_PARTY_LICENSE",
491				"testdata/firstparty/lib/libd.so.meta_lic",
492			},
493		},
494		{
495			condition: "notice",
496			name:      "apex",
497			roots:     []string{"highest.apex.meta_lic"},
498			expectedOut: &spdx.Document{
499				SPDXVersion:       "SPDX-2.2",
500				DataLicense:       "CC0-1.0",
501				SPDXIdentifier:    "DOCUMENT",
502				DocumentName:      "testdata-notice-highest.apex",
503				DocumentNamespace: generateSPDXNamespace("1970-01-01T00:00:00Z"),
504				CreationInfo:      getCreationInfo(t),
505				Packages: []*spdx.Package{
506					{
507						PackageName:             "testdata-notice-highest.apex.meta_lic",
508						PackageVersion:          "NOASSERTION",
509						PackageDownloadLocation: "NOASSERTION",
510						PackageSPDXIdentifier:   common.ElementID("testdata-notice-highest.apex.meta_lic"),
511						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
512					},
513					{
514						PackageName:             "testdata-notice-bin-bin1.meta_lic",
515						PackageVersion:          "NOASSERTION",
516						PackageDownloadLocation: "NOASSERTION",
517						PackageSPDXIdentifier:   common.ElementID("testdata-notice-bin-bin1.meta_lic"),
518						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
519					},
520					{
521						PackageName:             "testdata-notice-bin-bin2.meta_lic",
522						PackageVersion:          "NOASSERTION",
523						PackageDownloadLocation: "NOASSERTION",
524						PackageSPDXIdentifier:   common.ElementID("testdata-notice-bin-bin2.meta_lic"),
525						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
526					},
527					{
528						PackageName:             "testdata-notice-lib-liba.so.meta_lic",
529						PackageVersion:          "NOASSERTION",
530						PackageDownloadLocation: "NOASSERTION",
531						PackageSPDXIdentifier:   common.ElementID("testdata-notice-lib-liba.so.meta_lic"),
532						PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
533					},
534					{
535						PackageName:             "testdata-notice-lib-libb.so.meta_lic",
536						PackageVersion:          "NOASSERTION",
537						PackageDownloadLocation: "NOASSERTION",
538						PackageSPDXIdentifier:   common.ElementID("testdata-notice-lib-libb.so.meta_lic"),
539						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
540					},
541					{
542						PackageName:             "testdata-notice-lib-libc.a.meta_lic",
543						PackageVersion:          "NOASSERTION",
544						PackageDownloadLocation: "NOASSERTION",
545						PackageSPDXIdentifier:   common.ElementID("testdata-notice-lib-libc.a.meta_lic"),
546						PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
547					},
548					{
549						PackageName:             "testdata-notice-lib-libd.so.meta_lic",
550						PackageVersion:          "NOASSERTION",
551						PackageDownloadLocation: "NOASSERTION",
552						PackageSPDXIdentifier:   common.ElementID("testdata-notice-lib-libd.so.meta_lic"),
553						PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
554					},
555				},
556				Relationships: []*spdx.Relationship{
557					{
558						RefA:         common.MakeDocElementID("", "DOCUMENT"),
559						RefB:         common.MakeDocElementID("", "testdata-notice-highest.apex.meta_lic"),
560						Relationship: "DESCRIBES",
561					},
562					{
563						RefA:         common.MakeDocElementID("", "testdata-notice-highest.apex.meta_lic"),
564						RefB:         common.MakeDocElementID("", "testdata-notice-bin-bin1.meta_lic"),
565						Relationship: "CONTAINS",
566					},
567					{
568						RefA:         common.MakeDocElementID("", "testdata-notice-highest.apex.meta_lic"),
569						RefB:         common.MakeDocElementID("", "testdata-notice-bin-bin2.meta_lic"),
570						Relationship: "CONTAINS",
571					},
572					{
573						RefA:         common.MakeDocElementID("", "testdata-notice-highest.apex.meta_lic"),
574						RefB:         common.MakeDocElementID("", "testdata-notice-lib-liba.so.meta_lic"),
575						Relationship: "CONTAINS",
576					},
577					{
578						RefA:         common.MakeDocElementID("", "testdata-notice-highest.apex.meta_lic"),
579						RefB:         common.MakeDocElementID("", "testdata-notice-lib-libb.so.meta_lic"),
580						Relationship: "CONTAINS",
581					},
582					{
583						RefA:         common.MakeDocElementID("", "testdata-notice-bin-bin1.meta_lic"),
584						RefB:         common.MakeDocElementID("", "testdata-notice-lib-liba.so.meta_lic"),
585						Relationship: "CONTAINS",
586					},
587					{
588						RefA:         common.MakeDocElementID("", "testdata-notice-bin-bin1.meta_lic"),
589						RefB:         common.MakeDocElementID("", "testdata-notice-lib-libc.a.meta_lic"),
590						Relationship: "CONTAINS",
591					},
592					{
593						RefA:         common.MakeDocElementID("", "testdata-notice-lib-libb.so.meta_lic"),
594						RefB:         common.MakeDocElementID("", "testdata-notice-bin-bin2.meta_lic"),
595						Relationship: "RUNTIME_DEPENDENCY_OF",
596					},
597					{
598						RefA:         common.MakeDocElementID("", "testdata-notice-lib-libd.so.meta_lic"),
599						RefB:         common.MakeDocElementID("", "testdata-notice-bin-bin2.meta_lic"),
600						Relationship: "RUNTIME_DEPENDENCY_OF",
601					},
602				},
603				OtherLicenses: []*spdx.OtherLicense{
604					{
605						LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
606						ExtractedText:     "&&&First Party License&&&\n",
607						LicenseName:       "testdata-firstparty-FIRST_PARTY_LICENSE",
608					},
609					{
610						LicenseIdentifier: "LicenseRef-testdata-notice-NOTICE_LICENSE",
611						ExtractedText:     "%%%Notice License%%%\n",
612						LicenseName:       "testdata-notice-NOTICE_LICENSE",
613					},
614				},
615			},
616			expectedDeps: []string{
617				"testdata/firstparty/FIRST_PARTY_LICENSE",
618				"testdata/notice/NOTICE_LICENSE",
619				"testdata/notice/bin/bin1.meta_lic",
620				"testdata/notice/bin/bin2.meta_lic",
621				"testdata/notice/highest.apex.meta_lic",
622				"testdata/notice/lib/liba.so.meta_lic",
623				"testdata/notice/lib/libb.so.meta_lic",
624				"testdata/notice/lib/libc.a.meta_lic",
625				"testdata/notice/lib/libd.so.meta_lic",
626			},
627		},
628		{
629			condition: "notice",
630			name:      "container",
631			roots:     []string{"container.zip.meta_lic"},
632			expectedOut: &spdx.Document{
633				SPDXVersion:       "SPDX-2.2",
634				DataLicense:       "CC0-1.0",
635				SPDXIdentifier:    "DOCUMENT",
636				DocumentName:      "testdata-notice-container.zip",
637				DocumentNamespace: generateSPDXNamespace("1970-01-01T00:00:00Z"),
638				CreationInfo:      getCreationInfo(t),
639				Packages: []*spdx.Package{
640					{
641						PackageName:             "testdata-notice-container.zip.meta_lic",
642						PackageVersion:          "NOASSERTION",
643						PackageDownloadLocation: "NOASSERTION",
644						PackageSPDXIdentifier:   common.ElementID("testdata-notice-container.zip.meta_lic"),
645						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
646					},
647					{
648						PackageName:             "testdata-notice-bin-bin1.meta_lic",
649						PackageVersion:          "NOASSERTION",
650						PackageDownloadLocation: "NOASSERTION",
651						PackageSPDXIdentifier:   common.ElementID("testdata-notice-bin-bin1.meta_lic"),
652						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
653					},
654					{
655						PackageName:             "testdata-notice-bin-bin2.meta_lic",
656						PackageVersion:          "NOASSERTION",
657						PackageDownloadLocation: "NOASSERTION",
658						PackageSPDXIdentifier:   common.ElementID("testdata-notice-bin-bin2.meta_lic"),
659						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
660					},
661					{
662						PackageName:             "testdata-notice-lib-liba.so.meta_lic",
663						PackageVersion:          "NOASSERTION",
664						PackageDownloadLocation: "NOASSERTION",
665						PackageSPDXIdentifier:   common.ElementID("testdata-notice-lib-liba.so.meta_lic"),
666						PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
667					},
668					{
669						PackageName:             "testdata-notice-lib-libb.so.meta_lic",
670						PackageVersion:          "NOASSERTION",
671						PackageDownloadLocation: "NOASSERTION",
672						PackageSPDXIdentifier:   common.ElementID("testdata-notice-lib-libb.so.meta_lic"),
673						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
674					},
675					{
676						PackageName:             "testdata-notice-lib-libc.a.meta_lic",
677						PackageVersion:          "NOASSERTION",
678						PackageDownloadLocation: "NOASSERTION",
679						PackageSPDXIdentifier:   common.ElementID("testdata-notice-lib-libc.a.meta_lic"),
680						PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
681					},
682					{
683						PackageName:             "testdata-notice-lib-libd.so.meta_lic",
684						PackageVersion:          "NOASSERTION",
685						PackageDownloadLocation: "NOASSERTION",
686						PackageSPDXIdentifier:   common.ElementID("testdata-notice-lib-libd.so.meta_lic"),
687						PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
688					},
689				},
690				Relationships: []*spdx.Relationship{
691					{
692						RefA:         common.MakeDocElementID("", "DOCUMENT"),
693						RefB:         common.MakeDocElementID("", "testdata-notice-container.zip.meta_lic"),
694						Relationship: "DESCRIBES",
695					},
696					{
697						RefA:         common.MakeDocElementID("", "testdata-notice-container.zip.meta_lic"),
698						RefB:         common.MakeDocElementID("", "testdata-notice-bin-bin1.meta_lic"),
699						Relationship: "CONTAINS",
700					},
701					{
702						RefA:         common.MakeDocElementID("", "testdata-notice-container.zip.meta_lic"),
703						RefB:         common.MakeDocElementID("", "testdata-notice-bin-bin2.meta_lic"),
704						Relationship: "CONTAINS",
705					},
706					{
707						RefA:         common.MakeDocElementID("", "testdata-notice-container.zip.meta_lic"),
708						RefB:         common.MakeDocElementID("", "testdata-notice-lib-liba.so.meta_lic"),
709						Relationship: "CONTAINS",
710					},
711					{
712						RefA:         common.MakeDocElementID("", "testdata-notice-container.zip.meta_lic"),
713						RefB:         common.MakeDocElementID("", "testdata-notice-lib-libb.so.meta_lic"),
714						Relationship: "CONTAINS",
715					},
716					{
717						RefA:         common.MakeDocElementID("", "testdata-notice-bin-bin1.meta_lic"),
718						RefB:         common.MakeDocElementID("", "testdata-notice-lib-liba.so.meta_lic"),
719						Relationship: "CONTAINS",
720					},
721					{
722						RefA:         common.MakeDocElementID("", "testdata-notice-bin-bin1.meta_lic"),
723						RefB:         common.MakeDocElementID("", "testdata-notice-lib-libc.a.meta_lic"),
724						Relationship: "CONTAINS",
725					},
726					{
727						RefA:         common.MakeDocElementID("", "testdata-notice-lib-libb.so.meta_lic"),
728						RefB:         common.MakeDocElementID("", "testdata-notice-bin-bin2.meta_lic"),
729						Relationship: "RUNTIME_DEPENDENCY_OF",
730					},
731					{
732						RefA:         common.MakeDocElementID("", "testdata-notice-lib-libd.so.meta_lic"),
733						RefB:         common.MakeDocElementID("", "testdata-notice-bin-bin2.meta_lic"),
734						Relationship: "RUNTIME_DEPENDENCY_OF",
735					},
736				},
737				OtherLicenses: []*spdx.OtherLicense{
738					{
739						LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
740						ExtractedText:     "&&&First Party License&&&\n",
741						LicenseName:       "testdata-firstparty-FIRST_PARTY_LICENSE",
742					},
743					{
744						LicenseIdentifier: "LicenseRef-testdata-notice-NOTICE_LICENSE",
745						ExtractedText:     "%%%Notice License%%%\n",
746						LicenseName:       "testdata-notice-NOTICE_LICENSE",
747					},
748				},
749			},
750			expectedDeps: []string{
751				"testdata/firstparty/FIRST_PARTY_LICENSE",
752				"testdata/notice/NOTICE_LICENSE",
753				"testdata/notice/bin/bin1.meta_lic",
754				"testdata/notice/bin/bin2.meta_lic",
755				"testdata/notice/container.zip.meta_lic",
756				"testdata/notice/lib/liba.so.meta_lic",
757				"testdata/notice/lib/libb.so.meta_lic",
758				"testdata/notice/lib/libc.a.meta_lic",
759				"testdata/notice/lib/libd.so.meta_lic",
760			},
761		},
762		{
763			condition: "notice",
764			name:      "application",
765			roots:     []string{"application.meta_lic"},
766			expectedOut: &spdx.Document{
767				SPDXVersion:       "SPDX-2.2",
768				DataLicense:       "CC0-1.0",
769				SPDXIdentifier:    "DOCUMENT",
770				DocumentName:      "testdata-notice-application",
771				DocumentNamespace: generateSPDXNamespace("1970-01-01T00:00:00Z"),
772				CreationInfo:      getCreationInfo(t),
773				Packages: []*spdx.Package{
774					{
775						PackageName:             "testdata-notice-application.meta_lic",
776						PackageVersion:          "NOASSERTION",
777						PackageDownloadLocation: "NOASSERTION",
778						PackageSPDXIdentifier:   common.ElementID("testdata-notice-application.meta_lic"),
779						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
780					},
781					{
782						PackageName:             "testdata-notice-bin-bin3.meta_lic",
783						PackageVersion:          "NOASSERTION",
784						PackageDownloadLocation: "NOASSERTION",
785						PackageSPDXIdentifier:   common.ElementID("testdata-notice-bin-bin3.meta_lic"),
786						PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
787					},
788					{
789						PackageName:             "testdata-notice-lib-liba.so.meta_lic",
790						PackageVersion:          "NOASSERTION",
791						PackageDownloadLocation: "NOASSERTION",
792						PackageSPDXIdentifier:   common.ElementID("testdata-notice-lib-liba.so.meta_lic"),
793						PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
794					},
795					{
796						PackageName:             "testdata-notice-lib-libb.so.meta_lic",
797						PackageVersion:          "NOASSERTION",
798						PackageDownloadLocation: "NOASSERTION",
799						PackageSPDXIdentifier:   common.ElementID("testdata-notice-lib-libb.so.meta_lic"),
800						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
801					},
802				},
803				Relationships: []*spdx.Relationship{
804					{
805						RefA:         common.MakeDocElementID("", "DOCUMENT"),
806						RefB:         common.MakeDocElementID("", "testdata-notice-application.meta_lic"),
807						Relationship: "DESCRIBES",
808					},
809					{
810						RefA:         common.MakeDocElementID("", "testdata-notice-bin-bin3.meta_lic"),
811						RefB:         common.MakeDocElementID("", "testdata-notice-application.meta_lic"),
812						Relationship: "BUILD_TOOL_OF",
813					},
814					{
815						RefA:         common.MakeDocElementID("", "testdata-notice-application.meta_lic"),
816						RefB:         common.MakeDocElementID("", "testdata-notice-lib-liba.so.meta_lic"),
817						Relationship: "CONTAINS",
818					},
819					{
820						RefA:         common.MakeDocElementID("", "testdata-notice-lib-libb.so.meta_lic"),
821						RefB:         common.MakeDocElementID("", "testdata-notice-application.meta_lic"),
822						Relationship: "RUNTIME_DEPENDENCY_OF",
823					},
824				},
825				OtherLicenses: []*spdx.OtherLicense{
826					{
827						LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
828						ExtractedText:     "&&&First Party License&&&\n",
829						LicenseName:       "testdata-firstparty-FIRST_PARTY_LICENSE",
830					},
831					{
832						LicenseIdentifier: "LicenseRef-testdata-notice-NOTICE_LICENSE",
833						ExtractedText:     "%%%Notice License%%%\n",
834						LicenseName:       "testdata-notice-NOTICE_LICENSE",
835					},
836				},
837			},
838			expectedDeps: []string{
839				"testdata/firstparty/FIRST_PARTY_LICENSE",
840				"testdata/notice/NOTICE_LICENSE",
841				"testdata/notice/application.meta_lic",
842				"testdata/notice/bin/bin3.meta_lic",
843				"testdata/notice/lib/liba.so.meta_lic",
844				"testdata/notice/lib/libb.so.meta_lic",
845			},
846		},
847		{
848			condition: "notice",
849			name:      "binary",
850			roots:     []string{"bin/bin1.meta_lic"},
851			expectedOut: &spdx.Document{
852				SPDXVersion:       "SPDX-2.2",
853				DataLicense:       "CC0-1.0",
854				SPDXIdentifier:    "DOCUMENT",
855				DocumentName:      "testdata-notice-bin-bin1",
856				DocumentNamespace: generateSPDXNamespace("1970-01-01T00:00:00Z"),
857				CreationInfo:      getCreationInfo(t),
858				Packages: []*spdx.Package{
859					{
860						PackageName:             "testdata-notice-bin-bin1.meta_lic",
861						PackageVersion:          "NOASSERTION",
862						PackageDownloadLocation: "NOASSERTION",
863						PackageSPDXIdentifier:   common.ElementID("testdata-notice-bin-bin1.meta_lic"),
864						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
865					},
866					{
867						PackageName:             "testdata-notice-lib-liba.so.meta_lic",
868						PackageVersion:          "NOASSERTION",
869						PackageDownloadLocation: "NOASSERTION",
870						PackageSPDXIdentifier:   common.ElementID("testdata-notice-lib-liba.so.meta_lic"),
871						PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
872					},
873					{
874						PackageName:             "testdata-notice-lib-libc.a.meta_lic",
875						PackageVersion:          "NOASSERTION",
876						PackageDownloadLocation: "NOASSERTION",
877						PackageSPDXIdentifier:   common.ElementID("testdata-notice-lib-libc.a.meta_lic"),
878						PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
879					},
880				},
881				Relationships: []*spdx.Relationship{
882					{
883						RefA:         common.MakeDocElementID("", "DOCUMENT"),
884						RefB:         common.MakeDocElementID("", "testdata-notice-bin-bin1.meta_lic"),
885						Relationship: "DESCRIBES",
886					},
887					{
888						RefA:         common.MakeDocElementID("", "testdata-notice-bin-bin1.meta_lic"),
889						RefB:         common.MakeDocElementID("", "testdata-notice-lib-liba.so.meta_lic"),
890						Relationship: "CONTAINS",
891					},
892					{
893						RefA:         common.MakeDocElementID("", "testdata-notice-bin-bin1.meta_lic"),
894						RefB:         common.MakeDocElementID("", "testdata-notice-lib-libc.a.meta_lic"),
895						Relationship: "CONTAINS",
896					},
897				},
898				OtherLicenses: []*spdx.OtherLicense{
899					{
900						LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
901						ExtractedText:     "&&&First Party License&&&\n",
902						LicenseName:       "testdata-firstparty-FIRST_PARTY_LICENSE",
903					},
904					{
905						LicenseIdentifier: "LicenseRef-testdata-notice-NOTICE_LICENSE",
906						ExtractedText:     "%%%Notice License%%%\n",
907						LicenseName:       "testdata-notice-NOTICE_LICENSE",
908					},
909				},
910			},
911			expectedDeps: []string{
912				"testdata/firstparty/FIRST_PARTY_LICENSE",
913				"testdata/notice/NOTICE_LICENSE",
914				"testdata/notice/bin/bin1.meta_lic",
915				"testdata/notice/lib/liba.so.meta_lic",
916				"testdata/notice/lib/libc.a.meta_lic",
917			},
918		},
919		{
920			condition: "notice",
921			name:      "library",
922			roots:     []string{"lib/libd.so.meta_lic"},
923			expectedOut: &spdx.Document{
924				SPDXVersion:       "SPDX-2.2",
925				DataLicense:       "CC0-1.0",
926				SPDXIdentifier:    "DOCUMENT",
927				DocumentName:      "testdata-notice-lib-libd.so",
928				DocumentNamespace: generateSPDXNamespace("1970-01-01T00:00:00Z"),
929				CreationInfo:      getCreationInfo(t),
930				Packages: []*spdx.Package{
931					{
932						PackageName:             "testdata-notice-lib-libd.so.meta_lic",
933						PackageVersion:          "NOASSERTION",
934						PackageDownloadLocation: "NOASSERTION",
935						PackageSPDXIdentifier:   common.ElementID("testdata-notice-lib-libd.so.meta_lic"),
936						PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
937					},
938				},
939				Relationships: []*spdx.Relationship{
940					{
941						RefA:         common.MakeDocElementID("", "DOCUMENT"),
942						RefB:         common.MakeDocElementID("", "testdata-notice-lib-libd.so.meta_lic"),
943						Relationship: "DESCRIBES",
944					},
945				},
946				OtherLicenses: []*spdx.OtherLicense{
947					{
948						LicenseIdentifier: "LicenseRef-testdata-notice-NOTICE_LICENSE",
949						ExtractedText:     "%%%Notice License%%%\n",
950						LicenseName:       "testdata-notice-NOTICE_LICENSE",
951					},
952				},
953			},
954			expectedDeps: []string{
955				"testdata/notice/NOTICE_LICENSE",
956				"testdata/notice/lib/libd.so.meta_lic",
957			},
958		},
959		{
960			condition: "reciprocal",
961			name:      "apex",
962			roots:     []string{"highest.apex.meta_lic"},
963			expectedOut: &spdx.Document{
964				SPDXVersion:       "SPDX-2.2",
965				DataLicense:       "CC0-1.0",
966				SPDXIdentifier:    "DOCUMENT",
967				DocumentName:      "testdata-reciprocal-highest.apex",
968				DocumentNamespace: generateSPDXNamespace("1970-01-01T00:00:00Z"),
969				CreationInfo:      getCreationInfo(t),
970				Packages: []*spdx.Package{
971					{
972						PackageName:             "testdata-reciprocal-highest.apex.meta_lic",
973						PackageVersion:          "NOASSERTION",
974						PackageDownloadLocation: "NOASSERTION",
975						PackageSPDXIdentifier:   common.ElementID("testdata-reciprocal-highest.apex.meta_lic"),
976						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
977					},
978					{
979						PackageName:             "testdata-reciprocal-bin-bin1.meta_lic",
980						PackageVersion:          "NOASSERTION",
981						PackageDownloadLocation: "NOASSERTION",
982						PackageSPDXIdentifier:   common.ElementID("testdata-reciprocal-bin-bin1.meta_lic"),
983						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
984					},
985					{
986						PackageName:             "testdata-reciprocal-bin-bin2.meta_lic",
987						PackageVersion:          "NOASSERTION",
988						PackageDownloadLocation: "NOASSERTION",
989						PackageSPDXIdentifier:   common.ElementID("testdata-reciprocal-bin-bin2.meta_lic"),
990						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
991					},
992					{
993						PackageName:             "testdata-reciprocal-lib-liba.so.meta_lic",
994						PackageVersion:          "NOASSERTION",
995						PackageDownloadLocation: "NOASSERTION",
996						PackageSPDXIdentifier:   common.ElementID("testdata-reciprocal-lib-liba.so.meta_lic"),
997						PackageLicenseConcluded: "LicenseRef-testdata-reciprocal-RECIPROCAL_LICENSE",
998					},
999					{
1000						PackageName:             "testdata-reciprocal-lib-libb.so.meta_lic",
1001						PackageVersion:          "NOASSERTION",
1002						PackageDownloadLocation: "NOASSERTION",
1003						PackageSPDXIdentifier:   common.ElementID("testdata-reciprocal-lib-libb.so.meta_lic"),
1004						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
1005					},
1006					{
1007						PackageName:             "testdata-reciprocal-lib-libc.a.meta_lic",
1008						PackageVersion:          "NOASSERTION",
1009						PackageDownloadLocation: "NOASSERTION",
1010						PackageSPDXIdentifier:   common.ElementID("testdata-reciprocal-lib-libc.a.meta_lic"),
1011						PackageLicenseConcluded: "LicenseRef-testdata-reciprocal-RECIPROCAL_LICENSE",
1012					},
1013					{
1014						PackageName:             "testdata-reciprocal-lib-libd.so.meta_lic",
1015						PackageVersion:          "NOASSERTION",
1016						PackageDownloadLocation: "NOASSERTION",
1017						PackageSPDXIdentifier:   common.ElementID("testdata-reciprocal-lib-libd.so.meta_lic"),
1018						PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
1019					},
1020				},
1021				Relationships: []*spdx.Relationship{
1022					{
1023						RefA:         common.MakeDocElementID("", "DOCUMENT"),
1024						RefB:         common.MakeDocElementID("", "testdata-reciprocal-highest.apex.meta_lic"),
1025						Relationship: "DESCRIBES",
1026					},
1027					{
1028						RefA:         common.MakeDocElementID("", "testdata-reciprocal-highest.apex.meta_lic"),
1029						RefB:         common.MakeDocElementID("", "testdata-reciprocal-bin-bin1.meta_lic"),
1030						Relationship: "CONTAINS",
1031					},
1032					{
1033						RefA:         common.MakeDocElementID("", "testdata-reciprocal-highest.apex.meta_lic"),
1034						RefB:         common.MakeDocElementID("", "testdata-reciprocal-bin-bin2.meta_lic"),
1035						Relationship: "CONTAINS",
1036					},
1037					{
1038						RefA:         common.MakeDocElementID("", "testdata-reciprocal-highest.apex.meta_lic"),
1039						RefB:         common.MakeDocElementID("", "testdata-reciprocal-lib-liba.so.meta_lic"),
1040						Relationship: "CONTAINS",
1041					},
1042					{
1043						RefA:         common.MakeDocElementID("", "testdata-reciprocal-highest.apex.meta_lic"),
1044						RefB:         common.MakeDocElementID("", "testdata-reciprocal-lib-libb.so.meta_lic"),
1045						Relationship: "CONTAINS",
1046					},
1047					{
1048						RefA:         common.MakeDocElementID("", "testdata-reciprocal-bin-bin1.meta_lic"),
1049						RefB:         common.MakeDocElementID("", "testdata-reciprocal-lib-liba.so.meta_lic"),
1050						Relationship: "CONTAINS",
1051					},
1052					{
1053						RefA:         common.MakeDocElementID("", "testdata-reciprocal-bin-bin1.meta_lic"),
1054						RefB:         common.MakeDocElementID("", "testdata-reciprocal-lib-libc.a.meta_lic"),
1055						Relationship: "CONTAINS",
1056					},
1057					{
1058						RefA:         common.MakeDocElementID("", "testdata-reciprocal-lib-libb.so.meta_lic"),
1059						RefB:         common.MakeDocElementID("", "testdata-reciprocal-bin-bin2.meta_lic"),
1060						Relationship: "RUNTIME_DEPENDENCY_OF",
1061					},
1062					{
1063						RefA:         common.MakeDocElementID("", "testdata-reciprocal-lib-libd.so.meta_lic"),
1064						RefB:         common.MakeDocElementID("", "testdata-reciprocal-bin-bin2.meta_lic"),
1065						Relationship: "RUNTIME_DEPENDENCY_OF",
1066					},
1067				},
1068				OtherLicenses: []*spdx.OtherLicense{
1069					{
1070						LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
1071						ExtractedText:     "&&&First Party License&&&\n",
1072						LicenseName:       "testdata-firstparty-FIRST_PARTY_LICENSE",
1073					},
1074					{
1075						LicenseIdentifier: "LicenseRef-testdata-notice-NOTICE_LICENSE",
1076						ExtractedText:     "%%%Notice License%%%\n",
1077						LicenseName:       "testdata-notice-NOTICE_LICENSE",
1078					},
1079					{
1080						LicenseIdentifier: "LicenseRef-testdata-reciprocal-RECIPROCAL_LICENSE",
1081						ExtractedText:     "$$$Reciprocal License$$$\n",
1082						LicenseName:       "testdata-reciprocal-RECIPROCAL_LICENSE",
1083					},
1084				},
1085			},
1086			expectedDeps: []string{
1087				"testdata/firstparty/FIRST_PARTY_LICENSE",
1088				"testdata/notice/NOTICE_LICENSE",
1089				"testdata/reciprocal/RECIPROCAL_LICENSE",
1090				"testdata/reciprocal/bin/bin1.meta_lic",
1091				"testdata/reciprocal/bin/bin2.meta_lic",
1092				"testdata/reciprocal/highest.apex.meta_lic",
1093				"testdata/reciprocal/lib/liba.so.meta_lic",
1094				"testdata/reciprocal/lib/libb.so.meta_lic",
1095				"testdata/reciprocal/lib/libc.a.meta_lic",
1096				"testdata/reciprocal/lib/libd.so.meta_lic",
1097			},
1098		},
1099		{
1100			condition: "reciprocal",
1101			name:      "application",
1102			roots:     []string{"application.meta_lic"},
1103			expectedOut: &spdx.Document{
1104				SPDXVersion:       "SPDX-2.2",
1105				DataLicense:       "CC0-1.0",
1106				SPDXIdentifier:    "DOCUMENT",
1107				DocumentName:      "testdata-reciprocal-application",
1108				DocumentNamespace: generateSPDXNamespace("1970-01-01T00:00:00Z"),
1109				CreationInfo:      getCreationInfo(t),
1110				Packages: []*spdx.Package{
1111					{
1112						PackageName:             "testdata-reciprocal-application.meta_lic",
1113						PackageVersion:          "NOASSERTION",
1114						PackageDownloadLocation: "NOASSERTION",
1115						PackageSPDXIdentifier:   common.ElementID("testdata-reciprocal-application.meta_lic"),
1116						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
1117					},
1118					{
1119						PackageName:             "testdata-reciprocal-bin-bin3.meta_lic",
1120						PackageVersion:          "NOASSERTION",
1121						PackageDownloadLocation: "NOASSERTION",
1122						PackageSPDXIdentifier:   common.ElementID("testdata-reciprocal-bin-bin3.meta_lic"),
1123						PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
1124					},
1125					{
1126						PackageName:             "testdata-reciprocal-lib-liba.so.meta_lic",
1127						PackageVersion:          "NOASSERTION",
1128						PackageDownloadLocation: "NOASSERTION",
1129						PackageSPDXIdentifier:   common.ElementID("testdata-reciprocal-lib-liba.so.meta_lic"),
1130						PackageLicenseConcluded: "LicenseRef-testdata-reciprocal-RECIPROCAL_LICENSE",
1131					},
1132					{
1133						PackageName:             "testdata-reciprocal-lib-libb.so.meta_lic",
1134						PackageVersion:          "NOASSERTION",
1135						PackageDownloadLocation: "NOASSERTION",
1136						PackageSPDXIdentifier:   common.ElementID("testdata-reciprocal-lib-libb.so.meta_lic"),
1137						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
1138					},
1139				},
1140				Relationships: []*spdx.Relationship{
1141					{
1142						RefA:         common.MakeDocElementID("", "DOCUMENT"),
1143						RefB:         common.MakeDocElementID("", "testdata-reciprocal-application.meta_lic"),
1144						Relationship: "DESCRIBES",
1145					},
1146					{
1147						RefA:         common.MakeDocElementID("", "testdata-reciprocal-bin-bin3.meta_lic"),
1148						RefB:         common.MakeDocElementID("", "testdata-reciprocal-application.meta_lic"),
1149						Relationship: "BUILD_TOOL_OF",
1150					},
1151					{
1152						RefA:         common.MakeDocElementID("", "testdata-reciprocal-application.meta_lic"),
1153						RefB:         common.MakeDocElementID("", "testdata-reciprocal-lib-liba.so.meta_lic"),
1154						Relationship: "CONTAINS",
1155					},
1156					{
1157						RefA:         common.MakeDocElementID("", "testdata-reciprocal-lib-libb.so.meta_lic"),
1158						RefB:         common.MakeDocElementID("", "testdata-reciprocal-application.meta_lic"),
1159						Relationship: "RUNTIME_DEPENDENCY_OF",
1160					},
1161				},
1162				OtherLicenses: []*spdx.OtherLicense{
1163					{
1164						LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
1165						ExtractedText:     "&&&First Party License&&&\n",
1166						LicenseName:       "testdata-firstparty-FIRST_PARTY_LICENSE",
1167					},
1168					{
1169						LicenseIdentifier: "LicenseRef-testdata-notice-NOTICE_LICENSE",
1170						ExtractedText:     "%%%Notice License%%%\n",
1171						LicenseName:       "testdata-notice-NOTICE_LICENSE",
1172					},
1173					{
1174						LicenseIdentifier: "LicenseRef-testdata-reciprocal-RECIPROCAL_LICENSE",
1175						ExtractedText:     "$$$Reciprocal License$$$\n",
1176						LicenseName:       "testdata-reciprocal-RECIPROCAL_LICENSE",
1177					},
1178				},
1179			},
1180			expectedDeps: []string{
1181				"testdata/firstparty/FIRST_PARTY_LICENSE",
1182				"testdata/notice/NOTICE_LICENSE",
1183				"testdata/reciprocal/RECIPROCAL_LICENSE",
1184				"testdata/reciprocal/application.meta_lic",
1185				"testdata/reciprocal/bin/bin3.meta_lic",
1186				"testdata/reciprocal/lib/liba.so.meta_lic",
1187				"testdata/reciprocal/lib/libb.so.meta_lic",
1188			},
1189		},
1190		{
1191			condition: "reciprocal",
1192			name:      "binary",
1193			roots:     []string{"bin/bin1.meta_lic"},
1194			expectedOut: &spdx.Document{
1195				SPDXVersion:       "SPDX-2.2",
1196				DataLicense:       "CC0-1.0",
1197				SPDXIdentifier:    "DOCUMENT",
1198				DocumentName:      "testdata-reciprocal-bin-bin1",
1199				DocumentNamespace: generateSPDXNamespace("1970-01-01T00:00:00Z"),
1200				CreationInfo:      getCreationInfo(t),
1201				Packages: []*spdx.Package{
1202					{
1203						PackageName:             "testdata-reciprocal-bin-bin1.meta_lic",
1204						PackageVersion:          "NOASSERTION",
1205						PackageDownloadLocation: "NOASSERTION",
1206						PackageSPDXIdentifier:   common.ElementID("testdata-reciprocal-bin-bin1.meta_lic"),
1207						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
1208					},
1209					{
1210						PackageName:             "testdata-reciprocal-lib-liba.so.meta_lic",
1211						PackageVersion:          "NOASSERTION",
1212						PackageDownloadLocation: "NOASSERTION",
1213						PackageSPDXIdentifier:   common.ElementID("testdata-reciprocal-lib-liba.so.meta_lic"),
1214						PackageLicenseConcluded: "LicenseRef-testdata-reciprocal-RECIPROCAL_LICENSE",
1215					},
1216					{
1217						PackageName:             "testdata-reciprocal-lib-libc.a.meta_lic",
1218						PackageVersion:          "NOASSERTION",
1219						PackageDownloadLocation: "NOASSERTION",
1220						PackageSPDXIdentifier:   common.ElementID("testdata-reciprocal-lib-libc.a.meta_lic"),
1221						PackageLicenseConcluded: "LicenseRef-testdata-reciprocal-RECIPROCAL_LICENSE",
1222					},
1223				},
1224				Relationships: []*spdx.Relationship{
1225					{
1226						RefA:         common.MakeDocElementID("", "DOCUMENT"),
1227						RefB:         common.MakeDocElementID("", "testdata-reciprocal-bin-bin1.meta_lic"),
1228						Relationship: "DESCRIBES",
1229					},
1230					{
1231						RefA:         common.MakeDocElementID("", "testdata-reciprocal-bin-bin1.meta_lic"),
1232						RefB:         common.MakeDocElementID("", "testdata-reciprocal-lib-liba.so.meta_lic"),
1233						Relationship: "CONTAINS",
1234					},
1235					{
1236						RefA:         common.MakeDocElementID("", "testdata-reciprocal-bin-bin1.meta_lic"),
1237						RefB:         common.MakeDocElementID("", "testdata-reciprocal-lib-libc.a.meta_lic"),
1238						Relationship: "CONTAINS",
1239					},
1240				},
1241				OtherLicenses: []*spdx.OtherLicense{
1242					{
1243						LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
1244						ExtractedText:     "&&&First Party License&&&\n",
1245						LicenseName:       "testdata-firstparty-FIRST_PARTY_LICENSE",
1246					},
1247					{
1248						LicenseIdentifier: "LicenseRef-testdata-reciprocal-RECIPROCAL_LICENSE",
1249						ExtractedText:     "$$$Reciprocal License$$$\n",
1250						LicenseName:       "testdata-reciprocal-RECIPROCAL_LICENSE",
1251					},
1252				},
1253			},
1254			expectedDeps: []string{
1255				"testdata/firstparty/FIRST_PARTY_LICENSE",
1256				"testdata/reciprocal/RECIPROCAL_LICENSE",
1257				"testdata/reciprocal/bin/bin1.meta_lic",
1258				"testdata/reciprocal/lib/liba.so.meta_lic",
1259				"testdata/reciprocal/lib/libc.a.meta_lic",
1260			},
1261		},
1262		{
1263			condition: "reciprocal",
1264			name:      "library",
1265			roots:     []string{"lib/libd.so.meta_lic"},
1266			expectedOut: &spdx.Document{
1267				SPDXVersion:       "SPDX-2.2",
1268				DataLicense:       "CC0-1.0",
1269				SPDXIdentifier:    "DOCUMENT",
1270				DocumentName:      "testdata-reciprocal-lib-libd.so",
1271				DocumentNamespace: generateSPDXNamespace("1970-01-01T00:00:00Z"),
1272				CreationInfo:      getCreationInfo(t),
1273				Packages: []*spdx.Package{
1274					{
1275						PackageName:             "testdata-reciprocal-lib-libd.so.meta_lic",
1276						PackageVersion:          "NOASSERTION",
1277						PackageDownloadLocation: "NOASSERTION",
1278						PackageSPDXIdentifier:   common.ElementID("testdata-reciprocal-lib-libd.so.meta_lic"),
1279						PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
1280					},
1281				},
1282				Relationships: []*spdx.Relationship{
1283					{
1284						RefA:         common.MakeDocElementID("", "DOCUMENT"),
1285						RefB:         common.MakeDocElementID("", "testdata-reciprocal-lib-libd.so.meta_lic"),
1286						Relationship: "DESCRIBES",
1287					},
1288				},
1289				OtherLicenses: []*spdx.OtherLicense{
1290					{
1291						LicenseIdentifier: "LicenseRef-testdata-notice-NOTICE_LICENSE",
1292						ExtractedText:     "%%%Notice License%%%\n",
1293						LicenseName:       "testdata-notice-NOTICE_LICENSE",
1294					},
1295				},
1296			},
1297			expectedDeps: []string{
1298				"testdata/notice/NOTICE_LICENSE",
1299				"testdata/reciprocal/lib/libd.so.meta_lic",
1300			},
1301		},
1302		{
1303			condition: "restricted",
1304			name:      "apex",
1305			roots:     []string{"highest.apex.meta_lic"},
1306			expectedOut: &spdx.Document{
1307				SPDXVersion:       "SPDX-2.2",
1308				DataLicense:       "CC0-1.0",
1309				SPDXIdentifier:    "DOCUMENT",
1310				DocumentName:      "testdata-restricted-highest.apex",
1311				DocumentNamespace: generateSPDXNamespace("1970-01-01T00:00:00Z"),
1312				CreationInfo:      getCreationInfo(t),
1313				Packages: []*spdx.Package{
1314					{
1315						PackageName:             "testdata-restricted-highest.apex.meta_lic",
1316						PackageVersion:          "NOASSERTION",
1317						PackageDownloadLocation: "NOASSERTION",
1318						PackageSPDXIdentifier:   common.ElementID("testdata-restricted-highest.apex.meta_lic"),
1319						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
1320					},
1321					{
1322						PackageName:             "testdata-restricted-bin-bin1.meta_lic",
1323						PackageVersion:          "NOASSERTION",
1324						PackageDownloadLocation: "NOASSERTION",
1325						PackageSPDXIdentifier:   common.ElementID("testdata-restricted-bin-bin1.meta_lic"),
1326						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
1327					},
1328					{
1329						PackageName:             "testdata-restricted-bin-bin2.meta_lic",
1330						PackageVersion:          "NOASSERTION",
1331						PackageDownloadLocation: "NOASSERTION",
1332						PackageSPDXIdentifier:   common.ElementID("testdata-restricted-bin-bin2.meta_lic"),
1333						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
1334					},
1335					{
1336						PackageName:             "testdata-restricted-lib-liba.so.meta_lic",
1337						PackageVersion:          "NOASSERTION",
1338						PackageDownloadLocation: "NOASSERTION",
1339						PackageSPDXIdentifier:   common.ElementID("testdata-restricted-lib-liba.so.meta_lic"),
1340						PackageLicenseConcluded: "LicenseRef-testdata-restricted-RESTRICTED_LICENSE",
1341					},
1342					{
1343						PackageName:             "testdata-restricted-lib-libb.so.meta_lic",
1344						PackageVersion:          "NOASSERTION",
1345						PackageDownloadLocation: "NOASSERTION",
1346						PackageSPDXIdentifier:   common.ElementID("testdata-restricted-lib-libb.so.meta_lic"),
1347						PackageLicenseConcluded: "LicenseRef-testdata-restricted-RESTRICTED_LICENSE",
1348					},
1349					{
1350						PackageName:             "testdata-restricted-lib-libc.a.meta_lic",
1351						PackageVersion:          "NOASSERTION",
1352						PackageDownloadLocation: "NOASSERTION",
1353						PackageSPDXIdentifier:   common.ElementID("testdata-restricted-lib-libc.a.meta_lic"),
1354						PackageLicenseConcluded: "LicenseRef-testdata-reciprocal-RECIPROCAL_LICENSE",
1355					},
1356					{
1357						PackageName:             "testdata-restricted-lib-libd.so.meta_lic",
1358						PackageVersion:          "NOASSERTION",
1359						PackageDownloadLocation: "NOASSERTION",
1360						PackageSPDXIdentifier:   common.ElementID("testdata-restricted-lib-libd.so.meta_lic"),
1361						PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
1362					},
1363				},
1364				Relationships: []*spdx.Relationship{
1365					{
1366						RefA:         common.MakeDocElementID("", "DOCUMENT"),
1367						RefB:         common.MakeDocElementID("", "testdata-restricted-highest.apex.meta_lic"),
1368						Relationship: "DESCRIBES",
1369					},
1370					{
1371						RefA:         common.MakeDocElementID("", "testdata-restricted-highest.apex.meta_lic"),
1372						RefB:         common.MakeDocElementID("", "testdata-restricted-bin-bin1.meta_lic"),
1373						Relationship: "CONTAINS",
1374					},
1375					{
1376						RefA:         common.MakeDocElementID("", "testdata-restricted-highest.apex.meta_lic"),
1377						RefB:         common.MakeDocElementID("", "testdata-restricted-bin-bin2.meta_lic"),
1378						Relationship: "CONTAINS",
1379					},
1380					{
1381						RefA:         common.MakeDocElementID("", "testdata-restricted-highest.apex.meta_lic"),
1382						RefB:         common.MakeDocElementID("", "testdata-restricted-lib-liba.so.meta_lic"),
1383						Relationship: "CONTAINS",
1384					},
1385					{
1386						RefA:         common.MakeDocElementID("", "testdata-restricted-highest.apex.meta_lic"),
1387						RefB:         common.MakeDocElementID("", "testdata-restricted-lib-libb.so.meta_lic"),
1388						Relationship: "CONTAINS",
1389					},
1390					{
1391						RefA:         common.MakeDocElementID("", "testdata-restricted-bin-bin1.meta_lic"),
1392						RefB:         common.MakeDocElementID("", "testdata-restricted-lib-liba.so.meta_lic"),
1393						Relationship: "CONTAINS",
1394					},
1395					{
1396						RefA:         common.MakeDocElementID("", "testdata-restricted-bin-bin1.meta_lic"),
1397						RefB:         common.MakeDocElementID("", "testdata-restricted-lib-libc.a.meta_lic"),
1398						Relationship: "CONTAINS",
1399					},
1400					{
1401						RefA:         common.MakeDocElementID("", "testdata-restricted-lib-libb.so.meta_lic"),
1402						RefB:         common.MakeDocElementID("", "testdata-restricted-bin-bin2.meta_lic"),
1403						Relationship: "RUNTIME_DEPENDENCY_OF",
1404					},
1405					{
1406						RefA:         common.MakeDocElementID("", "testdata-restricted-lib-libd.so.meta_lic"),
1407						RefB:         common.MakeDocElementID("", "testdata-restricted-bin-bin2.meta_lic"),
1408						Relationship: "RUNTIME_DEPENDENCY_OF",
1409					},
1410				},
1411				OtherLicenses: []*spdx.OtherLicense{
1412					{
1413						LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
1414						ExtractedText:     "&&&First Party License&&&\n",
1415						LicenseName:       "testdata-firstparty-FIRST_PARTY_LICENSE",
1416					},
1417					{
1418						LicenseIdentifier: "LicenseRef-testdata-notice-NOTICE_LICENSE",
1419						ExtractedText:     "%%%Notice License%%%\n",
1420						LicenseName:       "testdata-notice-NOTICE_LICENSE",
1421					},
1422					{
1423						LicenseIdentifier: "LicenseRef-testdata-reciprocal-RECIPROCAL_LICENSE",
1424						ExtractedText:     "$$$Reciprocal License$$$\n",
1425						LicenseName:       "testdata-reciprocal-RECIPROCAL_LICENSE",
1426					},
1427					{
1428						LicenseIdentifier: "LicenseRef-testdata-restricted-RESTRICTED_LICENSE",
1429						ExtractedText:     "###Restricted License###\n",
1430						LicenseName:       "testdata-restricted-RESTRICTED_LICENSE",
1431					},
1432				},
1433			},
1434			expectedDeps: []string{
1435				"testdata/firstparty/FIRST_PARTY_LICENSE",
1436				"testdata/notice/NOTICE_LICENSE",
1437				"testdata/reciprocal/RECIPROCAL_LICENSE",
1438				"testdata/restricted/RESTRICTED_LICENSE",
1439				"testdata/restricted/bin/bin1.meta_lic",
1440				"testdata/restricted/bin/bin2.meta_lic",
1441				"testdata/restricted/highest.apex.meta_lic",
1442				"testdata/restricted/lib/liba.so.meta_lic",
1443				"testdata/restricted/lib/libb.so.meta_lic",
1444				"testdata/restricted/lib/libc.a.meta_lic",
1445				"testdata/restricted/lib/libd.so.meta_lic",
1446			},
1447		},
1448		{
1449			condition: "restricted",
1450			name:      "container",
1451			roots:     []string{"container.zip.meta_lic"},
1452			expectedOut: &spdx.Document{
1453				SPDXVersion:       "SPDX-2.2",
1454				DataLicense:       "CC0-1.0",
1455				SPDXIdentifier:    "DOCUMENT",
1456				DocumentName:      "testdata-restricted-container.zip",
1457				DocumentNamespace: generateSPDXNamespace("1970-01-01T00:00:00Z"),
1458				CreationInfo:      getCreationInfo(t),
1459				Packages: []*spdx.Package{
1460					{
1461						PackageName:             "testdata-restricted-container.zip.meta_lic",
1462						PackageVersion:          "NOASSERTION",
1463						PackageDownloadLocation: "NOASSERTION",
1464						PackageSPDXIdentifier:   common.ElementID("testdata-restricted-container.zip.meta_lic"),
1465						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
1466					},
1467					{
1468						PackageName:             "testdata-restricted-bin-bin1.meta_lic",
1469						PackageVersion:          "NOASSERTION",
1470						PackageDownloadLocation: "NOASSERTION",
1471						PackageSPDXIdentifier:   common.ElementID("testdata-restricted-bin-bin1.meta_lic"),
1472						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
1473					},
1474					{
1475						PackageName:             "testdata-restricted-bin-bin2.meta_lic",
1476						PackageVersion:          "NOASSERTION",
1477						PackageDownloadLocation: "NOASSERTION",
1478						PackageSPDXIdentifier:   common.ElementID("testdata-restricted-bin-bin2.meta_lic"),
1479						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
1480					},
1481					{
1482						PackageName:             "testdata-restricted-lib-liba.so.meta_lic",
1483						PackageVersion:          "NOASSERTION",
1484						PackageDownloadLocation: "NOASSERTION",
1485						PackageSPDXIdentifier:   common.ElementID("testdata-restricted-lib-liba.so.meta_lic"),
1486						PackageLicenseConcluded: "LicenseRef-testdata-restricted-RESTRICTED_LICENSE",
1487					},
1488					{
1489						PackageName:             "testdata-restricted-lib-libb.so.meta_lic",
1490						PackageVersion:          "NOASSERTION",
1491						PackageDownloadLocation: "NOASSERTION",
1492						PackageSPDXIdentifier:   common.ElementID("testdata-restricted-lib-libb.so.meta_lic"),
1493						PackageLicenseConcluded: "LicenseRef-testdata-restricted-RESTRICTED_LICENSE",
1494					},
1495					{
1496						PackageName:             "testdata-restricted-lib-libc.a.meta_lic",
1497						PackageVersion:          "NOASSERTION",
1498						PackageDownloadLocation: "NOASSERTION",
1499						PackageSPDXIdentifier:   common.ElementID("testdata-restricted-lib-libc.a.meta_lic"),
1500						PackageLicenseConcluded: "LicenseRef-testdata-reciprocal-RECIPROCAL_LICENSE",
1501					},
1502					{
1503						PackageName:             "testdata-restricted-lib-libd.so.meta_lic",
1504						PackageVersion:          "NOASSERTION",
1505						PackageDownloadLocation: "NOASSERTION",
1506						PackageSPDXIdentifier:   common.ElementID("testdata-restricted-lib-libd.so.meta_lic"),
1507						PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
1508					},
1509				},
1510				Relationships: []*spdx.Relationship{
1511					{
1512						RefA:         common.MakeDocElementID("", "DOCUMENT"),
1513						RefB:         common.MakeDocElementID("", "testdata-restricted-container.zip.meta_lic"),
1514						Relationship: "DESCRIBES",
1515					},
1516					{
1517						RefA:         common.MakeDocElementID("", "testdata-restricted-container.zip.meta_lic"),
1518						RefB:         common.MakeDocElementID("", "testdata-restricted-bin-bin1.meta_lic"),
1519						Relationship: "CONTAINS",
1520					},
1521					{
1522						RefA:         common.MakeDocElementID("", "testdata-restricted-container.zip.meta_lic"),
1523						RefB:         common.MakeDocElementID("", "testdata-restricted-bin-bin2.meta_lic"),
1524						Relationship: "CONTAINS",
1525					},
1526					{
1527						RefA:         common.MakeDocElementID("", "testdata-restricted-container.zip.meta_lic"),
1528						RefB:         common.MakeDocElementID("", "testdata-restricted-lib-liba.so.meta_lic"),
1529						Relationship: "CONTAINS",
1530					},
1531					{
1532						RefA:         common.MakeDocElementID("", "testdata-restricted-container.zip.meta_lic"),
1533						RefB:         common.MakeDocElementID("", "testdata-restricted-lib-libb.so.meta_lic"),
1534						Relationship: "CONTAINS",
1535					},
1536					{
1537						RefA:         common.MakeDocElementID("", "testdata-restricted-bin-bin1.meta_lic"),
1538						RefB:         common.MakeDocElementID("", "testdata-restricted-lib-liba.so.meta_lic"),
1539						Relationship: "CONTAINS",
1540					},
1541					{
1542						RefA:         common.MakeDocElementID("", "testdata-restricted-bin-bin1.meta_lic"),
1543						RefB:         common.MakeDocElementID("", "testdata-restricted-lib-libc.a.meta_lic"),
1544						Relationship: "CONTAINS",
1545					},
1546					{
1547						RefA:         common.MakeDocElementID("", "testdata-restricted-lib-libb.so.meta_lic"),
1548						RefB:         common.MakeDocElementID("", "testdata-restricted-bin-bin2.meta_lic"),
1549						Relationship: "RUNTIME_DEPENDENCY_OF",
1550					},
1551					{
1552						RefA:         common.MakeDocElementID("", "testdata-restricted-lib-libd.so.meta_lic"),
1553						RefB:         common.MakeDocElementID("", "testdata-restricted-bin-bin2.meta_lic"),
1554						Relationship: "RUNTIME_DEPENDENCY_OF",
1555					},
1556				},
1557				OtherLicenses: []*spdx.OtherLicense{
1558					{
1559						LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
1560						ExtractedText:     "&&&First Party License&&&\n",
1561						LicenseName:       "testdata-firstparty-FIRST_PARTY_LICENSE",
1562					},
1563					{
1564						LicenseIdentifier: "LicenseRef-testdata-notice-NOTICE_LICENSE",
1565						ExtractedText:     "%%%Notice License%%%\n",
1566						LicenseName:       "testdata-notice-NOTICE_LICENSE",
1567					},
1568					{
1569						LicenseIdentifier: "LicenseRef-testdata-reciprocal-RECIPROCAL_LICENSE",
1570						ExtractedText:     "$$$Reciprocal License$$$\n",
1571						LicenseName:       "testdata-reciprocal-RECIPROCAL_LICENSE",
1572					},
1573					{
1574						LicenseIdentifier: "LicenseRef-testdata-restricted-RESTRICTED_LICENSE",
1575						ExtractedText:     "###Restricted License###\n",
1576						LicenseName:       "testdata-restricted-RESTRICTED_LICENSE",
1577					},
1578				},
1579			},
1580			expectedDeps: []string{
1581				"testdata/firstparty/FIRST_PARTY_LICENSE",
1582				"testdata/notice/NOTICE_LICENSE",
1583				"testdata/reciprocal/RECIPROCAL_LICENSE",
1584				"testdata/restricted/RESTRICTED_LICENSE",
1585				"testdata/restricted/bin/bin1.meta_lic",
1586				"testdata/restricted/bin/bin2.meta_lic",
1587				"testdata/restricted/container.zip.meta_lic",
1588				"testdata/restricted/lib/liba.so.meta_lic",
1589				"testdata/restricted/lib/libb.so.meta_lic",
1590				"testdata/restricted/lib/libc.a.meta_lic",
1591				"testdata/restricted/lib/libd.so.meta_lic",
1592			},
1593		},
1594		{
1595			condition: "restricted",
1596			name:      "binary",
1597			roots:     []string{"bin/bin1.meta_lic"},
1598			expectedOut: &spdx.Document{
1599				SPDXVersion:       "SPDX-2.2",
1600				DataLicense:       "CC0-1.0",
1601				SPDXIdentifier:    "DOCUMENT",
1602				DocumentName:      "testdata-restricted-bin-bin1",
1603				DocumentNamespace: generateSPDXNamespace("1970-01-01T00:00:00Z"),
1604				CreationInfo:      getCreationInfo(t),
1605				Packages: []*spdx.Package{
1606					{
1607						PackageName:             "testdata-restricted-bin-bin1.meta_lic",
1608						PackageVersion:          "NOASSERTION",
1609						PackageDownloadLocation: "NOASSERTION",
1610						PackageSPDXIdentifier:   common.ElementID("testdata-restricted-bin-bin1.meta_lic"),
1611						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
1612					},
1613					{
1614						PackageName:             "testdata-restricted-lib-liba.so.meta_lic",
1615						PackageVersion:          "NOASSERTION",
1616						PackageDownloadLocation: "NOASSERTION",
1617						PackageSPDXIdentifier:   common.ElementID("testdata-restricted-lib-liba.so.meta_lic"),
1618						PackageLicenseConcluded: "LicenseRef-testdata-restricted-RESTRICTED_LICENSE",
1619					},
1620					{
1621						PackageName:             "testdata-restricted-lib-libc.a.meta_lic",
1622						PackageVersion:          "NOASSERTION",
1623						PackageDownloadLocation: "NOASSERTION",
1624						PackageSPDXIdentifier:   common.ElementID("testdata-restricted-lib-libc.a.meta_lic"),
1625						PackageLicenseConcluded: "LicenseRef-testdata-reciprocal-RECIPROCAL_LICENSE",
1626					},
1627				},
1628				Relationships: []*spdx.Relationship{
1629					{
1630						RefA:         common.MakeDocElementID("", "DOCUMENT"),
1631						RefB:         common.MakeDocElementID("", "testdata-restricted-bin-bin1.meta_lic"),
1632						Relationship: "DESCRIBES",
1633					},
1634					{
1635						RefA:         common.MakeDocElementID("", "testdata-restricted-bin-bin1.meta_lic"),
1636						RefB:         common.MakeDocElementID("", "testdata-restricted-lib-liba.so.meta_lic"),
1637						Relationship: "CONTAINS",
1638					},
1639					{
1640						RefA:         common.MakeDocElementID("", "testdata-restricted-bin-bin1.meta_lic"),
1641						RefB:         common.MakeDocElementID("", "testdata-restricted-lib-libc.a.meta_lic"),
1642						Relationship: "CONTAINS",
1643					},
1644				},
1645				OtherLicenses: []*spdx.OtherLicense{
1646					{
1647						LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
1648						ExtractedText:     "&&&First Party License&&&\n",
1649						LicenseName:       "testdata-firstparty-FIRST_PARTY_LICENSE",
1650					},
1651					{
1652						LicenseIdentifier: "LicenseRef-testdata-reciprocal-RECIPROCAL_LICENSE",
1653						ExtractedText:     "$$$Reciprocal License$$$\n",
1654						LicenseName:       "testdata-reciprocal-RECIPROCAL_LICENSE",
1655					},
1656					{
1657						LicenseIdentifier: "LicenseRef-testdata-restricted-RESTRICTED_LICENSE",
1658						ExtractedText:     "###Restricted License###\n",
1659						LicenseName:       "testdata-restricted-RESTRICTED_LICENSE",
1660					},
1661				},
1662			},
1663			expectedDeps: []string{
1664				"testdata/firstparty/FIRST_PARTY_LICENSE",
1665				"testdata/reciprocal/RECIPROCAL_LICENSE",
1666				"testdata/restricted/RESTRICTED_LICENSE",
1667				"testdata/restricted/bin/bin1.meta_lic",
1668				"testdata/restricted/lib/liba.so.meta_lic",
1669				"testdata/restricted/lib/libc.a.meta_lic",
1670			},
1671		},
1672		{
1673			condition: "restricted",
1674			name:      "library",
1675			roots:     []string{"lib/libd.so.meta_lic"},
1676			expectedOut: &spdx.Document{
1677				SPDXVersion:       "SPDX-2.2",
1678				DataLicense:       "CC0-1.0",
1679				SPDXIdentifier:    "DOCUMENT",
1680				DocumentName:      "testdata-restricted-lib-libd.so",
1681				DocumentNamespace: generateSPDXNamespace("1970-01-01T00:00:00Z"),
1682				CreationInfo:      getCreationInfo(t),
1683				Packages: []*spdx.Package{
1684					{
1685						PackageName:             "testdata-restricted-lib-libd.so.meta_lic",
1686						PackageVersion:          "NOASSERTION",
1687						PackageDownloadLocation: "NOASSERTION",
1688						PackageSPDXIdentifier:   common.ElementID("testdata-restricted-lib-libd.so.meta_lic"),
1689						PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
1690					},
1691				},
1692				Relationships: []*spdx.Relationship{
1693					{
1694						RefA:         common.MakeDocElementID("", "DOCUMENT"),
1695						RefB:         common.MakeDocElementID("", "testdata-restricted-lib-libd.so.meta_lic"),
1696						Relationship: "DESCRIBES",
1697					},
1698				},
1699				OtherLicenses: []*spdx.OtherLicense{
1700					{
1701						LicenseIdentifier: "LicenseRef-testdata-notice-NOTICE_LICENSE",
1702						ExtractedText:     "%%%Notice License%%%\n",
1703						LicenseName:       "testdata-notice-NOTICE_LICENSE",
1704					},
1705				},
1706			},
1707			expectedDeps: []string{
1708				"testdata/notice/NOTICE_LICENSE",
1709				"testdata/restricted/lib/libd.so.meta_lic",
1710			},
1711		},
1712		{
1713			condition: "proprietary",
1714			name:      "apex",
1715			roots:     []string{"highest.apex.meta_lic"},
1716			expectedOut: &spdx.Document{
1717				SPDXVersion:       "SPDX-2.2",
1718				DataLicense:       "CC0-1.0",
1719				SPDXIdentifier:    "DOCUMENT",
1720				DocumentName:      "testdata-proprietary-highest.apex",
1721				DocumentNamespace: generateSPDXNamespace("1970-01-01T00:00:00Z"),
1722				CreationInfo:      getCreationInfo(t),
1723				Packages: []*spdx.Package{
1724					{
1725						PackageName:             "testdata-proprietary-highest.apex.meta_lic",
1726						PackageVersion:          "NOASSERTION",
1727						PackageDownloadLocation: "NOASSERTION",
1728						PackageSPDXIdentifier:   common.ElementID("testdata-proprietary-highest.apex.meta_lic"),
1729						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
1730					},
1731					{
1732						PackageName:             "testdata-proprietary-bin-bin1.meta_lic",
1733						PackageVersion:          "NOASSERTION",
1734						PackageDownloadLocation: "NOASSERTION",
1735						PackageSPDXIdentifier:   common.ElementID("testdata-proprietary-bin-bin1.meta_lic"),
1736						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
1737					},
1738					{
1739						PackageName:             "testdata-proprietary-bin-bin2.meta_lic",
1740						PackageVersion:          "NOASSERTION",
1741						PackageDownloadLocation: "NOASSERTION",
1742						PackageSPDXIdentifier:   common.ElementID("testdata-proprietary-bin-bin2.meta_lic"),
1743						PackageLicenseConcluded: "LicenseRef-testdata-proprietary-PROPRIETARY_LICENSE",
1744					},
1745					{
1746						PackageName:             "testdata-proprietary-lib-liba.so.meta_lic",
1747						PackageVersion:          "NOASSERTION",
1748						PackageDownloadLocation: "NOASSERTION",
1749						PackageSPDXIdentifier:   common.ElementID("testdata-proprietary-lib-liba.so.meta_lic"),
1750						PackageLicenseConcluded: "LicenseRef-testdata-proprietary-PROPRIETARY_LICENSE",
1751					},
1752					{
1753						PackageName:             "testdata-proprietary-lib-libb.so.meta_lic",
1754						PackageVersion:          "NOASSERTION",
1755						PackageDownloadLocation: "NOASSERTION",
1756						PackageSPDXIdentifier:   common.ElementID("testdata-proprietary-lib-libb.so.meta_lic"),
1757						PackageLicenseConcluded: "LicenseRef-testdata-restricted-RESTRICTED_LICENSE",
1758					},
1759					{
1760						PackageName:             "testdata-proprietary-lib-libc.a.meta_lic",
1761						PackageVersion:          "NOASSERTION",
1762						PackageDownloadLocation: "NOASSERTION",
1763						PackageSPDXIdentifier:   common.ElementID("testdata-proprietary-lib-libc.a.meta_lic"),
1764						PackageLicenseConcluded: "LicenseRef-testdata-proprietary-PROPRIETARY_LICENSE",
1765					},
1766					{
1767						PackageName:             "testdata-proprietary-lib-libd.so.meta_lic",
1768						PackageVersion:          "NOASSERTION",
1769						PackageDownloadLocation: "NOASSERTION",
1770						PackageSPDXIdentifier:   common.ElementID("testdata-proprietary-lib-libd.so.meta_lic"),
1771						PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
1772					},
1773				},
1774				Relationships: []*spdx.Relationship{
1775					{
1776						RefA:         common.MakeDocElementID("", "DOCUMENT"),
1777						RefB:         common.MakeDocElementID("", "testdata-proprietary-highest.apex.meta_lic"),
1778						Relationship: "DESCRIBES",
1779					},
1780					{
1781						RefA:         common.MakeDocElementID("", "testdata-proprietary-highest.apex.meta_lic"),
1782						RefB:         common.MakeDocElementID("", "testdata-proprietary-bin-bin1.meta_lic"),
1783						Relationship: "CONTAINS",
1784					},
1785					{
1786						RefA:         common.MakeDocElementID("", "testdata-proprietary-highest.apex.meta_lic"),
1787						RefB:         common.MakeDocElementID("", "testdata-proprietary-bin-bin2.meta_lic"),
1788						Relationship: "CONTAINS",
1789					},
1790					{
1791						RefA:         common.MakeDocElementID("", "testdata-proprietary-highest.apex.meta_lic"),
1792						RefB:         common.MakeDocElementID("", "testdata-proprietary-lib-liba.so.meta_lic"),
1793						Relationship: "CONTAINS",
1794					},
1795					{
1796						RefA:         common.MakeDocElementID("", "testdata-proprietary-highest.apex.meta_lic"),
1797						RefB:         common.MakeDocElementID("", "testdata-proprietary-lib-libb.so.meta_lic"),
1798						Relationship: "CONTAINS",
1799					},
1800					{
1801						RefA:         common.MakeDocElementID("", "testdata-proprietary-bin-bin1.meta_lic"),
1802						RefB:         common.MakeDocElementID("", "testdata-proprietary-lib-liba.so.meta_lic"),
1803						Relationship: "CONTAINS",
1804					},
1805					{
1806						RefA:         common.MakeDocElementID("", "testdata-proprietary-bin-bin1.meta_lic"),
1807						RefB:         common.MakeDocElementID("", "testdata-proprietary-lib-libc.a.meta_lic"),
1808						Relationship: "CONTAINS",
1809					},
1810					{
1811						RefA:         common.MakeDocElementID("", "testdata-proprietary-lib-libb.so.meta_lic"),
1812						RefB:         common.MakeDocElementID("", "testdata-proprietary-bin-bin2.meta_lic"),
1813						Relationship: "RUNTIME_DEPENDENCY_OF",
1814					},
1815					{
1816						RefA:         common.MakeDocElementID("", "testdata-proprietary-lib-libd.so.meta_lic"),
1817						RefB:         common.MakeDocElementID("", "testdata-proprietary-bin-bin2.meta_lic"),
1818						Relationship: "RUNTIME_DEPENDENCY_OF",
1819					},
1820				},
1821				OtherLicenses: []*spdx.OtherLicense{
1822					{
1823						LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
1824						ExtractedText:     "&&&First Party License&&&\n",
1825						LicenseName:       "testdata-firstparty-FIRST_PARTY_LICENSE",
1826					},
1827					{
1828						LicenseIdentifier: "LicenseRef-testdata-notice-NOTICE_LICENSE",
1829						ExtractedText:     "%%%Notice License%%%\n",
1830						LicenseName:       "testdata-notice-NOTICE_LICENSE",
1831					},
1832					{
1833						LicenseIdentifier: "LicenseRef-testdata-proprietary-PROPRIETARY_LICENSE",
1834						ExtractedText:     "@@@Proprietary License@@@\n",
1835						LicenseName:       "testdata-proprietary-PROPRIETARY_LICENSE",
1836					},
1837					{
1838						LicenseIdentifier: "LicenseRef-testdata-restricted-RESTRICTED_LICENSE",
1839						ExtractedText:     "###Restricted License###\n",
1840						LicenseName:       "testdata-restricted-RESTRICTED_LICENSE",
1841					},
1842				},
1843			},
1844			expectedDeps: []string{
1845				"testdata/firstparty/FIRST_PARTY_LICENSE",
1846				"testdata/notice/NOTICE_LICENSE",
1847				"testdata/proprietary/PROPRIETARY_LICENSE",
1848				"testdata/proprietary/bin/bin1.meta_lic",
1849				"testdata/proprietary/bin/bin2.meta_lic",
1850				"testdata/proprietary/highest.apex.meta_lic",
1851				"testdata/proprietary/lib/liba.so.meta_lic",
1852				"testdata/proprietary/lib/libb.so.meta_lic",
1853				"testdata/proprietary/lib/libc.a.meta_lic",
1854				"testdata/proprietary/lib/libd.so.meta_lic",
1855				"testdata/restricted/RESTRICTED_LICENSE",
1856			},
1857		},
1858		{
1859			condition: "proprietary",
1860			name:      "container",
1861			roots:     []string{"container.zip.meta_lic"},
1862			expectedOut: &spdx.Document{
1863				SPDXVersion:       "SPDX-2.2",
1864				DataLicense:       "CC0-1.0",
1865				SPDXIdentifier:    "DOCUMENT",
1866				DocumentName:      "testdata-proprietary-container.zip",
1867				DocumentNamespace: generateSPDXNamespace("1970-01-01T00:00:00Z"),
1868				CreationInfo:      getCreationInfo(t),
1869				Packages: []*spdx.Package{
1870					{
1871						PackageName:             "testdata-proprietary-container.zip.meta_lic",
1872						PackageVersion:          "NOASSERTION",
1873						PackageDownloadLocation: "NOASSERTION",
1874						PackageSPDXIdentifier:   common.ElementID("testdata-proprietary-container.zip.meta_lic"),
1875						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
1876					},
1877					{
1878						PackageName:             "testdata-proprietary-bin-bin1.meta_lic",
1879						PackageVersion:          "NOASSERTION",
1880						PackageDownloadLocation: "NOASSERTION",
1881						PackageSPDXIdentifier:   common.ElementID("testdata-proprietary-bin-bin1.meta_lic"),
1882						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
1883					},
1884					{
1885						PackageName:             "testdata-proprietary-bin-bin2.meta_lic",
1886						PackageVersion:          "NOASSERTION",
1887						PackageDownloadLocation: "NOASSERTION",
1888						PackageSPDXIdentifier:   common.ElementID("testdata-proprietary-bin-bin2.meta_lic"),
1889						PackageLicenseConcluded: "LicenseRef-testdata-proprietary-PROPRIETARY_LICENSE",
1890					},
1891					{
1892						PackageName:             "testdata-proprietary-lib-liba.so.meta_lic",
1893						PackageVersion:          "NOASSERTION",
1894						PackageDownloadLocation: "NOASSERTION",
1895						PackageSPDXIdentifier:   common.ElementID("testdata-proprietary-lib-liba.so.meta_lic"),
1896						PackageLicenseConcluded: "LicenseRef-testdata-proprietary-PROPRIETARY_LICENSE",
1897					},
1898					{
1899						PackageName:             "testdata-proprietary-lib-libb.so.meta_lic",
1900						PackageVersion:          "NOASSERTION",
1901						PackageDownloadLocation: "NOASSERTION",
1902						PackageSPDXIdentifier:   common.ElementID("testdata-proprietary-lib-libb.so.meta_lic"),
1903						PackageLicenseConcluded: "LicenseRef-testdata-restricted-RESTRICTED_LICENSE",
1904					},
1905					{
1906						PackageName:             "testdata-proprietary-lib-libc.a.meta_lic",
1907						PackageVersion:          "NOASSERTION",
1908						PackageDownloadLocation: "NOASSERTION",
1909						PackageSPDXIdentifier:   common.ElementID("testdata-proprietary-lib-libc.a.meta_lic"),
1910						PackageLicenseConcluded: "LicenseRef-testdata-proprietary-PROPRIETARY_LICENSE",
1911					},
1912					{
1913						PackageName:             "testdata-proprietary-lib-libd.so.meta_lic",
1914						PackageVersion:          "NOASSERTION",
1915						PackageDownloadLocation: "NOASSERTION",
1916						PackageSPDXIdentifier:   common.ElementID("testdata-proprietary-lib-libd.so.meta_lic"),
1917						PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
1918					},
1919				},
1920				Relationships: []*spdx.Relationship{
1921					{
1922						RefA:         common.MakeDocElementID("", "DOCUMENT"),
1923						RefB:         common.MakeDocElementID("", "testdata-proprietary-container.zip.meta_lic"),
1924						Relationship: "DESCRIBES",
1925					},
1926					{
1927						RefA:         common.MakeDocElementID("", "testdata-proprietary-container.zip.meta_lic"),
1928						RefB:         common.MakeDocElementID("", "testdata-proprietary-bin-bin1.meta_lic"),
1929						Relationship: "CONTAINS",
1930					},
1931					{
1932						RefA:         common.MakeDocElementID("", "testdata-proprietary-container.zip.meta_lic"),
1933						RefB:         common.MakeDocElementID("", "testdata-proprietary-bin-bin2.meta_lic"),
1934						Relationship: "CONTAINS",
1935					},
1936					{
1937						RefA:         common.MakeDocElementID("", "testdata-proprietary-container.zip.meta_lic"),
1938						RefB:         common.MakeDocElementID("", "testdata-proprietary-lib-liba.so.meta_lic"),
1939						Relationship: "CONTAINS",
1940					},
1941					{
1942						RefA:         common.MakeDocElementID("", "testdata-proprietary-container.zip.meta_lic"),
1943						RefB:         common.MakeDocElementID("", "testdata-proprietary-lib-libb.so.meta_lic"),
1944						Relationship: "CONTAINS",
1945					},
1946					{
1947						RefA:         common.MakeDocElementID("", "testdata-proprietary-bin-bin1.meta_lic"),
1948						RefB:         common.MakeDocElementID("", "testdata-proprietary-lib-liba.so.meta_lic"),
1949						Relationship: "CONTAINS",
1950					},
1951					{
1952						RefA:         common.MakeDocElementID("", "testdata-proprietary-bin-bin1.meta_lic"),
1953						RefB:         common.MakeDocElementID("", "testdata-proprietary-lib-libc.a.meta_lic"),
1954						Relationship: "CONTAINS",
1955					},
1956					{
1957						RefA:         common.MakeDocElementID("", "testdata-proprietary-lib-libb.so.meta_lic"),
1958						RefB:         common.MakeDocElementID("", "testdata-proprietary-bin-bin2.meta_lic"),
1959						Relationship: "RUNTIME_DEPENDENCY_OF",
1960					},
1961					{
1962						RefA:         common.MakeDocElementID("", "testdata-proprietary-lib-libd.so.meta_lic"),
1963						RefB:         common.MakeDocElementID("", "testdata-proprietary-bin-bin2.meta_lic"),
1964						Relationship: "RUNTIME_DEPENDENCY_OF",
1965					},
1966				},
1967				OtherLicenses: []*spdx.OtherLicense{
1968					{
1969						LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
1970						ExtractedText:     "&&&First Party License&&&\n",
1971						LicenseName:       "testdata-firstparty-FIRST_PARTY_LICENSE",
1972					},
1973					{
1974						LicenseIdentifier: "LicenseRef-testdata-notice-NOTICE_LICENSE",
1975						ExtractedText:     "%%%Notice License%%%\n",
1976						LicenseName:       "testdata-notice-NOTICE_LICENSE",
1977					},
1978					{
1979						LicenseIdentifier: "LicenseRef-testdata-proprietary-PROPRIETARY_LICENSE",
1980						ExtractedText:     "@@@Proprietary License@@@\n",
1981						LicenseName:       "testdata-proprietary-PROPRIETARY_LICENSE",
1982					},
1983					{
1984						LicenseIdentifier: "LicenseRef-testdata-restricted-RESTRICTED_LICENSE",
1985						ExtractedText:     "###Restricted License###\n",
1986						LicenseName:       "testdata-restricted-RESTRICTED_LICENSE",
1987					},
1988				},
1989			},
1990			expectedDeps: []string{
1991				"testdata/firstparty/FIRST_PARTY_LICENSE",
1992				"testdata/notice/NOTICE_LICENSE",
1993				"testdata/proprietary/PROPRIETARY_LICENSE",
1994				"testdata/proprietary/bin/bin1.meta_lic",
1995				"testdata/proprietary/bin/bin2.meta_lic",
1996				"testdata/proprietary/container.zip.meta_lic",
1997				"testdata/proprietary/lib/liba.so.meta_lic",
1998				"testdata/proprietary/lib/libb.so.meta_lic",
1999				"testdata/proprietary/lib/libc.a.meta_lic",
2000				"testdata/proprietary/lib/libd.so.meta_lic",
2001				"testdata/restricted/RESTRICTED_LICENSE",
2002			},
2003		},
2004		{
2005			condition: "proprietary",
2006			name:      "application",
2007			roots:     []string{"application.meta_lic"},
2008			expectedOut: &spdx.Document{
2009				SPDXVersion:       "SPDX-2.2",
2010				DataLicense:       "CC0-1.0",
2011				SPDXIdentifier:    "DOCUMENT",
2012				DocumentName:      "testdata-proprietary-application",
2013				DocumentNamespace: generateSPDXNamespace("1970-01-01T00:00:00Z"),
2014				CreationInfo:      getCreationInfo(t),
2015				Packages: []*spdx.Package{
2016					{
2017						PackageName:             "testdata-proprietary-application.meta_lic",
2018						PackageVersion:          "NOASSERTION",
2019						PackageDownloadLocation: "NOASSERTION",
2020						PackageSPDXIdentifier:   common.ElementID("testdata-proprietary-application.meta_lic"),
2021						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
2022					},
2023					{
2024						PackageName:             "testdata-proprietary-bin-bin3.meta_lic",
2025						PackageVersion:          "NOASSERTION",
2026						PackageDownloadLocation: "NOASSERTION",
2027						PackageSPDXIdentifier:   common.ElementID("testdata-proprietary-bin-bin3.meta_lic"),
2028						PackageLicenseConcluded: "LicenseRef-testdata-restricted-RESTRICTED_LICENSE",
2029					},
2030					{
2031						PackageName:             "testdata-proprietary-lib-liba.so.meta_lic",
2032						PackageVersion:          "NOASSERTION",
2033						PackageDownloadLocation: "NOASSERTION",
2034						PackageSPDXIdentifier:   common.ElementID("testdata-proprietary-lib-liba.so.meta_lic"),
2035						PackageLicenseConcluded: "LicenseRef-testdata-proprietary-PROPRIETARY_LICENSE",
2036					},
2037					{
2038						PackageName:             "testdata-proprietary-lib-libb.so.meta_lic",
2039						PackageVersion:          "NOASSERTION",
2040						PackageDownloadLocation: "NOASSERTION",
2041						PackageSPDXIdentifier:   common.ElementID("testdata-proprietary-lib-libb.so.meta_lic"),
2042						PackageLicenseConcluded: "LicenseRef-testdata-restricted-RESTRICTED_LICENSE",
2043					},
2044				},
2045				Relationships: []*spdx.Relationship{
2046					{
2047						RefA:         common.MakeDocElementID("", "DOCUMENT"),
2048						RefB:         common.MakeDocElementID("", "testdata-proprietary-application.meta_lic"),
2049						Relationship: "DESCRIBES",
2050					},
2051					{
2052						RefA:         common.MakeDocElementID("", "testdata-proprietary-bin-bin3.meta_lic"),
2053						RefB:         common.MakeDocElementID("", "testdata-proprietary-application.meta_lic"),
2054						Relationship: "BUILD_TOOL_OF",
2055					},
2056					{
2057						RefA:         common.MakeDocElementID("", "testdata-proprietary-application.meta_lic"),
2058						RefB:         common.MakeDocElementID("", "testdata-proprietary-lib-liba.so.meta_lic"),
2059						Relationship: "CONTAINS",
2060					},
2061					{
2062						RefA:         common.MakeDocElementID("", "testdata-proprietary-lib-libb.so.meta_lic"),
2063						RefB:         common.MakeDocElementID("", "testdata-proprietary-application.meta_lic"),
2064						Relationship: "RUNTIME_DEPENDENCY_OF",
2065					},
2066				},
2067				OtherLicenses: []*spdx.OtherLicense{
2068					{
2069						LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
2070						ExtractedText:     "&&&First Party License&&&\n",
2071						LicenseName:       "testdata-firstparty-FIRST_PARTY_LICENSE",
2072					},
2073					{
2074						LicenseIdentifier: "LicenseRef-testdata-proprietary-PROPRIETARY_LICENSE",
2075						ExtractedText:     "@@@Proprietary License@@@\n",
2076						LicenseName:       "testdata-proprietary-PROPRIETARY_LICENSE",
2077					},
2078					{
2079						LicenseIdentifier: "LicenseRef-testdata-restricted-RESTRICTED_LICENSE",
2080						ExtractedText:     "###Restricted License###\n",
2081						LicenseName:       "testdata-restricted-RESTRICTED_LICENSE",
2082					},
2083				},
2084			},
2085			expectedDeps: []string{
2086				"testdata/firstparty/FIRST_PARTY_LICENSE",
2087				"testdata/proprietary/PROPRIETARY_LICENSE",
2088				"testdata/proprietary/application.meta_lic",
2089				"testdata/proprietary/bin/bin3.meta_lic",
2090				"testdata/proprietary/lib/liba.so.meta_lic",
2091				"testdata/proprietary/lib/libb.so.meta_lic",
2092				"testdata/restricted/RESTRICTED_LICENSE",
2093			},
2094		},
2095		{
2096			condition: "proprietary",
2097			name:      "binary",
2098			roots:     []string{"bin/bin1.meta_lic"},
2099			expectedOut: &spdx.Document{
2100				SPDXVersion:       "SPDX-2.2",
2101				DataLicense:       "CC0-1.0",
2102				SPDXIdentifier:    "DOCUMENT",
2103				DocumentName:      "testdata-proprietary-bin-bin1",
2104				DocumentNamespace: generateSPDXNamespace("1970-01-01T00:00:00Z"),
2105				CreationInfo:      getCreationInfo(t),
2106				Packages: []*spdx.Package{
2107					{
2108						PackageName:             "testdata-proprietary-bin-bin1.meta_lic",
2109						PackageVersion:          "NOASSERTION",
2110						PackageDownloadLocation: "NOASSERTION",
2111						PackageSPDXIdentifier:   common.ElementID("testdata-proprietary-bin-bin1.meta_lic"),
2112						PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
2113					},
2114					{
2115						PackageName:             "testdata-proprietary-lib-liba.so.meta_lic",
2116						PackageVersion:          "NOASSERTION",
2117						PackageDownloadLocation: "NOASSERTION",
2118						PackageSPDXIdentifier:   common.ElementID("testdata-proprietary-lib-liba.so.meta_lic"),
2119						PackageLicenseConcluded: "LicenseRef-testdata-proprietary-PROPRIETARY_LICENSE",
2120					},
2121					{
2122						PackageName:             "testdata-proprietary-lib-libc.a.meta_lic",
2123						PackageVersion:          "NOASSERTION",
2124						PackageDownloadLocation: "NOASSERTION",
2125						PackageSPDXIdentifier:   common.ElementID("testdata-proprietary-lib-libc.a.meta_lic"),
2126						PackageLicenseConcluded: "LicenseRef-testdata-proprietary-PROPRIETARY_LICENSE",
2127					},
2128				},
2129				Relationships: []*spdx.Relationship{
2130					{
2131						RefA:         common.MakeDocElementID("", "DOCUMENT"),
2132						RefB:         common.MakeDocElementID("", "testdata-proprietary-bin-bin1.meta_lic"),
2133						Relationship: "DESCRIBES",
2134					},
2135					{
2136						RefA:         common.MakeDocElementID("", "testdata-proprietary-bin-bin1.meta_lic"),
2137						RefB:         common.MakeDocElementID("", "testdata-proprietary-lib-liba.so.meta_lic"),
2138						Relationship: "CONTAINS",
2139					},
2140					{
2141						RefA:         common.MakeDocElementID("", "testdata-proprietary-bin-bin1.meta_lic"),
2142						RefB:         common.MakeDocElementID("", "testdata-proprietary-lib-libc.a.meta_lic"),
2143						Relationship: "CONTAINS",
2144					},
2145				},
2146				OtherLicenses: []*spdx.OtherLicense{
2147					{
2148						LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
2149						ExtractedText:     "&&&First Party License&&&\n",
2150						LicenseName:       "testdata-firstparty-FIRST_PARTY_LICENSE",
2151					},
2152					{
2153						LicenseIdentifier: "LicenseRef-testdata-proprietary-PROPRIETARY_LICENSE",
2154						ExtractedText:     "@@@Proprietary License@@@\n",
2155						LicenseName:       "testdata-proprietary-PROPRIETARY_LICENSE",
2156					},
2157				},
2158			},
2159			expectedDeps: []string{
2160				"testdata/firstparty/FIRST_PARTY_LICENSE",
2161				"testdata/proprietary/PROPRIETARY_LICENSE",
2162				"testdata/proprietary/bin/bin1.meta_lic",
2163				"testdata/proprietary/lib/liba.so.meta_lic",
2164				"testdata/proprietary/lib/libc.a.meta_lic",
2165			},
2166		},
2167		{
2168			condition: "proprietary",
2169			name:      "library",
2170			roots:     []string{"lib/libd.so.meta_lic"},
2171			expectedOut: &spdx.Document{
2172				SPDXVersion:       "SPDX-2.2",
2173				DataLicense:       "CC0-1.0",
2174				SPDXIdentifier:    "DOCUMENT",
2175				DocumentName:      "testdata-proprietary-lib-libd.so",
2176				DocumentNamespace: generateSPDXNamespace("1970-01-01T00:00:00Z"),
2177				CreationInfo:      getCreationInfo(t),
2178				Packages: []*spdx.Package{
2179					{
2180						PackageName:             "testdata-proprietary-lib-libd.so.meta_lic",
2181						PackageVersion:          "NOASSERTION",
2182						PackageDownloadLocation: "NOASSERTION",
2183						PackageSPDXIdentifier:   common.ElementID("testdata-proprietary-lib-libd.so.meta_lic"),
2184						PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
2185					},
2186				},
2187				Relationships: []*spdx.Relationship{
2188					{
2189						RefA:         common.MakeDocElementID("", "DOCUMENT"),
2190						RefB:         common.MakeDocElementID("", "testdata-proprietary-lib-libd.so.meta_lic"),
2191						Relationship: "DESCRIBES",
2192					},
2193				},
2194				OtherLicenses: []*spdx.OtherLicense{
2195					{
2196						LicenseIdentifier: "LicenseRef-testdata-notice-NOTICE_LICENSE",
2197						ExtractedText:     "%%%Notice License%%%\n",
2198						LicenseName:       "testdata-notice-NOTICE_LICENSE",
2199					},
2200				},
2201			},
2202			expectedDeps: []string{
2203				"testdata/notice/NOTICE_LICENSE",
2204				"testdata/proprietary/lib/libd.so.meta_lic",
2205			},
2206		},
2207	}
2208	for _, tt := range tests {
2209		t.Run(tt.condition+" "+tt.name, func(t *testing.T) {
2210			stdout := &bytes.Buffer{}
2211			stderr := &bytes.Buffer{}
2212
2213			rootFiles := make([]string, 0, len(tt.roots))
2214			for _, r := range tt.roots {
2215				rootFiles = append(rootFiles, "testdata/"+tt.condition+"/"+r)
2216			}
2217
2218			ctx := context{stdout, stderr, compliance.GetFS(tt.outDir), "", []string{tt.stripPrefix}, fakeTime}
2219
2220			spdxDoc, deps, err := sbomGenerator(&ctx, rootFiles...)
2221			if err != nil {
2222				t.Fatalf("sbom: error = %v, stderr = %v", err, stderr)
2223				return
2224			}
2225			if stderr.Len() > 0 {
2226				t.Errorf("sbom: gotStderr = %v, want none", stderr)
2227			}
2228
2229			if err := validate(spdxDoc); err != nil {
2230				t.Fatalf("sbom: document fails to validate: %v", err)
2231			}
2232
2233			gotData, err := json.Marshal(spdxDoc)
2234			if err != nil {
2235				t.Fatalf("sbom: failed to marshal spdx doc: %v", err)
2236				return
2237			}
2238
2239			t.Logf("Got SPDX Doc: %s", string(gotData))
2240
2241			expectedData, err := json.Marshal(tt.expectedOut)
2242			if err != nil {
2243				t.Fatalf("sbom: failed to marshal spdx doc: %v", err)
2244				return
2245			}
2246
2247			t.Logf("Want SPDX Doc: %s", string(expectedData))
2248
2249			// compare the spdx Docs
2250			compareSpdxDocs(t, spdxDoc, tt.expectedOut)
2251
2252			// compare deps
2253			t.Logf("got deps: %q", deps)
2254
2255			t.Logf("want deps: %q", tt.expectedDeps)
2256
2257			if g, w := deps, tt.expectedDeps; !reflect.DeepEqual(g, w) {
2258				t.Errorf("unexpected deps, wanted:\n%s\ngot:\n%s\n",
2259					strings.Join(w, "\n"), strings.Join(g, "\n"))
2260			}
2261		})
2262	}
2263}
2264
2265func getCreationInfo(t *testing.T) *spdx.CreationInfo {
2266	ci, err := builder2v2.BuildCreationInfoSection2_2("Organization", "Google LLC", nil)
2267	if err != nil {
2268		t.Errorf("Unable to get creation info: %v", err)
2269		return nil
2270	}
2271	return ci
2272}
2273
2274// validate returns an error if the Document is found to be invalid
2275func validate(doc *spdx.Document) error {
2276	if doc.SPDXVersion == "" {
2277		return fmt.Errorf("SPDXVersion: got nothing, want spdx version")
2278	}
2279	if doc.DataLicense == "" {
2280		return fmt.Errorf("DataLicense: got nothing, want Data License")
2281	}
2282	if doc.SPDXIdentifier == "" {
2283		return fmt.Errorf("SPDXIdentifier: got nothing, want SPDX Identifier")
2284	}
2285	if doc.DocumentName == "" {
2286		return fmt.Errorf("DocumentName: got nothing, want Document Name")
2287	}
2288	if fmt.Sprintf("%v", doc.CreationInfo.Creators[1].Creator) != "Google LLC" {
2289		return fmt.Errorf("Creator: got %v, want  'Google LLC'")
2290	}
2291	_, err := time.Parse(time.RFC3339, doc.CreationInfo.Created)
2292	if err != nil {
2293		return fmt.Errorf("Invalid time spec: %q: got error %q, want no error", doc.CreationInfo.Created, err)
2294	}
2295
2296	for _, license := range doc.OtherLicenses {
2297		if license.ExtractedText == "" {
2298			return fmt.Errorf("License file: %q: got nothing, want license text", license.LicenseName)
2299		}
2300	}
2301	return nil
2302}
2303
2304// compareSpdxDocs deep-compares two spdx docs by going through the info section, packages, relationships and licenses
2305func compareSpdxDocs(t *testing.T, actual, expected *spdx.Document) {
2306
2307	if actual == nil || expected == nil {
2308		t.Errorf("SBOM: SPDX Doc is nil! Got %v: Expected %v", actual, expected)
2309	}
2310
2311	if actual.DocumentName != expected.DocumentName {
2312		t.Errorf("sbom: unexpected SPDX Document Name got %q, want %q", actual.DocumentName, expected.DocumentName)
2313	}
2314
2315	if actual.SPDXVersion != expected.SPDXVersion {
2316		t.Errorf("sbom: unexpected SPDX Version got %s, want %s", actual.SPDXVersion, expected.SPDXVersion)
2317	}
2318
2319	if actual.DataLicense != expected.DataLicense {
2320		t.Errorf("sbom: unexpected SPDX DataLicense got %s, want %s", actual.DataLicense, expected.DataLicense)
2321	}
2322
2323	if actual.SPDXIdentifier != expected.SPDXIdentifier {
2324		t.Errorf("sbom: unexpected SPDX Identified got %s, want %s", actual.SPDXIdentifier, expected.SPDXIdentifier)
2325	}
2326
2327	if actual.DocumentNamespace != expected.DocumentNamespace {
2328		t.Errorf("sbom: unexpected SPDX Document Namespace got %s, want %s", actual.DocumentNamespace, expected.DocumentNamespace)
2329	}
2330
2331	// compare creation info
2332	compareSpdxCreationInfo(t, actual.CreationInfo, expected.CreationInfo)
2333
2334	// compare packages
2335	if len(actual.Packages) != len(expected.Packages) {
2336		t.Errorf("SBOM: Number of Packages is different! Got %d: Expected %d", len(actual.Packages), len(expected.Packages))
2337	}
2338
2339	for i, pkg := range actual.Packages {
2340		if !compareSpdxPackages(t, i, pkg, expected.Packages[i]) {
2341			break
2342		}
2343	}
2344
2345	// compare licenses
2346	if len(actual.OtherLicenses) != len(expected.OtherLicenses) {
2347		t.Errorf("SBOM: Number of Licenses in actual is different! Got %d: Expected %d", len(actual.OtherLicenses), len(expected.OtherLicenses))
2348	}
2349	for i, license := range actual.OtherLicenses {
2350		if !compareLicenses(t, i, license, expected.OtherLicenses[i]) {
2351			break
2352		}
2353	}
2354
2355	//compare Relationships
2356	if len(actual.Relationships) != len(expected.Relationships) {
2357		t.Errorf("SBOM: Number of Licenses in actual is different! Got %d: Expected %d", len(actual.Relationships), len(expected.Relationships))
2358	}
2359	for i, rl := range actual.Relationships {
2360		if !compareRelationShips(t, i, rl, expected.Relationships[i]) {
2361			break
2362		}
2363	}
2364}
2365
2366func compareSpdxCreationInfo(t *testing.T, actual, expected *spdx.CreationInfo) {
2367	if actual == nil || expected == nil {
2368		t.Errorf("SBOM: Creation info is nil! Got %q: Expected %q", actual, expected)
2369	}
2370
2371	if actual.LicenseListVersion != expected.LicenseListVersion {
2372		t.Errorf("SBOM: Creation info license version Error! Got %s: Expected %s", actual.LicenseListVersion, expected.LicenseListVersion)
2373	}
2374
2375	if len(actual.Creators) != len(expected.Creators) {
2376		t.Errorf("SBOM: Creation info creators Error! Got %d: Expected %d", len(actual.Creators), len(expected.Creators))
2377	}
2378
2379	for i, info := range actual.Creators {
2380		if info != expected.Creators[i] {
2381			t.Errorf("SBOM: Creation info creators Error! Got %q: Expected %q", info, expected.Creators[i])
2382		}
2383	}
2384}
2385
2386func compareSpdxPackages(t *testing.T, i int, actual, expected *spdx.Package) bool {
2387	if actual == nil || expected == nil {
2388		t.Errorf("SBOM: Packages are nil at index %d! Got %v: Expected %v", i, actual, expected)
2389		return false
2390	}
2391	if actual.PackageName != expected.PackageName {
2392		t.Errorf("SBOM: Package name Error at index %d! Got %s: Expected %s", i, actual.PackageName, expected.PackageName)
2393		return false
2394	}
2395
2396	if actual.PackageVersion != expected.PackageVersion {
2397		t.Errorf("SBOM: Package version Error at index %d! Got %s: Expected %s", i, actual.PackageVersion, expected.PackageVersion)
2398		return false
2399	}
2400
2401	if actual.PackageSPDXIdentifier != expected.PackageSPDXIdentifier {
2402		t.Errorf("SBOM: Package identifier Error at index %d! Got %s: Expected %s", i, actual.PackageSPDXIdentifier, expected.PackageSPDXIdentifier)
2403		return false
2404	}
2405
2406	if actual.PackageDownloadLocation != expected.PackageDownloadLocation {
2407		t.Errorf("SBOM: Package download location Error at index %d! Got %s: Expected %s", i, actual.PackageDownloadLocation, expected.PackageDownloadLocation)
2408		return false
2409	}
2410
2411	if actual.PackageLicenseConcluded != expected.PackageLicenseConcluded {
2412		t.Errorf("SBOM: Package license concluded Error at index %d! Got %s: Expected %s", i, actual.PackageLicenseConcluded, expected.PackageLicenseConcluded)
2413		return false
2414	}
2415	return true
2416}
2417
2418func compareRelationShips(t *testing.T, i int, actual, expected *spdx.Relationship) bool {
2419	if actual == nil || expected == nil {
2420		t.Errorf("SBOM: Relationships is nil at index %d! Got %v: Expected %v", i, actual, expected)
2421		return false
2422	}
2423
2424	if actual.RefA != expected.RefA {
2425		t.Errorf("SBOM: Relationship RefA Error at index %d! Got %s: Expected %s", i, actual.RefA, expected.RefA)
2426		return false
2427	}
2428
2429	if actual.RefB != expected.RefB {
2430		t.Errorf("SBOM: Relationship RefB Error at index %d! Got %s: Expected %s", i, actual.RefB, expected.RefB)
2431		return false
2432	}
2433
2434	if actual.Relationship != expected.Relationship {
2435		t.Errorf("SBOM: Relationship type Error at index %d! Got %s: Expected %s", i, actual.Relationship, expected.Relationship)
2436		return false
2437	}
2438	return true
2439}
2440
2441func compareLicenses(t *testing.T, i int, actual, expected *spdx.OtherLicense) bool {
2442	if actual == nil || expected == nil {
2443		t.Errorf("SBOM: Licenses is nil at index %d! Got %v: Expected %v", i, actual, expected)
2444		return false
2445	}
2446
2447	if actual.LicenseName != expected.LicenseName {
2448		t.Errorf("SBOM: License Name Error at index %d! Got %s: Expected %s", i, actual.LicenseName, expected.LicenseName)
2449		return false
2450	}
2451
2452	if actual.LicenseIdentifier != expected.LicenseIdentifier {
2453		t.Errorf("SBOM: License Identifier Error at index %d! Got %s: Expected %s", i, actual.LicenseIdentifier, expected.LicenseIdentifier)
2454		return false
2455	}
2456
2457	if actual.ExtractedText != expected.ExtractedText {
2458		t.Errorf("SBOM: License Extracted Text Error at index %d! Got: %q want: %q", i, actual.ExtractedText, expected.ExtractedText)
2459		return false
2460	}
2461	return true
2462}
2463
2464func fakeTime() string {
2465	t := time.UnixMicro(0)
2466	return t.UTC().Format("2006-01-02T15:04:05Z")
2467}
2468