FOSSology  4.4.0
Open Source License Compliance by Open Source Software
Nomos-fun-test.php
Go to the documentation of this file.
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2013 Hewlett-Packard Development Company, L.P.
4  SPDX-FileCopyrightText: © 2015 Siemens AG
5 
6  SPDX-License-Identifier: GPL-2.0-only
7 */
18 {
23  protected $testdir;
24 
29  protected function setUp() : void
30  {
31  parent::setUp();
32 
33  $this->testdir = dirname(dirname(__DIR__))."/agent_tests/testdata/NomosTestfiles/";
34  }
35 
45  public function testDiffNomos()
46  {
47  $sysConf = $this->testDb->getFossSysConf();
48  $nomos = $this->agentDir . "/agent/nomos";
49 
50  exec("find $this->testdir -type f -not \‍( -wholename \"*svn*\" \‍) -exec $nomos -c $sysConf -l '{}' + > scan.out", $out, $rtn);
51 
52  $file_correct = dirname(dirname(__FILE__))."/testdata/LastGoodNomosTestfilesScan";
53  $last = exec("wc -l < $file_correct");
54  $regtest_msg = "Right now, we have $last nomos regression tests\n";
55  print $regtest_msg;
56  $regtest_cmd = "echo '$regtest_msg' >./nomos-regression-test.html";
57  exec($regtest_cmd);
58  $old = str_replace('/','\/',dirname(dirname(__FILE__))."/testdata/");
59  exec("sed 's/ $old/ /g' ./scan.out > ./scan.out.r");
60  exec("sort $file_correct >./LastGoodNomosTestfilesScan.s");
61  exec("sort ./scan.out.r >./scan.out.s");
62  exec("diff ./LastGoodNomosTestfilesScan.s ./scan.out.s >./report.d", $out, $rtn);
63  $count = exec("cat report.d|wc -l", $out, $ret);
64  if ($count != 0) {
65  print "Some lines of licenses are different, see details below, or view ./report.d\n";
66  exec("cat ./report.d", $report);
67  foreach ($report as $line) print "$line\n";
68  }
69  $this->assertEquals($count,'0');
70  }
71 }
Tests for common CLI operations.
Runs regression test on NOMOS.
testDiffNomos()
Runs regression test on NOMOS based on LastGoodNomosTestfilesScan.
setUp()
Setup the test cases and initialize the objects.