FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
Nomos-fun-test.php
Go to the documentation of this file.
1 <?php
2 /***********************************************************
3  Copyright (C) 2013 Hewlett-Packard Development Company, L.P.
4  Copyright (C) 2015 Siemens AG
5 
6  This program is free software; you can redistribute it and/or
7  modify it under the terms of the GNU General Public License
8  version 2 as published by the Free Software Foundation.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License along
16  with this program; if not, write to the Free Software Foundation, Inc.,
17  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  ***********************************************************/
29 {
34  protected $testdir;
35 
40  protected function setUp()
41  {
42  parent::setUp();
43 
44  $this->testdir = dirname(dirname(__DIR__))."/agent_tests/testdata/NomosTestfiles/";
45  }
46 
56  public function testDiffNomos()
57  {
58  $sysConf = $this->testDb->getFossSysConf();
59  $nomos = $this->agentDir . "/agent/nomos";
60 
61  exec("find $this->testdir -type f -not \( -wholename \"*svn*\" \) -exec $nomos -c $sysConf -l '{}' + > scan.out", $out, $rtn);
62 
63  $file_correct = dirname(dirname(__FILE__))."/testdata/LastGoodNomosTestfilesScan";
64  $last = exec("wc -l < $file_correct");
65  $regtest_msg = "Right now, we have $last nomos regression tests\n";
66  print $regtest_msg;
67  $regtest_cmd = "echo '$regtest_msg' >./nomos-regression-test.html";
68  exec($regtest_cmd);
69  $old = str_replace('/','\/',dirname(dirname(__FILE__))."/testdata/");
70  exec("sed 's/ $old/ /g' ./scan.out > ./scan.out.r");
71  exec("sort $file_correct >./LastGoodNomosTestfilesScan.s");
72  exec("sort ./scan.out.r >./scan.out.s");
73  exec("diff ./LastGoodNomosTestfilesScan.s ./scan.out.s >./report.d", $out, $rtn);
74  $count = exec("cat report.d|wc -l", $out, $ret);
75  if ($count != 0) {
76  print "Some lines of licenses are different, see details below, or view ./report.d\n";
77  exec("cat ./report.d", $report);
78  foreach ($report as $line) print "$line\n";
79  }
80  $this->assertEquals($count,'0');
81  }
82 }
Runs regression test on NOMOS.
testDiffNomos()
Runs regression test on NOMOS based on LastGoodNomosTestfilesScan.
Tests for common CLI operations.
setUp()
Setup the test cases and initialize the objects.