Best Phoronix-test-suite code snippet using pts_test_run_manager.is_multi_test_stress_run
pts_test_execution.php
Source:pts_test_execution.php  
...52			self::test_run_error($test_run_manager, $test_run_request, '[' . $test_run_request->test_profile->get_identifier() . ' ' . $test_run_request->get_arguments_description() . '] ' . $error);53			return false;54		}55		$lock_file = $test_directory . 'run_lock';56		if(pts_client::create_lock($lock_file) == false && $test_run_manager->is_multi_test_stress_run() == false)57		{58			self::test_run_error($test_run_manager, $test_run_request, 'The ' . $test_identifier . ' test is already running.');59			return false;60		}61		$test_run_request->active = new pts_test_result_buffer_active();62		$test_run_request->generated_result_buffers = array();63		$execute_binary = $test_run_request->test_profile->get_test_executable();64		$times_to_run = $test_run_request->test_profile->get_times_to_run();65		$ignore_runs = $test_run_request->test_profile->get_runs_to_ignore();66		$ignore_runs_override = ($ir = pts_env::read('IGNORE_RUNS')) ? pts_strings::comma_explode($ir) : array();67		$test_type = $test_run_request->test_profile->get_test_hardware_type();68		$allow_cache_share = $test_run_request->test_profile->allow_cache_share() && $test_run_manager->allow_test_cache_share();69		$min_length = $test_run_request->test_profile->get_min_length();70		$max_length = $test_run_request->test_profile->get_max_length();71		$is_monitoring = false;72		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())73		{74			// Ensure enough space is available on disk during testing process75			self::test_run_error($test_run_manager, $test_run_request, 'There is not enough space (at ' . $test_directory . ') for this test to run.');76			pts_client::release_lock($lock_file);77			return false;78		}79		$to_execute = $test_run_request->test_profile->get_test_executable_dir();80		$pts_test_arguments = trim($test_run_request->test_profile->get_default_arguments() . ' ' . ($test_run_request->test_profile->get_default_arguments() != null && !empty($extra_arguments) ? str_replace($test_run_request->test_profile->get_default_arguments(), '', $extra_arguments) : $extra_arguments) . ' ' . $test_run_request->test_profile->get_default_post_arguments());81		$extra_runtime_variables = pts_tests::extra_environment_variables($test_run_request->test_profile);82		pts_triggered_system_events::pre_run_reboot_triggered_check($test_run_request->test_profile, $extra_runtime_variables);83		// Start84		$cache_share_pt2so = $test_directory . 'cache-share-' . PTS_INIT_TIME . '.pt2so';85		$cache_share_present = $allow_cache_share && is_file($cache_share_pt2so);86		pts_module_manager::module_process('__pre_test_run', $test_run_request);87		$time_test_start = microtime(true);88		pts_client::$display->test_run_start($test_run_manager, $test_run_request);89		sleep(2);90		if(!$cache_share_present && !$test_run_manager->DEBUG_no_test_execution_just_result_parse)91		{92			$pre_output = pts_tests::call_test_script($test_run_request->test_profile, 'pre', 'Running Pre-Test Script', $pts_test_arguments, $extra_runtime_variables, true);93			if($pre_output != null)94			{95				pts_client::$display->test_run_instance_output($pre_output);96			}97			if(is_file($test_directory . 'pre-test-exit-status'))98			{99			  // If the pre script writes its exit status to ~/pre-test-exit-status, if it's non-zero the test run failed100			  $exit_status = pts_file_io::file_get_contents($test_directory . 'pre-test-exit-status');101			  unlink($test_directory . 'pre-test-exit-status');102			  if($exit_status != 0)103			  {104					self::test_run_instance_error($test_run_manager, $test_run_request, 'The pre run script quit with a non-zero exit status.' . PHP_EOL);105					self::test_run_error($test_run_manager, $test_run_request, 'This test execution has been abandoned.');106					return false;107			  }108			}109		}110		pts_client::$display->display_interrupt_message($test_run_request->test_profile->get_pre_run_message());111		$runtime_identifier = time();112		$execute_binary_prepend = '';113		$execute_binary_prepend_final = './';114		if($test_run_request->exec_binary_prepend != null)115		{116			$execute_binary_prepend = $test_run_request->exec_binary_prepend;117		}118		if(!$cache_share_present && !$test_run_manager->DEBUG_no_test_execution_just_result_parse && $test_run_request->test_profile->is_root_required())119		{120			if(phodevi::is_root() == false)121			{122				pts_client::$display->test_run_error('This test must be run as root / administrator.');123			}124			$execute_binary_prepend .= ' ' . PTS_CORE_STATIC_PATH . 'root-access.sh ';125		}126		if($allow_cache_share && !is_file($cache_share_pt2so))127		{128			$cache_share = new pts_storage_object(false, false);129		}130		$backup_test_log_file = false;131		if($test_run_manager->do_save_results() && $test_run_manager->get_file_name() != null && pts_config::read_bool_config('PhoronixTestSuite/Options/Testing/SaveTestLogs', 'TRUE'))132		{133			$backup_test_log_dir = $test_run_manager->result_file->get_test_log_dir($test_run_request);134			if($backup_test_log_dir)135			{136				pts_file_io::mkdir($backup_test_log_dir, 0777, true);137				$backup_test_log_file = $backup_test_log_dir . $test_run_manager->get_results_identifier_simplified() . '.log';138			}139		}140		//141		// THE MAIN TESTING LOOP142		//143		for($i = 0, $times_result_produced = 0, $abort_testing = false, $time_test_start_actual = microtime(true), $defined_times_to_run = $times_to_run; $i < $times_to_run && $i < 256 && !$abort_testing; $i++)144		{145			if($test_run_manager->DEBUG_no_test_execution_just_result_parse)146			{147				$find_log_file = pts_file_io::glob($test_directory . basename($test_identifier) . '-*.log');148				if(!empty($find_log_file))149				{150					if(!isset($find_log_file[0]) || empty($find_log_file[0]))151					{152						pts_test_result_parser::debug_message('No existing log file found for this test profile. Generate one by first trying the debug-run command.');153						return false;154					}155					$test_log_file = $find_log_file[0];156					pts_test_result_parser::debug_message('Log File: ' . $test_log_file);157				}158				else159				{160					pts_test_result_parser::debug_message('No existing log file found for this test profile. Generate one by first trying the debug-run command.');161					return false;162				}163			}164			else if(phodevi::is_windows() && strpos($test_directory, ' ') !== false)165			{166				// On Windows systems with a space in the directory, to workaround some scripts easiest just punting the log file into temp dir167				$test_log_file = sys_get_temp_dir() . '\\' . basename($test_identifier) . '-' . $runtime_identifier . '-' . ($i + 1) . '.log';168			}169			else170			{171				$test_log_file = $test_directory . basename($test_identifier) . '-' . $runtime_identifier . '-' . ($i + 1) . '.log';172			}173			$is_expected_last_run = ($i == ($times_to_run - 1));174			$produced_monitoring_result = false;175			$has_result = false;176			$test_extra_runtime_variables = array_merge($extra_runtime_variables, array(177			'LOG_FILE' => $test_log_file,178			'DISPLAY' => getenv('DISPLAY'),179			'PATH' => pts_client::get_path(),180			'DEBUG_PATH' => pts_client::get_path(),181			));182			$restored_from_cache = false;183			if($cache_share_present)184			{185				$cache_share = pts_storage_object::recover_from_file($cache_share_pt2so);186				if($cache_share)187				{188					$test_result_std_output = $cache_share->read_object('test_results_output_' . $i);189					$test_extra_runtime_variables['LOG_FILE'] = $cache_share->read_object('log_file_location_' . $i);190					if($test_extra_runtime_variables['LOG_FILE'] != null)191					{192						file_put_contents($test_extra_runtime_variables['LOG_FILE'], $cache_share->read_object('log_file_' . $i));193						$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 initialized194						$restored_from_cache = true;195					}196				}197				unset($cache_share);198			}199			if(!$test_run_manager->DEBUG_no_test_execution_just_result_parse && $restored_from_cache == false)200			{201				if(!phodevi::is_windows() && is_file($to_execute . '/' . $execute_binary) && !is_executable($to_execute . '/' . $execute_binary) && pts_client::executable_in_path('chmod'))202				{203					shell_exec('chmod +x ' . $to_execute . '/' . $execute_binary);204				}205				$test_prepend = pts_env::read('TEST_EXEC_PREPEND') != null ? pts_env::read('TEST_EXEC_PREPEND') . ' ': null;206				pts_client::$display->test_run_instance_header($test_run_request);207				sleep(2);208				$host_env = $_SERVER;209				unset($host_env['argv']);210				$to_exec = 'exec';211				$post_test_args = ' 2>&1';212				if(phodevi::is_windows())213				{214					if(is_executable('C:\Windows\System32\cmd.exe') && (pts_file_io::file_get_contents_first_line($to_execute . '/' . $execute_binary) == '@echo off' || substr($execute_binary, -4) == '.bat'))215					{216						pts_client::$display->test_run_message('Using cmd.exe batch...');217						$to_exec = 'C:\Windows\System32\cmd.exe';218						$execute_binary_prepend = ' /c ';219						$execute_binary_prepend_final = '';220						$post_test_args = '';221					}222					else if(is_executable('C:\cygwin64\bin\bash.exe'))223					{224						$to_exec = 'C:\cygwin64\bin\bash.exe';225						$test_extra_runtime_variables['PATH'] = (isset($test_extra_runtime_variables['PATH']) ? $test_extra_runtime_variables['PATH'] : null) . ';C:\cygwin64\bin';226					}227					else228					{229						$execute_binary = '"' . $execute_binary . '"';230					}231				}232				pts_test_result_parser::debug_message('Test Run Directory: ' . $to_execute);233				pts_test_result_parser::debug_message('Test Run Command: ' . $test_prepend . $execute_binary_prepend . $execute_binary_prepend_final . $execute_binary . ' ' . $pts_test_arguments);234				$is_monitoring = pts_test_result_parser::system_monitor_task_check($test_run_request);235				$test_run_time_start = microtime(true);236				$descriptorspec = array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w'));237				if($test_prepend != null && pts_client::executable_in_path(trim($test_prepend)))238				{239					$to_exec = '';240				}241				$terv = $test_extra_runtime_variables;242				if(phodevi::is_windows())243				{244					foreach($terv as $terv_i => &$value)245					{246						if((is_dir($value) || is_file($value) || $terv_i == 'LOG_FILE') && strpos($value, ' ') !== false)247						{248							$value = '"' . $value . '"';249						}250					}251				}252				$test_process = proc_open($test_prepend . $to_exec . ' ' . $execute_binary_prepend . $execute_binary_prepend_final . $execute_binary . ' ' . $pts_test_arguments . $post_test_args, $descriptorspec, $pipes, $to_execute, array_merge($host_env, pts_client::environment_variables(), $terv));253				if(is_resource($test_process))254				{255					//echo proc_get_status($test_process)['pid'];256					pts_module_manager::module_process('__test_running', $test_process);257					$test_result_std_output = stream_get_contents($pipes[1]);258					fclose($pipes[1]);259					fclose($pipes[2]);260					$return_value = proc_close($test_process);261				}262				$test_run_time = microtime(true) - $test_run_time_start;263				$test_run_request->test_run_times[] = pts_math::set_precision($test_run_time, 2);264				$exit_status_pass = true;265				if(is_file($test_directory . 'test-exit-status'))266				{267					// If the test script writes its exit status to ~/test-exit-status, if it's non-zero the test run failed268					$exit_status = pts_file_io::file_get_contents($test_directory . 'test-exit-status');269					unlink($test_directory . 'test-exit-status');270					if($exit_status != 0)271					{272						//self::test_run_instance_error($test_run_manager, $test_run_request, 'The test quit with a non-zero exit status.');273						$exit_status_pass = false;274					}275				}276				$produced_monitoring_result = $is_monitoring ? pts_test_result_parser::system_monitor_task_post_test($test_run_request, $exit_status_pass && !in_array(($i + 1), $ignore_runs) && !in_array(($i + 1), $ignore_runs_override)) : false;277			}278			else279			{280				if($i == 1) // to only display once281				{282					pts_client::$display->test_run_message('Utilizing Data From Shared Cache');283				}284				$test_run_time = 0;285				$exit_status_pass = true;286			}287			pts_triggered_system_events::post_run_reboot_triggered_check($test_run_request->test_profile);288			if($test_result_std_output != null && !isset($test_result_std_output[10240]))289			{290				pts_client::$display->test_run_instance_output($test_result_std_output);291			}292			if(is_file($test_log_file) && filesize($test_log_file) == 0)293			{294				unlink($test_log_file);295			}296			if(is_file($test_log_file) && trim($test_result_std_output) == null)297			{298				$test_log_file_contents = file_get_contents($test_log_file);299				pts_client::$display->test_run_instance_output($test_log_file_contents);300				unset($test_log_file_contents);301			}302			if($exit_status_pass == false)303			{304				// If the test script writes its exit status to ~/test-exit-status, if it's non-zero the test run failed305				self::test_run_instance_error($test_run_manager, $test_run_request, 'The test quit with a non-zero exit status.');306				if($is_expected_last_run)307				{308					$scan_log = is_file($test_log_file) ? pts_file_io::file_get_contents($test_log_file) : $test_result_std_output;309					$test_run_error = pts_tests::scan_for_error($scan_log, $test_run_request->test_profile->get_test_executable_dir());310					if($test_run_error)311					{312						self::test_run_instance_error($test_run_manager, $test_run_request, 'E: ' . $test_run_error);313					}314				}315			}316			if(in_array(($i + 1), $ignore_runs))317			{318				pts_client::$display->test_run_instance_error('Ignoring this run result per test profile definition.');319			}320			else if($i == 0 && $test_run_request->test_profile->is_root_required() && !phodevi::is_root() && $is_monitoring)321			{322				// Useful for test profiles like system/wireguard that are timed test but can be interrupted by sudo323				pts_client::$display->test_run_instance_error('Ignoring first run in case root/sudo transition time skewed result.');324			}325			else if(in_array(($i + 1), $ignore_runs_override))326			{327				pts_client::$display->test_run_instance_error('Ignoring this run result per IGNORE_RUNS environment variable.');328			}329			else if($exit_status_pass)330			{331				// if it was monitoring, active result should already be set332				if(!$produced_monitoring_result) // XXX once single-run-multiple-outputs is supported, this check can be disabled to allow combination of results333				{334					$has_result = pts_test_result_parser::parse_result($test_run_request, $test_extra_runtime_variables['LOG_FILE']);335				}336				$has_result = $has_result || $produced_monitoring_result;337				if($has_result)338				{339					$times_result_produced++;340					if($test_run_time < 2 && $test_run_request->get_estimated_run_time() > 60 && !$restored_from_cache && !$test_run_manager->DEBUG_no_test_execution_just_result_parse)341					{342						// 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 run343						pts_client::$display->test_run_instance_error('The test run ended quickly.');344						if($is_expected_last_run)345						{346							$scan_log = is_file($test_log_file) ? pts_file_io::file_get_contents($test_log_file) : $test_result_std_output;347							$test_run_error = pts_tests::scan_for_error($scan_log, $test_run_request->test_profile->get_test_executable_dir());348							if($test_run_error)349							{350								self::test_run_instance_error($test_run_manager, $test_run_request, 'E: ' . $test_run_error);351							}352						}353					}354				}355				else if($test_run_request->test_profile->get_display_format() != 'NO_RESULT')356				{357					self::test_run_instance_error($test_run_manager, $test_run_request, 'The test run did not produce a result.');358					if($is_expected_last_run)359					{360						$scan_log = is_file($test_log_file) ? pts_file_io::file_get_contents($test_log_file) : $test_result_std_output;361						$test_run_error = pts_tests::scan_for_error($scan_log, $test_run_request->test_profile->get_test_executable_dir());362						if($test_run_error)363						{364							self::test_run_instance_error($test_run_manager, $test_run_request, 'E: ' . $test_run_error);365						}366					}367				}368				if($allow_cache_share && !is_file($cache_share_pt2so))369				{370					$cache_share->add_object('test_results_output_' . $i, $test_result_std_output);371					$cache_share->add_object('log_file_location_' . $i, $test_extra_runtime_variables['LOG_FILE']);372					$cache_share->add_object('log_file_' . $i, (is_file($test_log_file) ? file_get_contents($test_log_file) : null));373				}374			}375			if($is_expected_last_run && $times_result_produced > floor(($i - 2) / 2) && !$cache_share_present && !$test_run_manager->DEBUG_no_test_execution_just_result_parse && $test_run_manager->do_dynamic_run_count())376			{377				// The later check above ensures if the test is failing often the run count won't uselessly be increasing378				// Should we increase the run count?379				$increase_run_count = false;380				$runs_ignored_count = count($ignore_runs);381				if($defined_times_to_run == ($i + 1) && $times_result_produced > 0 && $times_result_produced < $defined_times_to_run && $i < 64)382				{383					// At least one run passed, but at least one run failed to produce a result. Increase count to try to get more successful runs384					$increase_run_count = $defined_times_to_run - $times_result_produced;385				}386				else if($times_result_produced >= 2)387				{388					// Dynamically increase run count if needed for statistical significance or other reasons389					$first_tr = array_slice($test_run_request->generated_result_buffers, 0, 1);390					$first_tr = array_shift($first_tr);391					$increase_run_count = $test_run_manager->increase_run_count_check($test_run_request, $first_tr->active, $defined_times_to_run, $time_test_start_actual); // XXX maybe check all generated buffers to see if to extend?392					if($increase_run_count === -1)393					{394						self::test_run_error($test_run_manager, $test_run_request, 'This run will not be saved due to noisy result.');395						$abort_testing = true;396					}397					else if($increase_run_count == true)398					{399						// Just increase the run count one at a time400						$increase_run_count = 1;401					}402				}403				if($increase_run_count > 0)404				{405					$times_to_run += $increase_run_count;406					$is_expected_last_run = false;407					//$test_run_request->test_profile->set_times_to_run($times_to_run);408				}409			}410			if($times_to_run > 1 && $i < ($times_to_run - 1))411			{412				if($cache_share_present == false && !$test_run_manager->DEBUG_no_test_execution_just_result_parse)413				{414					$interim_output = pts_tests::call_test_script($test_run_request->test_profile, 'interim', 'Running Interim Test Script', $pts_test_arguments, $extra_runtime_variables, true);415					if($interim_output != null)416					{417						pts_client::$display->test_run_instance_output($interim_output);418					}419					sleep(2); // Rest for a moment between tests420				}421				pts_module_manager::module_process('__interim_test_run', $test_run_request);422			}423			if(is_file($test_log_file))424			{425				if($is_expected_last_run)426				{427					// For now just passing the last test log file...428					pts_test_result_parser::generate_extra_data($test_run_request, $test_log_file);429				}430				pts_module_manager::module_process('__test_log_output', $test_log_file);431				if($backup_test_log_file)432				{433					file_put_contents($backup_test_log_file, '#####' . PHP_EOL . $test_run_manager->get_results_identifier() . ' - Run ' . ($i + 1) . PHP_EOL . date('Y-m-d H:i:s') . PHP_EOL . '#####' . PHP_EOL . file_get_contents($test_log_file) . PHP_EOL, FILE_APPEND);434				}435				if(pts_test_result_parser::debug_message('Log File At: ' . $test_log_file) == false)436				{437					unlink($test_log_file);438				}439			}440			if(is_file(PTS_USER_PATH . 'halt-testing') || is_file(PTS_USER_PATH . 'skip-test'))441			{442				break;443			}444			pts_client::$display->test_run_instance_complete($test_run_request);445		}446		$time_test_end_actual = microtime(true);447		if($cache_share_present == false && !$test_run_manager->DEBUG_no_test_execution_just_result_parse)448		{449			$post_output = pts_tests::call_test_script($test_run_request->test_profile, 'post', 'Running Post-Test Script', $pts_test_arguments, $extra_runtime_variables, true);450			if($post_output != null)451			{452				pts_client::$display->test_run_instance_output($post_output);453			}454			if(is_file($test_directory . 'post-test-exit-status'))455			{456				// If the post script writes its exit status to ~/post-test-exit-status, if it's non-zero the test run failed457				$exit_status = pts_file_io::file_get_contents($test_directory . 'post-test-exit-status');458				unlink($test_directory . 'post-test-exit-status');459				if($exit_status != 0)460				{461					self::test_run_instance_error($test_run_manager, $test_run_request, 'The post run script quit with a non-zero exit status.' . PHP_EOL);462					$abort_testing = true;463				}464			}465		}466		if(is_file(PTS_USER_PATH . 'halt-testing') || is_file(PTS_USER_PATH . 'skip-test'))467		{468			pts_client::release_lock($lock_file);469			return false;470		}471		if($abort_testing && !is_dir('/mnt/c/Windows')) // bash on Windows has issues where this is always called, looks like bad exit status on Windows472		{473			self::test_run_error($test_run_manager, $test_run_request, 'This test execution has been abandoned.');474			return false;475		}476		// End477		$time_test_end = microtime(true);478		$time_test_elapsed = $time_test_end - $time_test_start;479		$time_test_elapsed_actual = $time_test_end_actual - $time_test_start_actual;480		if(!empty($min_length))481		{482			if($min_length > $time_test_elapsed_actual)483			{484				// The test ended too quickly, results are not valid485				self::test_run_error($test_run_manager, $test_run_request, 'This test ended prematurely.');486				return false;487			}488		}489		if(!empty($max_length))490		{491			if($max_length < $time_test_elapsed_actual)492			{493				// The test took too much time, results are not valid494				self::test_run_error($test_run_manager, $test_run_request, 'This test run was exhausted.');495				return false;496			}497		}498		if($allow_cache_share && !is_file($cache_share_pt2so) && $cache_share instanceof pts_storage_object)499		{500			$cache_share->save_to_file($cache_share_pt2so);501			unset($cache_share);502		}503		if($test_run_manager->do_save_results() && (pts_config::read_bool_config('PhoronixTestSuite/Options/Testing/SaveInstallationLogs', 'TRUE')))504		{505			if($test_run_request->test_profile->test_installation->has_install_log() && $test_run_manager->result_file->get_test_installation_log_dir())506			{507				$backup_log_dir = $test_run_manager->result_file->get_test_installation_log_dir() . $test_run_manager->get_results_identifier_simplified() . '/';508				pts_file_io::mkdir($backup_log_dir, 0777, true);509				copy($test_run_request->test_profile->test_installation->get_install_log_location(), $backup_log_dir . $test_run_request->test_profile->get_identifier_simplified() . '.log');510			}511		}512		// Fill in any missing test details513		foreach($test_run_request->generated_result_buffers as &$sub_tr)514		{515			$arguments_description = $sub_tr->get_arguments_description();516			if(empty($arguments_description))517			{518				$arguments_description = $sub_tr->test_profile->get_test_subtitle();519			}520			$file_var_checks = array(521			array('pts-results-scale', 'set_result_scale', null),522			array('pts-results-proportion', 'set_result_proportion', null),523			array('pts-results-quantifier', 'set_result_quantifier', null),524			array('pts-test-version', 'set_version', null),525			array('pts-test-description', null, 'set_used_arguments_description'),526			array('pts-footnote', null, null),527			);528			foreach($file_var_checks as &$file_check)529			{530				list($file, $set_function, $result_set_function) = $file_check;531				if(is_file($test_directory . $file))532				{533					$file_contents = pts_file_io::file_get_contents($test_directory . $file);534					unlink($test_directory . $file);535					if(!empty($file_contents))536					{537						if(strpos($file_contents, "\n") !== false)538						{539							// If finding a line break, presumably a bad parse...540							// Seeing this behavior for pts-test-version with541							// system/blender yielding multi-line version from bad parsing on some distros542							// using pts_file_io::file_get_contents already trims the string543							continue;544						}545						if($set_function != null)546						{547							call_user_func(array($sub_tr->test_profile, $set_function), $file_contents);548						}549						else if($result_set_function != null)550						{551							if($result_set_function == 'set_used_arguments_description')552							{553								$arguments_description = $file_contents;554							}555							else556							{557								call_user_func(array($sub_tr, $result_set_function), $file_contents);558							}559						}560						else if($file == 'pts-footnote')561						{562							$sub_tr->test_profile->test_installation->set_install_footnote($file_contents);563						}564					}565				}566			}567			foreach(pts_client::environment_variables() as $key => $value)568			{569				if($value === null)570				{571					// Fixes PHP 8.1+ warning572					$value = '';573				}574				$arguments_description = $arguments_description != null ? str_replace('$' . $key, $value, $arguments_description) : '';575				if(!empty($extra_arguments) && !in_array($key, array('VIDEO_MEMORY', 'NUM_CPU_CORES', 'NUM_CPU_JOBS')))576				{577					$extra_arguments = str_replace('$' . $key, $value, $extra_arguments);578				}579			}580			$sub_tr->set_used_arguments_description($arguments_description);581			$sub_tr->set_used_arguments($extra_arguments);582			$this_backup_test_log_dir = $test_run_manager->result_file->get_test_log_dir($sub_tr);583			if($backup_test_log_file && !empty($backup_test_log_dir) && $backup_test_log_dir != $this_backup_test_log_dir && count($toxfer = pts_file_io::glob($backup_test_log_dir . '/*')) > 0)584			{585				// If test generated dynamic arguments and such, the backup log file may be different586				// or in cases where one run generates multiple results...587				pts_file_io::mkdir($this_backup_test_log_dir);588				// TODO: come up with way in log viewer to de-duplicate/symlink rather than copy...589				// there is also the possibility of the original backup_test_log_dir hash not being used so could be removed590				foreach($toxfer as $bf)591				{592					copy($bf, $this_backup_test_log_dir . basename($bf));593				}594			}595		}596		// Result Calculation597		// Ending Tasks598		pts_client::$display->display_interrupt_message($test_run_request->test_profile->get_post_run_message());599		$test_successful = self::calculate_end_result_post_processing($test_run_manager, $test_run_request); // Process results600		// Ensure entry in result file even if no result... (And report error string if appropriate)601		if(!$test_successful && $test_run_manager->do_save_results())602		{603			$test_run_request->test_result_buffer = new pts_test_result_buffer();604			$rid = $test_run_manager->get_results_identifier() != null ? $test_run_manager->get_results_identifier() : 'Result';605			$test_run_request->test_result_buffer->add_test_result($rid, '', '', pts_test_run_manager::process_json_report_attributes($test_run_request, (!empty(self::$test_run_error_collection) ? implode(' ', self::$test_run_error_collection) : '')), '', '');606			$test_run_manager->result_file->add_result($test_run_request);607		}608		// End Finalize609		pts_module_manager::module_process('__post_test_run', $test_run_request);610		$report_elapsed_time = $cache_share_present == false && $times_result_produced > 0;611		if($report_elapsed_time)612		{613			$test_run_request->test_profile->test_installation->add_latest_run_time($test_run_request, $time_test_elapsed);614		}615		if($test_run_manager->is_multi_test_stress_run() == false)616		{617			$test_run_request->test_profile->test_installation->test_runtime_error_handler($test_run_request, self::$test_run_error_collection);618			$test_run_request->test_profile->test_installation->save_test_install_metadata();619			pts_storage_object::add_in_file(PTS_CORE_STORAGE, 'total_testing_time', ($time_test_elapsed / 60));620		}621		if($report_elapsed_time && pts_client::do_anonymous_usage_reporting() && $time_test_elapsed >= 10)622		{623			// If anonymous usage reporting enabled, report test run-time to OpenBenchmarking.org624			pts_openbenchmarking_client::upload_usage_data('test_complete', array($test_run_request, $time_test_elapsed));625		}626		// Remove lock627		pts_client::release_lock($lock_file);628		return $test_successful;629	}...is_multi_test_stress_run
Using AI Code Generation
1require_once('pts-test-run-manager.php');2$test_run_manager = new pts_test_run_manager();3$test_run_manager->is_multi_test_stress_run();4require_once('pts_test_run_manager.php');5$test_run_manager = new pts_test_run_manager();6$test_run_manager->is_multi_test_stress_run();7require_once('pts-test-run-manager.php');8$test_run_manager = new pts_test_run_manager();9$test_run_manager->is_multi_test_stress_run();10require_once('pts_test_run_manager.php');11$test_run_manager = new pts_test_run_manager();12$test_run_manager->is_multi_test_stress_run();13require_once('pts-test-run-manager.php');14$test_run_manager = new pts_test_run_manager();15$test_run_manager->is_multi_test_stress_run();16require_once('pts_test_run_manager.php');17$test_run_manager = new pts_test_run_manager();18$test_run_manager->is_multi_test_stress_run();19require_once('pts-test-run-manager.php');20$test_run_manager = new pts_test_run_manager();21$test_run_manager->is_multi_test_stress_run();22require_once('pts_test_run_manager.php');23$test_run_manager = new pts_test_run_manager();24$test_run_manager->is_multi_test_stress_run();25require_once('pts-test-run-manager.php');26$test_run_manager = new pts_test_run_manager();27$test_run_manager->is_multi_test_stress_run();is_multi_test_stress_run
Using AI Code Generation
1$test_run_manager = new pts_test_run_manager();2$test_run_manager->set_test_profile('test-profile.xml');3$test_run_manager->set_test_arguments('test-arguments.xml');4$test_run_manager->set_test_identifier('test-identifier');5$test_run_manager->set_test_times_to_run(2);6$test_run_manager->set_test_run_count(2);7$test_run_manager->set_test_run_time(2);8$test_run_manager->set_test_run_time_maximum(2);9$test_run_manager->set_test_run_time_minimum(2);10$test_run_manager->set_test_run_time_standard_deviation(2);11$test_run_manager->set_test_run_time_variance(2);12$test_run_manager->set_test_run_buffer(2);13$test_run_manager->set_test_run_buffer_maximum(2);14$test_run_manager->set_test_run_buffer_minimum(2);15$test_run_manager->set_test_run_buffer_standard_deviation(2);16$test_run_manager->set_test_run_buffer_variance(2);17$test_run_manager->set_test_run_mode('TEST');18$test_run_manager->set_test_run_mode('PRE');is_multi_test_stress_run
Using AI Code Generation
1$test_run_manager = new pts_test_run_manager();2$test_run_manager->set_test_profile("pts/test-profiles/pts/test-profiles/pts/7zip-1.0.0.xml");3$test_run_manager->set_test_arguments("bzip2");4$test_run_manager->set_test_arguments("gzip");5$test_run_manager->set_test_arguments("xz");6$test_run_manager->set_test_arguments("lzip");7$test_run_manager->set_test_arguments("lzma");8$test_run_manager->set_test_arguments("lzop");9$test_run_manager->set_test_arguments("lz4");10$test_run_manager->set_test_arguments("zstd");11$test_run_manager->set_test_arguments("brotli");12$test_run_manager->set_test_run_count(1);13$test_run_manager->set_test_run_mode("Standard");14$test_run_manager->set_test_run_mode("Standard", 1);15$test_run_manager->set_test_run_mode("Standard", 2);16$test_run_manager->set_test_run_mode("Standard", 3);17$test_run_manager->set_test_run_mode("Standard", 4);18$test_run_manager->set_test_run_mode("Standard", 5);19$test_run_manager->set_test_run_mode("Standard", 6);20$test_run_manager->set_test_run_mode("Standard", 7);21$test_run_manager->set_test_run_mode("Standard", 8);22$test_run_manager->set_test_run_mode("Standard", 9);23$test_run_manager->set_test_run_mode("Standard", 10);24$test_run_manager->set_test_run_count(2);25$test_run_manager->set_test_run_mode("Standard");26$test_run_manager->set_test_run_mode("Standard", 1);27$test_run_manager->set_test_run_mode("Standard", 2);28$test_run_manager->set_test_run_mode("Standard", 3);29$test_run_manager->set_test_run_mode("Standard", 4);30$test_run_manager->set_test_run_mode("Standard", 5);31$test_run_manager->set_test_run_mode("Standard", 6);32$test_run_manager->set_test_run_mode("Standard", 7);33$test_run_manager->set_test_run_mode("Standard", 8);34$test_run_manager->set_test_run_mode("Standard",is_multi_test_stress_run
Using AI Code Generation
1require_once('/opt/phoronix-test-suite/pts-core/objects/pts_test_run_manager.php');2$test_run_manager = new pts_test_run_manager();3if($test_run_manager->is_multi_test_stress_run())4{5}6if($test_run_manager->is_multi_test_just_run())7{8}9if($test_run_manager->is_multi_test_stress_run() && $test_run_manager->is_multi_test_just_run())10{11}12if($test_run_manager->is_multi_test_stress_run() || $test_run_manager->is_multi_test_just_run())13{14}15if(!$test_run_manager->is_multi_test_stress_run() && !$test_run_manager->is_multi_test_just_run())16{17}18if(!$test_run_manager->is_multi_test_stress_run() || !$test_run_manager->is_multi_test_just_run())19{20}is_multi_test_stress_run
Using AI Code Generation
1if(pts_test_run_manager::is_multi_test_stress_run())2{3$test_run_request = pts_test_run_manager::test_run_request();4echo $test_run_request->test_profile->get_display_name();5}6{7echo "Single Test Run";8}9$test_run_request = pts_test_run_manager::test_run_request();10echo $test_run_request->test_profile->get_display_name();11$test_run_request = pts_test_run_manager::test_run_request();12echo $test_run_request->test_profile->get_identifier();13$test_run_request = pts_test_run_manager::test_run_request();14echo $test_run_request->test_profile->get_arguments_description();15$test_run_request = pts_test_run_manager::test_run_request();16echo $test_run_request->test_profile->get_arguments();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 is_multi_test_stress_run 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!!
