Best Phoronix-test-suite code snippet using pts_test_installer.end_compiler_mask
pts_test_installer.php
Source:pts_test_installer.php
...103 {104 pts_client::$display->test_install_start($test_install_request->test_profile->get_identifier());105 $test_install_request->special_environment_vars['INSTALL_FOOTNOTE'] = $test_install_request->test_profile->get_install_dir() . 'install-footnote';106 $installed = pts_test_installer::install_test_process($test_install_request, $no_prompts);107 $compiler_data = pts_test_installer::end_compiler_mask($test_install_request);108 if($installed)109 {110 if(pts_client::do_anonymous_usage_reporting() && $test_install_request->install_time_duration > 0)111 {112 // If anonymous usage reporting enabled, report install time to OpenBenchmarking.org113 pts_openbenchmarking_client::upload_usage_data('test_install', array($test_install_request, $test_install_request->install_time_duration));114 }115 $install_footnote = null;116 if(is_file($test_install_request->special_environment_vars['INSTALL_FOOTNOTE']))117 {118 $install_footnote = pts_file_io::file_get_contents($test_install_request->special_environment_vars['INSTALL_FOOTNOTE']);119 }120 pts_tests::update_test_install_xml($test_install_request->test_profile, $test_install_request->install_time_duration, true, $compiler_data, $install_footnote);121 $test_profiles[] = $test_install_request->test_profile;122 }123 else124 {125 $failed_installs[] = $test_install_request;126 }127 pts_file_io::unlink($test_install_request->special_environment_vars['INSTALL_FOOTNOTE']);128 }129 pts_module_manager::module_process('__post_install_process', $test_install_manager);130 pts_download_speed_manager::save_data();131 if(count($failed_installs) > 1)132 {133 echo PHP_EOL . 'The following tests failed to install:' . PHP_EOL . PHP_EOL;134 foreach($failed_installs as &$install_request)135 {136 echo ' - ' . $install_request->test_profile . PHP_EOL;137 // If many tests are being installed, show the error messages reported in order to reduce scrolling...138 if($install_request->install_error && isset($failed_installs[5]))139 {140 echo ' [' . $install_request->install_error . ']' . PHP_EOL;141 }142 }143 }144 }145 public static function only_download_test_files(&$test_profiles, $to_dir = null)146 {147 // Setup the install manager and add the tests148 $test_install_manager = new pts_test_install_manager();149 foreach($test_profiles as &$test_profile)150 {151 if($test_install_manager->add_test_profile($test_profile) != false)152 {153 pts_client::$display->generic_sub_heading('To Download Files: ' . $test_profile->get_identifier());154 }155 }156 if($test_install_manager->tests_to_install_count() == 0)157 {158 return true;159 }160 // Let the pts_test_install_manager make some estimations, etc...161 $test_install_manager->generate_download_file_lists();162 $test_install_manager->check_download_caches_for_files();163 // Begin the download process164 while(($test_install_request = $test_install_manager->next_in_install_queue()) != false)165 {166 //pts_client::$display->test_install_start($test_install_request->test_profile->get_identifier());167 pts_test_installer::download_test_files($test_install_request, $to_dir);168 }169 }170 protected static function download_test_files(&$test_install_request, $download_location = false, $no_prompts = false)171 {172 // Download needed files for a test173 if($test_install_request->get_download_object_count() == 0)174 {175 return true;176 }177 $identifier = $test_install_request->test_profile->get_identifier();178 pts_client::$display->test_install_downloads($test_install_request);179 if($download_location == false)180 {181 $download_location = $test_install_request->test_profile->get_install_dir();182 }183 pts_file_io::mkdir($download_location);184 $module_pass = array($identifier, $test_install_request->get_download_objects());185 pts_module_manager::module_process('__pre_test_download', $module_pass);186 foreach($test_install_request->get_download_objects() as $download_package)187 {188 $package_filename = $download_package->get_filename();189 $download_destination = $download_location . $package_filename;190 $download_destination_temp = $download_destination . '.pts';191 if($download_package->get_download_location_type() == null)192 {193 // Attempt a possible last-minute look-aside copy cache in case a previous test in the install queue downloaded this file already194 $lookaside_copy = pts_test_install_manager::file_lookaside_test_installations($download_package);195 if($lookaside_copy)196 {197 if($download_package->get_filesize() == 0)198 {199 $download_package->set_filesize(filesize($lookaside_copy));200 }201 $download_package->set_download_location('LOOKASIDE_DOWNLOAD_CACHE', array($lookaside_copy));202 }203 }204 switch($download_package->get_download_location_type())205 {206 case 'IN_DESTINATION_DIR':207 pts_client::$display->test_install_download_file('FILE_FOUND', $download_package);208 continue;209 case 'REMOTE_DOWNLOAD_CACHE':210 $download_tries = 0;211 do212 {213 foreach($download_package->get_download_location_path() as $remote_download_cache_file)214 {215 pts_client::$display->test_install_download_file('DOWNLOAD_FROM_CACHE', $download_package);216 pts_network::download_file($remote_download_cache_file, $download_destination_temp);217 if(!is_file($download_destination_temp) || filesize($download_destination_temp) == 0)218 {219 self::test_install_error(null, $test_install_request, 'The file failed to download from the cache.');220 pts_file_io::unlink($download_destination_temp);221 break;222 }223 else if($download_package->check_file_hash($download_destination_temp))224 {225 rename($download_destination_temp, $download_destination);226 break;227 }228 else229 {230 self::test_install_error(null, $test_install_request, 'The check-sum of the downloaded file failed.');231 pts_file_io::unlink($download_destination_temp);232 }233 }234 $download_tries++;235 }236 while(!is_file($download_destination) && $download_tries < 2);237 if(is_file($download_destination))238 {239 continue;240 }241 case 'MAIN_DOWNLOAD_CACHE':242 case 'LOCAL_DOWNLOAD_CACHE':243 case 'LOOKASIDE_DOWNLOAD_CACHE':244 $download_cache_file = pts_arrays::last_element($download_package->get_download_location_path());245 if(is_file($download_cache_file))246 {247 if((pts_config::read_bool_config('PhoronixTestSuite/Options/Installation/SymLinkFilesFromCache', 'FALSE') && $download_package->get_download_location_type() != 'LOOKASIDE_DOWNLOAD_CACHE'))248 {249 // For look-aside copies never symlink (unless a pre-packaged LiveCD) in case the other test ends up being un-installed250 // SymLinkFilesFromCache is disabled by default251 pts_client::$display->test_install_download_file('LINK_FROM_CACHE', $download_package);252 symlink($download_cache_file, $download_destination);253 }254 else255 {256 // File is to be copied257 // Try up to two times to copy a file258 $attempted_copies = 0;259 do260 {261 pts_client::$display->test_install_download_file('COPY_FROM_CACHE', $download_package);262 // $context = stream_context_create();263 // stream_context_set_params($context, array('notification' => array('pts_network', 'stream_status_callback')));264 // TODO: get the context working correctly for this copy()265 copy($download_cache_file, $download_destination_temp);266 pts_client::$display->test_install_progress_completed();267 // Verify that the file was copied fine268 if($download_package->check_file_hash($download_destination_temp))269 {270 rename($download_destination_temp, $download_destination);271 break;272 }273 else274 {275 self::test_install_error(null, $test_install_request, 'The check-sum of the copied file failed.');276 pts_file_io::unlink($download_destination_temp);277 }278 $attempted_copies++;279 }280 while($attempted_copies < 2);281 }282 if(is_file($download_destination))283 {284 continue;285 }286 }287 default:288 $package_urls = $download_package->get_download_url_array();289 // Download the file290 if(!is_file($download_destination) && count($package_urls) > 0 && $package_urls[0] != null)291 {292 $fail_count = 0;293 do294 {295 if(pts_network::internet_support_available())296 {297 if(!$no_prompts && pts_config::read_bool_config('PhoronixTestSuite/Options/Installation/PromptForDownloadMirror', 'FALSE') && count($package_urls) > 1)298 {299 // Prompt user to select mirror300 do301 {302 echo PHP_EOL . 'Available Download Mirrors:' . PHP_EOL . PHP_EOL;303 $url = pts_user_io::prompt_text_menu('Select Preferred Mirror', $package_urls, false);304 }305 while(pts_strings::is_url($url) == false);306 }307 else308 {309 // Auto-select mirror310 shuffle($package_urls);311 do312 {313 $url = array_pop($package_urls);314 }315 while(pts_strings::is_url($url) == false && !empty($package_urls));316 }317 pts_client::$display->test_install_download_file('DOWNLOAD', $download_package);318 $download_start = time();319 pts_network::download_file($url, $download_destination_temp);320 $download_end = time();321 }322 else323 {324 self::test_install_error(null, $test_install_request, 'Internet support is needed and it\'s disabled or not available.');325 return false;326 }327 if($download_package->check_file_hash($download_destination_temp))328 {329 // Download worked330 if(is_file($download_destination_temp))331 {332 rename($download_destination_temp, $download_destination);333 }334 if($download_package->get_filesize() > 0 && $download_end != $download_start)335 {336 pts_download_speed_manager::update_download_speed_average($download_package->get_filesize(), ($download_end - $download_start));337 }338 }339 else340 {341 // Download failed342 if(is_file($download_destination_temp) && filesize($download_destination_temp) < 500 && (stripos(file_get_contents($download_destination_temp), 'not found') !== false || strpos(file_get_contents($download_destination_temp), 404) !== false))343 {344 self::test_install_error(null, $test_install_request, 'File Not Found: ' . $url);345 $md5_failed = false;346 }347 else if(is_file($download_destination_temp) && filesize($download_destination_temp) > 0)348 {349 self::test_install_error(null, $test_install_request, 'Checksum Failed: ' . $url);350 $md5_failed = true;351 }352 else353 {354 self::test_install_error(null, $test_install_request, 'Download Failed: ' . $url);355 $md5_failed = false;356 }357 pts_file_io::unlink($download_destination_temp);358 $fail_count++;359 if($fail_count > 3)360 {361 $try_again = false;362 }363 else364 {365 if(count($package_urls) > 0 && $package_urls[0] != null)366 {367 self::test_install_error(null, $test_install_request, 'Attempting to download from alternate mirror.');368 $try_again = true;369 }370 else371 {372 if($no_prompts)373 {374 $try_again = false;375 }376 else if($md5_failed)377 {378 $try_again = pts_user_io::prompt_bool_input('Try downloading the file again', true, 'TRY_DOWNLOAD_AGAIN');379 }380 else381 {382 $try_again = false;383 }384 if($try_again)385 {386 $package_urls[] = $url;387 }388 }389 }390 if(!$try_again)391 {392 //self::test_install_error(null, $test_install_request, 'Download of Needed Test Dependencies Failed!');393 return false;394 }395 }396 }397 while(!is_file($download_destination));398 }399 pts_module_manager::module_process('__interim_test_download', $module_pass);400 }401 }402 pts_module_manager::module_process('__post_test_download', $identifier);403 return true;404 }405 public static function create_compiler_mask(&$test_install_request)406 {407 if(phodevi::is_bsd() || getenv('PTS_NO_COMPILER_MASK'))408 {409 // XXX: Using the compiler-mask causes a number of tests to fail to properly install due to compiler issues with at least PC-BSD 10.0410 return false;411 }412 // or pass false to $test_install_request to bypass the test checks413 $compilers = array();414 $external_dependencies = $test_install_request != false ? $test_install_request->test_profile->get_external_dependencies() : false;415 if($test_install_request === false || in_array('build-utilities', $external_dependencies))416 {417 // Handle C/C++ compilers for this external dependency418 $compilers['CC'] = array(pts_strings::first_in_string(pts_client::read_env('CC'), ' '), 'gcc', 'clang', 'icc', 'pcc');419 $compilers['CXX'] = array(pts_strings::first_in_string(pts_client::read_env('CXX'), ' '), 'g++', 'clang++', 'cpp');420 }421 if($test_install_request === false || in_array('fortran-compiler', $external_dependencies))422 {423 // Handle Fortran for this external dependency424 $compilers['F9X'] = array(pts_strings::first_in_string(pts_client::read_env('F9X'), ' '), pts_strings::first_in_string(pts_client::read_env('F95'), ' '), 'gfortran', 'f90', 'f95', 'fortran');425 }426 if(empty($compilers))427 {428 // If the test profile doesn't request a compiler external dependency, probably not compiling anything429 return false;430 }431 foreach($compilers as $compiler_type => $possible_compilers)432 {433 // Compilers to check for, listed in order of priority434 $compiler_found = false;435 foreach($possible_compilers as $i => $possible_compiler)436 {437 // first check to ensure not null sent to executable_in_path from env variable438 if($possible_compiler && (($compiler_path = is_executable($possible_compiler)) || ($compiler_path = pts_client::executable_in_path($possible_compiler, 'ccache'))))439 {440 // Replace the array of possible compilers with a string to the detected compiler executable441 $compilers[$compiler_type] = $compiler_path;442 $compiler_found = true;443 break;444 }445 }446 if($compiler_found == false)447 {448 unset($compilers[$compiler_type]);449 }450 }451 if(!empty($compilers))452 {453 // Create a temporary directory that will be at front of PATH and serve for masking the actual compiler454 if($test_install_request instanceof pts_test_install_request)455 {456 $mask_dir = pts_client::temporary_directory() . '/pts-compiler-mask-' . $test_install_request->test_profile->get_identifier_base_name() . $test_install_request->test_profile->get_test_profile_version() . '/';457 }458 else459 {460 $mask_dir = pts_client::temporary_directory() . '/pts-compiler-mask-' . rand(100, 999) . '/';461 }462 pts_file_io::mkdir($mask_dir);463 $compiler_extras = array(464 'CC' => array('safeguard-names' => array('gcc', 'cc'), 'environment-variables' => 'CFLAGS'),465 'CXX' => array('safeguard-names' => array('g++', 'c++'), 'environment-variables' => 'CXXFLAGS'),466 'F9X' => array('safeguard-names' => array('gfortran', 'f95'), 'environment-variables' => 'F9XFLAGS')467 );468 foreach($compilers as $compiler_type => $compiler_path)469 {470 $compiler_name = basename($compiler_path);471 $main_compiler = $mask_dir . $compiler_name;472 // take advantage of environment-variables to be sure they're found in the string473 $env_var_check = PHP_EOL;474 /*475 foreach(pts_arrays::to_array($compiler_extras[$compiler_type]['environment-variables']) as $env_var)476 {477 // since it's a dynamic check in script could probably get rid of this check...478 if(true || getenv($env_var))479 {480 $env_var_check .= 'if [[ $COMPILER_OPTIONS != "*$' . $env_var . '*" ]]' . PHP_EOL . 'then ' . PHP_EOL . 'COMPILER_OPTIONS="$COMPILER_OPTIONS $' . $env_var . '"' . PHP_EOL . 'fi' . PHP_EOL;481 }482 }483 */484 // Write the main mask for the compiler485 file_put_contents($main_compiler,486 '#!/bin/bash' . PHP_EOL . 'COMPILER_OPTIONS="$@"' . PHP_EOL . $env_var_check . PHP_EOL . 'echo $COMPILER_OPTIONS >> ' . $mask_dir . $compiler_type . '-options-' . $compiler_name . PHP_EOL . $compiler_path . ' "$@"' . PHP_EOL);487 // Make executable488 chmod($main_compiler, 0755);489 // The two below code chunks ensure the proper compiler is always hit490 if($test_install_request instanceof pts_test_install_request && !in_array($compiler_name, pts_arrays::to_array($compiler_extras[$compiler_type]['safeguard-names'])) && getenv($compiler_type) == false)491 {492 // So if e.g. clang becomes the default compiler, since it's not GCC, it will ensure CC is also set to clang beyond the masking below493 $test_install_request->special_environment_vars[$compiler_type] = $compiler_name;494 }495 // Just in case any test profile script is statically always calling 'gcc' or anything not CC, try to make sure it hits one of the safeguard-names so it redirects to the intended compiler under test496 foreach(pts_arrays::to_array($compiler_extras[$compiler_type]['safeguard-names']) as $safe_name)497 {498 if(!is_file($mask_dir . $safe_name))499 {500 symlink($main_compiler, $mask_dir . $safe_name);501 }502 }503 }504 if($test_install_request instanceof pts_test_install_request)505 {506 $test_install_request->compiler_mask_dir = $mask_dir;507 // Appending the rest of the path will be done automatically within call_test_script508 $test_install_request->special_environment_vars['PATH'] = $mask_dir;509 }510 return $mask_dir;511 }512 return false;513 }514 public static function end_compiler_mask(&$test_install_request)515 {516 if($test_install_request->compiler_mask_dir == false && !is_dir($test_install_request->compiler_mask_dir))517 {518 return false;519 }520 $compiler = false;521 foreach(pts_file_io::glob($test_install_request->compiler_mask_dir . '*-options-*') as $compiler_output)522 {523 $output_name = basename($compiler_output);524 $compiler_type = substr($output_name, 0, strpos($output_name, '-'));525 $compiler_choice = substr($output_name, (strrpos($output_name, 'options-') + 8));526 $compiler_lines = explode(PHP_EOL, pts_file_io::file_get_contents($compiler_output));527 // Clean-up / reduce the compiler options that are important528 $compiler_options = null;...
end_compiler_mask
Using AI Code Generation
1$installer = new pts_test_installer();2$installer->end_compiler_mask();3$installer = new pts_test_installer();4$installer->end_compiler_mask();5$installer = new pts_test_installer();6$installer->end_compiler_mask();7$installer = new pts_test_installer();8$installer->end_compiler_mask();9$installer = new pts_test_installer();10$installer->end_compiler_mask();11$installer = new pts_test_installer();12$installer->end_compiler_mask();13$installer = new pts_test_installer();14$installer->end_compiler_mask();15$installer = new pts_test_installer();16$installer->end_compiler_mask();17$installer = new pts_test_installer();18$installer->end_compiler_mask();19$installer = new pts_test_installer();20$installer->end_compiler_mask();21$installer = new pts_test_installer();22$installer->end_compiler_mask();23$installer = new pts_test_installer();24$installer->end_compiler_mask();
end_compiler_mask
Using AI Code Generation
1$testInstaller = new pts_test_installer();2$testInstaller->end_compiler_mask();3$testInstaller = new pts_test_installer();4$testInstaller->end_compiler_mask();5$testInstaller = new pts_test_installer();6$testInstaller->end_compiler_mask();7$testInstaller = new pts_test_installer();8$testInstaller->end_compiler_mask();9$testInstaller = new pts_test_installer();10$testInstaller->end_compiler_mask();11$testInstaller = new pts_test_installer();12$testInstaller->end_compiler_mask();13$testInstaller = new pts_test_installer();14$testInstaller->end_compiler_mask();15$testInstaller = new pts_test_installer();16$testInstaller->end_compiler_mask();17$testInstaller = new pts_test_installer();18$testInstaller->end_compiler_mask();19$testInstaller = new pts_test_installer();20$testInstaller->end_compiler_mask();21$testInstaller = new pts_test_installer();22$testInstaller->end_compiler_mask();23$testInstaller = new pts_test_installer();24$testInstaller->end_compiler_mask();25$testInstaller = new pts_test_installer();26$testInstaller->end_compiler_mask();
end_compiler_mask
Using AI Code Generation
1$test_installer = new pts_test_installer();2$test_installer->end_compiler_mask();3$test_installer = new pts_test_installer();4$test_installer->end_compiler_mask();5$test_installer = new pts_test_installer();6$test_installer->end_compiler_mask();7$test_installer = new pts_test_installer();8$test_installer->end_compiler_mask();9$test_installer = new pts_test_installer();10$test_installer->end_compiler_mask();11$test_installer = new pts_test_installer();12$test_installer->end_compiler_mask();13$test_installer = new pts_test_installer();14$test_installer->end_compiler_mask();15$test_installer = new pts_test_installer();16$test_installer->end_compiler_mask();
end_compiler_mask
Using AI Code Generation
1$test_installer = new pts_test_installer();2$test_installer->end_compiler_mask();3$test_installer = new pts_test_installer();4$test_installer->run_test();5public function run_test($test_arguments = null, $test_run_manager = null)6{7 $test_run_manager = $this->test_installation->run_test($test_arguments, $test_run_manager);8}9public function run_test($test_arguments = null, $test_run_manager = null)10{11 $test_run_manager = $this->test_profile->run_test($test_arguments, $test_run_manager);12 return $test_run_manager;13}14public function run_test($test_arguments = null, $test_run_manager = null)15{16 $test_run_manager = $this->test_installation->run_test($test_arguments, $test_run_manager);17 return $test_run_manager;18}19public function run_test($test_arguments = null, $test_run_manager = null)20{21 $test_run_manager = $this->test_profile->run_test($test_arguments, $test_run_manager);22 return $test_run_manager;23}
end_compiler_mask
Using AI Code Generation
1require_once('pts-test-installer.php');2$test_installer = new pts_test_installer();3$test_installer->end_compiler_mask();4require_once('pts-test-installer.php');5$test_installer = new pts_test_installer();6$test_profile = $test_installer->get_test_profile();7require_once('pts-test-installer.php');8$test_installer = new pts_test_installer();9$is_installed = $test_installer->is_test_profile_installed();10require_once('pts-test-installer.php');11$test_installer = new pts_test_installer();12$is_installed = $test_installer->install_test_profile();13require_once('pts-test-installer.php');14$test_installer = new pts_test_installer();15$is_installed = $test_installer->remove_test_profile();
end_compiler_mask
Using AI Code Generation
1$test_installer->end_compiler_mask();2$test_installer->install_deb_package('path of the deb package');3$test_installer->install_source_code('path of the source code');4$test_installer->install_package('path of the package');5$test_installer->install_tarball('path of the tarball');6$test_installer->install_zip('path of the zip file');7$test_installer->install_git('url of the git repository');
end_compiler_mask
Using AI Code Generation
1$compiler = new pts_test_compiler();2$compiler->compile('2.c');3echo $compiler->end_compiler_mask($compiler, 2);4$compiler = new pts_test_compiler();5$compiler->compile('3.c');6echo $compiler->end_compiler_mask($compiler, 2);7$compiler = new pts_test_compiler();8$compiler->compile('4.c');9echo $compiler->end_compiler_mask($compiler, 2);
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 end_compiler_mask 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!!