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