FOSSology  4.4.0
Open Source License Compliance by Open Source Software
OneShot-multiFile.php
Go to the documentation of this file.
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2012-2013 Hewlett-Packard Development Company, L.P.
4  SPDX-FileCopyrightText: © 2015 Siemens AG
5 
6  SPDX-License-Identifier: GPL-2.0-only
7 */
15 require_once ('CommonCliTest.php');
16 
22 {
27  public $files;
32  public $Results = array(
33  'Affero-v1.0' => 'AGPL-1.0-only',
34  'Apache-v1.1' => 'Apache-1.1',
35  'ApacheLicense-v2.0' => 'Apache-2.0',
36  'ApacheV2.0.gz' => 'No_license_found',
37  'BSD_style_a.txt' => 'BSD-style',
38  'BSD_style_b.txt' => 'BSD-style',
39  'BSD_style_c.txt' => 'BSD-3-Clause',
40  'BSD_style_d.txt' => 'BSD-3-Clause',
41  'BSD_style_e.txt' => 'BSD',
42  'BSD_style_f.txt' => 'BSD-2-Clause',
43  'BSD_style_g.txt' => 'BSD-3-Clause',
44  'BSD_style_h.txt' => 'BSD',
45  'BSD_style_i.txt' => 'BSD-3-Clause',
46  'BSD_style_j.txt' => 'BSD-3-Clause',
47  'BSD_style_k.txt' => 'Apache-1.1-style',
48  'BSD_style_l.txt' => 'BSD-style',
49  'BSD_style_m.txt' => 'BSD',
50  'BSD_style_n.txt' => 'BSD-3-Clause',
51  'BSD_style_o.txt' => 'BSD',
52  'BSD_style_p.txt' => 'BSD-style',
53  'BSD_style_q.txt' => 'BSD-style',
54  'BSD_style_r.txt' => 'BSD-style',
55  'BSD_style_s.txt' => 'OpenSSL',
56  'BSD_style_t.txt' => 'SSLeay',
57  'BSD_style_u.txt' => 'BSD-3-Clause',
58  'BSD_style_v.txt' => 'MIT-CMU-style',
59  'BSD_style_w.txt' => 'BSD-style',
60  'BSD_style_x.txt' => 'BSD-style,Govt-work',
61  'BSD_style_y.txt' => 'PHP-3.0',
62  'BSD_style_z.txt' => 'OLDAP-2.3',
63  'FILEgpl3.0' => 'GPL-3.0-only',
64  'FILEgplv2.1' => 'LGPL-2.1-only',
65  'OSIzlibLicense-2006-10-31' => 'Zlib',
66  'RCSL_v3.0_a.txt' => 'Dual-license,RCSL-3.0',
67  'RPSL_v1.0_a.txt' => 'RPSL-1.0',
68  'RPSL_v1.0_b.txt' => 'RPSL-1.0',
69  'agpl-3.0.txt' => 'AGPL-3.0-only',
70  'apple.lic' => 'APSL-2.0',
71  'gpl-3.0.txt' => 'GPL-3.0-only',
72  'gplv2.1' => 'LGPL-2.1-only',
73  'zlibLicense-1.2.2-2004-Oct-03' => 'Zlib',
74  'DNSDigest.c' => 'Apache-2.0,BSD-style,GPL',
75  'Oracle-Berkeley-DB.java' => 'Oracle-Berkeley-DB',
76  'sleepycat.php' => 'Sleepycat',
77  'jslint.js' => 'JSON',
78  );
79 
88  public function testOneShotmultiFile()
89  {
90  $this->files = dirname(dirname(dirname(dirname(__FILE__)))).'/testing/dataFiles/TestData/licenses/*';
91  /* check to see if the files exist and load up the array */
92  $this->gplv3 = dirname(dirname(dirname(dirname(__FILE__)))).'/testing/dataFiles/TestData/licenses/gpl-3.0.txt';
93  $this->assertTrue(file_exists(dirname(dirname(dirname(dirname(__FILE__)))).'/testing/dataFiles/TestData/licenses/'));
94 
95  list($output,) = $this->runNomos($this->files);
96  $out = explode("\n", trim($output));
97 
98  foreach($out as $nomosResults)
99  {
100  list(,$fileName,,,$licenses) = preg_split('/[\s]+/', $nomosResults);
101  $this->assertArrayHasKey($fileName, $this->Results,
102  "Failure, filename $fileName was not found in the master results\n");
103  $expected = $this->Results[$fileName];
104  $this->assertStringContainsString($licenses, $expected,
105  "Failure, Master results $expected \n do not match current results $licenses \n");
106  }
107  }
108 }
Tests for common CLI operations.
runNomos($args="", $files=array())
Run nomos using the arguments passed.
Perform a one-shot license analysis on multiple files.
testOneShotmultiFile()
Run NOMOS on multiple files at once.
char * trim(char *ptext)
Trimming whitespace.
Definition: fossconfig.c:690
list_t type structure used to keep various lists. (e.g. there are multiple lists).
Definition: nomos.h:308