19 require_once(
"./test_common.php");
31 public $SYSCONF_DIR =
"/usr/local/etc/fossology/";
40 public $fossology_testconfig;
43 public $scheduler_path;
49 public $fo_nomos_license_list_path;
58 global $fossology_testconfig;
59 global $scheduler_path;
61 global $fo_nomos_license_list_path;
63 fwrite(STDOUT,
"--> Running " . __METHOD__ .
" method.\n");
70 $fossology_testconfig = getenv(
'FOSSOLOGY_TESTCONFIG');
71 fwrite(STDOUT, __METHOD__ .
" got fossology_testconfig = '$fossology_testconfig'\n");
75 $fo_base_dir = realpath(__DIR__ .
'/../..');
76 $cp2foss_path = $fo_base_dir .
"/cli/cp2foss";
77 if (!is_executable($cp2foss_path)) {
78 print
"Error: cp2foss path '" . $cp2foss_path .
"' is not executable!\n";
81 $cp2foss_path .=
" -s ";
85 $fo_base_dir = realpath(__DIR__ .
'/../..');
86 $fo_nomos_license_list_path = $fo_base_dir .
"/cli/fo_nomos_license_list";
87 if (!is_executable($fo_nomos_license_list_path)) {
88 print
"Error: fo_nomos_license_list path '" . $fo_nomos_license_list_path .
"' is not executable!\n";
93 $scheduler_path = $fossology_testconfig .
"/mods-enabled/scheduler/agent/fo_scheduler";
94 if (!is_executable($scheduler_path)) {
95 print
"Error: Scheduler path '$scheduler_path' is not executable!\n";
100 $scheduler_cmd =
"$scheduler_path --daemon --reset --verbose=952 -c $fossology_testconfig";
101 print
"DEBUG: Starting scheduler with '$scheduler_cmd'\n";
102 exec($scheduler_cmd, $output, $return_var);
104 if ( $return_var != 0 ) {
105 print
"Error: Could not start scheduler '$scheduler_path'\n";
109 print
"\nStarting functional test for fo_nomos_license_list. \n";
115 protected function setUp()
118 fwrite(STDOUT,
"--> Running " . __METHOD__ .
" method.\n");
136 global $fossology_testconfig;
137 global $fo_nomos_license_list_path;
139 fwrite(STDOUT,
" ----> Running " . __METHOD__ .
"\n");
141 $upload_id = $upload[0];
143 $auth =
"--username fossy --password fossy -c $fossology_testconfig";
144 $uploadtree_id = $upload[1];
147 $command =
"$fo_nomos_license_list_path $auth -u $upload_id -t $uploadtree_id --container 1";
148 fwrite(STDOUT,
"DEBUG: Executing '$command'\n");
149 $last = exec(
"$command 2>&1", $out, $rtn);
150 $output_msg_count = count($out);
152 sort($out, SORT_STRING);
155 $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");
157 $this->assertEquals(
"test package/usr/include/libfossdb.h: LGPL-2.1", $out[0]);
158 fwrite(STDOUT,
"DEBUG: Done running " . __METHOD__ .
"\n");
162 $command =
"$fo_nomos_license_list_path $auth -u $upload_id -t $uploadtree_id";
163 fwrite(STDOUT,
"DEBUG: Executing '$command'\n");
164 $last = exec(
"$command 2>&1", $out, $rtn);
165 $output_msg_count = count($out);
167 sort($out, SORT_STRING);
169 $this->assertEquals(4, $output_msg_count,
"Test that the number of output lines from '$command' is $output_msg_count, have 9 licenses");
171 $this->assertEquals(
"test package/usr/include/libfossdb.h: LGPL-2.1", $out[0]);
172 fwrite(STDOUT,
"DEBUG: Done running " . __METHOD__ .
"\n");
181 global $fossology_testconfig;
182 global $cp2foss_path;
184 $test_dbh = connect_to_DB($fossology_testconfig);
186 $auth =
"--username fossy --password fossy -c $fossology_testconfig";
190 $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'";
191 fwrite(STDOUT,
"DEBUG: Executing '$command'\n");
192 $last = exec(
"$command 2>&1", $out, $rtn);
196 if ($out && $out[5]) {
197 $upload_id = get_upload_id($out[5]);
199 $this->assertFalse(
true);
202 $agent_status = check_agent_status($test_dbh,
"ununpack", $upload_id);
203 $this->assertEquals(1, $agent_status);
205 $uploadtree_id = get_uploadtree_id($test_dbh, $upload_id);
209 fwrite(STDOUT,
"DEBUG: upload_id is:$upload_id, uploadtree_id, is:$uploadtree_id\n");
210 return array($upload_id, $uploadtree_id);
218 global $fossology_testconfig;
219 global $fo_nomos_license_list_path;
222 fwrite(STDOUT,
" ----> Running " . __METHOD__ .
"\n");
223 $auth =
"--user fossy --password fossy -c $fossology_testconfig";
226 $command =
"$fo_nomos_license_list_path $auth -h";
227 fwrite(STDOUT,
"DEBUG: Executing '$command'\n");
228 $last = exec(
"$command 2>&1", $out, $rtn);
229 $output_msg_count = count($out);
230 $this->assertEquals(14, $output_msg_count,
"Test that the number of output lines from '$command' is $output_msg_count");
235 $command =
"$fo_nomos_license_list_path -h";
236 fwrite(STDOUT,
"DEBUG: Executing '$command'\n");
237 $last = exec(
"$command 2>&1", $out, $rtn);
238 $output_msg_count = count($out);
239 $this->assertEquals(14, $output_msg_count,
"Test that the number of output lines from '$command' is $output_msg_count");
241 fwrite(STDOUT,
"DEBUG: Done running " . __METHOD__ .
"\n");
251 global $fossology_testconfig;
253 fwrite(STDOUT,
"--> Running " . __METHOD__ .
" method.\n");
263 public static function tearDownAfterClass()
266 global $fossology_testconfig;
267 global $scheduler_path;
268 fwrite(STDOUT,
"--> Running " . __METHOD__ .
" method.\n");
271 print
"Stopping the scheduler\n";
272 $scheduler_cmd =
"$scheduler_path -k -c $fossology_testconfig";
273 print
"DEBUG: command is $scheduler_cmd \n";
274 exec($scheduler_cmd, $output, $return_var);
275 if ( $return_var != 0 ) {
276 print
"Error: Could not stop scheduler via '$scheduler_cmd'\n";
283 print
"End of functional tests for fo_nomos_license_list\n";
test_get_nomos_list()
first populate test data via upload from url, then get nomos license list
static setUpBeforeClass()
upload_from_url()
populate test data via upload from url
test cli fo_nomos_license_list
test_others()
help msg, etc