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