How to use test_run_error method of pts_test_execution class

Best Phoronix-test-suite code snippet using pts_test_execution.test_run_error

pts_test_execution.php

Source:pts_test_execution.php Github

copy

Full Screen

...16 along with this program. If not, see <http://www.gnu.org/licenses/>.17*/18class pts_test_execution19{20 protected static function test_run_error(&$test_run_manager, &$test_run_request, $error_msg)21 {22 $error_obj = array($test_run_manager, $test_run_request, $error_msg);23 pts_module_manager::module_process('__event_run_error', $error_obj);24 pts_client::$display->test_run_error($error_msg);25 }26 protected static function test_run_instance_error(&$test_run_manager, &$test_run_request, $error_msg)27 {28 $error_obj = array($test_run_manager, $test_run_request, $error_msg);29 pts_module_manager::module_process('__event_run_error', $error_obj);30 pts_client::$display->test_run_instance_error($error_msg);31 }32 public static function run_test(&$test_run_manager, &$test_run_request)33 {34 $test_identifier = $test_run_request->test_profile->get_identifier();35 $extra_arguments = $test_run_request->get_arguments();36 $arguments_description = $test_run_request->get_arguments_description();37 $full_output = pts_config::read_bool_config('PhoronixTestSuite/Options/General/FullOutput', 'FALSE');38 // Do the actual test running process39 $test_directory = $test_run_request->test_profile->get_install_dir();40 if(!is_dir($test_directory))41 {42 return false;43 }44 $lock_file = $test_directory . 'run_lock';45 if(pts_client::create_lock($lock_file) == false && $test_run_manager->is_multi_test_stress_run() == false)46 {47 self::test_run_error($test_run_manager, $test_run_request, 'The ' . $test_identifier . ' test is already running.');48 return false;49 }50 $active_result_buffer = new pts_test_result_buffer_active();51 $test_run_request->active = &$active_result_buffer;52 $execute_binary = $test_run_request->test_profile->get_test_executable();53 $times_to_run = $test_run_request->test_profile->get_times_to_run();54 $ignore_runs = $test_run_request->test_profile->get_runs_to_ignore();55 $test_type = $test_run_request->test_profile->get_test_hardware_type();56 $allow_cache_share = $test_run_request->test_profile->allow_cache_share();57 $min_length = $test_run_request->test_profile->get_min_length();58 $max_length = $test_run_request->test_profile->get_max_length();59 if($test_run_request->test_profile->get_environment_testing_size() > 1 && ceil(disk_free_space($test_directory) / 1048576) < $test_run_request->test_profile->get_environment_testing_size())60 {61 // Ensure enough space is available on disk during testing process62 self::test_run_error($test_run_manager, $test_run_request, 'There is not enough space (at ' . $test_directory . ') for this test to run.');63 pts_client::release_lock($lock_file);64 return false;65 }66 $to_execute = $test_run_request->test_profile->get_test_executable_dir();67 $pts_test_arguments = trim($test_run_request->test_profile->get_default_arguments() . ' ' . str_replace($test_run_request->test_profile->get_default_arguments(), '', $extra_arguments) . ' ' . $test_run_request->test_profile->get_default_post_arguments());68 $extra_runtime_variables = pts_tests::extra_environmental_variables($test_run_request->test_profile);69 // Start70 $cache_share_pt2so = $test_directory . 'cache-share-' . PTS_INIT_TIME . '.pt2so';71 $cache_share_present = $allow_cache_share && is_file($cache_share_pt2so);72 $test_run_request->set_used_arguments_description($arguments_description);73 pts_module_manager::module_process('__pre_test_run', $test_run_request);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 }353 }354 }355 if($abort_testing)356 {357 self::test_run_error($test_run_manager, $test_run_request, 'This test execution has been abandoned.');358 return false;359 }360 // End361 $time_test_end = time();362 $time_test_elapsed = $time_test_end - $time_test_start;363 $time_test_elapsed_actual = $time_test_end_actual - $time_test_start_actual;364 if(!empty($min_length))365 {366 if($min_length > $time_test_elapsed_actual)367 {368 // The test ended too quickly, results are not valid369 self::test_run_error($test_run_manager, $test_run_request, 'This test ended prematurely.');370 return false;371 }372 }373 if(!empty($max_length))374 {375 if($max_length < $time_test_elapsed_actual)376 {377 // The test took too much time, results are not valid378 self::test_run_error($test_run_manager, $test_run_request, 'This test run was exhausted.');379 return false;380 }381 }382 if($allow_cache_share && !is_file($cache_share_pt2so) && $cache_share instanceof pts_storage_object)383 {384 $cache_share->save_to_file($cache_share_pt2so);385 unset($cache_share);386 }387 if($test_run_manager->get_results_identifier() != null && (pts_config::read_bool_config('PhoronixTestSuite/Options/Testing/SaveInstallationLogs', 'FALSE')))388 {389 if(is_file($test_run_request->test_profile->get_install_dir() . 'install.log'))390 {391 $backup_log_dir = PTS_SAVE_RESULTS_PATH . $test_run_manager->get_file_name() . '/installation-logs/' . $test_run_manager->get_results_identifier() . '/';392 pts_file_io::mkdir($backup_log_dir, 0777, true);...

