54 require_once
"/usr/local/share/fossology/lib/php/bootstrap.php";
66 $GoodDir =
"regression/good/";
67 $PostDir =
"regression/post/";
68 $OutputDirTemplate =
"regression/output_";
69 $OutputDir = $OutputDirTemplate . posix_getpid();
73 $Options = getopt(
"hw:");
74 if ( array_key_exists(
'h', $Options))
80 if ( array_key_exists(
'w', $Options))
82 $WebHost = $Options[
'w'];
86 $WebHost =
"localhost";
90 if (mkdir($OutputDir, 0777,
true) ===
false)
92 echo
"Fatal: Could not create $OutputDir\n";
97 if (($DirH = opendir($GoodDir)) ===
false)
99 echo
"Fatal: Could not create $OutputDir\n";
107 while (($FileName = readdir($DirH)) !==
false)
109 if ($FileName[0] ==
'.')
continue;
114 $URL = $WebHost .
"/$FileName";
116 $ch = curl_init($URL);
118 $contents = curl_exec( $ch );
122 $OutFileName = $OutputDir .
"/$FileName";
123 if (file_put_contents($OutFileName, $contents) ===
false)
125 echo
"Failed to write contents to $OutFileName.\n";
129 $GoodFileName = $GoodDir .
"$FileName";
130 if (($GoodContents = file_get_contents($GoodFileName)) ===
false)
132 echo
"Failed to read good contents from $GoodFileName.\n";
136 if ($GoodContents != $contents)
138 echo
"Regression found: Baseline is $GoodFileName, new content is $OutFileName\n";
145 echo
"Total files checked: $FileCount\n";
146 echo
"No regression in: $GoodFileCount\n";
147 echo
"Regression found in: $BadFileCount\n";
155 function SetCurlArgs($ch)
159 curl_setopt($ch, CURLOPT_RETURNTRANSFER,
true);
160 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
161 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
163 CURLOPT_HTTPHEADER, array(
"Content-Type: 164 text/html; charset=utf-8"));
167 $http_proxy = $SysConf[
'FOSSOLOGY'][
'http_proxy'];
168 $ProxyServer = substr($http_proxy, 0, strrpos($http_proxy,
":"));
169 $ProxyPort = substr(strrchr($http_proxy,
":"), 1);
170 if (!empty($ProxyServer))
172 curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, TRUE);
173 curl_setopt($ch, CURLOPT_PROXY, $ProxyServer);
174 if (!empty($ProxyPort)) curl_setopt($ch, CURLOPT_PROXYPORT, $ProxyPort);
175 curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
184 function Usage($argc, $argv)
186 echo
"$argv[0] -h -w {web host}\n";
188 echo
" -w Web Host. Optional.\n";
189 echo
'e.g.: ./regressiontest.php -w "http://bobg.fc.hp.com/trunk"\n';
Usage()
Print Usage statement.
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN
bootstrap($sysconfdir="")
Bootstrap the fossology php library.
ConfigInit($sysconfdir, &$SysConf)
Initialize the fossology system after bootstrap().