30 protected $testfile = __DIR__.
'/../testdata/fossology-1.2.0-1.el5.i386.rpm';
35 private $testInstaller;
64 $cwd = dirname(__DIR__, 4).
'/build/src/pkgagent/agent_tests';
66 $this->agentDir = dirname(__DIR__, 4).
'/build/src/pkgagent/agent';
67 $this->testDb =
new TestPgDb(
"fosspkgagenttest");
68 $this->
dbManager = $this->testDb->getDbManager();
69 $tables = array(
'agent');
70 $this->testDb->createPlainTables($tables);
71 $this->testDb->createSequences([
'agent_agent_pk_seq']);
72 $this->testDb->createConstraints([
'agent_pkey']);
73 $this->testDb->alterTables($tables);
74 $db_conf = $this->testDb->getFossSysConf();
76 $this->testInstaller->init();
77 $this->testInstaller->cpRepo();
78 $this->testInstaller->install($cwd.
'/..');
79 $this->pkgagent = $this->agentDir .
'/pkgagent -c ' . $db_conf;
92 $last = exec(
"$this->pkgagent -h 2>&1", $usageOut, $rtn);
96 $usage =
"Usage: $this->agentDir/pkgagent [options] [file [file [...]]";
97 $dashI =
'-i :: initialize the database, then exit.';
98 $this->assertEquals($usage, $usageOut[0]);
99 $this->assertEquals($dashI,
trim($usageOut[1]));
112 $last = exec(
"$this->pkgagent -i 2>&1", $got, $rtn);
115 $this->fail(
"pkgagent FAILED!, return value is:$rtn\n");
117 $this->assertTrue(
true);
120 $this->fail(
"pkgagent FAILED! output in -i test\n");
121 print_r($got) .
"\n";
136 $expected = array(
'Name:fossology',
139 'Summary:FOSSology is a licenses exploration tool',
143 $last = exec(
"$this->pkgagent -C $this->testfile 2>&1", $got, $rtn);
148 $this->fail(
"pkgagent FAILED!, no output for test, stopping test");
152 foreach($expected as $match) {
153 if(FALSE === in_array($match, $got)){
154 $this->fail(
"pkgagent FAILED! did not fine $match in output\n");
157 $this->assertEquals(
'OK',$got[$size-1]);
171 $last = exec(
"$this->pkgagent -C -vv $this->testfile 2>&1", $got, $rtn);
176 $this->fail(
"pkgagent FAILED!, no output for -vv test, stopping test");
190 $expected = array(
'Name:fossology',
193 'Summary:FOSSology is a licenses exploration tool',
195 'Name:fossology-1.2.0-1.el5.src.rpm',
199 foreach($expected as $match) {
200 if(FALSE === in_array($match, $got)){
201 $this->fail(
"pkgagent FAILED! did not find $match in output\n");
204 $this->assertEquals(
'OK',$got[$size-1]);
208 protected function tearDown() : void {
210 if (!is_callable(
'pg_connect')) {
213 $this->testDb->fullDestruct();
214 $this->testDb =
null;
215 $this->testInstaller->uninstall($cwd.
'/..');
Test cli parameter i and v and rpm file and no parameters.
testHelp()
Test help message.
testOneRPM()
Test CLI with single RPM.
testI()
Test DB init flag.
setUp()
Set up test environment.
testOneRPMV()
Test CLI in verbose with one RPM.
char * trim(char *ptext)
Trimming whitespace.
fo_dbManager * dbManager
fo_dbManager object