Full Screen

Full Screen

test_run_error

Using AI Code Generation

copy

Full Screen

1require_once('pts-core/pts_test_execution.php');2$test_run_error = pts_test_execution::test_run_error('test_run_error', 0);3echo $test_run_error;4require_once('pts-core/pts_test_execution.php');5$test_run_error = pts_test_execution::test_run_error('test_run_error', 1);6echo $test_run_error;7require_once('pts-core/pts_test_execution.php');8$test_run_error = pts_test_execution::test_run_error('test_run_error', 2);9echo $test_run_error;10require_once('pts-core/pts_test_execution.php');11$test_run_error = pts_test_execution::test_run_error('test_run_error', 3);12echo $test_run_error;13require_once('pts-core/pts_test_execution.php');14$test_run_error = pts_test_execution::test_run_error('test_run_error', 4);15echo $test_run_error;16require_once('pts-core/pts_test_execution.php');17$test_run_error = pts_test_execution::test_run_error('test_run_error', 5);18echo $test_run_error;19require_once('pts-core/pts_test_execution.php');20$test_run_error = pts_test_execution::test_run_error('test_run_error', 6);21echo $test_run_error;22require_once('pts-core/pts_test_execution.php');23$test_run_error = pts_test_execution::test_run_error('test_run_error', 7);24echo $test_run_error;

Full Screen

Full Screen

test_run_error

Using AI Code Generation

copy

Full Screen

1include_once 'pts_test_execution.php';2$test_execution = new pts_test_execution();3$test_execution->test_run_error();4$test_execution->test_run_error_message();5$test_execution->test_run_error_output();6$test_execution->test_run_error_exit_code();7$test_execution->test_run_error();8$test_execution->test_run_error_message();9$test_execution->test_run_error_output();10$test_execution->test_run_error_exit_code();11$test_execution->test_run_error();12$test_execution->test_run_error_message();13$test_execution->test_run_error_output();14$test_execution->test_run_error_exit_code();15$test_execution->test_run_error();16$test_execution->test_run_error_message();17$test_execution->test_run_error_output();18$test_execution->test_run_error_exit_code();19$test_execution->test_run_error();20$test_execution->test_run_error_message();21$test_execution->test_run_error_output();22$test_execution->test_run_error_exit_code();23$test_execution->test_run_error();24$test_execution->test_run_error_message();25$test_execution->test_run_error_output();26$test_execution->test_run_error_exit_code();

Full Screen

Full Screen

test_run_error

Using AI Code Generation

copy

Full Screen

1include "pts_test_execution.php";2$obj = new pts_test_execution();3$obj->test_run_error();4Fatal error: Call to undefined method pts_test_execution::test_run_error() in /home/username/public_html/2.php on line 115include "pts_test_execution.php";6$obj = new pts_test_execution();7$obj->test_run_error();8Fatal error: Call to undefined method pts_test_execution::test_run_error() in /home/username/public_html/2.php on line 119include "pts_test_execution.php";10$obj = new pts_test_execution();11$obj->test_run_error();12Fatal error: Call to undefined method pts_test_execution::test_run_error() in /home/username/public_html/2.php on line 1113include "pts_test_execution.php";

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Phoronix-test-suite automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Trigger test_run_error code on LambdaTest Cloud Grid

Execute automation tests with test_run_error on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful