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