FOSSology  4.4.0
Open Source License Compliance by Open Source Software
Nightly.php
1 #!/usr/bin/php
2 <?php
3 /*
4  SPDX-FileCopyrightText: © 2011 Hewlett-Packard Development Company, L.P.
5 
6  SPDX-License-Identifier: GPL-2.0-only
7 */
8 
28 require_once('TestRun.php');
29 require_once('mailTo.php');
30 
31 global $mailTo;
32 
33 $usage = "$argv[0] [-h] [-p <path>]\n" .
34  "h: help, this message\n" .
35  "p path: the path to the fossology sources to test\n";
36 
37 $path = NULL;
38 
39 $options = getopt('hp:');
40 if(array_key_exists('h', $options))
41 {
42  echo $usage;
43  exit(0);
44 }
45 if(array_key_exists('p', $options))
46 {
47  $path = $options['p'];
48 }
49 
60 function reportError($error, $file=NULL)
61 {
62  global $mailTo;
63 
64  if(is_file($file))
65  {
66  if(is_readable($file))
67  {
68  $longMsg = file_get_contnets($file);
69  }
70  else
71  {
72  $longMsg = "$file was not readable\n";
73  }
74  }
75  else if(strlen($file) != 0)
76  {
77  if(is_string($file))
78  {
79  $longMsg = $file;
80  }
81  else
82  {
83  $longMsg = "Could not append a non-string to the message, " .
84  "reportError was passed an invalid 2nd parameter\n";
85  }
86  }
87 
88  $hdr = "There were errors in the nightly test setup." .
89  "The tests were not run due to one or more errors.\n\n";
90 
91  $msg = $hdr . $error . "\n" . $longMsg . "\n";
92 
93  // mailx will not take a string as the message body... save to a tmp
94  // file and give it that.
95 
96  $tmpFile = tempnam('.', 'testError');
97  $F = fopen($tmpFile, 'w') or die("Can not open tmp file $tmpFile\n");
98  fwrite($F, $msg);
99  fclose($F);
100  $last = exec("mailx -s 'test Setup Failed' $mailTo < $tmpFile ",$tossme, $rptGen);
101 }
102 
103 // Using the standard source path /home/fosstester/fossology
104 
105 if(array_key_exists('WORKSPACE', $_ENV))
106 {
107  $apath = $_ENV['WORKSPACE'];
108  print "workspaces:\napath:$apath\n";
109 }
110 
111 $tonight = new TestRun($path);
112 
113 print "Running tests\n";
114 $testPath = "$tonight->srcPath" . "/tests";
115 print "testpath is:$testPath\n";
116 if(!chdir($testPath))
117 {
118  $error = "Error can't cd to $testPath\n";
119  print $error;
120  reportError($error);
121  exit(1);
122 }
123 
124 print "Running Functional tests\n";
125 /*
126  * This fails if run by fosstester as Db.conf is not world readable and the
127  * script is not running a fossy... need to think about this...
128  *
129  */
130 $TestLast = exec('./testFOSSology.php -a -e', $results, $rtn);
131 print "after running tests the output is\n";
132 print_r($results) . "\n";
133 
134 
135 /*
136  * At this point should have results, generate the results summary and email it.
137  *
138  * 10-29-2009: the results are generated in testFOSSology.php and mailed there
139  * for now.... it should be done here.
140  */
141 
142 
143 /*
144  print "Stoping Scheduler\n";
145  if($tonight->stopScheduler() !== TRUE)
146  {
147  print "Error! Could not stop fossology-scheduler\n";
148  exit(1);
149  }
150  */
int s
The socket that the CLI will use to communicate.
Definition: fo_cli.c:37
if(!preg_match("/\s$projectGroup\s/", $groups) &&(posix_getgid() !=$gInfo[ 'gid']))
get monk license list of one specified uploadtree_id
Definition: migratetest.php:33