FOSSology  4.4.0
Open Source License Compliance by Open Source Software
verifyFossI16L335U29.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2010 Hewlett-Packard Development Company, L.P.
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
16 require_once('../../../tests/fossologyTestCase.php');
17 require_once('../../../tests/commonTestFuncs.php');
18 require_once('../../../tests/TestEnvironment.php');
19 require_once('../../../tests/testClasses/parseMiniMenu.php');
20 require_once('../../../tests/testClasses/parseFolderPath.php');
21 //require_once('../../../tests/testClasses/parseLicenseTbl.php');
22 require_once('../../../tests/testClasses/dom-parseLicenseTable.php');
23 
24 global $URL;
25 
27 {
28  public $mybrowser;
29  public $host;
30 
31  function setUp()
32  {
33  /*
34  * This test requires that the fossology test archive has been
35  * loaded under the name fossI16L335U29.tar.bz2
36  */
37  global $URL;
38  global $name;
39  global $safeName;
40 
41  $name = 'fossI16L335U29.tar.bz2';
42  $safeName = escapeDots($name);
43  $this->host = getHost($URL);
44 
45  $this->Login();
46 
47  /* check for existense of archive */
48  $page = $this->mybrowser->get($URL);
49  $page = $this->mybrowser->clickLink('Browse');
50  $this->assertTrue($this->myassertText($page, '/Browse/'),
51  "verifyFossl16L335 FAILED! Could not find Browse menu\n");
52  $page = $this->mybrowser->clickLink('Testing');
53  $this->assertTrue($this->myassertText($page, '/Testing/'),
54  "verifyFossl16L335 FAILED! Could not find Testing folder\n");
55  $result = $this->myassertText($page, "/$safeName/");
56  if(!($result)) { exit(FALSE); }
57  }
58 
59  function testVerifyFossl16L335()
60  {
61  global $URL;
62  global $name;
63  global $safeName;
64 
65  // licenseCounts recorded 2010-11-19 for release 1.3
66  $licenseCounts = array(
67  'GPL_v2' => 224,
68  'No_license_found' => 72,
69  'GPL' => 23,
70  'LGPL_v2.1' => 17,
71  'Apache_v2.0' => 2,
72  'GFDL' => 2,
73  'Public-domain' => 8,
74  'APSL_v2.0' => 1,
75  'Artistic' => 1,
76  'Boost' => 1,
77  'BSD' => 1,
78  'FSF-possibility' => 1,
79  'GPL_v2-possibility' => 1,
80  'LGPL_v2.1+' => 1,
81  'LGPL_v3+' => 1,
82  'NPL' => 1,
83  'OSL_v3.0' => 1,
84  'PHP-possibility' => 1,
85  'Python' => 1,
86  'See-doc(OTHER)' => 1,
87  'X11-possibility' => 1,
88  'Zope' => 1,
89 );
90 
91  $licenseSummary = array(
92  'Unique licenses'=> 22,
93  'Licenses found'=> 291,
94  'Files with no licenses'=> 72,
95  'Files'=> 345
96  );
97 
98  print "starting VerifyFossl16L335 test\n";
99  $page = $this->mybrowser->clickLink('Browse');
100  $this->assertTrue($this->myassertText($page, '/Browse/'),
101  "verifyFossl16L335 FAILED! Could not find Browse menu\n");
102  /* Testing folder */
103  $page = $this->mybrowser->clickLink('Testing');
104  //print "************ Page after upload link *************\n$page\n";
105  $this->assertTrue($this->myassertText($page, "/Browse/"),
106  "verifyFossl16L335 FAILED! Browse Title not found\n");
107  $this->assertTrue($this->myassertText($page, "/$safeName/"),
108  "verifyFossl16L335 FAILED! did not find $name\n");
109  $this->assertTrue($this->myassertText($page, "/>View</"),
110  "verifyFossl16L335 FAILED! >View< not found\n");
111  $this->assertTrue($this->myassertText($page, "/>Info</"),
112  "verifyFossl16L335 FAILED! >Info< not found\n");
113  $this->assertTrue($this->myassertText($page, "/>Download</"),
114  "verifyFossl16L335 FAILED! >Download< not found\n");
115 
116  /* Select archive */
117  $page = $this->mybrowser->clickLink($name);
118  //print "************ Page after select foss archive *************\n$page\n";
119  $this->assertTrue($this->myassertText($page, "/fossI16L335U29\.tar/"),
120  "FAILURE! Could not find fossI16L335U29.tar link\n");
121 
122  /* Select fossology link */
123  $page = $this->mybrowser->clickLink('fossI16L335U29.tar');
124  $page = $this->mybrowser->clickLink('fossology/');
125 
126  /* need to check that there are 16 items */
127  /* check that all the [xxx] items add to 335 */
128 
129  $this->assertTrue($this->myassertText($page, "/Makefile/"));
130  $this->assertTrue($this->myassertText($page, "/mkcheck\.sh/"),
131  "FAIL! did not find mkcheck.sh\n");
132  $this->assertTrue($this->myassertText($page, "/>View</"),
133  "FAIL! >View< not found\n");
134  $this->assertTrue($this->myassertText($page, "/>Info</"),
135  "FAIL! >Info< not found\n");
136  $this->assertTrue($this->myassertText($page, "/>Download</"),
137  "FAIL! >Download< not found\n");
138 
139  /* Select the License link to View License Historgram */
140  $mini = new parseMiniMenu($page);
141  $miniMenu = $mini->parseMiniMenu();
142  $url = makeUrl($this->host, $miniMenu['License Browser']);
143  if($url === NULL) { $this->fail("verifyFossl16L335 Failed, host/url is not set"); }
144 
145  $page = $this->mybrowser->get($url);
146  //print "page after get of $url is:\n$page\n";
147  $this->assertTrue($this->myassertText($page, '/License Browser/'),
148  "verifyFossl16L335 FAILED! Nomos License Browser Title not found\n");
149 
150  // check that license summarys are correct
151  $licSummary = new domParseLicenseTbl($page, 'licsummary', 0);
152  $licSummary->parseLicenseTbl();
153 
154  foreach ($licSummary->hList as $summary) {
155  $key = $summary['textOrLink'];
156  $this->assertEqual($licenseSummary[$key], $summary['count'],
157  "verifyFossl16L335 FAILED! $key does not equal $licenseSummary[$key],
158  got $summary[count]\n");
159  //print "summary is:\n";print_r($summary) . "\n";
160  }
161 
162  // get the license names and 'Show' links
163  $licHistogram = new domParseLicenseTbl($page, 'lichistogram',1);
164  $licHistogram->parseLicenseTbl();
165 
166  if($licHistogram->noRows === TRUE)
167  {
168  $this->fail("FATAL! no table rows to process, there should be many for"
169  . " this test, Stopping the test");
170  return;
171  }
172 
173  // verify every row against the standard by comparing the counts.
174  /*
175  * @todo check the show links, but to do that, need to gather another
176  * standard array to match against or just use the count from the
177  * baseline?
178  */
179 
180  foreach($licHistogram->hList as $licFound)
181  {
182  $key = $licFound['textOrLink'];
183  //print "VDB: key is:$key\n";
184  //print "licFound is:\n";print_r($licFound) . "\n";
185  if(array_key_exists($key,$licenseCounts))
186  {
187  $this->assertEqual($licenseCounts[$key], $licFound['count'],
188  "verifyFossl16L335 FAILED! the baseline count {$licenseCounts[$key]} does" .
189  " not equal {$licFound['count']} for license $key,\n" .
190  "Expected: {$licenseCounts[$key]},\n" .
191  " Got: {$licFound['count']}\n");
192  }
193  else
194  {
195  $this->fail("verifyFossl16L335 A License was found that is " .
196  "not in the standard:\n$key\n");
197  }
198  }
199  }
200 }
Login($User=NULL, $Password=NULL)