public function get_contained_test_profiles()
 {
     $contained = array();
     foreach ($this->tests as $test) {
         $test_profile = new pts_test_profile($test['test']);
         if ($test_profile->is_supported(false)) {
             array_push($contained, $test_profile);
         }
     }
     return $contained;
 }
 protected static function search_test_profiles($q)
 {
     $ret = null;
     foreach (pts_openbenchmarking::available_tests() as $test) {
         $tp = new pts_test_profile($test);
         if (stripos($test, $q) !== false || stripos($tp->get_title(), $q) === 0) {
             $ret .= '<h3>' . $tp->get_title() . '</h3><p>' . $tp->get_description() . '<br /><a href="http://openbenchmarking.org/test/' . $tp->get_identifier(false) . '">Learn More On OpenBenchmarking.org</a></p>';
         }
     }
     return $ret;
 }
 public function get_environment_size($include_extensions = true)
 {
     $estimated_size = parent::get_environment_size();
     if ($include_extensions) {
         $extends = $this->get_test_extension();
         if (!empty($extends)) {
             $test_profile = new pts_test_profile($extends);
             $estimated_size += $test_profile->get_environment_size(true);
         }
     }
     return $estimated_size;
 }
 public static function preload($REQUEST)
 {
     $test = implode('/', $REQUEST);
     if (pts_test_profile::is_test_profile($test)) {
         $test = new pts_test_profile($test);
         if ($test->get_title() != null) {
             self::$test_profile = $test;
             return true;
         }
     }
     return 'pts_webui_tests';
 }
 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)
 {
     $test_profile = new pts_test_profile($r[0]);
     if ($test_profile->is_test_installed() == false) {
         echo PHP_EOL . 'This test is not installed.' . PHP_EOL;
         return false;
     }
     if (pts_user_io::prompt_bool_input('Are you sure you wish to remove the test ' . $test_profile, false)) {
         pts_client::remove_installed_test($test_profile);
         echo PHP_EOL . $test_profile . ' has been removed.' . PHP_EOL;
     } else {
         echo PHP_EOL;
     }
 }
 public static function run($r)
 {
     pts_client::$display->generic_heading('Unsupported Tests');
     foreach (pts_openbenchmarking::available_tests() as $identifier) {
         $unsupported = false;
         $test_profile = new pts_test_profile($identifier);
         if ($test_profile->is_test_architecture_supported() == false) {
             $unsupported = 'UNSUPPORTED ARCHITECTURE';
         } else {
             if ($test_profile->is_test_platform_supported() == false) {
                 $unsupported = 'UNSUPPORTED PLATFORM';
             }
         }
         if ($unsupported) {
             echo sprintf('%-28ls - %-30ls %-9ls', $identifier, $unsupported, $repo_index['tests'][$id]['test_type']) . PHP_EOL;
         }
     }
 }
 public static function run($r)
 {
     pts_client::$display->generic_heading('Available Tests');
     $test_count = 0;
     foreach (pts_openbenchmarking::available_tests(false) as $identifier) {
         $repo = substr($identifier, 0, strpos($identifier, '/'));
         $id = substr($identifier, strlen($repo) + 1);
         $repo_index = pts_openbenchmarking::read_repository_index($repo);
         if (!in_array(phodevi::operating_system(), $repo_index['tests'][$id]['supported_platforms']) || empty($repo_index['tests'][$id]['title'])) {
             // Don't show unsupported tests
             continue;
         }
         echo sprintf('%-30ls - %-35ls %-9ls', $identifier, $repo_index['tests'][$id]['title'], $repo_index['tests'][$id]['test_type']) . PHP_EOL;
         $test_count++;
     }
     foreach (pts_file_io::glob(PTS_TEST_PROFILE_PATH . 'local/*/test-definition.xml') as $path) {
         $test_profile = new pts_test_profile('local/' . basename(dirname($path)));
         if ($test_profile->get_title() != null && $test_profile->is_supported(false)) {
             echo sprintf('%-30ls - %-35ls %-9ls', $test_profile->get_identifier(), $test_profile->get_title(), $test_profile->get_test_hardware_type()) . PHP_EOL;
             $test_count++;
         }
     }
     if ($test_count == 0) {
         echo PHP_EOL . 'No tests found. Please check that you have Internet connectivity to download test profile data from OpenBenchmarking.org. The Phoronix Test Suite has documentation on configuring the network setup, proxy settings, and PHP network options. Please contact Phoronix Media if you continuing to experience problems.' . PHP_EOL . PHP_EOL;
     }
 }
 public function __construct($result_file, $read_only_result_objects = false)
 {
     $this->save_identifier = $result_file;
     $this->extra_attributes = array();
     $this->systems = array();
     $this->result_objects = array();
     if ($result_file == null) {
         return;
     } else {
         if (is_file($result_file)) {
             $this->file_location = $result_file;
             $result_file = file_get_contents($result_file);
         } else {
             if (!isset($result_file[1024]) && defined('PTS_SAVE_RESULTS_PATH') && is_file(PTS_SAVE_RESULTS_PATH . $result_file . '/composite.xml')) {
                 $this->file_location = PTS_SAVE_RESULTS_PATH . $result_file . '/composite.xml';
                 $result_file = file_get_contents($this->file_location);
             }
         }
     }
     $xml = simplexml_load_string($result_file, 'SimpleXMLElement', LIBXML_COMPACT | LIBXML_PARSEHUGE);
     if (isset($xml->Generated)) {
         $this->title = self::clean_input($xml->Generated->Title);
         $this->description = self::clean_input($xml->Generated->Description);
         $this->notes = self::clean_input($xml->Generated->Notes);
         $this->internal_tags = self::clean_input($xml->Generated->InternalTags);
         $this->reference_id = self::clean_input($xml->Generated->ReferenceID);
         $this->preset_environment_variables = self::clean_input($xml->Generated->PreSetEnvironmentVariables);
     }
     if (isset($xml->System)) {
         foreach ($xml->System as $s) {
             $system = new pts_result_file_system(self::clean_input($s->Identifier->__toString()), self::clean_input($s->Hardware->__toString()), self::clean_input($s->Software->__toString()), json_decode(self::clean_input($s->JSON), true), self::clean_input($s->User->__toString()), self::clean_input($s->Notes->__toString()), self::clean_input($s->TimeStamp->__toString()), self::clean_input($s->ClientVersion->__toString()));
             array_push($this->systems, $system);
         }
     }
     if (isset($xml->Result)) {
         foreach ($xml->Result as $result) {
             $test_profile = new pts_test_profile($result->Identifier != null ? $result->Identifier->__toString() : null, null, !$read_only_result_objects);
             $test_profile->set_test_title($result->Title->__toString());
             $test_profile->set_version($result->AppVersion->__toString());
             $test_profile->set_result_scale($result->Scale->__toString());
             $test_profile->set_result_proportion($result->Proportion->__toString());
             $test_profile->set_display_format($result->DisplayFormat->__toString());
             $test_result = new pts_test_result($test_profile);
             $test_result->set_used_arguments_description($result->Description->__toString());
             $test_result->set_used_arguments($result->Arguments->__toString());
             $result_buffer = new pts_test_result_buffer();
             foreach ($result->Data->Entry as $entry) {
                 $result_buffer->add_test_result($entry->Identifier->__toString(), $entry->Value->__toString(), $entry->RawString->__toString(), isset($entry->JSON) ? $entry->JSON->__toString() : null);
             }
             $test_result->set_test_result_buffer($result_buffer);
             $this->result_objects[$test_result->get_comparison_hash(true, false)] = $test_result;
         }
     }
     unset($xml);
 }
 public static function render_page_process($PATH)
 {
     $test_profile = new pts_test_profile($_GET['tp']);
     $name = $test_profile->get_title();
     $description = $test_profile->get_description();
     echo '<h2>' . $name . ' [' . $test_profile->get_identifier() . '] </h2>';
     echo '<p><em>' . $description . '</em></p>';
     echo '<p>More information on this test can be found via <a target="_blank" href="http://openbenchmarking.org/test/' . $test_profile->get_identifier() . '">OpenBenchmarking.org</a>.</p>';
     $test_options = $test_profile->get_test_option_objects();
     echo '<input type="hidden" name="test_add[]" value="' . $test_profile->get_identifier() . '" />';
     $test_prefix = "test_option_" . str_replace('.', '-', microtime(true)) . "_";
     echo '<input type="hidden" name="test_prefix[]" value="' . $test_prefix . '" />';
     if (count($test_options) == 0) {
         echo '<p><strong>No configurable user options for this test.</strong></p>';
     } else {
         for ($i = 0; $i < count($test_options); $i++) {
             $o = $test_options[$i];
             $option_count = $o->option_count();
             echo '<p id="' . $test_prefix . $o->get_identifier() . '_name">' . $o->get_name() . '</p>';
             if ($option_count == 0) {
                 echo '<p><input type="text" name="' . $test_prefix . $o->get_identifier() . '" id="' . $test_prefix . $o->get_identifier() . '" /></p>';
             } else {
                 echo '<input name="' . $test_prefix . $o->get_identifier() . '_selected" id="' . $test_prefix . $o->get_identifier() . '_selected" type="hidden" value="' . $o->get_name() . ': ' . $o->get_option_name(0) . '" />';
                 echo '<p><select name="' . $test_prefix . $o->get_identifier() . '" id="' . $test_prefix . $o->get_identifier() . '" onChange="phoromatic_test_select_update_selected_name(this);">';
                 $opts = array();
                 for ($j = 0; $j < $option_count; $j++) {
                     $v = $o->format_option_value_from_input($o->get_option_value($j));
                     echo '<option value="' . $v . '">' . $o->get_option_name($j) . '</option>';
                     array_push($opts, $o->get_name() . ': ' . $o->get_option_name($j) . '::' . $v);
                 }
                 if ($j > 1) {
                     echo '<option value="' . implode('||', $opts) . '">Test All Options</option>';
                 }
                 echo '</select></p>';
             }
         }
     }
     echo '<hr />';
 }
 public static function render_page_process($PATH)
 {
     $test_profile = new pts_test_profile($_GET['tp']);
     $name = $test_profile->get_title();
     $description = $test_profile->get_description();
     echo '<h2>' . $name . ' [' . $test_profile->get_identifier() . '] </h2>';
     echo '<p><em>' . $description . '</em></p>';
     echo '<p>More information on this test can be found via <a target="_blank" href="http://openbenchmarking.org/test/' . $test_profile->get_identifier() . '">OpenBenchmarking.org</a>.</p>';
     $test_options = $test_profile->get_test_option_objects();
     if (count($test_options) == 0) {
         echo '<p><strong>No configurable user options for this test.</strong></p>';
     } else {
         for ($i = 0; $i < count($test_options); $i++) {
             $o = $test_options[$i];
             $option_count = $o->option_count();
             echo '<input type="hidden" name="test_add[]" value="' . $test_profile->get_identifier() . '" />';
             if (isset($_GET['build_suite'])) {
                 $test_prefix = "test_option_" . microtime() . "_";
                 echo '<input type="hidden" name="test_prefix[]" value="' . $test_prefix . '" />';
             } else {
                 $test_prefix = "test_option_" . $_GET['tp'] . "_";
             }
             echo '<p id="' . $test_prefix . $o->get_identifier() . '_name">' . $o->get_name() . '</p>';
             if ($option_count == 0) {
                 echo '<p><input type="text" name="' . $test_prefix . $o->get_identifier() . '" id="' . $test_prefix . $o->get_identifier() . '" /></p>';
             } else {
                 echo '<input name="' . $test_prefix . $o->get_identifier() . '_selected" id="' . $test_prefix . $o->get_identifier() . '_selected" type="hidden" value="' . $o->get_name() . ': ' . $o->get_option_name(0) . '" />';
                 echo '<p><select name="' . $test_prefix . $o->get_identifier() . '" id="' . $test_prefix . $o->get_identifier() . '" onChange="phoromatic_test_select_update_selected_name(this);">';
                 for ($j = 0; $j < $option_count; $j++) {
                     echo '<option value="' . $o->format_option_value_from_input($o->get_option_value($j)) . '">' . $o->get_option_name($j) . '</option>';
                 }
                 echo '</select></p>';
             }
         }
     }
     echo '<br /><br /><p><input name="submit" value="Add" type="submit" onclick="" /></p>';
 }
 public static function generate_overview_object(&$overview_table, $overview_type)
 {
     switch ($overview_type) {
         case 'GEOMETRIC_MEAN':
             $title = 'Geometric Mean';
             $math_call = array('pts_math', 'geometric_mean');
             break;
         case 'HARMONIC_MEAN':
             $title = 'Harmonic Mean';
             $math_call = array('pts_math', 'harmonic_mean');
             break;
         case 'AGGREGATE_SUM':
             $title = 'Aggregate Sum';
             $math_call = 'array_sum';
             break;
         default:
             return false;
     }
     $result_buffer = new pts_test_result_buffer();
     if ($overview_table instanceof pts_result_file) {
         list($days_keys1, $days_keys, $shred) = pts_ResultFileTable::result_file_to_result_table($overview_table);
         foreach ($shred as $system_key => &$system) {
             $to_show = array();
             foreach ($system as &$days) {
                 $days = $days->get_value();
             }
             array_push($to_show, pts_math::set_precision(call_user_func($math_call, $system), 2));
             $result_buffer->add_test_result($system_key, implode(',', $to_show), null);
         }
     } else {
         $days_keys = null;
         foreach ($overview_table as $system_key => &$system) {
             if ($days_keys == null) {
                 // TODO: Rather messy and inappropriate way of getting the days keys
                 $days_keys = array_keys($system);
                 break;
             }
         }
         foreach ($overview_table as $system_key => &$system) {
             $to_show = array();
             foreach ($system as &$days) {
                 array_push($to_show, call_user_func($math_call, $days));
             }
             $result_buffer->add_test_result($system_key, implode(',', $to_show), null);
         }
     }
     $test_profile = new pts_test_profile(null, null, false);
     $test_profile->set_test_title($title);
     $test_profile->set_result_scale($title);
     $test_profile->set_display_format('BAR_GRAPH');
     $test_result = new pts_test_result($test_profile);
     $test_result->set_used_arguments_description('Analytical Overview');
     $test_result->set_test_result_buffer($result_buffer);
     return $test_result;
 }
 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 static function render_page_process($PATH)
 {
     $main = null;
     $identifier_item = isset($PATH[1]) ? $PATH[0] . '/' . $PATH[1] : false;
     if ($identifier_item && pts_test_profile::is_test_profile($identifier_item)) {
         $tp = new pts_test_profile($identifier_item);
         $tp_identifier = $tp->get_identifier(false);
         $main .= '<h1>' . $tp->get_title() . '</h1><p>' . $tp->get_description() . '</p>';
         $main .= '<p><strong>' . $tp->get_test_hardware_type() . ' - ' . phoromatic_server::test_result_count_for_test_profile($_SESSION['AccountID'], $tp_identifier) . ' Results On This Account - ' . $tp->get_test_software_type() . ' - Maintained By: ' . $tp->get_maintainer() . ' - Supported Platforms: ' . implode(', ', $tp->get_supported_platforms()) . '</strong></p>';
         $main .= '<p><a href="http://openbenchmarking.org/test/' . $tp_identifier . '">Find out more about this test profile on OpenBenchmarking.org</a>.</p>';
         $main .= '<h2>Recent Results With This Test</h2>';
         $stmt = phoromatic_server::$db->prepare('SELECT Title, PPRID FROM phoromatic_results WHERE AccountID = :account_id AND UploadID IN (SELECT DISTINCT UploadID FROM phoromatic_results_results WHERE AccountID = :account_id AND TestProfile LIKE :tp) ORDER BY UploadTime DESC LIMIT 30');
         $stmt->bindValue(':account_id', $_SESSION['AccountID']);
         $stmt->bindValue(':tp', $tp_identifier . '%');
         $result = $stmt->execute();
         $recent_result_count = 0;
         while ($result && ($row = $result->fetchArray())) {
             $recent_result_count++;
             $main .= '<h2><a href="/?result/' . $row['PPRID'] . '">' . $row['Title'] . '</a></h2>';
         }
         if ($recent_result_count == 0) {
             $main .= '<p>No results found on this Phoromatic Server for the ' . $tp->get_title() . ' test profile.</p>';
         } else {
             if ($recent_result_count > 5) {
                 $stmt = phoromatic_server::$db->prepare('SELECT UploadID, SystemID, UploadTime FROM phoromatic_results WHERE AccountID = :account_id AND UploadID IN (SELECT DISTINCT UploadID FROM phoromatic_results_results WHERE AccountID = :account_id AND TestProfile LIKE :tp) ORDER BY UploadTime DESC LIMIT 1000');
                 $stmt->bindValue(':account_id', $_SESSION['AccountID']);
                 $stmt->bindValue(':tp', $tp_identifier . '%');
                 $result = $stmt->execute();
                 $recent_result_count = 0;
                 $result_file = new pts_result_file(null, true);
                 while ($result && ($row = $result->fetchArray())) {
                     $composite_xml = phoromatic_server::phoromatic_account_result_path($_SESSION['AccountID'], $row['UploadID']) . 'composite.xml';
                     if (!is_file($composite_xml)) {
                         continue;
                     }
                     // Add to result file
                     $system_name = strtotime($row['UploadTime']) . ': ' . phoromatic_server::system_id_to_name($row['SystemID']);
                     $sub_result_file = new pts_result_file($composite_xml, true);
                     foreach ($sub_result_file->get_result_objects() as $obj) {
                         if ($obj->test_profile->get_identifier(false) == $tp_identifier) {
                             $obj->test_result_buffer->rename(null, $system_name);
                             $result_file->add_result($obj);
                         }
                     }
                 }
                 $table = null;
                 $extra_attributes = array('multi_way_comparison_invert_default' => false);
                 $f = false;
                 foreach ($result_file->get_result_objects() as $obj) {
                     $obj->test_profile->set_display_format('SCATTER_PLOT');
                     foreach ($obj->test_result_buffer->buffer_items as $i => &$item) {
                         if (!is_numeric(substr($item->get_result_identifier(), 0, strpos($item->get_result_identifier(), ':')))) {
                             unset($obj->test_result_buffer->buffer_items[$i]);
                         }
                     }
                     $result_file = null;
                     $main .= '<p align="center">' . pts_render::render_graph_inline_embed($obj, $result_file, $extra_attributes) . '</p>';
                 }
             }
         }
     } else {
         $dc = pts_strings::add_trailing_slash(pts_strings::parse_for_home_directory(pts_config::read_user_config('PhoronixTestSuite/Options/Installation/CacheDirectory', PTS_DOWNLOAD_CACHE_PATH)));
         $dc_exists = is_file($dc . 'pts-download-cache.json');
         if ($dc_exists) {
             $cache_json = file_get_contents($dc . 'pts-download-cache.json');
             $cache_json = json_decode($cache_json, true);
         }
         $test_counts_for_account = phoromatic_server::test_result_count_for_test_profiles($_SESSION['AccountID']);
         foreach (pts_openbenchmarking::available_tests() as $test) {
             $cache_checked = false;
             if ($dc_exists) {
                 if ($cache_json && isset($cache_json['phoronix-test-suite']['cached-tests'])) {
                     $cache_checked = true;
                     if (!in_array($test, $cache_json['phoronix-test-suite']['cached-tests'])) {
                         //continue;
                     }
                 }
             }
             if (!$cache_checked && phoromatic_server::read_setting('show_local_tests_only') && pts_test_install_request::test_files_in_cache($test, true, true) == false) {
                 continue;
             }
             $tp = new pts_test_profile($test);
             if ($tp->get_title() == null) {
                 continue;
             }
             $test_count = 0;
             $tpid = $tp->get_identifier(false);
             foreach ($test_counts_for_account as $test => $count) {
                 if (strpos($test, $tpid) !== false) {
                     $test_count += $count;
                     unset($test_counts_for_account[$test]);
                 }
             }
             $main .= '<h1 style="margin-bottom: 0;"><a href="/?tests/' . $tp->get_identifier(false) . '">' . $tp->get_title() . '</a></h1>';
             $main .= '<p style="font-size: 90%;"><strong>' . $tp->get_test_hardware_type() . '</strong> <em>-</em> ' . $test_count . ' Results On This Account' . ' </p>';
         }
     }
     echo phoromatic_webui_header_logged_in();
     echo '<div id="pts_phoromatic_main_area">' . $main . '</div>';
     echo phoromatic_webui_footer();
 }
 public static function validate_test_profile(&$test_profile)
 {
     if ($test_profile->get_file_location() == null) {
         echo PHP_EOL . 'ERROR: The file location of the XML test profile source could not be determined.' . PHP_EOL;
         return false;
     }
     // Validate the XML against the XSD Schemas
     libxml_clear_errors();
     // Now re-create the pts_test_profile object around the rewritten XML
     $test_profile = new pts_test_profile($test_profile->get_identifier());
     $valid = $test_profile->validate();
     if ($valid == false) {
         echo PHP_EOL . 'Errors occurred parsing the main XML.' . PHP_EOL;
         pts_validation::process_libxml_errors();
         return false;
     }
     // Rewrite the main XML file to ensure it is properly formatted, elements are ordered according to the schema, etc...
     $test_profile_writer = new pts_test_profile_writer();
     $test_profile_writer->rebuild_test_profile($test_profile);
     $test_profile_writer->save_xml($test_profile->get_file_location());
     // Now re-create the pts_test_profile object around the rewritten XML
     $test_profile = new pts_test_profile($test_profile->get_identifier());
     $valid = $test_profile->validate();
     if ($valid == false) {
         echo PHP_EOL . 'Errors occurred parsing the main XML.' . PHP_EOL;
         pts_validation::process_libxml_errors();
         return false;
     } else {
         echo PHP_EOL . 'Test Profile XML Is Valid.' . PHP_EOL;
     }
     // Validate the downloads file
     $download_xml_file = $test_profile->get_file_download_spec();
     if (empty($download_xml_file) == false) {
         $writer = new pts_test_profile_downloads_writer();
         $writer->rebuild_download_file($test_profile);
         $writer->save_xml($download_xml_file);
         $downloads_parser = new pts_test_downloads_nye_XmlReader($download_xml_file);
         $valid = $downloads_parser->validate();
         if ($valid == false) {
             echo PHP_EOL . 'Errors occurred parsing the downloads XML.' . PHP_EOL;
             pts_validation::process_libxml_errors();
             return false;
         } else {
             echo PHP_EOL . 'Test Downloads XML Is Valid.' . PHP_EOL;
         }
         // Validate the individual download files
         echo PHP_EOL . 'Testing File Download URLs.' . PHP_EOL;
         $files_missing = 0;
         $file_count = 0;
         foreach (pts_test_install_request::read_download_object_list($test_profile) as $download) {
             foreach ($download->get_download_url_array() as $url) {
                 $stream_context = pts_network::stream_context_create();
                 stream_context_set_params($stream_context, array('notification' => 'pts_stream_status_callback'));
                 $file_pointer = fopen($url, 'r', false, $stream_context);
                 if ($file_pointer == false) {
                     echo 'File Missing: ' . $download->get_filename() . ' / ' . $url . PHP_EOL;
                     $files_missing++;
                 } else {
                     fclose($file_pointer);
                 }
                 $file_count++;
             }
         }
         if ($files_missing > 0) {
             return false;
         }
     }
     // Validate the parser file
     $parser_file = $test_profile->get_file_parser_spec();
     if (empty($parser_file) == false) {
         $writer = self::rebuild_result_parser_file($parser_file);
         $writer->saveXMLFile($parser_file);
         $parser = new pts_parse_results_nye_XmlReader($parser_file);
         $valid = $parser->validate();
         if ($valid == false) {
             echo PHP_EOL . 'Errors occurred parsing the results parser XML.' . PHP_EOL;
             pts_validation::process_libxml_errors();
             return false;
         } else {
             echo PHP_EOL . 'Test Results Parser XML Is Valid.' . PHP_EOL;
         }
     }
     // Make sure no extra files are in there
     $allowed_files = pts_validation::test_profile_permitted_files();
     foreach (pts_file_io::glob($test_profile->get_resource_dir() . '*') as $tp_file) {
         if (!is_file($tp_file) || !in_array(basename($tp_file), $allowed_files)) {
             echo PHP_EOL . basename($tp_file) . ' is not allowed in the test package.' . PHP_EOL;
             return false;
         }
     }
     return true;
 }
 public function get_comparison_hash($show_version_and_attributes = true, $raw_output = true)
 {
     if ($show_version_and_attributes) {
         $tp = $this->test_profile->get_identifier(true);
         if ($tp == null) {
             $tp = $this->test_profile->get_title();
         } else {
             if (($x = strrpos($tp, '.')) !== false) {
                 // remove the last segment of the test profile version that should be in xx.yy.zz format
                 // this removal is done since the zz segment should be maintainable between comparisons
                 $tp = substr($tp, 0, $x);
             }
         }
         return pts_test_profile::generate_comparison_hash($tp, $this->get_arguments(), $this->get_arguments_description(), $this->test_profile->get_app_version(), $raw_output);
     } else {
         $tp = $this->test_profile->get_identifier(false);
         if ($tp == null) {
             $tp = $this->test_profile->get_title();
         }
         return pts_test_profile::generate_comparison_hash($tp, $this->get_arguments(), null, null, $raw_output);
     }
 }
 public function get_contained_test_profiles()
 {
     $contained = array();
     // read the repo
     $repo_index = pts_openbenchmarking::read_repository_index($this->repo);
     if (isset($repo_index['tests']) && is_array($repo_index['tests'])) {
         foreach ($repo_index['tests'] as $test_identifier => &$test) {
             if (!in_array(phodevi::operating_system(), $test['supported_platforms']) || empty($test['title'])) {
                 // Initial check to not do unsupported tests
                 continue;
             }
             if ($this->is_virtual_os_selector && !in_array($this->virtual, array_map('strtolower', $test['supported_platforms']))) {
                 // Doing a virtual suite of all tests specific to an OS, but this test profile is not supported there
                 continue;
             } else {
                 if ($this->is_virtual_subsystem_selector && $this->virtual != strtolower($test['test_type'])) {
                     // Doing a virtual suite of all tests specific to a test_type, but this test profile is not supported there
                     continue;
                 } else {
                     if ($this->is_virtual_software_type && $this->virtual != strtolower($test['software_type'])) {
                         // Doing a virtual suite of all tests specific to a software_type, but this test profile is not supported there
                         continue;
                     } else {
                         if ($this->is_virtual_internal_tag && !in_array($this->virtual, array_map('strtolower', $test['internal_tags']))) {
                             // Doing a virtual suite of all tests matching an internal tag
                             continue;
                         }
                     }
                 }
             }
             $test_version = array_shift($test['versions']);
             $test_profile = new pts_test_profile($this->repo . '/' . $test_identifier . '-' . $test_version);
             if ($test_profile->get_display_format() != 'BAR_GRAPH' || !in_array($test_profile->get_license(), array('Free', 'Non-Free'))) {
                 // Also ignore these tests
                 continue;
             }
             if ($this->is_virtual_installed && $test_profile->is_test_installed() == false) {
                 // Test is not installed
                 continue;
             }
             if ($test_profile->is_supported(false)) {
                 // All checks passed, add to virtual suite
                 array_push($contained, $test_profile);
                 continue;
             }
         }
     }
     return $contained;
 }
 public function get_result_object(&$result)
 {
     $test_profile = new pts_test_profile($result->Identifier != null ? $result->Identifier->__toString() : null);
     $test_profile->set_test_title($result->Title->__toString());
     $test_profile->set_version($result->AppVersion->__toString());
     $test_profile->set_result_scale($result->Scale->__toString());
     $test_profile->set_result_proportion($result->Proportion->__toString());
     $test_profile->set_display_format($result->DisplayFormat->__toString());
     $test_result = new pts_test_result($test_profile);
     $test_result->set_used_arguments_description($result->Description->__toString());
     $test_result->set_used_arguments($result->Arguments->__toString());
     $result_buffer = new pts_test_result_buffer();
     foreach ($result->Data->Entry as $entry) {
         $result_buffer->add_test_result($entry->Identifier->__toString(), $entry->Value->__toString(), $entry->RawString->__toString(), isset($entry->JSON) ? $entry->JSON->__toString() : null);
     }
     $test_result->set_test_result_buffer($result_buffer);
     return $test_result;
 }
 protected static function result_upload_supported(&$result_file)
 {
     foreach ($result_file->get_result_objects() as $result_object) {
         $test_profile = new pts_test_profile($result_object->test_profile->get_identifier());
         if ($test_profile->allow_results_sharing() == false) {
             echo PHP_EOL . $result_object->test_profile->get_identifier() . ' does not allow test results to be uploaded.' . PHP_EOL . PHP_EOL;
             return false;
         }
     }
     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 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 get_file_parser_spec()
 {
     $spec = is_file($this->get_resource_dir() . 'results-definition.xml') ? $this->get_resource_dir() . 'results-definition.xml' : false;
     if (!$spec) {
         $extends = $this->get_test_extension();
         if (!empty($extends)) {
             $test_profile = new pts_test_profile($extends);
             $spec = $test_profile->get_file_parser_spec();
         }
     }
     return $spec;
 }
 public static function is_test_or_suite($identifier)
 {
     return pts_test_profile::is_test_profile($identifier) || pts_test_suite::is_suite($identifier);
 }