FOSSology  4.4.0
Open Source License Compliance by Open Source Software
SchedulerTestRunnerCli.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2021 Siemens AG
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
8 namespace Fossology\CliXml\Test;
9 
11 
12 include_once(__DIR__.'/../../../lib/php/Test/Agent/AgentTestMockHelper.php');
13 include_once(__DIR__.'/SchedulerTestRunner.php');
14 
16 {
18  private $testDb;
19 
20  public function __construct(TestPgDb $testDb)
21  {
22  $this->testDb = $testDb;
23  }
24 
25  public function run($uploadId, $userId=2, $groupId=2, $jobId=1, $args="")
26  {
27  $sysConf = $this->testDb->getFossSysConf();
28 
29  $agentName = "clixml";
30 
31  $agentDir = dirname(dirname(__DIR__));
32  $execDir = "$agentDir/agent";
33 
34  $pipeFd = popen($cmd = "echo $uploadId | $execDir/$agentName --userID=$userId --groupID=$groupId --jobId=$jobId --scheduler_start -c $sysConf $args", "r");
35  $success = $pipeFd !== false;
36 
37  $output = "";
38  $retCode = -1;
39  if ($success) {
40  while (($buffer = fgets($pipeFd, 4096)) !== false) {
41  $output .= $buffer;
42  }
43  $retCode = pclose($pipeFd);
44  } else {
45  print "failed opening pipe to $cmd";
46  }
47 
48  return array($success, $output, $retCode);
49  }
50 }
int Test
Definition: util.c:20