public static function render_page_process($PATH)
    {
        $results = pts_tests::test_results_by_date();
        $sections = array(mktime(date('H'), date('i') - 10, 0, date('n'), date('j')) => 'Just Now', mktime(0, 0, 0, date('n'), date('j')) => 'Today', mktime(0, 0, 0, date('n'), date('j') - date('N') + 1) => 'This Week', mktime(0, 0, 0, date('n'), 1) => 'This Month', mktime(0, 0, 0, date('n') - 1, 1) => 'Last Month', mktime(0, 0, 0, 1, 1) => 'This Year', mktime(0, 0, 0, 1, 1, date('Y') - 1) => 'Last Year');
        echo '<div id="results_linear_display" style="overflow: hidden;"></div>';
        echo '<script text="text/javascript">
			pts_web_socket.add_onopen_event("results_grouped_by_date");
			pts_web_socket.add_onmessage_event("results_grouped_by_date", "display_grouped_results_by_date");

		</script>';
    }
 public static function run($r)
 {
     $installed_tests = pts_tests::installed_tests();
     pts_client::$display->generic_heading(count($installed_tests) . ' Tests Installed');
     if (count($installed_tests) > 0) {
         foreach ($installed_tests as $identifier) {
             $test_profile = new pts_test_profile($identifier);
             $name = $test_profile->get_title();
             if ($name != false) {
                 echo sprintf('%-26ls - %-30ls' . PHP_EOL, $identifier, $name);
             }
         }
     }
 }
 public static function run($r)
 {
     $installed_tests = pts_tests::installed_tests();
     pts_client::$display->generic_heading(count($installed_tests) . ' Tests Installed');
     if (count($installed_tests) > 0) {
         echo sprintf('%-18ls   %-8ls %-13ls %-11ls %-13ls %-10ls', 'TEST', 'VERSION', 'INSTALL DATE', 'LAST RUN', 'AVG RUN-TIME', 'TIMES RUN') . PHP_EOL;
         foreach ($installed_tests as $identifier) {
             $test_profile = new pts_test_profile($identifier);
             if ($test_profile && $test_profile->test_installation && $test_profile->test_installation->get_installed_version() != null) {
                 $avg_time = $test_profile->test_installation->get_average_run_time();
                 $avg_time = !empty($avg_time) ? pts_strings::format_time($avg_time, 'SECONDS', false) : 'N/A';
                 $last_run = $test_profile->test_installation->get_last_run_date();
                 $last_run = $last_run == '0000-00-00' ? 'NEVER' : $last_run;
                 echo sprintf('%-18ls - %-8ls %-13ls %-11ls %-13ls %-10ls', $identifier, $test_profile->test_installation->get_installed_version(), $test_profile->test_installation->get_install_date(), $last_run, $avg_time, $test_profile->test_installation->get_run_count()) . PHP_EOL;
             }
         }
     }
 }
 protected static function install_test_process(&$test_install_request, $no_prompts)
 {
     // Install a test
     $identifier = $test_install_request->test_profile->get_identifier();
     $test_install_directory = $test_install_request->test_profile->get_install_dir();
     pts_file_io::mkdir(dirname($test_install_directory));
     pts_file_io::mkdir($test_install_directory);
     $installed = false;
     if (ceil(disk_free_space($test_install_directory) / 1048576) < $test_install_request->test_profile->get_download_size() + 128) {
         self::test_install_error(null, $test_install_request, 'There is not enough space at ' . $test_install_directory . ' for the test files.');
     } else {
         if (ceil(disk_free_space($test_install_directory) / 1048576) < $test_install_request->test_profile->get_environment_size(false) + 128) {
             self::test_install_error(null, $test_install_request, 'There is not enough space at ' . $test_install_directory . ' for this test.');
         } else {
             pts_test_installer::setup_test_install_directory($test_install_request, true);
             // Download test files
             $download_test_files = pts_test_installer::download_test_files($test_install_request, false, $no_prompts);
             if ($download_test_files == false) {
                 self::test_install_error(null, $test_install_request, 'Downloading of needed test files failed.');
                 return false;
             }
             if ($test_install_request->test_profile->get_file_installer() != false) {
                 self::create_compiler_mask($test_install_request);
                 pts_module_manager::module_process('__pre_test_install', $identifier);
                 pts_client::$display->test_install_begin($test_install_request);
                 $pre_install_message = $test_install_request->test_profile->get_pre_install_message();
                 $post_install_message = $test_install_request->test_profile->get_post_install_message();
                 $install_agreement = $test_install_request->test_profile->get_installation_agreement_message();
                 if (!empty($install_agreement)) {
                     if (pts_strings::is_url($install_agreement)) {
                         $install_agreement = pts_network::http_get_contents($install_agreement);
                         if (empty($install_agreement)) {
                             self::test_install_error(null, $test_install_request, 'The user agreement could not be found. Test installation aborted.');
                             return false;
                         }
                     }
                     echo $install_agreement . PHP_EOL;
                     if (!$no_prompts) {
                         $user_agrees = pts_user_io::prompt_bool_input('Do you agree to these terms', false, 'INSTALL_AGREEMENT');
                         if (!$user_agrees) {
                             self::test_install_error(null, $test_install_request, 'User agreement failed; this test will not be installed.');
                             return false;
                         }
                     }
                 }
                 pts_client::$display->display_interrupt_message($pre_install_message);
                 $install_time_length_start = microtime(true);
                 $install_log = pts_tests::call_test_script($test_install_request->test_profile, 'install', null, $test_install_directory, $test_install_request->special_environment_vars, false);
                 $test_install_request->install_time_duration = ceil(microtime(true) - $install_time_length_start);
                 pts_client::$display->display_interrupt_message($post_install_message);
                 if (!empty($install_log)) {
                     file_put_contents($test_install_directory . 'install.log', $install_log);
                     pts_file_io::unlink($test_install_directory . 'install-failed.log');
                     pts_client::$display->test_install_output($install_log);
                 }
                 if (is_file($test_install_directory . 'install-exit-status')) {
                     // If the installer writes its exit status to ~/install-exit-status, if it's non-zero the install failed
                     $install_exit_status = pts_file_io::file_get_contents($test_install_directory . 'install-exit-status');
                     unlink($test_install_directory . 'install-exit-status');
                     if ($install_exit_status != 0 && phodevi::is_windows() == false) {
                         $install_error = null;
                         // TODO: perhaps better way to handle this than to remove pts-install.xml
                         pts_file_io::unlink($test_install_directory . 'pts-install.xml');
                         if (is_file($test_install_directory . 'install.log')) {
                             $install_log = pts_file_io::file_get_contents($test_install_directory . 'install.log');
                             $install_error = pts_tests::scan_for_error($install_log, $test_install_directory);
                             copy($test_install_directory . 'install.log', $test_install_directory . 'install-failed.log');
                         }
                         //pts_test_installer::setup_test_install_directory($test_install_request, true); // Remove installed files from the bunked installation
                         self::test_install_error(null, $test_install_request, 'The installer exited with a non-zero exit status.');
                         if ($install_error != null) {
                             $test_install_request->install_error = pts_tests::pretty_error_string($install_error);
                             if ($test_install_request->install_error != null) {
                                 self::test_install_error(null, $test_install_request, 'ERROR: ' . $test_install_request->install_error);
                             }
                         }
                         pts_client::$display->test_install_error('LOG: ' . str_replace(pts_core::user_home_directory(), '~/', $test_install_directory) . 'install-failed.log' . PHP_EOL);
                         if (pts_client::do_anonymous_usage_reporting()) {
                             // If anonymous usage reporting enabled, report test install failure to OpenBenchmarking.org
                             pts_openbenchmarking_client::upload_usage_data('test_install_failure', array($test_install_request, $install_error));
                         }
                         return false;
                     }
                 }
                 pts_module_manager::module_process('__post_test_install', $identifier);
                 $installed = true;
                 if (pts_config::read_bool_config('PhoronixTestSuite/Options/Installation/RemoveDownloadFiles', 'FALSE')) {
                     // Remove original downloaded files
                     foreach ($test_install_request->get_download_objects() as $download_object) {
                         pts_file_io::unlink($test_install_directory . $download_object->get_filename());
                     }
                 }
             } else {
                 pts_client::$display->test_install_error('No installation script found.');
                 $installed = true;
             }
             // Additional validation checks?
             $custom_validated_output = pts_tests::call_test_script($test_install_request->test_profile, 'validate-install', PHP_EOL . 'Validating Installation...' . PHP_EOL, $test_install_directory, null, false);
             if (!empty($custom_validated_output) && !pts_strings::string_bool($custom_validated_output)) {
                 $installed = false;
             }
         }
     }
     echo PHP_EOL;
     return $installed;
 }
Esempio n. 5
0
 public static function invalid_command($passed_args = null)
 {
     pts_tests::invalid_command_helper($passed_args);
 }
 public static function invalid_command($passed_args = null)
 {
     pts_tests::recently_saved_results();
 }
    public static function render_page_process($PATH)
    {
        echo '<div style="background: #CCC; padding: 10px; margin: 10px 20px;">Thanks for trying out the Phoronix Test Suite GUI. With Phoronix Test Suite 5.0 the GUI is still considered in an <strong>experimental / tech preview state</strong>. The GUI should be more end-user friendly and reach feature parity with the command-line interface in forthcoming releases. Your feedback is appreciated on the GUI while the command-line interface continues to be our primary focus along with remotely-managed enterprise features like <a href="http://www.phoromatic.com/">Phoromatic</a> and <a href="http://openbenchmarking.org/">OpenBenchmarking.org</a>. <a href="/early">Read more details on the GUI</a>.</div>';
        echo '<h1>' . pts_core::program_title(false) . '</h1>';
        echo '<div id="pts_side_pane">';
        $hw_component_modal = array('CPU' => phodevi::read_property('cpu', 'model'), 'Motherboard' => phodevi::read_property('motherboard', 'identifier'), 'Memory' => phodevi::read_property('memory', 'identifier'), 'Disk' => phodevi::read_property('disk', 'identifier'), 'GPU' => phodevi::read_property('gpu', 'model'));
        echo '<ul>';
        foreach ($hw_component_modal as $type => $component) {
            echo '<a href="/?component/' . $type . '"><li>' . $component . '</li></a>';
        }
        echo '</ul>';
        echo '<hr />';
        $sw_component_modal = array(1 => phodevi::read_property('system', 'operating-system'), 2 => phodevi::read_property('system', 'kernel-string'), 3 => phodevi::read_property('system', 'display-driver-string'), 4 => phodevi::read_property('system', 'opengl-driver'), 5 => phodevi::read_property('system', 'compiler'));
        echo '<ul>';
        foreach ($sw_component_modal as $type => $component) {
            echo '<a href="/?component/Software"><li>' . $component . '</li></a>';
        }
        echo '</ul>';
        echo '<div class="pts_pane_window"><strong>OpenBenchmarking.org</strong><br />Log-in to gain access to additional features.</div>';
        echo '<ul>';
        echo '<a href="/?settings"><li>Software Settings</li></a>';
        echo '<a href="/?about"><li>About The Phoronix Test Suite</li></a>';
        echo '</ul>';
        echo '</div>';
        echo '<div id="pts_search_bar">';
        echo 'SEARCH: <input type="text" size="30" id="pts_search" name="search" onkeydown="if(event.keyCode == 13) { if(document.getElementById(\'pts_search\').value.length < 3) { alert(\'Please enter a longer search query.\'); return false; } else { window.location.href = \'/?search/\' + document.getElementById(\'pts_search\').value; } return false; }" />';
        echo '</div>';
        // Graphs
        echo '<div id="svg_graphs" style="margin: 10px 0; text-align: right;"></div>';
        echo '<div style="overflow: hidden;">';
        echo '<div class="pts_list_box">';
        $results = pts_tests::test_results_by_date();
        $result_count = count($results);
        $results = array_slice($results, 0, 10, true);
        echo '<ol>';
        echo '<li><u>Recent Benchmark Results</u></li>';
        foreach ($results as $result) {
            $result_file = new pts_result_file($result);
            echo '<a href="?result/' . $result . '"><li>' . $result_file->get_title() . '</li></a>';
        }
        echo '<a href="?results"><li><strong>' . $result_count . ' Results Saved</strong></li></a>';
        echo '</ol>';
        echo '</div>';
        echo '<div class="pts_list_box">';
        $tests = pts_openbenchmarking_client::recently_updated_tests(10);
        echo '<ol>';
        echo '<li><u>Recently Updated Tests</u></li>';
        foreach ($tests as $test) {
            $test_profile = new pts_test_profile($test);
            echo '<a href="?test/' . $test . '"><li>' . $test_profile->get_title() . '</li></a>';
        }
        echo '<a href="?tests"><li><strong>' . pts_openbenchmarking_client::tests_available() . ' Tests Available</strong></li></a>';
        echo '</ol>';
        echo '</div>';
        echo '<div class="pts_list_box">';
        $tests = pts_openbenchmarking_client::popular_tests(10);
        echo '<ol>';
        echo '<li><u>Most Popular Tests</u></li>';
        foreach ($tests as $test) {
            $test_profile = new pts_test_profile($test);
            echo '<a href="?test/' . $test . '"><li>' . $test_profile->get_title() . '</li></a>';
        }
        echo '<a href="?tests"><li><strong>' . pts_openbenchmarking_client::tests_available() . ' Tests Available</strong></li></a>';
        echo '</ol>';
        echo '</div>';
        echo '</div>';
        echo '<script text="text/javascript">

			pts_web_socket.add_onopen_event("user-svg-system-graphs");
			setInterval(function(){if(pts_web_socket.is_connected()) { pts_web_socket.send("user-svg-system-graphs"); }},1000);
			pts_web_socket.add_onmessage_event("svg_graphs", "update_svg_graph_space");
		</script>';
    }
 public function custom_test_support_check()
 {
     /*
     As of Phoronix Test Suite 4.4, the software will check for the presence of a 'support-check' file.
     Any test profile can optionally include a support-check.sh file to check for arbitrary commands not covered by
     the rest of the PTS testing architecture, e.g. to check for the presence of systemd on the target system. If
     the script finds that the system is incompatible with the test, it can write a custom error message to the file
     specified by the $TEST_CUSTOM_ERROR environment variable. If the $TEST_CUSTOM_ERROR target is written to, the PTS
     client will abort the test installation with the specified error message.
     */
     $support_check_file = $this->get_resource_dir() . 'support-check.sh';
     if (PTS_IS_CLIENT && is_file($support_check_file)) {
         $environment['TEST_CUSTOM_ERROR'] = pts_client::temporary_directory() . '/PTS-' . $this->get_identifier_base_name() . '-' . rand(1000, 9999);
         $support_check = pts_tests::call_test_script($this, 'support-check', null, null, $environment, false);
         if (is_file($environment['TEST_CUSTOM_ERROR'])) {
             $support_result = pts_file_io::file_get_contents($environment['TEST_CUSTOM_ERROR']);
             pts_file_io::delete($environment['TEST_CUSTOM_ERROR']);
             return $support_result;
         }
     }
     return true;
 }
 protected function search_pts(&$user, $search)
 {
     $json['pts']['msg']['name'] = 'search_results';
     if (strlen($search) < 3) {
         $json['pts']['status']['error'] = 'Longer search query needed; at least three characters required.';
         $this->send_json_data($user->socket, $json);
         return false;
     } else {
         if (is_numeric($search)) {
             $json['pts']['status']['error'] = 'An alpha-numeric string is needed to perform this search.';
             $this->send_json_data($user->socket, $json);
             return false;
         }
     }
     $test_matches = pts_openbenchmarking_client::search_tests($search, true);
     $json['pts']['msg']['exact_hits'] = 0;
     $json['pts']['msg']['search_query'] = $search;
     if (count($test_matches) > 0) {
         $json['pts']['msg']['test_profiles'] = array();
         $json['pts']['msg']['exact_hits'] = 1;
         $json['pts']['msg']['tests'] = array();
         for ($i = 0; $i < count($test_matches); $i++) {
             $json['pts']['msg']['tests'][] = $test_matches[$i];
             $tp = new pts_test_profile($test_matches[$i]);
             $json['pts']['msg']['test_profiles'][] = base64_encode($tp->to_json());
         }
     } else {
         // DO MORE BROAD SEARCH, NOT A TEST...
         $test_matches = pts_openbenchmarking_client::search_tests($search, false);
         $json['pts']['msg']['test_profiles'] = array();
         $json['pts']['msg']['tests'] = array();
         for ($i = 0; $i < count($test_matches); $i++) {
             $json['pts']['msg']['tests'][] = $test_matches[$i];
             $tp = new pts_test_profile($test_matches[$i]);
             $json['pts']['msg']['test_profiles'][] = base64_encode($tp->to_json());
         }
         // SEARCH TEST PROFILES
     }
     $json['pts']['msg']['results'] = array();
     $json['pts']['msg']['result_files'] = array();
     if (count($test_matches) > 0) {
         $result_matches = pts_tests::search_test_results($search, 'RESULTS');
         foreach ($result_matches as $result) {
             $result_file = new pts_result_file($result);
             $json['pts']['msg']['results'][] = $result;
             $json['pts']['msg']['result_files'][] = base64_encode($result_file->to_json());
         }
     } else {
         $result_matches = pts_tests::search_test_results($search, 'ALL');
         foreach ($result_matches as $result) {
             $result_file = new pts_result_file($result);
             $json['pts']['msg']['results'][] = $result;
             $json['pts']['msg']['result_files'][] = base64_encode($result_file->to_json());
         }
     }
     $this->send_json_data($user->socket, $json);
 }
 public static function run_test(&$test_run_manager, &$test_run_request)
 {
     $test_identifier = $test_run_request->test_profile->get_identifier();
     $extra_arguments = $test_run_request->get_arguments();
     $arguments_description = $test_run_request->get_arguments_description();
     $full_output = pts_config::read_bool_config('PhoronixTestSuite/Options/General/FullOutput', 'FALSE');
     // Do the actual test running process
     $test_directory = $test_run_request->test_profile->get_install_dir();
     if (!is_dir($test_directory)) {
         return false;
     }
     $lock_file = $test_directory . 'run_lock';
     if (pts_client::create_lock($lock_file) == false && $test_run_manager->is_multi_test_stress_run() == false) {
         self::test_run_error($test_run_manager, $test_run_request, 'The ' . $test_identifier . ' test is already running.');
         return false;
     }
     $active_result_buffer = new pts_test_result_buffer_active();
     $test_run_request->active =& $active_result_buffer;
     $execute_binary = $test_run_request->test_profile->get_test_executable();
     $times_to_run = $test_run_request->test_profile->get_times_to_run();
     $ignore_runs = $test_run_request->test_profile->get_runs_to_ignore();
     $test_type = $test_run_request->test_profile->get_test_hardware_type();
     $allow_cache_share = $test_run_request->test_profile->allow_cache_share();
     $min_length = $test_run_request->test_profile->get_min_length();
     $max_length = $test_run_request->test_profile->get_max_length();
     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()) {
         // Ensure enough space is available on disk during testing process
         self::test_run_error($test_run_manager, $test_run_request, 'There is not enough space (at ' . $test_directory . ') for this test to run.');
         pts_client::release_lock($lock_file);
         return false;
     }
     $to_execute = $test_run_request->test_profile->get_test_executable_dir();
     $pts_test_arguments = trim($test_run_request->test_profile->get_default_arguments() . ' ' . str_replace($test_run_request->test_profile->get_default_arguments(), '', $extra_arguments) . ' ' . $test_run_request->test_profile->get_default_post_arguments());
     $extra_runtime_variables = pts_tests::extra_environmental_variables($test_run_request->test_profile);
     // Start
     $cache_share_pt2so = $test_directory . 'cache-share-' . PTS_INIT_TIME . '.pt2so';
     $cache_share_present = $allow_cache_share && is_file($cache_share_pt2so);
     $test_run_request->set_used_arguments_description($arguments_description);
     pts_module_manager::module_process('__pre_test_run', $test_run_request);
     $time_test_start = time();
     pts_client::$display->test_run_start($test_run_manager, $test_run_request);
     if (!$cache_share_present) {
         $pre_output = pts_tests::call_test_script($test_run_request->test_profile, 'pre', 'Running Pre-Test Script', $pts_test_arguments, $extra_runtime_variables, true);
         if ($pre_output != null && (pts_client::is_debug_mode() || $full_output)) {
             pts_client::$display->test_run_instance_output($pre_output);
         }
         if (is_file($test_directory . 'pre-test-exit-status')) {
             // If the pre script writes its exit status to ~/pre-test-exit-status, if it's non-zero the test run failed
             $exit_status = pts_file_io::file_get_contents($test_directory . 'pre-test-exit-status');
             unlink($test_directory . 'pre-test-exit-status');
             if ($exit_status != 0) {
                 self::test_run_instance_error($test_run_manager, $test_run_request, 'The pre run script exited with a non-zero exit status.' . PHP_EOL);
                 self::test_run_error($test_run_manager, $test_run_request, 'This test execution has been abandoned.');
                 return false;
             }
         }
     }
     pts_client::$display->display_interrupt_message($test_run_request->test_profile->get_pre_run_message());
     $runtime_identifier = time();
     $execute_binary_prepend = '';
     if ($test_run_request->exec_binary_prepend != null) {
         $execute_binary_prepend = $test_run_request->exec_binary_prepend;
     }
     if (!$cache_share_present && $test_run_request->test_profile->is_root_required()) {
         if (phodevi::is_root() == false) {
             pts_client::$display->test_run_error('This test must be run as the root / administrator account.');
         }
         $execute_binary_prepend .= ' ' . PTS_CORE_STATIC_PATH . 'root-access.sh ';
     }
     if ($allow_cache_share && !is_file($cache_share_pt2so)) {
         $cache_share = new pts_storage_object(false, false);
     }
     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')) {
         $backup_test_log_dir = PTS_SAVE_RESULTS_PATH . $test_run_manager->get_file_name() . '/test-logs/active/' . $test_run_manager->get_results_identifier() . '/';
         pts_file_io::delete($backup_test_log_dir);
         pts_file_io::mkdir($backup_test_log_dir, 0777, true);
     } else {
         $backup_test_log_dir = false;
     }
     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++) {
         pts_client::$display->test_run_instance_header($test_run_request);
         $test_log_file = $test_directory . basename($test_identifier) . '-' . $runtime_identifier . '-' . ($i + 1) . '.log';
         $is_expected_last_run = $i == $times_to_run - 1;
         $test_extra_runtime_variables = array_merge($extra_runtime_variables, array('LOG_FILE' => $test_log_file, 'DISPLAY' => getenv('DISPLAY'), 'PATH' => getenv('PATH')));
         $restored_from_cache = false;
         if ($cache_share_present) {
             $cache_share = pts_storage_object::recover_from_file($cache_share_pt2so);
             if ($cache_share) {
                 $test_result = $cache_share->read_object('test_results_output_' . $i);
                 $test_extra_runtime_variables['LOG_FILE'] = $cache_share->read_object('log_file_location_' . $i);
                 if ($test_extra_runtime_variables['LOG_FILE'] != null) {
                     file_put_contents($test_extra_runtime_variables['LOG_FILE'], $cache_share->read_object('log_file_' . $i));
                     $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 initialized
                     $restored_from_cache = true;
                 }
             }
             unset($cache_share);
         }
         if ($restored_from_cache == false) {
             $test_run_command = 'cd ' . $to_execute . ' && ' . $execute_binary_prepend . './' . $execute_binary . ' ' . $pts_test_arguments . ' 2>&1';
             pts_client::test_profile_debug_message('Test Run Command: ' . $test_run_command);
             $is_monitoring = pts_test_result_parser::system_monitor_task_check($test_run_request->test_profile);
             $test_run_time_start = time();
             if (phodevi::is_windows() || pts_client::read_env('USE_PHOROSCRIPT_INTERPRETER') != false) {
                 $phoroscript = new pts_phoroscript_interpreter($to_execute . '/' . $execute_binary, $test_extra_runtime_variables, $to_execute);
                 $phoroscript->execute_script($pts_test_arguments);
                 $test_result = null;
             } else {
                 //$test_result = pts_client::shell_exec($test_run_command, $test_extra_runtime_variables);
                 $descriptorspec = array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
                 $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));
                 if (is_resource($test_process)) {
                     //echo proc_get_status($test_process)['pid'];
                     pts_module_manager::module_process('__test_running', $test_process);
                     $test_result = stream_get_contents($pipes[1]);
                     fclose($pipes[1]);
                     fclose($pipes[2]);
                     $return_value = proc_close($test_process);
                 }
             }
             $test_run_time = time() - $test_run_time_start;
             $monitor_result = $is_monitoring ? pts_test_result_parser::system_monitor_task_post_test($test_run_request->test_profile) : 0;
         }
         if (!isset($test_result[10240]) || pts_client::is_debug_mode() || $full_output) {
             pts_client::$display->test_run_instance_output($test_result);
         }
         if (is_file($test_log_file) && trim($test_result) == null && (filesize($test_log_file) < 10240 || pts_client::is_debug_mode() || $full_output)) {
             $test_log_file_contents = file_get_contents($test_log_file);
             pts_client::$display->test_run_instance_output($test_log_file_contents);
             unset($test_log_file_contents);
         }
         $test_run_request->test_result_standard_output = $test_result;
         $exit_status_pass = true;
         if (is_file($test_directory . 'test-exit-status')) {
             // If the test script writes its exit status to ~/test-exit-status, if it's non-zero the test run failed
             $exit_status = pts_file_io::file_get_contents($test_directory . 'test-exit-status');
             unlink($test_directory . 'test-exit-status');
             if ($exit_status != 0) {
                 self::test_run_instance_error($test_run_manager, $test_run_request, 'The test exited with a non-zero exit status.');
                 if ($is_expected_last_run && is_file($test_log_file)) {
                     $scan_log = pts_file_io::file_get_contents($test_log_file);
                     $test_run_error = pts_tests::scan_for_error($scan_log, $test_run_request->test_profile->get_test_executable_dir());
                     if ($test_run_error) {
                         self::test_run_instance_error($test_run_manager, $test_run_request, 'E: ' . $test_run_error);
                     }
                 }
                 $exit_status_pass = false;
             }
         }
         if (!in_array($i + 1, $ignore_runs) && $exit_status_pass) {
             if (isset($monitor_result) && $monitor_result != 0) {
                 $test_run_request->active->active_result = $monitor_result;
             } else {
                 pts_test_result_parser::parse_result($test_run_request, $test_extra_runtime_variables['LOG_FILE']);
             }
             pts_client::test_profile_debug_message('Test Result Value: ' . $test_run_request->active->active_result);
             if (!empty($test_run_request->active->active_result)) {
                 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) {
                     // 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 run
                     self::test_run_instance_error($test_run_manager, $test_run_request, 'The test run ended prematurely.');
                     if ($is_expected_last_run && is_file($test_log_file)) {
                         $scan_log = pts_file_io::file_get_contents($test_log_file);
                         $test_run_error = pts_tests::scan_for_error($scan_log, $test_run_request->test_profile->get_test_executable_dir());
                         if ($test_run_error) {
                             self::test_run_instance_error($test_run_manager, $test_run_request, 'E: ' . $test_run_error);
                         }
                     }
                 } else {
                     // TODO integrate active_result into active buffer
                     $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);
                 }
             } else {
                 if ($test_run_request->test_profile->get_display_format() != 'NO_RESULT') {
                     self::test_run_instance_error($test_run_manager, $test_run_request, 'The test run did not produce a result.');
                     if ($is_expected_last_run && is_file($test_log_file)) {
                         $scan_log = pts_file_io::file_get_contents($test_log_file);
                         $test_run_error = pts_tests::scan_for_error($scan_log, $test_run_request->test_profile->get_test_executable_dir());
                         if ($test_run_error) {
                             self::test_run_instance_error($test_run_manager, $test_run_request, 'E: ' . $test_run_error);
                         }
                     }
                 }
             }
             if ($allow_cache_share && !is_file($cache_share_pt2so)) {
                 $cache_share->add_object('test_results_output_' . $i, $test_run_request->active->active_result);
                 $cache_share->add_object('log_file_location_' . $i, $test_extra_runtime_variables['LOG_FILE']);
                 $cache_share->add_object('log_file_' . $i, is_file($test_log_file) ? file_get_contents($test_log_file) : null);
             }
         }
         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()) {
             // The later check above ensures if the test is failing often the run count won't uselessly be increasing
             // Should we increase the run count?
             $increase_run_count = false;
             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) {
                 // At least one run passed, but at least one run failed to produce a result. Increase count to try to get more successful runs
                 $increase_run_count = $defined_times_to_run - $active_result_buffer->get_trial_run_count();
             } else {
                 if ($active_result_buffer->get_trial_run_count() >= 2) {
                     // Dynamically increase run count if needed for statistical significance or other reasons
                     $increase_run_count = $test_run_manager->increase_run_count_check($active_result_buffer, $defined_times_to_run, $test_run_time);
                     if ($increase_run_count === -1) {
                         $abort_testing = true;
                     } else {
                         if ($increase_run_count == true) {
                             // Just increase the run count one at a time
                             $increase_run_count = 1;
                         }
                     }
                 }
             }
             if ($increase_run_count > 0) {
                 $times_to_run += $increase_run_count;
                 $is_expected_last_run = false;
                 //$test_run_request->test_profile->set_times_to_run($times_to_run);
             }
         }
         if ($times_to_run > 1 && $i < $times_to_run - 1) {
             if ($cache_share_present == false) {
                 $interim_output = pts_tests::call_test_script($test_run_request->test_profile, 'interim', 'Running Interim Test Script', $pts_test_arguments, $extra_runtime_variables, true);
                 if ($interim_output != null && (pts_client::is_debug_mode() || $full_output)) {
                     pts_client::$display->test_run_instance_output($interim_output);
                 }
                 //sleep(2); // Rest for a moment between tests
             }
             pts_module_manager::module_process('__interim_test_run', $test_run_request);
         }
         if (is_file($test_log_file)) {
             if ($is_expected_last_run) {
                 // For now just passing the last test log file...
                 // TODO XXX: clean this up with log files to preserve when needed, let multiple log files exist for extra_data, etc
                 pts_test_result_parser::generate_extra_data($test_run_request, $test_log_file);
             }
             if ($backup_test_log_dir) {
                 copy($test_log_file, $backup_test_log_dir . basename($test_log_file));
             }
             if (pts_client::test_profile_debug_message('Log File At: ' . $test_log_file) == false) {
                 unlink($test_log_file);
             }
         }
         if (is_file(PTS_USER_PATH . 'halt-testing') || is_file(PTS_USER_PATH . 'skip-test')) {
             pts_client::release_lock($lock_file);
             return false;
         }
         pts_client::$display->test_run_instance_complete($test_run_request);
     }
     $time_test_end_actual = time();
     if ($cache_share_present == false) {
         $post_output = pts_tests::call_test_script($test_run_request->test_profile, 'post', 'Running Post-Test Script', $pts_test_arguments, $extra_runtime_variables, true);
         if ($post_output != null && (pts_client::is_debug_mode() || $full_output)) {
             pts_client::$display->test_run_instance_output($post_output);
         }
         if (is_file($test_directory . 'post-test-exit-status')) {
             // If the post script writes its exit status to ~/post-test-exit-status, if it's non-zero the test run failed
             $exit_status = pts_file_io::file_get_contents($test_directory . 'post-test-exit-status');
             unlink($test_directory . 'post-test-exit-status');
             if ($exit_status != 0) {
                 self::test_run_instance_error($test_run_manager, $test_run_request, 'The post run script exited with a non-zero exit status.' . PHP_EOL);
                 $abort_testing = true;
             }
         }
     }
     if ($abort_testing) {
         self::test_run_error($test_run_manager, $test_run_request, 'This test execution has been abandoned.');
         return false;
     }
     // End
     $time_test_end = time();
     $time_test_elapsed = $time_test_end - $time_test_start;
     $time_test_elapsed_actual = $time_test_end_actual - $time_test_start_actual;
     if (!empty($min_length)) {
         if ($min_length > $time_test_elapsed_actual) {
             // The test ended too quickly, results are not valid
             self::test_run_error($test_run_manager, $test_run_request, 'This test ended prematurely.');
             return false;
         }
     }
     if (!empty($max_length)) {
         if ($max_length < $time_test_elapsed_actual) {
             // The test took too much time, results are not valid
             self::test_run_error($test_run_manager, $test_run_request, 'This test run was exhausted.');
             return false;
         }
     }
     if ($allow_cache_share && !is_file($cache_share_pt2so) && $cache_share instanceof pts_storage_object) {
         $cache_share->save_to_file($cache_share_pt2so);
         unset($cache_share);
     }
     if ($test_run_manager->get_results_identifier() != null && pts_config::read_bool_config('PhoronixTestSuite/Options/Testing/SaveInstallationLogs', 'FALSE')) {
         if (is_file($test_run_request->test_profile->get_install_dir() . 'install.log')) {
             $backup_log_dir = PTS_SAVE_RESULTS_PATH . $test_run_manager->get_file_name() . '/installation-logs/' . $test_run_manager->get_results_identifier() . '/';
             pts_file_io::mkdir($backup_log_dir, 0777, true);
             copy($test_run_request->test_profile->get_install_dir() . 'install.log', $backup_log_dir . basename($test_identifier) . '.log');
         }
     }
     // Fill in missing test details
     if (empty($arguments_description)) {
         $arguments_description = $test_run_request->test_profile->get_test_subtitle();
     }
     $file_var_checks = array(array('pts-results-scale', 'set_result_scale', null), array('pts-results-proportion', 'set_result_proportion', null), array('pts-results-quantifier', 'set_result_quantifier', null), array('pts-test-version', 'set_version', null), array('pts-test-description', null, 'set_used_arguments_description'), array('pts-footnote', null, null));
     foreach ($file_var_checks as &$file_check) {
         list($file, $set_function, $result_set_function) = $file_check;
         if (is_file($test_directory . $file)) {
             $file_contents = pts_file_io::file_get_contents($test_directory . $file);
             unlink($test_directory . $file);
             if (!empty($file_contents)) {
                 if ($set_function != null) {
                     call_user_func(array($test_run_request->test_profile, $set_function), $file_contents);
                 } else {
                     if ($result_set_function != null) {
                         if ($result_set_function == 'set_used_arguments_description') {
                             $arguments_description = $file_contents;
                         } else {
                             call_user_func(array($test_run_request, $result_set_function), $file_contents);
                         }
                     } else {
                         if ($file == 'pts-footnote') {
                             $test_run_request->test_profile->test_installation->set_install_footnote($file_contents);
                         }
                     }
                 }
             }
         }
     }
     if (empty($arguments_description)) {
         $arguments_description = 'Phoronix Test Suite v' . PTS_VERSION;
     }
     foreach (pts_client::environmental_variables() as $key => $value) {
         $arguments_description = str_replace('$' . $key, $value, $arguments_description);
         if (!in_array($key, array('VIDEO_MEMORY', 'NUM_CPU_CORES', 'NUM_CPU_JOBS'))) {
             $extra_arguments = str_replace('$' . $key, $value, $extra_arguments);
         }
     }
     // Any device notes to add to PTS test notes area?
     foreach (phodevi::read_device_notes($test_type) as $note) {
         pts_test_notes_manager::add_note($note);
     }
     // As of PTS 4.4, this is removed and superceded effectively by reporting the notes to table
     // Any special information (such as forced AA/AF levels for graphics) to add to the description string of the result?
     /*
     if(($special_string = phodevi::read_special_settings_string($test_type)) != null)
     {
     	if(strpos($arguments_description, $special_string) === false)
     	{
     		if($arguments_description != null)
     		{
     			$arguments_description .= ' | ';
     		}
     
     		$arguments_description .= $special_string;
     	}
     }
     */
     // Result Calculation
     $test_run_request->set_used_arguments_description($arguments_description);
     $test_run_request->set_used_arguments($extra_arguments);
     pts_test_result_parser::calculate_end_result($test_run_request, $active_result_buffer);
     // Process results
     pts_client::$display->test_run_end($test_run_request);
     pts_client::$display->display_interrupt_message($test_run_request->test_profile->get_post_run_message());
     pts_module_manager::module_process('__post_test_run', $test_run_request);
     $report_elapsed_time = $cache_share_present == false && $test_run_request->active->get_result() != 0;
     pts_tests::update_test_install_xml($test_run_request->test_profile, $report_elapsed_time ? $time_test_elapsed : 0);
     pts_storage_object::add_in_file(PTS_CORE_STORAGE, 'total_testing_time', $time_test_elapsed / 60);
     if ($report_elapsed_time && pts_client::do_anonymous_usage_reporting() && $time_test_elapsed >= 60) {
         // If anonymous usage reporting enabled, report test run-time to OpenBenchmarking.org
         pts_openbenchmarking_client::upload_usage_data('test_complete', array($test_run_request, $time_test_elapsed));
     }
     // Remove lock
     pts_client::release_lock($lock_file);
     return $active_result_buffer;
 }
 public function prompt_save_name()
 {
     if ($this->file_name != null) {
         return;
     }
     // Prompt to save a file when running a test
     $save_name = null;
     if ($env = pts_client::read_env('TEST_RESULTS_NAME')) {
         $save_name = $env;
         //echo 'Saving Results To: ' . $proposed_name . PHP_EOL;
     }
     if (!$this->batch_mode || $this->batch_mode['PromptSaveName']) {
         $is_reserved_word = false;
         // Be of help to the user by showing recently saved test results
         if ($save_name == null) {
             pts_tests::recently_saved_results();
         }
         $save_name_length = strlen($save_name);
         while (empty($save_name) || ($is_reserved_word = pts_types::is_test_or_suite($save_name)) || $save_name_length > 126) {
             if ($is_reserved_word) {
                 echo PHP_EOL . 'The name of the saved file cannot be the same as a test/suite: ' . $save_name . PHP_EOL;
                 $is_reserved_word = false;
             }
             if ($save_name_length > 126) {
                 echo PHP_EOL . 'The name of the saved file must have between 2 and 126 characters in length.' . PHP_EOL;
             }
             pts_client::$display->generic_prompt('Enter a name to save these results under: ');
             $save_name = pts_user_io::read_user_input();
         }
     }
     $this->set_save_name($save_name);
 }
