43 require_once
"/usr/local/share/fossology/lib/php/bootstrap.php";
55 $GoodDir =
"regression/good/";
56 $PostDir =
"regression/post/";
57 $OutputDirTemplate =
"regression/output_";
58 $OutputDir = $OutputDirTemplate . posix_getpid();
62 $Options = getopt(
"hw:");
63 if ( array_key_exists(
'h', $Options))
69 if ( array_key_exists(
'w', $Options))
71 $WebHost = $Options[
'w'];
75 $WebHost =
"localhost";
79 if (mkdir($OutputDir, 0777,
true) ===
false)
81 echo
"Fatal: Could not create $OutputDir\n";
86 if (($DirH = opendir($GoodDir)) ===
false)
88 echo
"Fatal: Could not create $OutputDir\n";
96 while (($FileName = readdir($DirH)) !==
false)
98 if ($FileName[0] ==
'.')
continue;
103 $URL = $WebHost .
"/$FileName";
105 $ch = curl_init($URL);
107 $contents = curl_exec( $ch );
111 $OutFileName = $OutputDir .
"/$FileName";
112 if (file_put_contents($OutFileName, $contents) ===
false)
114 echo
"Failed to write contents to $OutFileName.\n";
118 $GoodFileName = $GoodDir .
"$FileName";
119 if (($GoodContents = file_get_contents($GoodFileName)) ===
false)
121 echo
"Failed to read good contents from $GoodFileName.\n";
125 if ($GoodContents != $contents)
127 echo
"Regression found: Baseline is $GoodFileName, new content is $OutFileName\n";
134 echo
"Total files checked: $FileCount\n";
135 echo
"No regression in: $GoodFileCount\n";
136 echo
"Regression found in: $BadFileCount\n";
144 function SetCurlArgs($ch)
148 curl_setopt($ch, CURLOPT_RETURNTRANSFER,
true);
149 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
150 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
152 CURLOPT_HTTPHEADER, array(
"Content-Type:
153 text/html; charset=utf-8"));
156 $http_proxy = $SysConf[
'FOSSOLOGY'][
'http_proxy'];
157 $ProxyServer = substr($http_proxy, 0, strrpos($http_proxy,
":"));
158 $ProxyPort = substr(strrchr($http_proxy,
":"), 1);
159 if (!empty($ProxyServer))
161 curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, TRUE);
162 curl_setopt($ch, CURLOPT_PROXY, $ProxyServer);
163 if (!empty($ProxyPort)) curl_setopt($ch, CURLOPT_PROXYPORT, $ProxyPort);
164 curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
173 function Usage($argc, $argv)
175 echo
"$argv[0] -h -w {web host}\n";
177 echo
" -w Web Host. Optional.\n";
178 echo
'e.g.: ./regressiontest.php -w "http://bobg.fc.hp.com/trunk"\n';
ConfigInit($sysconfdir, &$SysConf, $exitOnDbFail=true)
Initialize the fossology system after bootstrap().
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.