8 require_once(
"./test_common.php");
20 public $SYSCONF_DIR =
"/usr/local/etc/fossology/";
29 public $fossology_testconfig;
32 public $scheduler_path;
38 public $fo_nomos_license_list_path;
47 global $fossology_testconfig;
48 global $scheduler_path;
50 global $fo_nomos_license_list_path;
52 fwrite(STDOUT,
"--> Running " . __METHOD__ .
" method.\n");
59 $fossology_testconfig = getenv(
'FOSSOLOGY_TESTCONFIG');
60 fwrite(STDOUT, __METHOD__ .
" got fossology_testconfig = '$fossology_testconfig'\n");
64 $fo_base_dir = realpath(__DIR__ .
'/../..');
65 $cp2foss_path = $fo_base_dir .
"/cli/cp2foss";
66 if (!is_executable($cp2foss_path)) {
67 print
"Error: cp2foss path '" . $cp2foss_path .
"' is not executable!\n";
70 $cp2foss_path .=
" -s ";
74 $fo_base_dir = realpath(__DIR__ .
'/../..');
75 $fo_nomos_license_list_path = $fo_base_dir .
"/cli/fo_nomos_license_list";
76 if (!is_executable($fo_nomos_license_list_path)) {
77 print
"Error: fo_nomos_license_list path '" . $fo_nomos_license_list_path .
"' is not executable!\n";
82 $scheduler_path = $fossology_testconfig .
"/mods-enabled/scheduler/agent/fo_scheduler";
83 if (!is_executable($scheduler_path)) {
84 print
"Error: Scheduler path '$scheduler_path' is not executable!\n";
89 $scheduler_cmd =
"$scheduler_path --daemon --reset --verbose=952 -c $fossology_testconfig";
90 print
"DEBUG: Starting scheduler with '$scheduler_cmd'\n";
91 exec($scheduler_cmd, $output, $return_var);
93 if ( $return_var != 0 ) {
94 print
"Error: Could not start scheduler '$scheduler_path'\n";
98 print
"\nStarting functional test for fo_nomos_license_list. \n";
104 protected function setUp() : void
107 fwrite(STDOUT,
"--> Running " . __METHOD__ .
" method.\n");
125 global $fossology_testconfig;
126 global $fo_nomos_license_list_path;
128 fwrite(STDOUT,
" ----> Running " . __METHOD__ .
"\n");
130 $upload_id = $upload[0];
132 $auth =
"--username fossy --password fossy -c $fossology_testconfig";
133 $uploadtree_id = $upload[1];
136 $command =
"$fo_nomos_license_list_path $auth -u $upload_id -t $uploadtree_id --container 1";
137 fwrite(STDOUT,
"DEBUG: Executing '$command'\n");
138 $last = exec(
"$command 2>&1", $out, $rtn);
139 $output_msg_count = count($out);
141 sort($out, SORT_STRING);
144 $this->assertEquals(9, $output_msg_count,
" upload[1] is:$upload[1], Test that the number of output lines from '$command' is $output_msg_count, have 9 licenses");
146 $this->assertEquals(
"test package/usr/include/libfossdb.h: LGPL-2.1", $out[0]);
147 fwrite(STDOUT,
"DEBUG: Done running " . __METHOD__ .
"\n");
151 $command =
"$fo_nomos_license_list_path $auth -u $upload_id -t $uploadtree_id";
152 fwrite(STDOUT,
"DEBUG: Executing '$command'\n");
153 $last = exec(
"$command 2>&1", $out, $rtn);
154 $output_msg_count = count($out);
156 sort($out, SORT_STRING);
158 $this->assertEquals(4, $output_msg_count,
"Test that the number of output lines from '$command' is $output_msg_count, have 9 licenses");
160 $this->assertEquals(
"test package/usr/include/libfossdb.h: LGPL-2.1", $out[0]);
161 fwrite(STDOUT,
"DEBUG: Done running " . __METHOD__ .
"\n");
170 global $fossology_testconfig;
171 global $cp2foss_path;
173 $test_dbh = connect_to_DB($fossology_testconfig);
175 $auth =
"--username fossy --password fossy -c $fossology_testconfig";
179 $command =
"$cp2foss_path $auth http://www.fossology.org/testdata/rpms/fedora/10/i386/fossology-devel-1.1.0-1.fc10.i386.rpm -d 'fossology des' -f 'fossology path' -n 'test package' -q 'all'";
180 fwrite(STDOUT,
"DEBUG: Executing '$command'\n");
181 $last = exec(
"$command 2>&1", $out, $rtn);
185 if ($out && $out[5]) {
186 $upload_id = get_upload_id($out[5]);
188 $this->assertFalse(
true);
191 $agent_status = check_agent_status($test_dbh,
"ununpack", $upload_id);
192 $this->assertEquals(1, $agent_status);
194 $uploadtree_id = get_uploadtree_id($test_dbh, $upload_id);
198 fwrite(STDOUT,
"DEBUG: upload_id is:$upload_id, uploadtree_id, is:$uploadtree_id\n");
199 return array($upload_id, $uploadtree_id);
207 global $fossology_testconfig;
208 global $fo_nomos_license_list_path;
211 fwrite(STDOUT,
" ----> Running " . __METHOD__ .
"\n");
212 $auth =
"--user fossy --password fossy -c $fossology_testconfig";
215 $command =
"$fo_nomos_license_list_path $auth -h";
216 fwrite(STDOUT,
"DEBUG: Executing '$command'\n");
217 $last = exec(
"$command 2>&1", $out, $rtn);
218 $output_msg_count = count($out);
219 $this->assertEquals(14, $output_msg_count,
"Test that the number of output lines from '$command' is $output_msg_count");
224 $command =
"$fo_nomos_license_list_path -h";
225 fwrite(STDOUT,
"DEBUG: Executing '$command'\n");
226 $last = exec(
"$command 2>&1", $out, $rtn);
227 $output_msg_count = count($out);
228 $this->assertEquals(14, $output_msg_count,
"Test that the number of output lines from '$command' is $output_msg_count");
230 fwrite(STDOUT,
"DEBUG: Done running " . __METHOD__ .
"\n");
240 global $fossology_testconfig;
242 fwrite(STDOUT,
"--> Running " . __METHOD__ .
" method.\n");
252 public static function tearDownAfterClass() : void
255 global $fossology_testconfig;
256 global $scheduler_path;
257 fwrite(STDOUT,
"--> Running " . __METHOD__ .
" method.\n");
260 print
"Stopping the scheduler\n";
261 $scheduler_cmd =
"$scheduler_path -k -c $fossology_testconfig";
262 print
"DEBUG: command is $scheduler_cmd \n";
263 exec($scheduler_cmd, $output, $return_var);
264 if ( $return_var != 0 ) {
265 print
"Error: Could not stop scheduler via '$scheduler_cmd'\n";
272 print
"End of functional tests for fo_nomos_license_list\n";
test cli fo_nomos_license_list
upload_from_url()
populate test data via upload from url
static setUpBeforeClass()
test_get_nomos_list()
first populate test data via upload from url, then get nomos license list
test_others()
help msg, etc