private function runMonk($args = "", $files = array()) { $sysConf = $this->testDb->getFossSysConf(); $confFile = $sysConf . "/fossology.conf"; system("touch " . $confFile); $config = "[FOSSOLOGY]\ndepth = 0\npath = {$sysConf}/repo\n"; file_put_contents($confFile, $config); $agentName = "monk"; $agentDir = dirname(dirname(__DIR__)); $execDir = __DIR__; system("install -D {$agentDir}/VERSION-monk {$sysConf}/mods-enabled/{$agentName}/VERSION"); foreach ($files as $file) { $args .= " " . escapeshellarg($file); } $pipeFd = popen("{$execDir}/{$agentName} -c {$sysConf} {$args}", "r"); $this->assertTrue($pipeFd !== false, 'running monk failed'); $output = ""; while (($buffer = fgets($pipeFd, 4096)) !== false) { $output .= $buffer; } $retCode = pclose($pipeFd); unlink("{$sysConf}/mods-enabled/{$agentName}/VERSION"); rmdir("{$sysConf}/mods-enabled/{$agentName}"); rmdir("{$sysConf}/mods-enabled"); unlink($confFile); return array($output, $retCode); }
protected function runNomos($args = "", $files = array()) { $sysConf = $this->testDb->getFossSysConf(); $confFile = $sysConf . "/fossology.conf"; system("touch " . $confFile); $config = "[FOSSOLOGY]\ndepth = 0\npath = {$sysConf}/repo\n"; file_put_contents($confFile, $config); $execDir = $this->agentDir . '/agent'; system("install -D {$this->agentDir}/VERSION {$sysConf}/mods-enabled/nomos/VERSION"); foreach ($files as $file) { $args .= " " . escapeshellarg($file); } $pipeFd = popen("{$execDir}/nomos -c {$sysConf} {$args}", "r"); $this->assertTrue($pipeFd !== false, 'running nomos failed'); $output = ""; while (($buffer = fgets($pipeFd, 4096)) !== false) { $output .= $buffer; } $retCode = pclose($pipeFd); unlink("{$sysConf}/mods-enabled/nomos/VERSION"); //unlink("$sysConf/mods-enabled/nomos"); //rmdir("$sysConf/mods-enabled"); unlink($confFile); return array($output, $retCode); }
private function setUpRepo() { $sysConf = $this->testDb->getFossSysConf(); $this->testInstaller = new TestInstaller($sysConf); $this->testInstaller->init(); $this->testInstaller->cpRepo(); $this->testInstaller->install($this->agentDir); }
public function testIt() { $sysConf = $this->testDb->getFossSysConf(); $returnCode = 0; $lines = array(); exec("./testlibs " . $sysConf . "/Db.conf", $lines, $returnCode); $this->assertEquals($expected = 0, $returnCode, "error: " . implode("\n", $lines)); }
protected function setUp() { $this->testDb = new TestPgDb("fossclitest"); $tables = array('users', 'upload', 'uploadtree_a', 'uploadtree', 'copyright', 'groups', 'group_user_member', 'agent', 'copyright_decision', 'copyright_ars', 'ars_master'); $this->testDb->createPlainTables($tables); $this->testDb->createInheritedTables(array('uploadtree_a')); $this->testDb->createInheritedArsTables(array('copyright')); $this->testDb->insertData($tables); $sysConf = $this->testDb->getFossSysConf(); $this->fo_copyright_list_path = dirname(__DIR__) . '/fo_copyright_list -c ' . $sysConf; $this->testInstaller = new TestInstaller($sysConf); $this->testInstaller->init(); }
public function testNullFile() { global $TEST_DATA_PATH; global $TEST_RESULT_PATH; $fossology_testconfig = $this->testDb->getFossSysConf(); $UNUNPACK_CMD = $this->agentDir . "/agent/ununpack"; if (!empty($TEST_RESULT_PATH)) { exec("/bin/rm -rf {$TEST_RESULT_PATH}"); } $command = "{$UNUNPACK_CMD} -qCR {$TEST_DATA_PATH}/null-file -d {$TEST_RESULT_PATH} -c {$fossology_testconfig} > /dev/null 2>&1"; $last = exec($command, $usageOut, $rtn); $this->assertNotEquals($rtn, 0); $this->assertFileNotExists("{$TEST_RESULT_PATH}/null-file.dir/"); }
private function runCopyright() { $sysConf = $this->testDb->getFossSysConf() . time(); mkdir($sysConf); copy($this->testDb->getFossSysConf() . "/Db.conf", "{$sysConf}/Db.conf"); system("touch " . $sysConf . "/fossology.conf"); $copyDir = dirname(dirname(dirname(dirname(__DIR__)))) . "/copyright/"; system("install -D {$copyDir}/VERSION-copyright {$sysConf}/mods-enabled/copyright/VERSION"); $retCode = 0; system("echo | " . $copyDir . "agent/copyright -c " . $sysConf . " 2>/dev/null", $retCode); $this->assertEquals(0, $retCode, 'this test requires a working copyright agent which creates the necessary tables'); unlink("{$sysConf}/mods-enabled/copyright/VERSION"); rmdir("{$sysConf}/mods-enabled/copyright"); rmdir("{$sysConf}/mods-enabled"); unlink($sysConf . "/fossology.conf"); unlink($sysConf . "/Db.conf"); rmdir($sysConf); }
function setUp() { global $TEST_DATA_PATH; global $TEST_RESULT_PATH; if (empty($TEST_DATA_PATH) || empty($TEST_RESULT_PATH)) { $this->markTestSkipped(); } $this->testDb = new TestPgDb('ununpackNormal'); $this->agentDir = dirname(dirname(__DIR__)) . "/"; $this->ununpack = $this->agentDir . "/agent/ununpack"; $sysConf = $this->testDb->getFossSysConf(); $this->testInstaller = new TestInstaller($sysConf); $this->testInstaller->init(); $this->testInstaller->install($this->agentDir); $this->testDb->createSequences(array(), true); $this->testDb->createPlainTables(array(), true); $this->testDb->alterTables(array(), true); }
public function run($uploadId, $userId = 2, $groupId = 2, $jobId = 1, $args = "") { $sysConf = $this->testDb->getFossSysConf(); $agentName = "spdx2"; $agentDir = dirname(dirname(__DIR__)); $execDir = "{$agentDir}/agent"; $pipeFd = popen($cmd = "echo {$uploadId} | {$execDir}/{$agentName} --userID={$userId} --groupID={$groupId} --jobId={$jobId} --scheduler_start -c {$sysConf} {$args}", "r"); $success = $pipeFd !== false; $output = ""; $retCode = -1; if ($success) { while (($buffer = fgets($pipeFd, 4096)) !== false) { $output .= $buffer; } $retCode = pclose($pipeFd); } else { print "failed opening pipe to {$cmd}"; } return array($success, $output, $retCode); }
private function runnerReuserScanWithARepoClearingEnhanced($runner) { $this->setUpTables(); $this->setUpRepo(); $originallyClearedItemId = 23; /* upload 3 in the test db is the same as upload 2 -> items 13-24 in upload 2 correspond to 33-44 */ $reusingUploadItemShift = 20; $this->dbManager->queryOnce("UPDATE uploadtree_a SET pfile_fk=351 WHERE uploadtree_pk={$originallyClearedItemId}+{$reusingUploadItemShift}", __METHOD__ . '.minorChange'); $this->uploadDao->addReusedUpload($uploadId = 3, $reusedUpload = 2, $this->groupId, $this->groupId, $reuseMode = 1); $repoPath = $this->testDb->getFossSysConf() . '/repo/files/'; $this->treeDao->shouldReceive('getRepoPathOfPfile')->with(4)->andReturn($repoPath . '04621571bcbabce75c4dd1c6445b87dec0995734.59cacdfce5051cd8a1d8a1f2dcce40a5.12320'); $this->treeDao->shouldReceive('getRepoPathOfPfile')->with(351)->andReturn($repoPath . 'c518ce1658140b65fa0132ad1130cb91512416bf.8e913e594d24ff3aeabe350107d97815.35829'); list($clearingLicense1, $clearingLicense2, $addedEventIds) = $this->insertDecisionFromTwoEvents(DecisionScopes::REPO, $originallyClearedItemId); $clearingLicenses = array($clearingLicense1, $clearingLicense2); list($success, $output, $retCode) = $runner->run($uploadId, $this->userId, $this->groupId); $this->assertTrue($success, 'cannot run runner'); $this->assertEquals($retCode, 0, 'reuser failed: ' . $output); $newUploadClearings = $this->getFilteredClearings($uploadId, $this->groupId); $potentiallyReusableClearings = $this->getFilteredClearings($reusedUpload, $this->groupId); assertThat($newUploadClearings, is(arrayWithSize(1))); assertThat($potentiallyReusableClearings, is(arrayWithSize(1))); /** @var ClearingDecision */ $potentiallyReusableClearing = $potentiallyReusableClearings[0]; /** @var ClearingDecision */ $newClearing = $newUploadClearings[0]; /* they are actually the same ClearingDecision * only sameFolder and sameUpload are different */ assertThat($newClearing, not(equalTo($potentiallyReusableClearing))); assertThat($newClearing->getClearingLicenses(), arrayContainingInAnyOrder($clearingLicenses)); assertThat($newClearing->getType(), equalTo($potentiallyReusableClearing->getType())); assertThat($newClearing->getScope(), equalTo($potentiallyReusableClearing->getScope())); assertThat($newClearing->getUploadTreeId(), equalTo($potentiallyReusableClearing->getUploadTreeId() + $reusingUploadItemShift)); /* reuser should have not created a correct local event history */ $bounds = $this->uploadDao->getItemTreeBounds($originallyClearedItemId + $reusingUploadItemShift); $newEvents = $this->clearingDao->getRelevantClearingEvents($bounds, $this->groupId); assertThat($newEvents, is(arrayWithSize(count($clearingLicenses)))); /** @var ClearingEvent $newEvent */ foreach ($newEvents as $newEvent) { assertThat($newEvent->getEventId(), anyOf($addedEventIds)); assertThat($newEvent->getClearingLicense(), anyOf($clearingLicenses)); } $this->rmRepo(); }
private function rmRepo() { $sysConf = $this->testDb->getFossSysConf(); system("rm {$sysConf}/repo -rf"); unlink($sysConf . "/fossology.conf"); }
private function rmRepo() { $sysConf = $this->testDb->getFossSysConf(); system("rm {$sysConf}/repo -rf"); }