52 $test_environment_variable =
'FOSSOLOGY_TESTCONFIG';
56 $fossology_testconfig = getenv($test_environment_variable);
58 if ($fossology_testconfig && strlen($fossology_testconfig) > 1) {
59 $sysconfdir = $fossology_testconfig;
66 $sysconfdir = $argv[1];
71 if (isset($sysconfdir)) {
72 if (is_readable(
"$sysconfdir/Db.conf")) {
73 print
"Found a readable '$sysconfdir/Db.conf' file\n";
76 $db_conf_contents = file_get_contents(
"$sysconfdir/Db.conf");
79 $db_match = preg_match(
'/dbname\s*\=\s*(.*?)[; ]/i', $db_conf_contents, $matches);
82 $database_name = $matches[1];
83 print
"Found database name '$database_name'\n";
86 print
"Did not find a dbname= parameter in '$sysconfdir/Db.conf'\n";
91 print
"A SYSCONFDIR was specified as '$sysconfdir' but no Db.conf file was found there!\n";
96 print
"No SYSCONFDIR was specified, so will attempt to delete all test DBs\n";
102 $postgres_params =
"dbname=template1 ";
103 $postgres_params .=
"host=localhost ";
105 $postgres_params .=
"user=fossologytest ";
106 $postgres_params .=
"password=fossologytest ";
108 $PG_CONN = pg_connect($postgres_params)
109 or die("FAIL: Could not connect to postgres server\n");
112 if ( empty($database_name) ) {
115 $sql =
"SELECT datname from pg_database where datname like 'fossologytest%'";
117 or die("FAIL: Could not query postgres database\n");
120 while ($row = pg_fetch_row($result)) {
122 echo
"Dropping test database $dbname\n";
123 $drop_sql =
"DROP DATABASE $dbname";
125 or die("FAIL: Could not drop database '$dbname'\n");
130 echo
"Dropping test database $database_name ONLY.\n";
131 $drop_sql =
"DROP DATABASE $database_name";
133 or die("FAIL: Could not drop drop database '$dbname'\n");
139 $system_temp_dir = sys_get_temp_dir();
140 $temp_dirs = glob($system_temp_dir . '
143 if (!empty($sysconfdir)) {
144 $temp_dirs = array($sysconfdir);
147 foreach ($temp_dirs as $temp_dir) {
150 if (preg_match(
'/\/fossologytest_\d{8}_\d{6}\/?$/', $temp_dir)) {
151 echo
"Deleting $temp_dir\n";
159 if (empty($sysconfdir)) {
160 print
"Attempting to clean up old-style FOSSology test databases\n";
164 $postgres_params =
"dbname=template1 ";
165 $postgres_params .=
"host=localhost ";
166 $postgres_params .=
"user=fossy ";
167 $postgres_params .=
"password=fossy ";
169 $PG_CONN = pg_connect($postgres_params)
170 or die("FAIL: Could not connect to postgres server\n");
173 $sql = "SELECT datname from pg_database where datname like 'fosstest%'";
175 or die("FAIL: Could not query postgres database\n");
178 while ($row = pg_fetch_row($result)) {
180 echo
"Dropping test databases $dbname\n";
181 $drop_sql =
"DROP DATABASE $dbname";
182 pg_query($PG_CONN, $drop_sql)
183 or die("FAIL: Could not drop database $dbname\n");
189 print "Done cleaning up FOSSology test databases\n";
if(!$Test &&$OptionQ) if($stdin_flag) if($Verbose) else
if(!preg_match("/\s$projectGroup\s/", $groups)&&(posix_getgid()!=$gInfo['gid']))
get monk license list of one specified uploadtree_id
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN