How to use is_debug_mode method of pts_client class

Best Phoronix-test-suite code snippet using pts_client.is_debug_mode

pts_client.php

Source:pts_client.php Github

copy

Full Screen

...379 {380 self::$display = new pts_web_display_mode();381 return;382 }383 $env_mode = pts_client::is_debug_mode() ? 'BASIC' : $override_display_mode;384 switch(($env_mode != false || ($env_mode = pts_client::read_env('PTS_DISPLAY_MODE')) != false ? $env_mode : pts_config::read_user_config('PhoronixTestSuite/Options/General/DefaultDisplayMode', 'DEFAULT')))385 {386 case 'BASIC':387 self::$display = new pts_basic_display_mode();388 break;389 case 'BATCH':390 case 'CONCISE':391 self::$display = new pts_concise_display_mode();392 break;393 case 'SHORT':394 self::$display = new pts_short_display_mode();395 break;396 case 'DEFAULT':397 default:398 self::$display = new pts_concise_display_mode();399 break;400 }401 }402 public static function program_requirement_checks($only_show_required = false)403 {404 $extension_checks = pts_needed_extensions();405 $printed_required_header = false;406 $printed_optional_header = false;407 foreach($extension_checks as $extension)408 {409 if($extension[1] == false)410 {411 if($extension[0] == 1)412 {413 // Oops, this extension is required414 if($printed_required_header == false)415 {416 echo PHP_EOL . 'The following PHP extensions are REQUIRED by the Phoronix Test Suite:' . PHP_EOL . PHP_EOL;417 $printed_required_header = true;418 }419 }420 else421 {422 if(($only_show_required || PTS_IS_DAEMONIZED_SERVER_PROCESS) && $printed_required_header == false)423 {424 continue;425 }426 // This extension is missing but optional427 if($printed_optional_header == false)428 {429 echo PHP_EOL . ($printed_required_header ? null : 'NOTICE: ') . 'The following PHP extensions are OPTIONAL but recommended:' . PHP_EOL . PHP_EOL;430 $printed_optional_header = true;431 }432 }433 echo sprintf('%-8ls %-30ls' . PHP_EOL, $extension[2], $extension[3]);434 }435 }436 if($printed_required_header || $printed_optional_header)437 {438 echo PHP_EOL;439 if($printed_required_header)440 {441 exit;442 }443 }444 }445 private static function build_temp_cache()446 {447 $pso = pts_storage_object::recover_from_file(PTS_TEMP_STORAGE);448 if($pso == false)449 {450 $pso = new pts_storage_object();451 }452 $pso->add_object('environmental_variables_for_modules', pts_module_manager::modules_environmental_variables());453 $pso->add_object('command_alias_list', pts_documentation::client_commands_aliases());454 $pso->save_to_file(PTS_TEMP_STORAGE);455 }456 private static function core_storage_init_process()457 {458 $pso = pts_storage_object::recover_from_file(PTS_CORE_STORAGE);459 if($pso == false)460 {461 $pso = new pts_storage_object(true, true);462 }463 // OpenBenchmarking.org - GSID464 $global_gsid = $pso->read_object('global_system_id');465 $global_gsid_e = $pso->read_object('global_system_id_e');466 $global_gsid_p = $pso->read_object('global_system_id_p');467 if(empty($global_gsid) || pts_openbenchmarking::is_valid_gsid_format($global_gsid) == false)468 {469 // Global System ID for anonymous uploads, etc470 $requested_gsid = true;471 $global_gsid = pts_openbenchmarking_client::request_gsid();472 if(is_array($global_gsid))473 {474 $pso->add_object('global_system_id', $global_gsid['gsid']); // GSID475 $pso->add_object('global_system_id_p', $global_gsid['gsid_p']); // GSID_P476 $pso->add_object('global_system_id_e', $global_gsid['gsid_e']); // GSID_E477 pts_define('PTS_GSID', $global_gsid['gsid']);478 pts_define('PTS_GSID_E', $global_gsid['gsid_e']);479 }480 }481 else if(pts_openbenchmarking::is_valid_gsid_e_format($global_gsid_e) == false || pts_openbenchmarking::is_valid_gsid_p_format($global_gsid_p) == false)482 {483 pts_define('PTS_GSID', $global_gsid);484 $requested_gsid = false;485 $global_gsid = pts_openbenchmarking_client::retrieve_gsid();486 if(is_array($global_gsid))487 {488 $pso->add_object('global_system_id_p', $global_gsid['gsid_p']); // GSID_P489 $pso->add_object('global_system_id_e', $global_gsid['gsid_e']); // GSID_E490 pts_define('PTS_GSID_E', $global_gsid['gsid_e']);491 }492 }493 else494 {495 pts_define('PTS_GSID', $global_gsid);496 pts_define('PTS_GSID_E', $global_gsid_e);497 $requested_gsid = false;498 }499 $machine_self_id = $pso->read_object('machine_self_id');500 if(empty($machine_self_id))501 {502 $ns = md5('phoronix-test-suite');503 $binary_ns = null;504 for($i = 0; $i < strlen($ns); $i += 2)505 {506 $binary_ns .= chr(hexdec($ns[$i] . $ns[$i + 1]));507 }508 $msi_hash = sha1($binary_ns . uniqid(PTS_CORE_VERSION, true) . getenv('USERNAME') . getenv('USER') . getenv('HOSTNAME') . pts_network::get_local_ip());509 $machine_self_id = sprintf('%08s-%04s-%04x-%04x-%12s', substr($msi_hash, 0, 8), substr($msi_hash, 8, 4), (hexdec(substr($msi_hash, 12, 4)) & 0x0fff) | 0x5000, (hexdec(substr($msi_hash, 16, 4)) & 0x3fff) | 0x8000, substr($msi_hash, 20, 12));510 // machine_self_id is self-generated unique name for Phoromatic/OB purposes in UUIDv5 format511 $pso->add_object('machine_self_id', $machine_self_id);512 }513 pts_define('PTS_MACHINE_SELF_ID', $machine_self_id);514 // Last Run Processing515 $last_core_version = $pso->read_object('last_core_version');516 pts_define('FIRST_RUN_ON_PTS_UPGRADE', ($last_core_version != PTS_CORE_VERSION));517 if(FIRST_RUN_ON_PTS_UPGRADE || ($pso->read_object('last_php_version') != PTS_PHP_VERSION))518 {519 // Report any missing/recommended extensions520 self::program_requirement_checks();521 }522 if(FIRST_RUN_ON_PTS_UPGRADE)523 {524 if($requested_gsid == false)525 {526 pts_openbenchmarking_client::update_gsid();527 }528 pts_client::build_temp_cache();529 }530 $pso->add_object('last_core_version', PTS_CORE_VERSION); // PTS version last run531 $pso->add_object('last_php_version', PTS_PHP_VERSION); // PHP version last run532 //$last_pts_version = $pso->read_object('last_pts_version');533 // do something here with $last_pts_version if you want that information534 $pso->add_object('last_pts_version', PTS_VERSION); // PTS version last run535 // Last Run Processing536 $last_run = $pso->read_object('last_run_time');537 pts_define('IS_FIRST_RUN_TODAY', (substr($last_run, 0, 10) != date('Y-m-d')));538 $pso->add_object('last_run_time', date('Y-m-d H:i:s')); // Time PTS was last run539 pts_define('TIME_SINCE_LAST_RUN', ceil((time() - strtotime($last_run)) / 60)); // TIME_SINCE_LAST_RUN is in minutes540 // User Agreement Checking541 $agreement_cs = $pso->read_object('user_agreement_cs');542 $pso->add_object('user_agreement_cs', $agreement_cs); // User agreement check-sum543 // Phodevi Cache Handling544 $phodevi_cache = $pso->read_object('phodevi_smart_cache');545 if($phodevi_cache instanceof phodevi_cache && pts_client::read_env('NO_PHODEVI_CACHE') == false)546 {547 $phodevi_cache = $phodevi_cache->restore_cache(PTS_USER_PATH, PTS_CORE_VERSION);548 phodevi::set_device_cache($phodevi_cache);549 if(($external_phodevi_cache = pts_client::read_env('EXTERNAL_PHODEVI_CACHE')))550 {551 if(is_dir($external_phodevi_cache) && is_file($external_phodevi_cache . '/core.pt2so'))552 {553 $external_phodevi_cache .= '/core.pt2so';554 }555 if(is_file($external_phodevi_cache))556 {557 $external_phodevi_cache = pts_storage_object::force_recover_from_file($external_phodevi_cache);558 if($external_phodevi_cache != false)559 {560 $external_phodevi_cache = $external_phodevi_cache->read_object('phodevi_smart_cache');561 $external_phodevi_cache = $external_phodevi_cache->restore_cache(null, PTS_CORE_VERSION);562 if($external_phodevi_cache != false)563 {564 //unset($external_phodevi_cache['system']['operating-system']);565 //unset($external_phodevi_cache['system']['vendor-identifier']);566 phodevi::set_device_cache($external_phodevi_cache);567 }568 }569 }570 }571 }572 // Archive to disk573 $pso->save_to_file(PTS_CORE_STORAGE);574 }575 public static function register_phoromatic_server($server_ip, $http_port)576 {577 self::$phoromatic_servers[] = array('ip' => $server_ip, 'http_port' => $http_port);578 }579 public static function available_phoromatic_servers()580 {581 $phoromatic_servers = array();582 $possible_servers = pts_network::find_zeroconf_phoromatic_servers(true);583 foreach(self::$phoromatic_servers as $server)584 {585 $possible_servers[] = array($server['ip'], $server['http_port']);586 }587 $user_config_phoromatic_servers = pts_config::read_user_config('PhoronixTestSuite/Options/General/PhoromaticServers', '');588 foreach(explode(',', $user_config_phoromatic_servers) as $static_server)589 {590 $static_server = explode(':', $static_server);591 if(count($static_server) == 2)592 {593 $possible_servers[] = array($static_server[0], $static_server[1]);594 }595 }596 if(is_file(PTS_USER_PATH . 'phoromatic-servers'))597 {598 $phoromatic_servers_file = pts_file_io::file_get_contents(PTS_USER_PATH . 'phoromatic-servers');599 foreach(explode(PHP_EOL, $phoromatic_servers_file) as $ps_file_line)600 {601 $ps_file_line = explode(':', trim($ps_file_line));602 if(count($ps_file_line) == 2 && ip2long($ps_file_line[0]) !== false && is_numeric($ps_file_line) && $ps_file_line > 100)603 {604 $possible_servers[] = array($ps_file_line[0], $ps_file_line[1]);605 }606 }607 }608 foreach($possible_servers as $possible_server)609 {610 // possible_server[0] is the Phoromatic Server IP611 // possible_server[1] is the Phoromatic Server HTTP PORT612 if(in_array($possible_server[0], array_keys($phoromatic_servers)))613 {614 continue;615 }616 $server_response = pts_network::http_get_contents('http://' . $possible_server[0] . ':' . $possible_server[1] . '/server.php', false, false, 3);617 if(stripos($server_response, 'Phoromatic') !== false)618 {619 trigger_error('Phoromatic Server Auto-Detected At: ' . $possible_server[0] . ':' . $possible_server[1], E_USER_NOTICE);620 $phoromatic_servers[$possible_server[0]] = array('ip' => $possible_server[0], 'http_port' => $possible_server[1]);621 }622 }623 return $phoromatic_servers;624 }625 public static function user_agreement_check($command)626 {627 $pso = pts_storage_object::recover_from_file(PTS_CORE_STORAGE);628 if($pso == false)629 {630 return false;631 }632 $config_md5 = $pso->read_object('user_agreement_cs');633 $current_md5 = md5_file(PTS_PATH . 'pts-core/user-agreement.txt');634 if(($config_md5 != $current_md5 || pts_config::read_user_config('PhoronixTestSuite/Options/OpenBenchmarking/AnonymousUsageReporting', 'UNKNOWN') == 'UNKNOWN') && !PTS_IS_DAEMONIZED_SERVER_PROCESS && getenv('PTS_SILENT_MODE') != 1 && $config_md5 != 'enterprise-agree')635 {636 $prompt_in_method = pts_client::check_command_for_function($command, 'pts_user_agreement_prompt');637 $user_agreement = file_get_contents(PTS_PATH . 'pts-core/user-agreement.txt');638 if($prompt_in_method)639 {640 $user_agreement_return = call_user_func(array($command, 'pts_user_agreement_prompt'), $user_agreement);641 if(is_array($user_agreement_return))642 {643 if(count($user_agreement_return) == 3)644 {645 list($agree, $usage_reporting) = $user_agreement_return;646 }647 else648 {649 $agree = array_shift($user_agreement_return);650 $usage_reporting = -1;651 }652 }653 else654 {655 $agree = $user_agreement_return;656 $usage_reporting = -1;657 }658 }659 if($prompt_in_method == false || $usage_reporting == -1)660 {661 pts_client::$display->generic_heading('User Agreement');662 echo wordwrap($user_agreement, 65);663 $agree = pts_user_io::prompt_bool_input('Do you agree to these terms and wish to proceed', true);664 $usage_reporting = $agree ? pts_user_io::prompt_bool_input('Enable anonymous usage / statistics reporting', true) : -1;665 }666 if($agree)667 {668 echo PHP_EOL;669 $pso->add_object('user_agreement_cs', $current_md5);670 $pso->save_to_file(PTS_CORE_STORAGE);671 }672 else673 {674 pts_client::exit_client('In order to run the Phoronix Test Suite, you must agree to the listed terms.');675 }676 pts_config::user_config_generate(array(677 'PhoronixTestSuite/Options/OpenBenchmarking/AnonymousUsageReporting' => pts_config::bool_to_string($usage_reporting)));678 }679 }680 public static function swap_variables($user_str, $replace_call)681 {682 if(is_array($replace_call))683 {684 if(count($replace_call) != 2 || method_exists($replace_call[0], $replace_call[1]) == false)685 {686 echo PHP_EOL . 'Var Swap With Method Failed.' . PHP_EOL;687 return $user_str;688 }689 }690 else if(!function_exists($replace_call))691 {692 echo PHP_EOL . 'Var Swap With Function Failed.' . PHP_EOL;693 return $user_str;694 }695 $offset = 0;696 $replace_call_return = false;697 while($offset < strlen($user_str) && ($s = strpos($user_str, '$', $offset)) !== false)698 {699 $s++;700 $var_name = substr($user_str, $s, (($e = strpos($user_str, ' ', $s)) == false ? strlen($user_str) : $e) - $s);701 if($replace_call_return === false)702 {703 $replace_call_return = call_user_func($replace_call);704 }705 $var_replacement = isset($replace_call_return[$var_name]) ? $replace_call_return[$var_name] : null;706 if($var_replacement != null)707 {708 $user_str = str_replace('$' . $var_name, $var_replacement, $user_str);709 }710 else711 {712 // echo "\nVariable Swap For $var_name Failed.\n";713 }714 $offset = $s + strlen($var_replacement);715 }716 return $user_str;717 }718 public static function setup_test_result_directory($save_to)719 {720 $save_to_dir = PTS_SAVE_RESULTS_PATH . $save_to;721 if(strpos(basename($save_to_dir), '.'))722 {723 $save_to_dir = dirname($save_to_dir);724 }725 if($save_to_dir != '.')726 {727 pts_file_io::mkdir($save_to_dir);728 }729 copy(PTS_CORE_STATIC_PATH . 'result-viewer.html', $save_to_dir . '/index.html');730 return $save_to_dir;731 }732 public static function remove_installed_test(&$test_profile)733 {734 pts_file_io::delete($test_profile->get_install_dir(), null, true);735 }736 public static function exit_client($string = null, $exit_status = 0)737 {738 // Exit the Phoronix Test Suite client739 pts_define('PTS_EXIT', 1);740 if($string != null)741 {742 echo PHP_EOL . $string . PHP_EOL;743 }744 exit($exit_status);745 }746 public static function current_user()747 {748 // Current system user749 return ($pts_user = pts_openbenchmarking_client::user_name()) != null ? $pts_user : phodevi::read_property('system', 'username');750 }751 public static function test_profile_debug_message($message)752 {753 $reported = false;754 if(pts_client::is_debug_mode())755 {756 pts_client::$display->test_run_instance_error($message);757 $reported = true;758 }759 return $reported;760 }761 public static function generate_result_file_graphs($test_results_identifier, $save_to_dir = false, $extra_attributes = null)762 {763 if($save_to_dir)764 {765 if(pts_file_io::mkdir($save_to_dir . '/result-graphs') == false)766 {767 // Directory must exist, so remove any old graph files first768 foreach(pts_file_io::glob($save_to_dir . '/result-graphs/*') as $old_file)769 {770 unlink($old_file);771 }772 }773 }774 if($test_results_identifier instanceof pts_result_file)775 {776 $result_file = &$test_results_identifier;777 }778 else779 {780 $result_file = new pts_result_file($test_results_identifier);781 }782 $generated_graphs = array();783 $generated_graph_tables = false;784 // Render overview chart785 if($save_to_dir)786 {787 $chart = new pts_ResultFileTable($result_file);788 $chart->renderChart($save_to_dir . '/result-graphs/overview.BILDE_EXTENSION');789 $intent = -1;790 if(($intent = pts_result_file_analyzer::analyze_result_file_intent($result_file, $intent, true)) || $result_file->get_system_count() == 1)791 {792 $chart = new pts_ResultFileCompactSystemsTable($result_file, $intent);793 }794 else795 {796 $chart = new pts_ResultFileSystemsTable($result_file);797 }798 $chart->renderChart($save_to_dir . '/result-graphs/systems.BILDE_EXTENSION');799 unset($chart);800 if($intent && is_dir($save_to_dir . '/system-logs/'))801 {802 $chart = new pts_DetailedSystemComponentTable($result_file, $save_to_dir . '/system-logs/', $intent);803 if($chart)804 {805 $chart->renderChart($save_to_dir . '/result-graphs/detailed_component.BILDE_EXTENSION');806 }807 }808 }809 $result_objects = $result_file->get_result_objects();810 $test_titles = array();811 foreach($result_objects as &$result_object)812 {813 $test_titles[] = $result_object->test_profile->get_title();814 }815 $offset = 0;816 foreach($result_objects as $key => &$result_object)817 {818 $save_to = $save_to_dir;819 $offset++;820 if($save_to_dir && is_dir($save_to_dir))821 {822 $save_to .= '/result-graphs/' . $offset . '.BILDE_EXTENSION';823 if(PTS_IS_CLIENT)824 {825 if($result_file->is_multi_way_comparison(null, $extra_attributes) || pts_client::read_env('GRAPH_GROUP_SIMILAR'))826 {827 $table_keys = array();828 foreach($test_titles as $this_title_index => $this_title)829 {830 if(isset($test_titles[$key]) && $this_title == $test_titles[$key])831 {832 $table_keys[] = $this_title_index;833 }834 }835 }836 else837 {838 $table_keys = $key;839 }840 $chart = new pts_ResultFileTable($result_file, null, $table_keys);841 $chart->renderChart($save_to_dir . '/result-graphs/' . $offset . '_table.BILDE_EXTENSION');842 unset($chart);843 $generated_graph_tables = true;844 }845 }846 $graph = pts_render::render_graph($result_object, $result_file, $save_to, $extra_attributes);847 if($graph == false)848 {849 continue;850 }851 $generated_graphs[] = $graph;852 }853 // Generate mini / overview graphs854 if($save_to_dir)855 {856 $graph = new pts_OverviewGraph($result_file);857 if($graph->doSkipGraph() == false)858 {859 $graph->renderGraph();860 // Check to see if skip_graph was realized during the rendering process861 if($graph->doSkipGraph() == false)862 {863 $graph->svg_dom->output($save_to_dir . '/result-graphs/visualize.BILDE_EXTENSION');864 }865 }866 unset($graph);867 $graph = new pts_RadarOverviewGraph($result_file);868 if($graph->doSkipGraph() == false)869 {870 $graph->renderGraph();871 // Check to see if skip_graph was realized during the rendering process872 if($graph->doSkipGraph() == false)873 {874 $graph->svg_dom->output($save_to_dir . '/result-graphs/radar.BILDE_EXTENSION');875 }876 }877 unset($graph);878 }879 // Save the result viewer880 if(count($generated_graphs) > 0 && $save_to_dir)881 {882 copy(PTS_CORE_STATIC_PATH . 'result-viewer.html', $save_to_dir . '/index.html');883 }884 return $generated_graphs;885 }886 public static function process_shutdown_tasks()887 {888 // TODO: possibly do something like posix_getpid() != pts_client::$startup_pid in case shutdown function is called from a child process889 // Generate Phodevi Smart Cache890 if(pts_client::read_env('NO_PHODEVI_CACHE') == false && pts_client::read_env('EXTERNAL_PHODEVI_CACHE') == false)891 {892 if(pts_config::read_bool_config('PhoronixTestSuite/Options/General/UsePhodeviCache', 'TRUE'))893 {894 pts_storage_object::set_in_file(PTS_CORE_STORAGE, 'phodevi_smart_cache', phodevi::get_phodevi_cache_object(PTS_USER_PATH, PTS_CORE_VERSION));895 }896 else897 {898 pts_storage_object::set_in_file(PTS_CORE_STORAGE, 'phodevi_smart_cache', null);899 }900 }901 if(is_array(self::$lock_pointers))902 {903 foreach(array_keys(self::$lock_pointers) as $lock_file)904 {905 self::release_lock($lock_file);906 }907 }908 foreach(self::$forked_pids as $pid)909 {910 if(is_dir('/proc/' . $pid) && function_exists('posix_kill'))911 {912 posix_kill($pid, SIGKILL);913 }914 }915 }916 public static function do_anonymous_usage_reporting()917 {918 return pts_config::read_bool_config('PhoronixTestSuite/Options/OpenBenchmarking/AnonymousUsageReporting', 0);919 }920 public static function release_lock($lock_file)921 {922 // Remove lock923 if(isset(self::$lock_pointers[$lock_file]) == false)924 {925 return false;926 }927 if(is_resource(self::$lock_pointers[$lock_file]))928 {929 fclose(self::$lock_pointers[$lock_file]);930 }931 pts_file_io::unlink($lock_file);932 unset(self::$lock_pointers[$lock_file]);933 }934 public static function check_command_for_function($option, $check_function)935 {936 $in_option = false;937 if(is_file(PTS_COMMAND_PATH . $option . '.php'))938 {939 if(!class_exists($option, false) && is_file(PTS_COMMAND_PATH . $option . '.php'))940 {941 include(PTS_COMMAND_PATH . $option . '.php');942 }943 if(method_exists($option, $check_function))944 {945 $in_option = true;946 }947 }948 return $in_option;949 }950 public static function regenerate_graphs($result_file_identifier, $full_process_string = false, $extra_graph_attributes = null)951 {952 $save_to_dir = pts_client::setup_test_result_directory($result_file_identifier);953 $generated_graphs = pts_client::generate_result_file_graphs($result_file_identifier, $save_to_dir, $extra_graph_attributes);954 $generated = count($generated_graphs) > 0;955 if($generated && $full_process_string)956 {957 echo PHP_EOL . $full_process_string . PHP_EOL;958 pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $result_file_identifier . '/index.html');959 }960 return $generated;961 }962 public static function execute_command($command, $pass_args = null)963 {964 if(!class_exists($command, false) && is_file(PTS_COMMAND_PATH . $command . '.php'))965 {966 include(PTS_COMMAND_PATH . $command . '.php');967 }968 if(is_file(PTS_COMMAND_PATH . $command . '.php') && method_exists($command, 'argument_checks'))969 {970 $argument_checks = call_user_func(array($command, 'argument_checks'));971 foreach($argument_checks as &$argument_check)972 {973 $function_check = $argument_check->get_function_check();974 $method_check = false;975 if(is_array($function_check) && count($function_check) == 2)976 {977 $method_check = $function_check[0];978 $function_check = $function_check[1];979 }980 if(substr($function_check, 0, 1) == '!')981 {982 $function_check = substr($function_check, 1);983 $return_fails_on = true;984 }985 else986 {987 $return_fails_on = false;988 }989 990 if($method_check != false)991 {992 if(!method_exists($method_check, $function_check))993 {994 echo PHP_EOL . 'Method check fails.' . PHP_EOL;995 continue;996 }997 $function_check = array($method_check, $function_check);998 }999 else if(!function_exists($function_check))1000 {1001 continue;1002 }1003 if($argument_check->get_argument_index() == 'VARIABLE_LENGTH')1004 {1005 $return_value = null;1006 foreach($pass_args as $arg)1007 {1008 $return_value = call_user_func_array($function_check, array($arg));1009 if($return_value == true)1010 {1011 break;1012 }1013 }1014 }1015 else1016 {1017 $return_value = call_user_func_array($function_check, array((isset($pass_args[$argument_check->get_argument_index()]) ? $pass_args[$argument_check->get_argument_index()] : null)));1018 }1019 if($return_value == $return_fails_on)1020 {1021 $command_alias = defined($command . '::doc_use_alias') ? constant($command . '::doc_use_alias') : $command;1022 if((isset($pass_args[$argument_check->get_argument_index()]) && !empty($pass_args[$argument_check->get_argument_index()])) || ($argument_check->get_argument_index() == 'VARIABLE_LENGTH' && !empty($pass_args)))1023 {1024 trigger_error('Invalid Argument: ' . implode(' ', $pass_args), E_USER_ERROR);1025 }1026 else1027 {1028 trigger_error('Phoronix Test Suite Argument Missing.', E_USER_ERROR);1029 }1030 echo PHP_EOL . 'CORRECT SYNTAX:' . PHP_EOL . 'phoronix-test-suite ' . str_replace('_', '-', $command_alias) . ' ' . implode(' ', $argument_checks) . PHP_EOL . PHP_EOL;1031 if(method_exists($command, 'invalid_command'))1032 {1033 call_user_func_array(array($command, 'invalid_command'), $pass_args);1034 echo PHP_EOL;1035 }1036 return false;1037 }1038 else1039 {1040 if($argument_check->get_function_return_key() != null && !isset($pass_args[$argument_check->get_function_return_key()]))1041 {1042 $pass_args[$argument_check->get_function_return_key()] = $return_value;1043 }1044 }1045 }1046 }1047 pts_module_manager::module_process('__pre_option_process', $command);1048 if(is_file(PTS_COMMAND_PATH . $command . '.php'))1049 {1050 self::$current_command = $command;1051 if(method_exists($command, 'run'))1052 {1053 call_user_func(array($command, 'run'), $pass_args);1054 }1055 else1056 {1057 echo PHP_EOL . 'There is an error in the requested command: ' . $command . PHP_EOL . PHP_EOL;1058 }1059 }1060 else if(($t = pts_module::valid_run_command($command)) != false)1061 {1062 list($module, $module_command) = $t;1063 pts_module_manager::set_current_module($module);1064 pts_module_manager::run_command($module, $module_command, $pass_args);1065 pts_module_manager::set_current_module(null);1066 }1067 echo PHP_EOL;1068 pts_module_manager::module_process('__post_option_process', $command);1069 }1070 public static function current_command()1071 {1072 return self::$current_command;1073 }1074 public static function terminal_width()1075 {1076 static $terminal_width = null;1077 if($terminal_width == null)1078 {1079 $chars = 80;1080 if(pts_client::read_env('TERMINAL_WIDTH') != false && is_numeric(pts_client::read_env('TERMINAL_WIDTH')) >= 80)1081 {1082 $terminal_width = pts_client::read_env('TERMINAL_WIDTH');1083 }1084 else if(pts_client::executable_in_path('stty'))1085 {1086 $terminal_width = explode(' ', trim(shell_exec('stty size 2>&1')));1087 if(count($terminal_width) == 2 && is_numeric($terminal_width[1]) && $terminal_width[1] >= 80)1088 {1089 $chars = $terminal_width[1];1090 }1091 }1092 else if(pts_client::executable_in_path('tput'))1093 {1094 $terminal_width = trim(shell_exec('tput cols 2>&1'));1095 if(is_numeric($terminal_width) && $terminal_width > 1)1096 {1097 $chars = $terminal_width;1098 }1099 }1100 $terminal_width = $chars;1101 }1102 return $terminal_width;1103 }1104 public static function is_process_running($process)1105 {1106 if(phodevi::is_linux())1107 {1108 // Checks if process is running on the system1109 $running = shell_exec('ps -C ' . strtolower($process) . ' 2>&1');1110 $running = trim(str_replace(array('PID', 'TTY', 'TIME', 'CMD'), '', $running));1111 }1112 else if(phodevi::is_solaris())1113 {1114 // Checks if process is running on the system1115 $ps = shell_exec('ps -ef 2>&1');1116 $running = strpos($ps, ' ' . strtolower($process)) != false ? 'TRUE' : null;1117 }1118 else if(pts_client::executable_in_path('ps') != false)1119 {1120 // Checks if process is running on the system1121 $ps = shell_exec('ps -ax 2>&1');1122 $running = strpos($ps, ' ' . strtolower($process)) != false ? 'TRUE' : null;1123 }1124 else1125 {1126 $running = null;1127 }1128 return !empty($running);1129 }1130 public static function parse_value_string_double_identifier($value_string)1131 {1132 // i.e. with PRESET_OPTIONS='stream.run-type=Add'1133 $values = array();1134 foreach(explode(';', $value_string) as $preset)1135 {1136 if(count($preset = pts_strings::trim_explode('=', $preset)) == 2)1137 {1138 $dot = strrpos($preset[0], '.');1139 if($dot !== false && ($test = substr($preset[0], 0, $dot)) != null && ($option = substr($preset[0], ($dot + 1))) != null)1140 {1141 $values[$test][$option] = $preset[1];1142 }1143 }1144 }1145 return $values;1146 }1147 public static function create_temporary_file($file_extension = null)1148 {1149 $temp_file = tempnam(pts_client::temporary_directory(), 'PTS');1150 if($file_extension)1151 {1152 $extended_file = pts_client::temporary_directory() . '/' . basename($temp_file) . $file_extension;1153 if(rename($temp_file, $extended_file))1154 {1155 $temp_file = $extended_file;1156 }1157 }1158 return $temp_file;1159 }1160 public static function create_temporary_directory($prefix = null)1161 {1162 $tmpdir = pts_client::temporary_directory();1163 do1164 {1165 $randname = '/pts-' . $prefix . rand(0, 9999);1166 }1167 while(is_dir($tmpdir . $randname));1168 mkdir($tmpdir . $randname);1169 return $tmpdir . $randname . '/';1170 }1171 public static function temporary_directory()1172 {1173 return sys_get_temp_dir();1174 }1175 public static function read_env($var)1176 {1177 return getenv($var);1178 }1179 public static function pts_set_environment_variable($name, $value)1180 {1181 // Sets an environmental variable1182 return getenv($name) == false && putenv($name . '=' . $value);1183 }1184 public static function shell_exec($exec, $extra_vars = null)1185 {1186 // Same as shell_exec() but with the PTS env variables added in1187 // Convert pts_client::environmental_variables() into shell export variable syntax1188 $var_string = '';1189 $extra_vars = ($extra_vars == null ? pts_client::environmental_variables() : array_merge(pts_client::environmental_variables(), $extra_vars));1190 foreach(array_keys($extra_vars) as $key)1191 {1192 $var_string .= 'export ' . $key . '=' . str_replace(' ', '\ ', trim($extra_vars[$key])) . ';';1193 }1194 $var_string .= ' ';1195 return shell_exec($var_string . $exec);1196 }1197 public static function executable_in_path($executable, $ignore_paths_with = false)1198 {1199 static $cache = null;1200 if(!isset($cache[$executable]) || $ignore_paths_with)1201 {1202 $paths = pts_strings::trim_explode((phodevi::is_windows() ? ';' : ':'), (($path = pts_client::read_env('PATH')) == false ? '/usr/local/bin:/usr/bin:/usr/sbin:/bin' : $path));1203 $executable_path = false;1204 foreach($paths as $path)1205 {1206 $path = pts_strings::add_trailing_slash($path);1207 if(is_executable($path . $executable))1208 {1209 if($ignore_paths_with && stripos($path, $ignore_paths_with) !== false)1210 {1211 continue;1212 }1213 $executable_path = $path . $executable;1214 break;1215 }1216 }1217 if($ignore_paths_with)1218 {1219 // Don't cache calls using the $ignore_paths_with parameter1220 return $executable_path;1221 }1222 $cache[$executable] = $executable_path;1223 }1224 return $cache[$executable];1225 }1226 public static function display_web_page($URL, $alt_text = null, $default_open = true, $auto_open = false)1227 {1228 if((pts_client::read_env('DISPLAY') == false && pts_client::read_env('WAYLAND_DISPLAY') == false && phodevi::is_windows() == false && phodevi::is_macosx() == false) || defined('PHOROMATIC_PROCESS'))1229 {1230 return;1231 }1232 if($auto_open == false)1233 {1234 $view_results = pts_user_io::prompt_bool_input(($alt_text == null ? 'Do you want to view the results in your web browser' : $alt_text), $default_open);1235 }1236 else1237 {1238 $view_results = true;1239 }1240 if($view_results)1241 {1242 static $browser = null;1243 if($browser == null)1244 {1245 $config_browser = pts_config::read_user_config('PhoronixTestSuite/Options/General/DefaultBrowser', null);1246 if($config_browser != null && (is_executable($config_browser) || ($config_browser = pts_client::executable_in_path($config_browser))))1247 {1248 $browser = $config_browser;1249 }1250 else if(phodevi::is_windows())1251 {1252 $windows_browsers = array(1253 'C:\Program Files (x86)\Mozilla Firefox\firefox.exe',1254 'C:\Program Files\Internet Explorer\iexplore.exe'1255 );1256 foreach($windows_browsers as $browser_test)1257 {1258 if(is_executable($browser_test))1259 {1260 $browser = $browser_test;1261 break;1262 }1263 }1264 if(substr($URL, 0, 1) == '\\')1265 {1266 $URL = 'file:///C:' . str_replace('/', '\\', $URL);1267 }1268 }1269 else1270 {1271 $possible_browsers = array('firefox', 'mozilla', 'x-www-browser', 'open', 'xdg-open', 'iceweasel', 'konqueror', 'epiphany', 'google-chrome', 'midori', 'epiphany-browser', 'epiphany');1272 foreach($possible_browsers as &$b)1273 {1274 if(($b = pts_client::executable_in_path($b)))1275 {1276 $browser = $b;1277 break;1278 }1279 }1280 }1281 }1282 if($browser != null)1283 {1284 shell_exec($browser . ' "' . $URL . '" 2> /dev/null &');1285 }1286 else1287 {1288 echo PHP_EOL . 'No Web Browser Found.' . PHP_EOL;1289 }1290 }1291 }1292 public static function cache_hardware_calls()1293 {1294 phodevi::system_hardware(true);1295 phodevi::supported_sensors();1296 phodevi::unsupported_sensors();1297 }1298 public static function cache_software_calls()1299 {1300 phodevi::system_software(true);1301 }1302 public static function remove_saved_result_file($identifier)1303 {1304 pts_file_io::delete(PTS_SAVE_RESULTS_PATH . $identifier, null, true);1305 }1306 public static function saved_test_results()1307 {1308 $results = array();1309 $ignore_ids = array();1310 foreach(pts_file_io::glob(PTS_SAVE_RESULTS_PATH . '*/composite.xml') as $result_file)1311 {1312 $identifier = basename(dirname($result_file));1313 if(!in_array($identifier, $ignore_ids))1314 {1315 $results[] = $identifier;1316 }1317 }1318 return $results;1319 }1320 public static function timed_function($function, $function_parameters, $time, $continue_while_true_function = null, $continue_while_true_function_parameters)1321 {1322 if(($time < 0.5 && $time != -1) || $time > 300)1323 {1324 return;1325 }1326 if(function_exists('pcntl_fork') && function_exists('posix_setsid'))1327 {1328 $current_pid = function_exists('posix_getpid') ? posix_getpid() : -1;1329 $pid = pcntl_fork();1330 if($pid == -1)1331 {1332 trigger_error('Could not fork ' . $function . '.', E_USER_ERROR);1333 }1334 else if($pid)1335 {1336 self::$forked_pids[] = $pid;1337 }1338 else1339 {1340 posix_setsid();1341 $loop_continue = true;1342 while($loop_continue && is_file(PTS_USER_LOCK) && ($continue_while_true_function === true || ($loop_continue = call_user_func_array($continue_while_true_function, $continue_while_true_function_parameters))))1343 {1344 call_user_func_array($function, $function_parameters);1345 if($time > 0)1346 {1347 sleep($time);1348 }1349 else if($time == -1)1350 {1351 $loop_continue = false;1352 }1353 if($current_pid != -1 && !is_dir('/proc/' . $current_pid))1354 {1355 exit;1356 }1357 clearstatcache();1358 }1359 if(function_exists('posix_kill'))1360 {1361 posix_kill(posix_getpid(), SIGINT);1362 }1363 exit(0);1364 }1365 }1366 else1367 {1368 if(is_array($function))1369 {1370 $function = implode(':', $function);1371 }1372 trigger_error('php-pcntl and php-posix must be installed for calling ' . $function . '.', E_USER_ERROR);1373 }1374 }1375 public static function fork($fork_function, $fork_function_parameters = null)1376 {1377 if(!is_array($fork_function_parameters))1378 {1379 $fork_function_parameters = array($fork_function_parameters);1380 }1381 if(function_exists('pcntl_fork'))1382 {1383 $current_pid = function_exists('posix_getpid') ? posix_getpid() : -1;1384 $pid = pcntl_fork();1385 if($pid == -1)1386 {1387 trigger_error('Could not fork ' . $fork_function . '.', E_USER_ERROR);1388 }1389 else if($pid)1390 {1391 // PARENT1392 self::$forked_pids[] = $pid;1393 return true;1394 }1395 else1396 {1397 // CHILD1398 // posix_setsid();1399 call_user_func_array($fork_function, $fork_function_parameters);1400 if(function_exists('posix_kill'))1401 {1402 posix_kill(posix_getpid(), SIGINT);1403 }1404 exit(0);1405 }1406 }1407 else1408 {1409 // No PCNTL Support1410 call_user_func_array($fork_function, $fork_function_parameters);1411 }1412 return false;1413 }1414 public static function code_error_handler($error_code, $error_string, $error_file, $error_line)1415 {1416 /*if(!(error_reporting() & $error_code))1417 {1418 return;1419 }*/1420 switch($error_code)1421 {1422 case E_USER_ERROR:1423 $error_type = 'PROBLEM';1424 if(pts_client::is_debug_mode() == false)1425 {1426 $error_file = null;1427 $error_line = 0;1428 }1429 break;1430 case E_USER_NOTICE:1431 if(pts_client::is_debug_mode() == false)1432 {1433 return;1434 }1435 $error_type = 'NOTICE';1436 break;1437 case E_USER_WARNING:1438 $error_type = 'NOTICE'; // Yes, report warnings as a notice1439 if(pts_client::is_debug_mode() == false)1440 {1441 $error_file = null;1442 $error_line = 0;1443 }1444 break;1445 case E_ERROR:1446 case E_PARSE:1447 $error_type = 'ERROR';1448 break;1449 case E_WARNING:1450 case E_NOTICE:1451 $error_type = 'NOTICE';1452 if(($s = strpos($error_string, 'Undefined ')) !== false && ($x = strpos($error_string, ': ', $s)) !== false)1453 {1454 $error_string = 'Undefined: ' . substr($error_string, ($x + 2));1455 }1456 else1457 {1458 $ignore_errors = array(1459 'Name or service not known',1460 'HTTP request failed',1461 'fopen',1462 'fsockopen',1463 'file_get_contents',1464 'failed to connect',1465 'unable to connect',1466 'directory not empty'1467 );1468 foreach($ignore_errors as $error_check)1469 {1470 if(stripos($error_string, $error_check) !== false)1471 {1472 return;1473 }1474 }1475 }1476 break;1477 default:1478 $error_type = $error_code;1479 break;1480 }1481 if(pts_client::$pts_logger != false)1482 {1483 pts_client::$pts_logger->report_error($error_type, $error_string, $error_file, $error_line);1484 }1485 if(pts_client::$display != false)1486 {1487 pts_client::$display->triggered_system_error($error_type, $error_string, $error_file, $error_line);1488 }1489 else1490 {1491 echo PHP_EOL . $error_string;1492 if($error_file != null && $error_line != null)1493 {1494 echo ' in ' . $error_file . ':' . $error_line;1495 }1496 echo PHP_EOL;1497 }1498 if($error_type == 'ERROR')1499 {1500 exit(1);1501 }1502 }1503 public static function set_debug_mode($dmode)1504 {1505 self::$debug_mode = ($dmode == true);1506 }1507 public static function is_debug_mode()1508 {1509 return self::$debug_mode == true;1510 }1511}1512// Some extra magic1513set_error_handler(array('pts_client', 'code_error_handler'));1514if(PTS_IS_CLIENT && (PTS_IS_DEV_BUILD || pts_client::is_debug_mode()))1515{1516 // Enable more verbose error reporting only when PTS is in development with milestone (alpha/beta) releases but no release candidate (r) or gold versions1517 error_reporting(E_ALL | E_NOTICE | E_STRICT);1518}1519?>...

Full Screen

Full Screen

pts_test_execution.php

Source:pts_test_execution.php Github

copy

Full Screen

...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 }...

Full Screen

Full Screen

is_debug_mode

Using AI Code Generation

copy

Full Screen

1$pts_client = new pts_client();2if ($pts_client->is_debug_mode()) {3 echo "Debug mode is enabled";4}5$pts_client = new pts_client();6if ($pts_client->is_debug_mode()) {7 echo "Debug mode is enabled";8}9$pts_client = new pts_client();10if ($pts_client->is_debug_mode()) {11 echo "Debug mode is enabled";12}13$pts_client = new pts_client();14if ($pts_client->is_debug_mode()) {15 echo "Debug mode is enabled";16}17$pts_client = new pts_client();18if ($pts_client->is_debug_mode()) {19 echo "Debug mode is enabled";20}21$pts_client = new pts_client();22if ($pts_client->is_debug_mode()) {23 echo "Debug mode is enabled";24}25$pts_client = new pts_client();26if ($pts_client->is_debug_mode()) {27 echo "Debug mode is enabled";28}29$pts_client = new pts_client();30if ($pts_client->is_debug_mode()) {31 echo "Debug mode is enabled";32}33$pts_client = new pts_client();34if ($pts_client->is_debug_mode()) {35 echo "Debug mode is enabled";36}37$pts_client = new pts_client();38if ($pts_client->is_debug_mode()) {39 echo "Debug mode is enabled";40}41$pts_client = new pts_client();42if ($pts_client->is_debug_mode()) {43 echo "Debug mode is enabled";44}

Full Screen

Full Screen

is_debug_mode

Using AI Code Generation

copy

Full Screen

1if (pts_client::is_debug_mode()) {2 echo "Debug mode is enabled";3} else {4 echo "Debug mode is disabled";5}6pts_client::set_debug_mode(true);7if (pts_client::is_debug_mode()) {8 echo "Debug mode is enabled";9} else {10 echo "Debug mode is disabled";11}12pts_client::set_debug_mode(false);13if (pts_client::is_debug_mode()) {14 echo "Debug mode is enabled";15} else {16 echo "Debug mode is disabled";17}18pts_client::set_debug_mode(true);19if (pts_client::is_debug_mode()) {20 echo "Debug mode is enabled";21} else {22 echo "Debug mode is disabled";23}24pts_client::set_debug_mode(false);25if (pts_client::is_debug_mode()) {26 echo "Debug mode is enabled";27} else {28 echo "Debug mode is disabled";29}30pts_client::set_debug_mode(true);31if (pts_client::is_debug_mode()) {32 echo "Debug mode is enabled";33} else {34 echo "Debug mode is disabled";35}36pts_client::set_debug_mode(false);37if (pts_client::is_debug_mode()) {38 echo "Debug mode is enabled";39} else {40 echo "Debug mode is disabled";41}42pts_client::set_debug_mode(true);43if (pts_client::is_debug_mode()) {44 echo "Debug mode is enabled";45} else {46 echo "Debug mode is disabled";47}

Full Screen

Full Screen

is_debug_mode

Using AI Code Generation

copy

Full Screen

1require_once('pts-core.php');2$pts_client = new pts_client();3if($pts_client->is_debug_mode())4{5}6{7}8require_once('pts-core.php');9$pts_client = new pts_client();10if($pts_client->is_debug_mode())11{12}13{14}15require_once('pts-core.php');16$pts_client = new pts_client();17if($pts_client->is_debug_mode())18{19}20{21}22require_once('pts-core.php');23$pts_client = new pts_client();24if($pts_client->is_debug_mode())25{26}27{28}29require_once('pts-core.php');30$pts_client = new pts_client();31if($pts_client->is_debug_mode())32{33}34{35}36require_once('pts-core.php');37$pts_client = new pts_client();38if($pts_client->is_debug_mode())39{40}41{42}43require_once('pts-core.php');44$pts_client = new pts_client();45if($pts_client->is_debug_mode())46{47}48{49}50require_once('pts-core.php');51$pts_client = new pts_client();52if($pts_client->is_debug_mode())53{54}55{56}57require_once('pts-core.php');

Full Screen

Full Screen

is_debug_mode

Using AI Code Generation

copy

Full Screen

1require_once('pts_client.php');2if (pts_client::is_debug_mode())3{4echo "Debug mode is on";5}6{7echo "Debug mode is off";8}9require_once('pts_client.php');10if (pts_client::is_debug_mode())11{12echo "Debug mode is on";13}14{15echo "Debug mode is off";16}17require_once('pts_client.php');18if (pts_client::is_debug_mode())19{20echo "Debug mode is on";21}22{23echo "Debug mode is off";24}25require_once('pts_client.php');26if (pts_client::is_debug_mode())27{28echo "Debug mode is on";29}30{31echo "Debug mode is off";32}33require_once('pts_client.php');34if (pts_client::is_debug_mode())35{36echo "Debug mode is on";37}38{39echo "Debug mode is off";40}41require_once('pts_client.php');42if (pts_client::is_debug_mode())43{44echo "Debug mode is on";45}46{47echo "Debug mode is off";48}49require_once('pts_client.php');50if (pts_client::is_debug_mode())51{52echo "Debug mode is on";53}54{55echo "Debug mode is off";56}57require_once('pts_client.php');58if (pts_client::is_debug_mode())59{60echo "Debug mode is on";61}62{63echo "Debug mode is off";64}65require_once('pts_client.php');66if (pts_client::is_debug_mode

Full Screen

Full Screen

is_debug_mode

Using AI Code Generation

copy

Full Screen

1require_once 'pts_client.php';2if(pts_client::is_debug_mode())3{4 echo "Debug mode is ON";5}6{7 echo "Debug mode is OFF";8}9Related Posts: PHP | is_int() Function10PHP | is_float() Function11PHP | is_string() Function12PHP | is_numeric() Function13PHP | is_bool() Function14PHP | is_array() Function15PHP | is_object() Function16PHP | is_null() Function17PHP | is_resource() Function18PHP | is_scalar() Function19PHP | is_callable() Function20PHP | is_subclass_of() Function21PHP | is_a() Function22PHP | is_iterable() Function23PHP | is_countable() Function24PHP | is_infinite() Function25PHP | is_finite() Function26PHP | is_nan() Function27PHP | is_dir() Function28PHP | is_file() Function29PHP | is_link() Function30PHP | is_executable() Function31PHP | is_readable() Function32PHP | is_writable() Function33PHP | is_uploaded_file() Function34PHP | is_writeable() Function35PHP | is_readable() Function36PHP | is_executable() Function37PHP | is_link() Function38PHP | is_file() Function39PHP | is_dir() Function40PHP | is_nan() Function41PHP | is_finite() Function42PHP | is_infinite() Function43PHP | is_countable() Function44PHP | is_iterable() Function45PHP | is_a() Function46PHP | is_subclass_of() Function47PHP | is_callable() Function48PHP | is_scalar() Function49PHP | is_resource() Function50PHP | is_null() Function51PHP | is_object() Function52PHP | is_array() Function53PHP | is_bool() Function54PHP | is_numeric() Function55PHP | is_string() Function56PHP | is_float() Function57PHP | is_int() Function58PHP | is_float() Function59PHP | is_string() Function60PHP | is_numeric() Function61PHP | is_bool() Function62PHP | is_array() Function63PHP | is_object() Function64PHP | is_null() Function65PHP | is_resource() Function66PHP | is_scalar() Function67PHP | is_callable() Function68PHP | is_subclass_of() Function

Full Screen

Full Screen

is_debug_mode

Using AI Code Generation

copy

Full Screen

1require_once('pts_client.php');2$pts_client = new pts_client();3if($pts_client->is_debug_mode())4{5 echo 'debug mode is on';6}7{8 echo 'debug mode is off';9}10if(!$pts_client->is_debug_mode())11{12 echo 'debug mode is off';13}14{15 echo 'debug mode is on';16}17if($pts_client->is_debug_mode() == false)18{19 echo 'debug mode is off';20}21{22 echo 'debug mode is on';23}24if($pts_client->is_debug_mode() == true)25{26 echo 'debug mode is on';27}28{29 echo 'debug mode is off';30}31if($pts_client->is_debug_mode() != true)32{33 echo 'debug mode is off';34}35{36 echo 'debug mode is on';37}38if($pts_client->is_debug_mode() != false)39{40 echo 'debug mode is on';41}42{43 echo 'debug mode is off';44}45if($pts_client->is_debug_mode() !== true)46{47 echo 'debug mode is off';48}49{50 echo 'debug mode is on';51}52if($pts_client->is_debug_mode() !== false)53{54 echo 'debug mode is on';55}56{57 echo 'debug mode is off';58}59if($pts_client->is_debug_mode() !== true)60{61 echo 'debug mode is off';62}63{64 echo 'debug mode is on';65}66if($pts_client->is_debug_mode() !== false)67{68 echo 'debug mode is on';69}70{71 echo 'debug mode is off';72}

Full Screen

Full Screen

is_debug_mode

Using AI Code Generation

copy

Full Screen

1require_once('pts_client.php');2$pts_client = new pts_client();3$pts_client->is_debug_mode(true);4$pts_client->debug($variable);5require_once('pts_client.php');6$pts_client = new pts_client();7$pts_client->is_debug_mode(true);8$pts_client->debug('variable');9require_once('pts_client.php');10$pts_client = new pts_client();11$pts_client->is_debug_mode(true);12$pts_client->debug('Hello World');13require_once('pts_client.php');14$pts_client = new pts_client();15$pts_client->is_debug_mode(true);16$pts_client->debug('Hello World');17$pts_client->debug('This is a debugging message');18require_once('pts_client.php');19$pts_client = new pts_client();20$pts_client->is_debug_mode(true);

Full Screen

Full Screen

is_debug_mode

Using AI Code Generation

copy

Full Screen

1if ($client->is_debug_mode())2{3echo "Debug mode is enabled";4}5{6echo "Debug mode is not enabled";7}

Full Screen

Full Screen

is_debug_mode

Using AI Code Generation

copy

Full Screen

1if(pts_client::is_debug_mode())2{3echo "Debug mode is on";4}5{6echo "Debug mode is off";7}8pts_client::set_debug_mode(true);9if(pts_client::is_debug_mode())10{11echo "Debug mode is on";12}13{14echo "Debug mode is off";15}16pts_client::set_debug_mode(false);17if(pts_client::is_debug_mode())18{19echo "Debug mode is on";20}21{22echo "Debug mode is off";23}24pts_client::set_debug_mode("on");25if(pts_client::is_debug_mode())26{27echo "Debug mode is on";28}29{30echo "Debug mode is off";31}32pts_client::set_debug_mode("off");33if(pts_client::is_debug_mode())34{

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 is_debug_mode code on LambdaTest Cloud Grid

Execute automation tests with is_debug_mode 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