39 require_once (
'TestEnvironment.php');
40 require_once (
'testClasses/check4jobs.php');
41 require_once (
'mailTo.php');
44 $usage.=
"Usage: $argv[0] [-l path] {[-a] | [-b] | [-h] | [-s] | [-v -l]}\n";
45 $usage.=
"-a: Run all FOSSology Test Suites\n" .
46 "-b: Run the basic test suite. This runs the SiteTests and any Tests " .
47 "that don't depend on uploads\n" .
48 "-h: Display Usage\n" .
49 "-l path: test results file path \n" .
50 "-s: Run SiteTests only (this is a lightweight suite)\n" .
51 "-v -l: Run the Verify Tests. These tests require uploads to be uploaded first." .
52 " See the test documentation for details\n" .
53 " You must specify a log file when using -v, best to use the same log file" .
54 " that was used in a previous run for example -a -l foo, then -v -l foo when" .
55 " all the files have been uploaded with -a.";
62 $SiteTests =
'../ui/tests/SiteTests';
63 $BasicTests =
'../ui/tests/BasicTests';
64 $UserTests =
'../ui/tests/Users';
65 $EmailTests =
'../ui/tests/EmailNotification';
66 $CopyRight =
'copyright';
68 $pkgAgent =
'pkgagent';
69 $VerifyTests =
'../ui/tests/VerifyTests';
76 $date = date(
'Y-m-d');
77 $time = date(
'h:i:s-a');
78 $defaultLog =
"/FossTestResults-$date-$time";
83 $options = getopt(
'abehl:sv');
84 if (empty($options)) {
88 if (array_key_exists(
'h', $options)) {
92 if (array_key_exists(
'l', $options)) {
93 $logFile = $options[
'l'];
94 $logFileName = basename($logFile);
99 $logFile = $cwd . $defaultLog;
101 $logFileName = basename($logFile);
109 function _runTestEnvSetup() {
118 if (chdir($Home) === FALSE) {
119 LogAndPrint($LF,
"_runTestEnvSetup ERROR: can't cd to $Home\n");
121 LogAndPrint($LF,
"\n");
122 $UpLast = exec(
"./uploadTestData.php >> $logFile 2>&1", $dummy, $SUrtn);
123 LogAndPrint($LF,
"\n");
124 $UpLast = exec(
"./fo-runTests.php -l uploadCopyrightData.php -n 'Upload copyright data'>> $logFile 2>&1", $dummy, $Copyrtn);
125 $AALast = exec(
"./fo-runTests.php -l AgentAddData.php -n 'Agent Add Uploads'>> $logFile 2>&1", $dummy, $AArtn);
126 LogAndPrint($LF,
"\n");
129 LogAndPrint($LF,
"ERROR when running uploadTestData.php\n");
130 foreach($dummy as $ErrorLine) {
131 print
"$ErrorLine\n";
136 LogAndPrint($LF,
"ERROR when running uploadCopyrightData.php\n");
137 foreach($dummy as $ErrorLine) {
138 print
"$ErrorLine\n";
143 LogAndPrint($LF,
"ERROR when running AgentAddData.php\n");
144 foreach($dummy as $ErrorLine) {
145 print
"$ErrorLine\n";
150 print
"Warning! There were errors in the test setup, one or more test may fail as a result\n";
154 function getSvnVer() {
155 return (`svnversion`);
158 function LogAndPrint($FileHandle, $message) {
159 if (empty($message)) {
162 if (empty($FileHandle)) {
165 if (-1 == fwrite($FileHandle, $message)) {
178 if (array_key_exists(
"a", $options)) {
179 $LF = fopen($logFile,
'w') or die("can't open $logFile $phperrormsg\n");
180 print "Using log file:$logFile\n";
181 if (chdir($Home) === FALSE) {
182 LogAndPrint($LF,
"All Tests ERROR: can't cd to $Home\n");
184 LogAndPrint($LF,
"Running All Tests on: $date at $time using subversion version: $Svn\n");
186 $Cleanup =
"This program does not remove the testing folders in case" .
187 " there was a failure and it needs to be looked at. Run " .
188 "the script/test runTestCleanup.php to clean things up.\n";
190 print wordwrap($Cleanup);
196 $cmd =
"./fo-runTests.php createUIUsers.php -n 'Create UI Users Test' >> $logFile 2>&1";
197 $UIusers = exec($cmd, $dummy, $UsrRtn);
199 LogAndPrint($LF,
"ERROR when running createUIUsers.php: return code:$UsrRtn\n");
200 LogAndPrint($LF,
"last line returned is:$UIusers\n");
201 foreach($dummy as $ErrorLine) {
202 LogAndPrint($LF,
"$ErrorLine\n");
204 LogAndPrint($LF,
"The Email Notification tests mail fail as a result\n");
206 $ctdLast = exec(
'./checkTestData.php', $ctdOut, $ctdRtn);
209 LogAndPrint($LF,
"ERROR when running check4TestData, see previous errors\n");
212 if (chdir($SiteTests) === FALSE) {
213 LogandPrint($LF,
"ALL Tests ERROR: can't cd to $SiteTests\n");
217 $SiteLast = exec(
"./runSiteTests.php >> $logFile 2>&1", $dummy, $Srtn);
218 LogAndPrint($LF,
"\n");
219 if (chdir(
'../BasicTests') === FALSE) {
220 LogAndPrint($LF,
"ALL Tests ERROR: can't cd to $BasicTests\n");
222 $BasicLast = exec(
"./runBasicTests.php >> $logFile 2>&1", $dummy, $Brtn);
223 LogAndPrint($LF,
"\n");
228 if (chdir(
'../Users') === FALSE) {
229 LogAndPrint($LF,
"ALL Tests ERROR: can't cd to $UserTests\n");
231 $testList =
"addUserTest.php dupUserTest.php noEmailUserTest.php userEditAnyTest.php";
232 $uCmnd =
"/usr/local/bin/fo-runTests -l $testList -n 'User Tests' >> $logFile 2>&1";
233 $UsersLast = exec($uCmnd, $dummy, $Urtn);
234 LogAndPrint($LF,
"\n");
236 if (chdir($Home) === FALSE) {
237 $cUInoHome =
"All Tests ERROR: can't cd to $Home\n";
238 LogAndPrint($LF, $cUInoHome);
241 if (chdir($EmailTests) === FALSE) {
242 LogAndPrint($LF,
"ALL Tests ERROR: can't cd to $EmailTests\n");
245 $EmailLast = exec(
"fo-runTests -l \"`ls`\" -n 'Email Tests' >> $logFile 2>&1", $dummy, $ENrtn);
246 LogAndPrint($LF,
"\n");
248 if (chdir($Home) === FALSE) {
249 $cUInoHome =
"All Tests ERROR: can't cd to $Home\n";
250 LogAndPrint($LF, $cUInoHome);
253 if (chdir($pkgAgent) === FALSE) {
254 LogAndPrint($LF,
"ALL Tests ERROR: can't cd to $pkgAgent\n");
256 $PkgLast = exec(
"fo-runTests -l \"`ls cli*`\" -n 'Package Agent Tests'" .
257 " >> $logFile 2>&1", $dummy, $Pkgrtn);
258 LogAndPrint($LF,
"\n");
266 if (chdir($Home) === FALSE) {
267 $UInoHome =
"All Tests ERROR: can't cd to $Home\n";
268 LogAndPrint($LF, $UInoHome);
270 print
"Waiting for jobs to finish...\n";
271 $last = exec(
'./wait4jobs.php', $tossme, $jobsDone);
272 foreach($tossme as $line){
275 print
"testFOSSology: jobsDone is:$jobsDone\n";
276 if ($jobsDone != 0) {
277 print
"ERROR! jobs are not finished after two hours, not running" .
278 "verify tests, please investigate and run verify tests by hand\n";
279 print
"Monitor the job Q and when the setup jobs are done, run:\n";
280 print
"$myname -v -l $logFile\n";
283 if ($jobsDone == 0) {
284 if (chdir($Home) === FALSE) {
285 $cUInoHome =
"All Tests ERROR: can't cd to $Home\n";
286 LogAndPrint($LF, $cUInoHome);
288 if (chdir($nomos) === FALSE) {
289 LogAndPrint($LF,
"ALL Tests ERROR: can't cd to $nomos\n");
292 $nomosTests = array(
'ckZendTest.php',
'verifyRedHatTest.php');
293 foreach($nomosTests as $test)
295 $last = exec(
"fo-runTests -l $test -n 'Nomos Tests' >> $logFile 2>&1", $dummy, $rtn);
296 LogAndPrint($LF,
"\n");
299 LogAndPrint($LF,
"Starting cli1Test\n" );
300 $last = exec(
'phpunit ./cli1Test.php', $punitOut, $puRtn);
303 LogAndPrint($LF,
"cli1Test Failed\n");
304 LogAndPrint($LF, $punitOut);
305 LogAndPrint($LF,
"\n");
309 LogAndPrint($LF,
"cli1Test Passed\n");
310 LogAndPrint($LF,
"$last\n");
313 if (chdir($Home) === FALSE) {
314 $cUInoHome =
"All Tests ERROR: can't cd to $Home\n";
315 LogAndPrint($LF, $cUInoHome);
318 if (chdir($CopyRight) === FALSE) {
319 LogAndPrint($LF,
"ALL Tests ERROR: can't cd to $CopyRight\n");
321 $CopyLast = exec(
"fo-runTests -l \"`ls verify*`\" -n 'CopyRight Tests' >> $logFile 2>&1", $dummy, $CRrtn);
322 LogAndPrint($LF,
"\n");
325 $last = exec(
'phpunit cliParamsTest.php', $punitOut, $puRtn);
328 LogAndPrint($LF,
"cli1Test Failed\n");
329 LogAndPrint($LF, $punitOut);
330 LogAndPrint($LF,
"\n");
334 LogAndPrint($LF,
"cli1Test Passed\n");
335 LogAndPrint($LF,
"$last\n");
339 verifyUploads($logFile);
340 if (!is_null($rtn = saveResults())) {
341 print
"ERROR! could not save the test results, please save by hand\n";
342 print
"saveResults returned the following error:\n$rtn\n";
345 $resultsHome =
"/home/fosstester/public_html/TestResults/Data/Latest/";
346 $reportHome =
"$resultsHome" .
"$logFileName";
348 if(array_key_exists(
'e', $options)) {
349 $last = exec(
"./textReport.php -f $reportHome |
350 mailx -s \"test results\" $mailTo ",$tossme, $rptGen);
352 $last = system(
"./textReport.php -f $reportHome", $rtn);
353 if($last === FALSE) {
354 print
"Error! Counld not generate text summary report\n";
361 if (array_key_exists(
"b", $options)) {
362 $LF = fopen($logFile,
'w') or die("can't open $logFile $phperrormsg\n");
363 print "Using log file:$logFile\n";
364 if (chdir($Home) === FALSE) {
365 $BnoHome =
"Basic Tests ERROR: can't cd to $Home\n";
366 LogAndPrint($LF, $BnoHome);
368 $startB =
"Running Basic/SiteTests on: $date at $time\n";
369 LogAndPrint($LF, $startB);
370 if (chdir($SiteTests) === FALSE) {
371 $noBS =
"Basic/Site Tests ERROR: can't cd to $SiteTests\n";
372 LogAndPrint($LF, $noBS);
375 $SiteLast = exec(
"./runSiteTests.php >> $logFile 2>&1", $dummy, $Srtn);
376 if (chdir(
'../BasicTests') === FALSE) {
377 $noBT =
"Basic Tests ERROR: can't cd to $BasicTests\n";
378 LogAndPrint($LF, $noBT);
381 $BasicLast = exec(
"./runBasicTests.php >> $logFile 2>&1", $dummy, $Srtn);
386 if (array_key_exists(
"s", $options)) {
387 $LF = fopen($logFile,
'w') or die("can't open $logFile $phperrormsg\n");
388 print "Using log file:$logFile\n";
389 $Sstart = "Running SiteTests on: $date at $time\n";
390 LogAndPrint($LF, $Sstart);
391 if (chdir($SiteTests) === FALSE) {
392 $noST =
"Site Tests ERROR: can't cd to $SiteTests\n";
393 LogAndPrint($LF, $noST);
395 $SiteLast = exec(
"./runSiteTests.php >> $logFile 2>&1", $dummy, $Srtn);
400 if (array_key_exists(
"v", $options)) {
401 if (array_key_exists(
"l", $options)) {
402 $logFile = $options[
'l'];
408 $position = strpos($logFile,
'/');
409 if($position === FALSE) {
410 $logFile = getcwd() .
"/$logFile";
412 $logFileName = basename($logFile);
414 print
"Error, must supply a path to a log file with -v option\n";
418 print
"calling verifyUploads with:$logFile\n";
419 if (!verifyUploads($logFile)) {
420 print
"NOTE: One or more verify upload tests had errors, please investigate\n";
421 echo
"by running ui/tests/VerifyTests/runVerifyTests.php\n";
424 if (!is_null($rtn = saveResults())) {
425 print
"ERROR! could not save the test results, please save by hand\n";
430 function saveResults() {
437 $resultsHome =
"/home/fosstester/public_html/TestResults/Data/Latest/";
438 if (chdir($Home) === FALSE) {
439 $nohome =
"Save Data ERROR: can't cd to $Home\n";
440 LogAndPrint($LF, $nohome);
445 $reportHome =
"$resultsHome" .
"$logFileName";
446 if (!rename($logFile, $reportHome)) {
447 $E =
"Error, could not move\n$logFile\nto\n$reportHome\n";
448 $E.=
"Please move it by hand so the reports will be current\n";
453 function verifyUploads($logfile) {
458 if (empty($logfile)) {
461 $VLF = fopen($logfile,
'a') or die("Can't open $logfile, $phperrormsg");
462 $Vstart = "\nRunning Verify Tests on: $date at $time\n";
463 LogAndPrint($VLF, $Vstart);
464 if (chdir($Home) === FALSE) {
465 $noVhome =
"Verify Tests ERROR: can't cd to $Home\n";
466 LogAndPrint($VLF, $noVhome);
468 if (chdir($VerifyTests) === FALSE) {
469 $noVT =
"Verify Tests ERROR: can't cd to $VerifyTests\n";
470 LogAndPrint($VLF, $noVT);
473 echo
"Running runVerifyTests\n";
474 $VerifyLast = exec(
"./runVerifyTests.php >> $logfile 2>&1", $dummy, $Vrtn);
if(!preg_match("/\s$projectGroup\s/", $groups) &&(posix_getgid() !=$gInfo[ 'gid']))
get monk license list of one specified uploadtree_id