44 protected $testInstaller;
58 $this->testDb =
new TestPgDb(
"nomosfun" . time());
59 $this->agentDir = dirname(dirname(__DIR__));
60 $this->testdir = dirname(dirname(__DIR__)) .
61 "/agent_tests/testdata/NomosTestfiles/";
63 $sysConf = $this->testDb->getFossSysConf();
65 $this->testInstaller->init();
66 $this->testInstaller->install($this->agentDir);
68 $this->testDb->createSequences(array(
69 'license_ref_rf_pk_seq' 71 $this->testDb->createPlainTables(array(
75 $this->testDb->alterTables(array(
86 $this->testInstaller->uninstall($this->agentDir);
87 $this->testInstaller->clear();
88 $this->testInstaller->rmRepo();
101 protected function runNomos($args =
"", $files = array())
103 $sysConf = $this->testDb->getFossSysConf();
105 $confFile = $sysConf .
"/fossology.conf";
106 system(
"touch " . $confFile);
107 $config =
"[FOSSOLOGY]\ndepth = 0\npath = $sysConf/repo\n";
108 file_put_contents($confFile, $config);
110 $execDir = $this->agentDir .
'/agent';
112 "install -D $this->agentDir/VERSION $sysConf/mods-enabled/nomos/VERSION");
114 foreach ($files as $file) {
115 $args .=
" " . escapeshellarg($file);
118 $pipeFd = popen(
"$execDir/nomos -c $sysConf $args",
"r");
119 $this->assertTrue($pipeFd !==
false,
'running nomos failed');
122 while (($buffer = fgets($pipeFd, 4096)) !==
false) {
125 $retCode = pclose($pipeFd);
127 unlink(
"$sysConf/mods-enabled/nomos/VERSION");
146 $nomos = dirname(dirname(__DIR__)) .
'/agent/nomos';
147 list ($output,) = $this->
runNomos($args =
"-h");
149 $out = explode(
"\n", $output);
150 $usage =
"Usage: $nomos [options] [file [file [...]]";
151 $this->assertEquals($usage, $out[0]);
runNomos($args="", $files=array())
Run nomos using the arguments passed.
Tests for common CLI operations.
tearDown()
Destruct the objects initialized during setUp()
testHelp()
Test for nomos help message.
setUp()
Setup the test cases and initialize the objects.