Best Phoronix-test-suite code snippet using pts_tests.call_test_script
pts_test_execution.php
Source:pts_test_execution.php
...74 $time_test_start = time();75 pts_client::$display->test_run_start($test_run_manager, $test_run_request);76 if(!$cache_share_present)77 {78 $pre_output = pts_tests::call_test_script($test_run_request->test_profile, 'pre', 'Running Pre-Test Script', $pts_test_arguments, $extra_runtime_variables, true);79 if($pre_output != null && (pts_client::is_debug_mode() || $full_output))80 {81 pts_client::$display->test_run_instance_output($pre_output);82 }83 if(is_file($test_directory . 'pre-test-exit-status'))84 {85 // If the pre script writes its exit status to ~/pre-test-exit-status, if it's non-zero the test run failed86 $exit_status = pts_file_io::file_get_contents($test_directory . 'pre-test-exit-status');87 unlink($test_directory . 'pre-test-exit-status');88 if($exit_status != 0)89 {90 self::test_run_instance_error($test_run_manager, $test_run_request, 'The pre run script exited with a non-zero exit status.' . PHP_EOL);91 self::test_run_error($test_run_manager, $test_run_request, 'This test execution has been abandoned.');92 return false;93 }94 }95 }96 pts_client::$display->display_interrupt_message($test_run_request->test_profile->get_pre_run_message());97 $runtime_identifier = time();98 $execute_binary_prepend = '';99 if($test_run_request->exec_binary_prepend != null)100 {101 $execute_binary_prepend = $test_run_request->exec_binary_prepend;102 }103 if(!$cache_share_present && $test_run_request->test_profile->is_root_required())104 {105 if(phodevi::is_root() == false)106 {107 pts_client::$display->test_run_error('This test must be run as the root / administrator account.');108 }109 $execute_binary_prepend .= ' ' . PTS_CORE_STATIC_PATH . 'root-access.sh ';110 }111 if($allow_cache_share && !is_file($cache_share_pt2so))112 {113 $cache_share = new pts_storage_object(false, false);114 }115 if($test_run_manager->get_results_identifier() != null && $test_run_manager->get_file_name() != null && pts_config::read_bool_config('PhoronixTestSuite/Options/Testing/SaveTestLogs', 'FALSE'))116 {117 $backup_test_log_dir = PTS_SAVE_RESULTS_PATH . $test_run_manager->get_file_name() . '/test-logs/active/' . $test_run_manager->get_results_identifier() . '/';118 pts_file_io::delete($backup_test_log_dir);119 pts_file_io::mkdir($backup_test_log_dir, 0777, true);120 }121 else122 {123 $backup_test_log_dir = false;124 }125 for($i = 0, $abort_testing = false, $time_test_start_actual = time(), $defined_times_to_run = $times_to_run; $i < $times_to_run && $i < 256 && !$abort_testing; $i++)126 {127 pts_client::$display->test_run_instance_header($test_run_request);128 $test_log_file = $test_directory . basename($test_identifier) . '-' . $runtime_identifier . '-' . ($i + 1) . '.log';129 $is_expected_last_run = ($i == ($times_to_run - 1));130 $test_extra_runtime_variables = array_merge($extra_runtime_variables, array(131 'LOG_FILE' => $test_log_file,132 'DISPLAY' => getenv('DISPLAY'),133 'PATH' => getenv('PATH'),134 ));135 $restored_from_cache = false;136 if($cache_share_present)137 {138 $cache_share = pts_storage_object::recover_from_file($cache_share_pt2so);139 if($cache_share)140 {141 $test_result = $cache_share->read_object('test_results_output_' . $i);142 $test_extra_runtime_variables['LOG_FILE'] = $cache_share->read_object('log_file_location_' . $i);143 if($test_extra_runtime_variables['LOG_FILE'] != null)144 {145 file_put_contents($test_extra_runtime_variables['LOG_FILE'], $cache_share->read_object('log_file_' . $i));146 $test_run_time = 0; // This wouldn't be used for a cache share since it would always be the same, but declare the value so the variable is at least initialized147 $restored_from_cache = true;148 }149 }150 unset($cache_share);151 }152 if($restored_from_cache == false)153 {154 $test_run_command = 'cd ' . $to_execute . ' && ' . $execute_binary_prepend . './' . $execute_binary . ' ' . $pts_test_arguments . ' 2>&1';155 pts_client::test_profile_debug_message('Test Run Command: ' . $test_run_command);156 $is_monitoring = pts_test_result_parser::system_monitor_task_check($test_run_request->test_profile);157 $test_run_time_start = time();158 if(phodevi::is_windows() || pts_client::read_env('USE_PHOROSCRIPT_INTERPRETER') != false)159 {160 $phoroscript = new pts_phoroscript_interpreter($to_execute . '/' . $execute_binary, $test_extra_runtime_variables, $to_execute);161 $phoroscript->execute_script($pts_test_arguments);162 $test_result = null;163 }164 else165 {166 //$test_result = pts_client::shell_exec($test_run_command, $test_extra_runtime_variables);167 $descriptorspec = array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w'));168 $test_process = proc_open('exec ' . $execute_binary_prepend . './' . $execute_binary . ' ' . $pts_test_arguments . ' 2>&1', $descriptorspec, $pipes, $to_execute, array_merge($_ENV, pts_client::environmental_variables(), $test_extra_runtime_variables));169 if(is_resource($test_process))170 {171 //echo proc_get_status($test_process)['pid'];172 pts_module_manager::module_process('__test_running', $test_process);173 $test_result = stream_get_contents($pipes[1]);174 fclose($pipes[1]);175 fclose($pipes[2]);176 $return_value = proc_close($test_process);177 }178 }179 $test_run_time = time() - $test_run_time_start;180 $monitor_result = $is_monitoring ? pts_test_result_parser::system_monitor_task_post_test($test_run_request->test_profile) : 0;181 }182 if(!isset($test_result[10240]) || pts_client::is_debug_mode() || $full_output)183 {184 pts_client::$display->test_run_instance_output($test_result);185 }186 if(is_file($test_log_file) && trim($test_result) == null && (filesize($test_log_file) < 10240 || pts_client::is_debug_mode() || $full_output))187 {188 $test_log_file_contents = file_get_contents($test_log_file);189 pts_client::$display->test_run_instance_output($test_log_file_contents);190 unset($test_log_file_contents);191 }192 $test_run_request->test_result_standard_output = $test_result;193 $exit_status_pass = true;194 if(is_file($test_directory . 'test-exit-status'))195 {196 // If the test script writes its exit status to ~/test-exit-status, if it's non-zero the test run failed197 $exit_status = pts_file_io::file_get_contents($test_directory . 'test-exit-status');198 unlink($test_directory . 'test-exit-status');199 if($exit_status != 0)200 {201 self::test_run_instance_error($test_run_manager, $test_run_request, 'The test exited with a non-zero exit status.');202 if($is_expected_last_run && is_file($test_log_file))203 {204 $scan_log = pts_file_io::file_get_contents($test_log_file);205 $test_run_error = pts_tests::scan_for_error($scan_log, $test_run_request->test_profile->get_test_executable_dir());206 if($test_run_error)207 {208 self::test_run_instance_error($test_run_manager, $test_run_request, 'E: ' . $test_run_error);209 }210 }211 $exit_status_pass = false;212 }213 }214 if(!in_array(($i + 1), $ignore_runs) && $exit_status_pass)215 {216 if(isset($monitor_result) && $monitor_result != 0)217 {218 $test_run_request->active->active_result = $monitor_result;219 }220 else221 {222 pts_test_result_parser::parse_result($test_run_request, $test_extra_runtime_variables['LOG_FILE']);223 }224 pts_client::test_profile_debug_message('Test Result Value: ' . $test_run_request->active->active_result);225 if(!empty($test_run_request->active->active_result))226 {227 if($test_run_time < 2 && intval($test_run_request->active->active_result) == $test_run_request->active->active_result && $test_run_request->test_profile->get_estimated_run_time() > 60 && !$restored_from_cache)228 {229 // If the test ended in less than two seconds, outputted some int, and normally the test takes much longer, then it's likely some invalid run230 self::test_run_instance_error($test_run_manager, $test_run_request, 'The test run ended prematurely.');231 if($is_expected_last_run && is_file($test_log_file))232 {233 $scan_log = pts_file_io::file_get_contents($test_log_file);234 $test_run_error = pts_tests::scan_for_error($scan_log, $test_run_request->test_profile->get_test_executable_dir());235 if($test_run_error)236 {237 self::test_run_instance_error($test_run_manager, $test_run_request, 'E: ' . $test_run_error);238 }239 }240 }241 else242 {243 // TODO integrate active_result into active buffer244 $active_result_buffer->add_trial_run_result($test_run_request->active->active_result, $test_run_request->active->active_min_result, $test_run_request->active->active_max_result);245 }246 }247 else if($test_run_request->test_profile->get_display_format() != 'NO_RESULT')248 {249 self::test_run_instance_error($test_run_manager, $test_run_request, 'The test run did not produce a result.');250 if($is_expected_last_run && is_file($test_log_file))251 {252 $scan_log = pts_file_io::file_get_contents($test_log_file);253 $test_run_error = pts_tests::scan_for_error($scan_log, $test_run_request->test_profile->get_test_executable_dir());254 if($test_run_error)255 {256 self::test_run_instance_error($test_run_manager, $test_run_request, 'E: ' . $test_run_error);257 }258 }259 }260 if($allow_cache_share && !is_file($cache_share_pt2so))261 {262 $cache_share->add_object('test_results_output_' . $i, $test_run_request->active->active_result);263 $cache_share->add_object('log_file_location_' . $i, $test_extra_runtime_variables['LOG_FILE']);264 $cache_share->add_object('log_file_' . $i, (is_file($test_log_file) ? file_get_contents($test_log_file) : null));265 }266 }267 if($is_expected_last_run && $active_result_buffer->get_trial_run_count() > floor(($i - 2) / 2) && !$cache_share_present && $test_run_manager->do_dynamic_run_count())268 {269 // The later check above ensures if the test is failing often the run count won't uselessly be increasing270 // Should we increase the run count?271 $increase_run_count = false;272 if($defined_times_to_run == ($i + 1) && $active_result_buffer->get_trial_run_count() > 0 && $active_result_buffer->get_trial_run_count() < $defined_times_to_run && $i < 64)273 {274 // At least one run passed, but at least one run failed to produce a result. Increase count to try to get more successful runs275 $increase_run_count = $defined_times_to_run - $active_result_buffer->get_trial_run_count();276 }277 else if($active_result_buffer->get_trial_run_count() >= 2)278 {279 // Dynamically increase run count if needed for statistical significance or other reasons280 $increase_run_count = $test_run_manager->increase_run_count_check($active_result_buffer, $defined_times_to_run, $test_run_time);281 if($increase_run_count === -1)282 {283 $abort_testing = true;284 }285 else if($increase_run_count == true)286 {287 // Just increase the run count one at a time288 $increase_run_count = 1;289 }290 }291 if($increase_run_count > 0)292 {293 $times_to_run += $increase_run_count;294 $is_expected_last_run = false;295 //$test_run_request->test_profile->set_times_to_run($times_to_run);296 }297 }298 if($times_to_run > 1 && $i < ($times_to_run - 1))299 {300 if($cache_share_present == false)301 {302 $interim_output = pts_tests::call_test_script($test_run_request->test_profile, 'interim', 'Running Interim Test Script', $pts_test_arguments, $extra_runtime_variables, true);303 if($interim_output != null && (pts_client::is_debug_mode() || $full_output))304 {305 pts_client::$display->test_run_instance_output($interim_output);306 }307 //sleep(2); // Rest for a moment between tests308 }309 pts_module_manager::module_process('__interim_test_run', $test_run_request);310 }311 if(is_file($test_log_file))312 {313 if($is_expected_last_run)314 {315 // For now just passing the last test log file...316 // TODO XXX: clean this up with log files to preserve when needed, let multiple log files exist for extra_data, etc317 pts_test_result_parser::generate_extra_data($test_run_request, $test_log_file);318 }319 if($backup_test_log_dir)320 {321 copy($test_log_file, $backup_test_log_dir . basename($test_log_file));322 }323 if(pts_client::test_profile_debug_message('Log File At: ' . $test_log_file) == false)324 {325 unlink($test_log_file);326 }327 }328 if(is_file(PTS_USER_PATH . 'halt-testing') || is_file(PTS_USER_PATH . 'skip-test'))329 {330 pts_client::release_lock($lock_file);331 return false;332 }333 pts_client::$display->test_run_instance_complete($test_run_request);334 }335 $time_test_end_actual = time();336 if($cache_share_present == false)337 {338 $post_output = pts_tests::call_test_script($test_run_request->test_profile, 'post', 'Running Post-Test Script', $pts_test_arguments, $extra_runtime_variables, true);339 if($post_output != null && (pts_client::is_debug_mode() || $full_output))340 {341 pts_client::$display->test_run_instance_output($post_output);342 }343 if(is_file($test_directory . 'post-test-exit-status'))344 {345 // If the post script writes its exit status to ~/post-test-exit-status, if it's non-zero the test run failed346 $exit_status = pts_file_io::file_get_contents($test_directory . 'post-test-exit-status');347 unlink($test_directory . 'post-test-exit-status');348 if($exit_status != 0)349 {350 self::test_run_instance_error($test_run_manager, $test_run_request, 'The post run script exited with a non-zero exit status.' . PHP_EOL);351 $abort_testing=true;352 }...
call_test_script
Using AI Code Generation
1$test = new pts_test();2$test->test_profile = new pts_test_profile('test-profile');3$test->test_profile->set_test_hardware_type('CPU');4$test->test_profile->set_test_software_type('Benchmark');5$test->test_profile->set_test_executable('test-executable');6$test->test_profile->set_test_arguments('test-arguments');
call_test_script
Using AI Code Generation
1require_once('pts-core/pts_tests.php');2$test = new pts_test('test1');3$test->call_test_script('test2');4require_once('pts-core/pts_tests.php');5$test = new pts_test('test1');6$test->call_test_script('test3');7require_once('pts-core/pts_tests.php');8$test = new pts_test('test1');9$test->call_test_script('test4');10require_once('pts-core/pts_tests.php');11$test = new pts_test('test1');12$test->call_test_script('test5');13require_once('pts-core/pts_tests.php');14$test = new pts_test('test1');15$test->call_test_script('test6');16require_once('pts-core/pts_tests.php');17$test = new pts_test('test1');18$test->call_test_script('test7');19require_once('pts-core/pts_tests.php');20$test = new pts_test('test1');21$test->call_test_script('test8');22require_once('pts-core/pts_tests.php');23$test = new pts_test('test1');24$test->call_test_script('test9');25require_once('pts-core/pts_tests.php');26$test = new pts_test('test1');27$test->call_test_script('test10');28require_once('pts-core/pts_tests.php');
call_test_script
Using AI Code Generation
1require_once('pts-core/pts_tests.php');2$test = new pts_test_profile('test');3$test->set_test_executable('test.sh');4$test->set_test_arguments('test.sh');5$test->set_test_installation('test.sh');6$test->set_test_profile('test.sh');7$test->set_test_profile('test.sh');8echo $test->call_test_script('test.sh', 'test.sh');9require_once('pts-core/pts_test_profile.php');10$test = new pts_test_profile('test');11$test->set_test_executable('test.sh');12$test->set_test_arguments('test.sh');13$test->set_test_installation('test.sh');14$test->set_test_profile('test.sh');15$test->set_test_profile('test.sh');16echo $test->call_test_script('test.sh', 'test.sh');17require_once('pts-core/pts_test_result.php');18$test = new pts_test_result('test');19$test->set_test_executable('test.sh');20$test->set_test_arguments('test.sh');21$test->set_test_installation('test.sh');22$test->set_test_profile('test.sh');23$test->set_test_profile('test.sh');24echo $test->call_test_script('test.sh', 'test.sh');25require_once('pts-core/pts_test_run_request.php');26$test = new pts_test_run_request('test');27$test->set_test_executable('test.sh');28$test->set_test_arguments('test.sh');29$test->set_test_installation('test.sh');30$test->set_test_profile('test.sh');31$test->set_test_profile('test.sh');32echo $test->call_test_script('test.sh', 'test.sh');33require_once('pts-core/pts_test_run_manager.php');34$test = new pts_test_run_manager('test');35$test->set_test_executable('test.sh');36$test->set_test_arguments('test.sh');37$test->set_test_installation('test.sh');
call_test_script
Using AI Code Generation
1require_once('pts_tests.php');2$test = new pts_tests();3echo $test->call_test_script('1.php');4Code : require_once('pts_tests.php'); $test = new pts_tests(); echo $test->call_test_script('1.php');5Code : echo shell_exec('php 1.php');6Code : $test = new pts_tests(); echo $test->call_test_script('1.php');
call_test_script
Using AI Code Generation
1$output = pts_tests::call_test_script('test_name', 'test_script_name');2echo $output;3$output = pts_tests::call_test_script('test_name', 'test_script_name');4echo $output;5$output = pts_tests::call_test_script('test_name', 'test_script_name');6echo $output;7$output = pts_tests::call_test_script('test_name', 'test_script_name');8echo $output;9$output = pts_tests::call_test_script('test_name', 'test_script_name');10echo $output;
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Execute automation tests with call_test_script on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.
Test now for FreeGet 100 minutes of automation test minutes FREE!!