Esempio n. 12
0
 public static function recently_saved_results()
 {
     $recent_results = pts_tests::test_results_by_date();
     if (count($recent_results) > 0) {
         $recent_results = array_slice($recent_results, 0, 5, true);
         $res_length = strlen(pts_strings::find_longest_string($recent_results)) + 2;
         $current_time = time();
         foreach ($recent_results as $m_time => &$recent_result) {
             $days = floor(($current_time - $m_time) / 86400);
             $recent_result = sprintf('%-' . $res_length . 'ls [%-ls]', $recent_result, $days == 0 ? 'Today' : pts_strings::days_ago_format_string($days) . ' old');
         }
         echo PHP_EOL . 'Recently Saved Test Results:' . PHP_EOL;
         echo pts_user_io::display_text_list($recent_results) . PHP_EOL;
         return true;
     }
     return false;
 }
 public static function run($r)
 {
     // Force refresh of OB repository to ensure the latest profiles
     pts_openbenchmarking::refresh_repository_lists(null, true);
     // Determine cache location
     $dc_write_directory = pts_strings::add_trailing_slash(pts_strings::parse_for_home_directory(pts_config::read_user_config('PhoronixTestSuite/Options/Installation/CacheDirectory', PTS_DOWNLOAD_CACHE_PATH)));
     echo PHP_EOL . 'Download Cache Directory: ' . $dc_write_directory . PHP_EOL;
     if ($dc_write_directory == null || !is_writable($dc_write_directory)) {
         echo 'No writable download cache directory was found. A download cache cannot be created.' . PHP_EOL . PHP_EOL;
         return false;
     }
     if (!empty($r)) {
         $test_profiles = pts_types::identifiers_to_test_profile_objects($r, true, true);
         if (count($test_profiles) > 0) {
             echo PHP_EOL . 'Downloading Test Files For: ' . implode(' ', $test_profiles);
             pts_test_installer::only_download_test_files($test_profiles, $dc_write_directory);
         }
     }
     $json_download_cache = array('phoronix-test-suite' => array('main' => array('generated' => time()), 'download-cache' => array()));
     foreach (pts_tests::partially_installed_tests() as $test) {
         $test_profile = new pts_test_profile($test);
         echo PHP_EOL . 'Checking Downloads For: ' . $test . PHP_EOL;
         foreach (pts_test_install_request::read_download_object_list($test_profile, false) as $file) {
             $cached_valid = false;
             if (is_file($dc_write_directory . $file->get_filename()) && $file->check_file_hash($dc_write_directory . $file->get_filename())) {
                 echo '   Previously Cached: ' . $file->get_filename() . PHP_EOL;
                 $cached_valid = true;
             } else {
                 if (is_dir($test_profile->get_install_dir())) {
                     if (is_file($test_profile->get_install_dir() . $file->get_filename()) && $file->check_file_hash($test_profile->get_install_dir() . $file->get_filename())) {
                         echo '   Caching: ' . $file->get_filename() . PHP_EOL;
                         if (copy($test_profile->get_install_dir() . $file->get_filename(), $dc_write_directory . $file->get_filename())) {
                             $cached_valid = true;
                         }
                     }
                 }
             }
             if ($cached_valid) {
                 if (!isset($json_download_cache['phoronix-test-suite']['download-cache'][$file->get_filename()])) {
                     $json_download_cache['phoronix-test-suite']['download-cache'][$file->get_filename()] = array('file_name' => $file->get_filename(), 'file_size' => $file->get_filesize(), 'associated_tests' => array($test_profile->get_identifier()), 'md5' => $file->get_md5(), 'sha256' => $file->get_sha256());
                 } else {
                     if ($file->get_md5() == $json_download_cache['phoronix-test-suite']['download-cache'][$file->get_filename()]['md5'] && $file->get_sha256() == $json_download_cache['phoronix-test-suite']['download-cache'][$file->get_filename()]['sha256']) {
                         array_push($json_download_cache['phoronix-test-suite']['download-cache'][$file->get_filename()]['associated_tests'], $test_profile->get_identifier());
                     }
                 }
             }
         }
     }
     // Find files in download-cache/ that weren't part of an installed test (but could have just been tossed in there) to cache
     foreach (glob($dc_write_directory . '/*') as $cached_file) {
         $file_name = basename($cached_file);
         if (!isset($json_download_cache['phoronix-test-suite']['download-cache'][$file_name]) && $file_name != 'pts-download-cache.json') {
             $json_download_cache['phoronix-test-suite']['download-cache'][$file_name] = array('file_name' => $file_name, 'file_size' => filesize($cached_file), 'associated_tests' => array(), 'md5' => md5_file($cached_file), 'sha256' => hash_file('sha256', $cached_file));
         }
     }
     $cached_tests = array();
     foreach (pts_openbenchmarking::available_tests(true, true) as $test) {
         if (pts_test_install_request::test_files_in_cache($test, true, true) == false) {
             continue;
         }
         array_push($cached_tests, $test);
     }
     $json_download_cache['phoronix-test-suite']['cached-tests'] = $cached_tests;
     file_put_contents($dc_write_directory . 'pts-download-cache.json', json_encode($json_download_cache, defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0));
     echo PHP_EOL;
 }
 public static function run($r)
 {
     pts_client::$display->generic_heading('Random Test Execution');
     $allow_new_tests_to_be_installed = pts_user_io::prompt_bool_input('Allow new tests to be installed', true);
     $allow_new_dependencies_to_be_installed = $allow_new_tests_to_be_installed ? pts_user_io::prompt_bool_input('Allow new test external dependencies to be installed', false) : false;
     $limit_test_subsystem = pts_user_io::prompt_bool_input('Limit tests to a given subsystem', false);
     $limit_test_subsystem = $limit_test_subsystem ? pts_user_io::prompt_text_menu('Select subsystem(s) to test', pts_types::subsystem_targets(), true) : false;
     $upload_to_openbenchmarking = pts_user_io::prompt_bool_input('Auto-upload test results to OpenBenchmarking.org', true);
     while (1) {
         $to_test = array();
         if ($limit_test_subsystem) {
             foreach (explode(',', $limit_test_subsystem) as $test_type) {
                 $tests = pts_openbenchmarking_client::popular_tests(-1, $test_type);
                 $to_test = array_merge($to_test, $tests);
             }
             if (empty($to_test)) {
                 pts_client::$display->generic_sub_heading('No tests could be found to run.');
                 return false;
             }
             shuffle($to_test);
             $to_test = array_slice($to_test, 0, rand(1, 12));
         } else {
             if (rand(1, 6) == 2) {
                 $ob_ids = pts_openbenchmarking_client::popular_openbenchmarking_results();
                 $ob_type = rand(0, 1) == 1 ? 'recent_popular_results' : 'recent_results';
                 if (isset($ob_ids[$ob_type]) && !empty($ob_ids[$ob_type])) {
                     shuffle($ob_ids[$ob_type]);
                     $to_test = array(array_pop($ob_ids[$ob_type]));
                 }
             }
         }
         if (empty($to_test)) {
             // Randomly pick some installed tests
             $installed_tests = pts_tests::installed_tests();
             if ($installed_tests > 3) {
                 shuffle($installed_tests);
                 $to_test = array_slice($installed_tests, 0, rand(1, 8));
             }
             if (!isset($to_test[2]) && $allow_new_tests_to_be_installed) {
                 $available_tests = pts_openbenchmarking::available_tests();
                 shuffle($available_tests);
                 $to_test = array_merge($to_test, array_slice($available_tests, 0, rand(1, 10)));
             }
         }
         if (empty($to_test)) {
             pts_client::$display->generic_sub_heading('No tests could be found to run.');
             return false;
         }
         echo PHP_EOL;
         pts_client::$display->generic_sub_heading('Tests To Run: ' . implode(', ', $to_test));
         // QUERY FROM OB
         $random_titles = array(phodevi::read_property('cpu', 'model') . ' Benchmarks', phodevi::read_property('system', 'operating-system') . ' Benchmarks', phodevi::read_property('system', 'operating-system') . ' Performance', phodevi::read_property('cpu', 'model') . ' Performance', phodevi::read_property('cpu', 'model') . ' + ' . phodevi::read_property('gpu', 'model') . ' + ' . phodevi::read_property('motherboard', 'identifier'), phodevi::read_property('motherboard', 'identifier') . ' On ' . phodevi::read_property('system', 'operating-system'), phodevi::read_property('cpu', 'model') . ' On ' . phodevi::read_property('system', 'operating-system'), phodevi::read_property('system', 'kernel') . ' + ' . phodevi::read_property('system', 'operating-system') . ' Tests');
         shuffle($random_titles);
         $title = array_pop($random_titles);
         if ($limit_test_subsystem) {
             $subsystems_to_test = explode(',', $limit_test_subsystem);
             $subsystems_to_avoid = array_diff(pts_types::subsystem_targets(), $subsystems_to_test);
             pts_client::pts_set_environment_variable('SKIP_TESTING_SUBSYSTEMS', implode(',', $subsystems_to_avoid));
         }
         if ($allow_new_tests_to_be_installed) {
             pts_test_installer::standard_install($to_test, false, true, $allow_new_dependencies_to_be_installed);
         }
         $batch_mode_settings = array('UploadResults' => false, 'SaveResults' => true, 'PromptForTestDescription' => false, 'RunAllTestCombinations' => false, 'PromptSaveName' => false, 'PromptForTestIdentifier' => false, 'OpenBrowser' => false);
         if ($upload_to_openbenchmarking) {
             $batch_mode_settings['UploadResults'] = true;
             pts_openbenchmarking_client::override_client_setting('UploadSystemLogsByDefault', true);
         }
         pts_test_run_manager::set_batch_mode($batch_mode_settings);
         $test_run_manager = new pts_test_run_manager($batch_mode_settings, 2);
         if ($test_run_manager->initial_checks($to_test) != false) {
             if ($test_run_manager->load_tests_to_run($to_test)) {
                 // SETUP
                 $test_run_manager->auto_save_results($title, null, 'Various open-source benchmarks by the ' . pts_core::program_title(true) . '.', true);
                 $test_run_manager->auto_generate_results_identifier();
                 echo PHP_EOL;
                 pts_client::$display->generic_sub_heading('Result File: ' . $test_run_manager->get_file_name());
                 pts_client::$display->generic_sub_heading('Result Identifier: ' . $test_run_manager->get_results_identifier());
                 // BENCHMARK
                 $test_run_manager->pre_execution_process();
                 $test_run_manager->call_test_runs();
                 $test_run_manager->post_execution_process();
                 pts_client::remove_saved_result_file($test_run_manager->get_file_name());
             }
         }
         echo PHP_EOL;
         sleep(30);
     }
 }
 public static function render_page_process($PATH)
 {
     $local_only = false;
     switch (isset($PATH[0]) ? $PATH[0] : null) {
         case 'locally_available_tests':
             $local_only = true;
             $selected = 'Locally Available Tests';
             $tests = pts_openbenchmarking::available_tests();
             break;
         case 'available_tests':
             $selected = 'Available Tests';
             $tests = pts_openbenchmarking::available_tests();
             break;
         case 'installed_tests':
         default:
             $tests = pts_tests::installed_tests();
             $selected = 'Installed Tests';
             break;
     }
     echo '<h2>';
     $sub_links = array('Available Tests' => 'tests/available_tests', 'Locally Available Tests' => 'tests/locally_available_tests', 'Installed Tests' => 'tests/installed_tests');
     foreach ($sub_links as $txt => $loc) {
         echo '<a href="/?' . $loc . '">' . ($selected == $txt ? '<span class="alt">' : null) . $txt . ($selected == $txt ? '<span class="alt">' : null) . '</a> ';
     }
     echo '</h2>';
     $installed_dependencies = pts_external_dependencies::installed_dependency_names();
     $tests_to_show = array();
     foreach ($tests as $identifier) {
         $test_profile = new pts_test_profile($identifier);
         if (!$test_profile->is_supported(false) || $test_profile->get_title() == null) {
             // Don't show unsupported tests
             continue;
         }
         if ($local_only && count($test_dependencies = $test_profile->get_dependencies()) > 0) {
             $dependencies_met = true;
             foreach ($test_dependencies as $d) {
                 if (!in_array($d, $installed_dependencies)) {
                     $dependencies_met = false;
                     break;
                 }
             }
             if ($dependencies_met == false) {
                 continue;
             }
         }
         if ($local_only && pts_test_install_request::test_files_available_locally($test_profile) == false) {
             continue;
         }
         array_push($tests_to_show, $test_profile);
     }
     echo '<div style="overflow: hidden;">';
     $tests_to_show = array_unique($tests_to_show);
     usort($tests_to_show, array('pts_webui_tests', 'cmp_result_object_sort'));
     $category = null;
     foreach ($tests_to_show as &$test_profile) {
         if ($category != $test_profile->get_test_hardware_type()) {
             $category = $test_profile->get_test_hardware_type();
             echo '</div><a name="' . $category . '"></a>' . PHP_EOL . '<h2>' . $category . '</h2>' . PHP_EOL . '<div style="overflow: hidden;">';
             $popularity_index = pts_openbenchmarking_client::popular_tests(-1, pts_openbenchmarking_client::read_repository_test_profile_attribute($test_profile, 'test_type'));
         }
         $last_updated = pts_openbenchmarking_client::read_repository_test_profile_attribute($test_profile, 'last_updated');
         $popularity = array_search($test_profile->get_identifier(false), $popularity_index);
         $secondary_message = null;
         if ($last_updated > time() - 60 * 60 * 24 * 21) {
             // Mark it as newly updated if uploaded in past 3 weeks
             $secondary_message = '<strong>Newly Updated.</strong>';
         } else {
             if ($popularity === 0) {
                 $secondary_message = '<strong>Most Popular.</strong>';
             } else {
                 if ($popularity < 4) {
                     $secondary_message = '<strong>Very Popular.</strong>';
                 }
             }
         }
         echo '<a href="?test/' . $test_profile->get_identifier() . '"><div class="pts_blue_bar"><strong>' . trim($test_profile->get_title() . ' ' . $test_profile->get_app_version()) . '</strong><br /><span style="">~' . max(1, round($test_profile->get_estimated_run_time() / 60)) . ' mins To Run. ' . $secondary_message . '</span></div></a>';
     }
     echo '</div>';
 }
 public function is_supported_value($input)
 {
     $supported = false;
     if (is_array($this->option_supported_values)) {
         if (in_array($input, $this->option_supported_values)) {
             $supported = true;
         }
     } else {
         if (empty($input) && $this->option_default_value != null) {
             $supported = true;
         } else {
             switch ($this->option_supported_values) {
                 case 'NUMERIC':
                     if (is_numeric($input)) {
                         $supported = true;
                     }
                     break;
                 case 'NUMERIC_DASH':
                     if (!empty($input) && pts_strings::string_only_contains($input, pts_strings::CHAR_NUMERIC | pts_strings::CHAR_DASH)) {
                         $supported = true;
                     }
                     break;
                 case 'ALPHA_NUMERIC':
                     if (!empty($input) && pts_strings::string_only_contains($input, pts_strings::CHAR_NUMERIC | pts_strings::CHAR_LETTER)) {
                         $supported = true;
                     }
                     break;
                 case 'HTTP_URL':
                     if (substr($input, 0, 7) == 'http://') {
                         $supported = true;
                     }
                     break;
                 case 'LOCAL_DIRECTORY':
                     if (is_dir($input)) {
                         $supported = true;
                     }
                     break;
                 case 'LOCAL_FILE':
                     if (is_file($input)) {
                         $supported = true;
                     }
                     break;
                 case 'LOCAL_EXECUTABLE':
                     if (is_executable($input)) {
                         $supported = true;
                     }
                     break;
                 case 'PTS_TEST_RESULT':
                     if (pts_result_file::is_test_result_file($input)) {
                         $supported = true;
                     }
                 case 'INSTALLED_TEST':
                     if (in_array($input, pts_tests::installed_tests())) {
                         $supported = true;
                     }
                 case 'VALID_SAVE_NAME':
                     if (!empty($input) && pts_types::identifier_to_object($input) == false) {
                         $supported = true;
                     }
                 case 'NOT_EMPTY':
                     if (!empty($input)) {
                         $supported = true;
                     }
                 case '':
                     $supported = true;
                     break;
             }
         }
     }
     if ($supported && !empty($this->option_function_check)) {
         $supported = call_user_func($this->option_function_check, $input) == true;
     }
     return $supported;
 }