35 protected $testInstaller;
47 protected function setUp() : void
49 $this->testDb =
new TestPgDb(
"nomosfun" . time());
50 $this->agentDir = dirname(__DIR__, 4).
'/build/src/nomos';
51 $this->testdir = dirname(dirname(__DIR__)) .
52 "/agent_tests/testdata/NomosTestfiles/";
54 $sysConf = $this->testDb->getFossSysConf();
56 $this->testInstaller->init();
57 $this->testInstaller->install($this->agentDir);
59 $this->testDb->createSequences(array(
60 'license_ref_rf_pk_seq'
62 $this->testDb->createPlainTables(array(
66 $this->testDb->alterTables(array(
77 $this->testInstaller->uninstall($this->agentDir);
78 $this->testInstaller->clear();
79 $this->testInstaller->rmRepo();
92 protected function runNomos($args =
"", $files = array())
94 $sysConf = $this->testDb->getFossSysConf();
96 $confFile = $sysConf .
"/fossology.conf";
97 system(
"touch " . $confFile);
98 $config =
"[FOSSOLOGY]\ndepth = 0\npath = $sysConf/repo\n";
99 file_put_contents($confFile, $config);
101 $execDir = $this->agentDir .
'/agent';
103 "install -D $this->agentDir/VERSION $sysConf/mods-enabled/nomos/VERSION");
105 foreach ($files as $file) {
106 $args .=
" " . escapeshellarg($file);
109 $pipeFd = popen(
"$execDir/nomos -c $sysConf $args",
"r");
110 $this->assertTrue($pipeFd !==
false,
'running nomos failed');
113 while (($buffer = fgets($pipeFd, 4096)) !==
false) {
116 $retCode = pclose($pipeFd);
118 unlink(
"$sysConf/mods-enabled/nomos/VERSION");
137 $nomos = dirname(__DIR__, 4) .
'/build/src/nomos/agent/nomos';
138 list ($output,) = $this->
runNomos($args =
"-h");
140 $out = explode(
"\n", $output);
141 $usage =
"Usage: $nomos [options] [file [file [...]]";
142 $this->assertEquals($usage, $out[0]);
Tests for common CLI operations.
setUp()
Setup the test cases and initialize the objects.
tearDown()
Destruct the objects initialized during setUp()
runNomos($args="", $files=array())
Run nomos using the arguments passed.
testHelp()
Test for nomos help message.