28 function setupTestEnv($workingDir, $agent, $agentTable=
true)
30 $SYSCONF_DIR =
"$workingDir/testconf";
31 $confFile =
"fossology.conf";
32 $agentDir =
"$workingDir/../..";
34 exec(
"rm -rf $SYSCONF_DIR");
35 if(!mkdir($SYSCONF_DIR)) {
36 die(
"Unable to create $SYSCONF_DIR");
38 $confFile_fh = fopen(
"$SYSCONF_DIR/$confFile",
'w')
39 or die("FAIL: Could not open $SYSCONF_DIR/$confFile for writing\n");
40 fwrite($confFile_fh, ";fossology.
conf for testing\n");
41 fwrite($confFile_fh, "[FOSSOLOGY]\nport = 24693\n");
42 fwrite($confFile_fh, "address = localhost\n");
43 fwrite($confFile_fh, "depth = 0\n");
44 fwrite($confFile_fh, "path = $SYSCONF_DIR\n");
45 fwrite($confFile_fh, "[HOSTS]\n");
46 fwrite($confFile_fh, "localhost = localhost AGENT_DIR 10\n");
47 fwrite($confFile_fh, "[REPOSITORY]\n");
48 fwrite($confFile_fh, "localhost = * 00 ff\n");
49 fwrite($confFile_fh, "[DIRECTORIES]\n");
50 fwrite($confFile_fh, "PROJECTUSER=fossy\n");
51 fwrite($confFile_fh, "PROJECTGROUP=fossy\n");
52 fwrite($confFile_fh, "MODDIR=$workingDir/../../..\n");
53 fwrite($confFile_fh, 'LIBEXECDIR=$MODDIR/../install/
db' . "\n");
54 fwrite($confFile_fh, "LOGDIR=$SYSCONF_DIR\n");
56 symlink("$workingDir/../../../../VERSION", "$SYSCONF_DIR/VERSION");
57 mkdir("$SYSCONF_DIR/mods-enabled");
58 symlink($agentDir, "$SYSCONF_DIR/mods-enabled/$agent");
60 $DB_COMMAND = "../../../testing/
db/createTestDB.php -c $SYSCONF_DIR -e";
62 exec($DB_COMMAND, $dbout, $rc);
64 print
"Can not create database for this testing sucessfully!\n";
67 preg_match(
"/(\d+)/", $dbout[0], $matches);
68 $test_name = $matches[1];
70 $version_array = parse_ini_file(
"$db_conf/VERSION");
71 $db_array = parse_ini_file(
"$db_conf/Db.conf");
72 $DB_NAME = $db_array[
"dbname"];
73 $db_user = $db_array[
"user"];
74 $db_pass = $db_array[
"password"];
75 $db_host = $db_array[
"host"];
76 $PG_CONN = pg_connect(
"host=$db_host port=5432 dbname=$DB_NAME user=$db_user password=$db_pass")
77 or die("Could not connect");
79 if($agentTable == true) {
80 $sql =
"CREATE TABLE agent (agent_pk serial, agent_name character varying(32), agent_rev character varying(32)," 81 .
" agent_desc character varying(255) DEFAULT NULL, agent_enabled boolean DEFAULT true, agent_parms text," 82 .
" agent_ts timestamp with time zone DEFAULT now());";
84 pg_free_result($result);
85 $sql =
"INSERT INTO agent(agent_name, agent_rev) VALUES('$agent','\"" . $version_array[
"VERSION"]
86 .
"\"." . $version_array[
"COMMIT_HASH"] .
"');";
88 pg_free_result($result);
90 return array($test_name, $db_conf, $DB_NAME,
$PG_CONN);
if(!preg_match("/\s$projectGroup\s/", $groups)&&(posix_getgid()!=$gInfo['gid']))
get monk license list of one specified uploadtree_id
fo_conf * conf
The loaded configuration data.
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN