FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
OneShot-multiFile.php
Go to the documentation of this file.
1 <?php
2 /***********************************************************
3  Copyright (C) 2012-2013 Hewlett-Packard Development Company, L.P.
4  Copyright (C) 2015 Siemens AG
5 
6  This program is free software; you can redistribute it and/or
7  modify it under the terms of the GNU General Public License
8  version 2 as published by the Free Software Foundation.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License along
16  with this program; if not, write to the Free Software Foundation, Inc.,
17  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  ***********************************************************/
26 require_once ('CommonCliTest.php');
27 
33 {
38  public $files;
43  public $Results = array(
44  'Affero-v1.0' => 'AGPL-1.0',
45  'Apache-v1.1' => 'Apache-1.1',
46  'ApacheLicense-v2.0' => 'Apache-2.0',
47  'ApacheV2.0.gz' => 'No_license_found',
48  'BSD_style_a.txt' => 'BSD-style',
49  'BSD_style_b.txt' => 'BSD-style',
50  'BSD_style_c.txt' => 'BSD-3-Clause',
51  'BSD_style_d.txt' => 'BSD-3-Clause',
52  'BSD_style_e.txt' => 'BSD',
53  'BSD_style_f.txt' => 'BSD-2-Clause',
54  'BSD_style_g.txt' => 'BSD-3-Clause',
55  'BSD_style_h.txt' => 'BSD',
56  'BSD_style_i.txt' => 'BSD-3-Clause',
57  'BSD_style_j.txt' => 'BSD-3-Clause',
58  'BSD_style_k.txt' => 'Apache-1.1-style',
59  'BSD_style_l.txt' => 'BSD-style',
60  'BSD_style_m.txt' => 'BSD',
61  'BSD_style_n.txt' => 'BSD-3-Clause',
62  'BSD_style_o.txt' => 'BSD',
63  'BSD_style_p.txt' => 'BSD-style',
64  'BSD_style_q.txt' => 'BSD-style',
65  'BSD_style_r.txt' => 'BSD-style',
66  'BSD_style_s.txt' => 'OpenSSL',
67  'BSD_style_t.txt' => 'SSLeay',
68  'BSD_style_u.txt' => 'BSD-3-Clause',
69  'BSD_style_v.txt' => 'MIT-CMU-style',
70  'BSD_style_w.txt' => 'BSD-style',
71  'BSD_style_x.txt' => 'BSD-style,Govt-work',
72  'BSD_style_y.txt' => 'PHP-3.0',
73  'BSD_style_z.txt' => 'OLDAP-2.3',
74  'FILEgpl3.0' => 'GPL-3.0+',
75  'FILEgplv2.1' => 'LGPL-2.1+',
76  'OSIzlibLicense-2006-10-31' => 'Zlib',
77  'RCSL_v3.0_a.txt' => 'Dual-license,RCSL-3.0',
78  'RPSL_v1.0_a.txt' => 'RPSL-1.0',
79  'RPSL_v1.0_b.txt' => 'RPSL-1.0',
80  'agpl-3.0.txt' => 'AGPL-3.0',
81  'apple.lic' => 'APSL-2.0',
82  'gpl-3.0.txt' => 'GPL-3.0+',
83  'gplv2.1' => 'LGPL-2.1+',
84  'zlibLicense-1.2.2-2004-Oct-03' => 'Zlib',
85  'DNSDigest.c' => 'Apache-2.0,BSD-style,GPL',
86  'Oracle-Berkeley-DB.java' => 'Oracle-Berkeley-DB',
87  'sleepycat.php' => 'Sleepycat',
88  'jslint.js' => 'JSON',
89  );
90 
99  public function testOneShotmultiFile()
100  {
101  $this->files = dirname(dirname(dirname(dirname(__FILE__)))).'/testing/dataFiles/TestData/licenses/*';
102  /* check to see if the files exist and load up the array */
103  $this->gplv3 = dirname(dirname(dirname(dirname(__FILE__)))).'/testing/dataFiles/TestData/licenses/gpl-3.0.txt';
104  $this->assertTrue(file_exists(dirname(dirname(dirname(dirname(__FILE__)))).'/testing/dataFiles/TestData/licenses/'));
105 
106  list($output,) = $this->runNomos($this->files);
107  $out = explode("\n", trim($output));
108 
109  foreach($out as $nomosResults)
110  {
111  list(,$fileName,,,$licenses) = preg_split('/[\s]+/', $nomosResults);
112  $this->assertArrayHasKey($fileName, $this->Results,
113  "Failure, filename $fileName was not found in the master results\n");
114  $expected = $this->Results[$fileName];
115  $this->assertContains($licenses, $expected,
116  "Failure, Master results $expected \n do not match current results $licenses \n");
117  }
118  }
119 }
testOneShotmultiFile()
Run NOMOS on multiple files at once.
runNomos($args="", $files=array())
Run nomos using the arguments passed.
Tests for common CLI operations.
Perform a one-shot license analysis on multiple files.
list_t type structure used to keep various lists. (e.g. there are multiple lists).
Definition: nomos.h:321
char * trim(char *ptext)
Trimming whitespace.
Definition: fossconfig.c:695