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;
     }
 }
 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 static function run($r)
 {
     pts_client::$display->generic_heading('Test Suite Creation');
     $suite_name = pts_user_io::prompt_user_input('Enter name of suite');
     $suite_test_type = pts_user_io::prompt_text_menu('Select test type', pts_types::subsystem_targets());
     $suite_maintainer = pts_user_io::prompt_user_input('Enter suite maintainer name');
     $suite_description = pts_user_io::prompt_user_input('Enter suite description');
     $possible_suites = pts_openbenchmarking::available_suites();
     $possible_tests = pts_openbenchmarking::available_tests();
     $suite_writer = new pts_test_suite_writer();
     $suite_writer->add_suite_information($suite_name, '1.0.0', $suite_maintainer, $suite_test_type, $suite_description);
     foreach ($r as $test_object) {
         $test_object = pts_types::identifier_to_object($test_object);
         if ($test_object instanceof pts_test_profile) {
             list($args, $description) = pts_test_run_options::prompt_user_options($test_object);
             for ($i = 0; $i < count($args); $i++) {
                 // Not binding the test profile version to this suite, otherwise change false to true
                 $suite_writer->add_to_suite($test_object->get_identifier(false), $args[$i], $description[$i]);
             }
         } else {
             if ($test_object instanceof pts_test_suite) {
                 $suite_writer->add_to_suite($test_object->get_identifier(), null, null);
             }
         }
     }
     $input_option = null;
     do {
         switch ($input_option) {
             case 'Add Test':
                 $test_to_add = pts_user_io::prompt_text_menu('Enter test name', $possible_tests);
                 $test_profile = new pts_test_profile($test_to_add);
                 list($args, $description) = pts_test_run_options::prompt_user_options($test_profile);
                 for ($i = 0; $i < count($args); $i++) {
                     $suite_writer->add_to_suite($test_to_add, $args[$i], $description[$i]);
                 }
                 break;
             case 'Add Sub-Suite':
                 $suite_to_add = pts_user_io::prompt_text_menu('Enter test suite', $possible_suites);
                 $suite_writer->add_to_suite($suite_to_add, null, null);
                 break;
         }
         echo PHP_EOL . 'Available Options:' . PHP_EOL;
         $input_option = pts_user_io::prompt_text_menu('Select next operation', array('Add Test', 'Add Sub-Suite', 'Save & Exit'));
     } while ($input_option != 'Save & Exit');
     $suite_identifier = $suite_writer->clean_save_name_string($suite_name);
     $save_to = PTS_TEST_SUITE_PATH . 'local/' . $suite_identifier . '/suite-definition.xml';
     mkdir(dirname($save_to));
     if ($suite_writer->save_xml($save_to) != false) {
         echo PHP_EOL . PHP_EOL . 'Saved To: ' . $save_to . PHP_EOL . 'To run this suite, type: phoronix-test-suite benchmark ' . $suite_identifier . PHP_EOL . 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;
         }
     }
 }
 protected function process_hand_shake($user, $buffer)
 {
     $buffer_wrote = parent::process_hand_shake($user, $buffer);
     return $buffer_wrote;
     // TODO potentially don't need below code for this back-end XXX
     if ($buffer_wrote > 0) {
         $resource = substr($user->res, strrpos($user->res, '/') + 1);
         switch (strstr($resource . ' ', ' ', true)) {
             case 'start-user-session':
                 $json = array();
                 $json['pts']['msg']['name'] = 'user_session_start';
                 $this->add_to_status('Starting Session', $json);
                 $this->send_json_data($user->socket, $json);
                 // Phodevi
                 $this->add_to_status('Generating Phodevi Cache + VFS', $json);
                 $this->send_json_data($user->socket, $json);
                 phodevi::system_software(true);
                 phodevi::system_hardware(true);
                 $this->phodevi_vfs = new phodevi_vfs();
                 $this->phodevi_vfs->list_cache_nodes();
                 // Sensors
                 $this->add_to_status('Starting Phodevi Sensor Handler', $json);
                 $this->send_json_data($user->socket, $json);
                 $this->sensor_logging = new phodevi_sensor_monitor(array('all'));
                 $this->sensor_logging->sensor_logging_start();
                 // Test Information
                 $this->add_to_status('Downloading Test Information', $json);
                 $this->send_json_data($user->socket, $json);
                 pts_openbenchmarking::available_tests(true);
                 // Complete
                 $this->add_to_status('Session Startup Complete', $json);
                 $this->send_json_data($user->socket, $json);
                 //$this->disconnect($user->socket);
                 break;
         }
         return true;
     }
 }
 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 render_page_process($PATH)
    {
        if (isset($_POST['suite_title'])) {
            //	echo '<pre>';
            //	var_dump($_POST);
            //	echo '</pre>';
            if (strlen($_POST['suite_title']) < 3) {
                echo '<h2>Suite title must be at least three characters.</h2>';
            }
            //echo 'TEST SUITE: ' . $_POST['suite_title'] . '<br />';
            //echo 'TEST SUITE: ' . $_POST['suite_description'] . '<br />';
            $tests = array();
            foreach ($_POST['test_add'] as $i => $test_identifier) {
                $test_prefix = $_POST['test_prefix'][$i];
                $args = array();
                $args_name = array();
                foreach ($_POST as $i => $v) {
                    if (strpos($i, $test_prefix) !== false && substr($i, -9) != '_selected') {
                        if (strpos($v, '||') !== false) {
                            $opts = explode('||', $v);
                            $a = array();
                            $d = array();
                            foreach ($opts as $opt) {
                                $t = explode('::', $opt);
                                array_push($a, $t[1]);
                                array_push($d, $t[0]);
                            }
                            array_push($args, $a);
                            array_push($args_name, $d);
                        } else {
                            array_push($args, array($v));
                            array_push($args_name, array($_POST[$i . '_selected']));
                        }
                    }
                }
                $test_args = array();
                $test_args_description = array();
                pts_test_run_options::compute_all_combinations($test_args, null, $args, 0);
                pts_test_run_options::compute_all_combinations($test_args_description, null, $args_name, 0, ' - ');
                foreach (array_keys($test_args) as $i) {
                    array_push($tests, array('test' => $test_identifier, 'description' => $test_args_description[$i], 'args' => $test_args[$i]));
                }
            }
            if (count($tests) < 1) {
                echo '<h2>You must add at least one test to the suite.</h2>';
            }
            $suite_writer = new pts_test_suite_writer();
            $version_bump = 0;
            do {
                $suite_version = '1.' . $version_bump . '.0';
                $suite_id = $suite_writer->clean_save_name_string($_POST['suite_title']) . '-' . $suite_version;
                $suite_dir = phoromatic_server::phoromatic_account_suite_path($_SESSION['AccountID'], $suite_id);
                $version_bump++;
            } while (is_dir($suite_dir));
            pts_file_io::mkdir($suite_dir);
            $save_to = $suite_dir . '/suite-definition.xml';
            $suite_writer->add_suite_information($_POST['suite_title'], $suite_version, $_SESSION['UserName'], 'System', $_POST['suite_description']);
            foreach ($tests as $m) {
                $suite_writer->add_to_suite($m['test'], $m['args'], $m['description']);
            }
            $suite_writer->save_xml($save_to);
            echo '<h2>Saved As ' . $suite_id . '</h2>';
        }
        echo phoromatic_webui_header_logged_in();
        $main = '<h1>Local Suites</h1><p>Find already created local test suites by your account/group via the <a href="/?local_suites">local suites</a> page.</p>';
        if (!PHOROMATIC_USER_IS_VIEWER) {
            $main .= '<h1>Build Suite</h1><p>A test suite in the realm of the Phoronix Test Suite, OpenBenchmarking.org, and Phoromatic is <strong>a collection of test profiles with predefined settings</strong>. Establishing a test suite makes it easy to run repetitive testing on the same set of test profiles by simply referencing the test suite name.</p>';
            $main .= '<form action="' . $_SERVER['REQUEST_URI'] . '" name="build_suite" id="build_suite" method="post" onsubmit="return validate_suite();">
			<h3>Title:</h3>
			<p><input type="text" name="suite_title" /></p>
			<h3>Description:</h3>
			<p><textarea name="suite_description" id="suite_description" cols="60" rows="2"></textarea></p>
			<h3>Tests In Schedule:</h3>
			<p><div id="test_details"></div></p>
			<h3>Add Another Test</h3>';
            $main .= '<select name="add_to_suite_select_test" id="add_to_suite_select_test" onchange="phoromatic_build_suite_test_details();">';
            $dc = pts_strings::add_trailing_slash(pts_client::parse_home_directory(pts_config::read_user_config('PhoronixTestSuite/Options/Installation/CacheDirectory', PTS_DOWNLOAD_CACHE_PATH)));
            $dc_exists = is_file($dc . 'pts-download-cache.json');
            foreach (pts_openbenchmarking::available_tests(false, true) as $test) {
                $cache_checked = false;
                if ($dc_exists) {
                    $cache_json = file_get_contents($dc . 'pts-download-cache.json');
                    $cache_json = json_decode($cache_json, true);
                    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;
                }
                $main .= '<option value="' . $test . '">' . $test . '</option>';
            }
            $main .= '</select>';
            $main .= '<p align="right"><input name="submit" value="Create Suite" type="submit" onclick="return pts_rmm_validate_suite();" /></p>';
        }
        echo '<div id="pts_phoromatic_main_area">' . $main . '</div>';
        echo phoromatic_webui_footer();
    }
    public static function render_page_process($PATH)
    {
        $main = null;
        echo phoromatic_webui_header_logged_in();
        if (!empty($PATH[0]) && is_numeric($PATH[0])) {
            $stmt = phoromatic_server::$db->prepare('SELECT * FROM phoromatic_schedules WHERE AccountID = :account_id AND ScheduleID = :schedule_id');
            $stmt->bindValue(':account_id', $_SESSION['AccountID']);
            $stmt->bindValue(':schedule_id', $PATH[0]);
            $result = $stmt->execute();
            $row = $result->fetchArray();
            if (empty($row)) {
                $main = '<h1>Test Schedules</h1>';
                $main .= '<h3>No Resource Found</h3>';
            } else {
                if (!PHOROMATIC_USER_IS_VIEWER) {
                    if (isset($_POST['add_to_schedule_select_test'])) {
                        $name = $_POST['add_to_schedule_select_test'];
                        $args = array();
                        $args_name = array();
                        foreach ($_POST as $i => $v) {
                            if (substr($i, 0, 12) == 'test_option_' && substr($i, -9) != '_selected') {
                                array_push($args, $v);
                                array_push($args_name, $_POST[$i . '_selected']);
                            }
                        }
                        $args_name = implode(' - ', $args_name);
                        $args = implode(' ', $args);
                        if (!empty($name)) {
                            $stmt = phoromatic_server::$db->prepare('INSERT INTO phoromatic_schedules_tests (AccountID, ScheduleID, TestProfile, TestArguments, TestDescription) VALUES (:account_id, :schedule_id, :test_profile, :test_arguments, :test_description)');
                            $stmt->bindValue(':account_id', $_SESSION['AccountID']);
                            $stmt->bindValue(':schedule_id', $PATH[0]);
                            $stmt->bindValue(':test_profile', $name);
                            $stmt->bindValue(':test_arguments', $args);
                            $stmt->bindValue(':test_description', $args_name);
                            $result = $stmt->execute();
                            phoromatic_add_activity_stream_event('tests_for_schedule', $PATH[0], 'added');
                        }
                    } else {
                        if (isset($PATH[1]) && $PATH[1] == 'remove' && !empty($PATH[2])) {
                            // REMOVE TEST
                            $to_remove = explode(PHP_EOL, base64_decode($PATH[2]));
                            $stmt = phoromatic_server::$db->prepare('DELETE FROM phoromatic_schedules_tests WHERE AccountID = :account_id AND ScheduleID = :schedule_id AND TestProfile = :test AND TestArguments = :test_args');
                            $stmt->bindValue(':account_id', $_SESSION['AccountID']);
                            $stmt->bindValue(':schedule_id', $PATH[0]);
                            $stmt->bindValue(':test', $to_remove[0]);
                            $stmt->bindValue(':test_args', $to_remove[1]);
                            $result = $stmt->execute();
                            phoromatic_add_activity_stream_event('tests_for_schedule', $to_remove[0] . ' - ' . $to_remove[1], 'removed');
                        } else {
                            if (isset($PATH[1]) && $PATH[1] == 'delete-trigger' && !empty($PATH[2])) {
                                // REMOVE TRIGGER
                                $trigger = base64_decode($PATH[2]);
                                $stmt = phoromatic_server::$db->prepare('DELETE FROM phoromatic_schedules_triggers WHERE AccountID = :account_id AND Trigger = :trigger AND ScheduleID = :schedule_id');
                                $stmt->bindValue(':account_id', $_SESSION['AccountID']);
                                $stmt->bindValue(':schedule_id', $PATH[0]);
                                $stmt->bindValue(':trigger', $trigger);
                                $result = $stmt->execute();
                                if ($result) {
                                    $main .= '<h2 style="color: red;">Trigger Removed: ' . $trigger . '</h2>';
                                }
                            } else {
                                if (isset($PATH[1]) && in_array($PATH[1], array('activate', 'deactivate'))) {
                                    switch ($PATH[1]) {
                                        case 'deactivate':
                                            $new_state = 0;
                                            break;
                                        case 'activate':
                                        default:
                                            $new_state = 1;
                                            break;
                                    }
                                    // REMOVE TEST
                                    $stmt = phoromatic_server::$db->prepare('UPDATE phoromatic_schedules SET State = :new_state WHERE AccountID = :account_id AND ScheduleID = :schedule_id');
                                    $stmt->bindValue(':account_id', $_SESSION['AccountID']);
                                    $stmt->bindValue(':schedule_id', $PATH[0]);
                                    $stmt->bindValue(':new_state', $new_state);
                                    $result = $stmt->execute();
                                    $row['State'] = $new_state;
                                    phoromatic_add_activity_stream_event('schedule', $PATH[0], $PATH[1]);
                                } else {
                                    if (isset($_POST['do_manual_test_run'])) {
                                        $stmt = phoromatic_server::$db->prepare('INSERT INTO phoromatic_schedules_triggers (AccountID, ScheduleID, Trigger, TriggeredOn) VALUES (:account_id, :schedule_id, :trigger, :triggered_on)');
                                        $stmt->bindValue(':account_id', $_SESSION['AccountID']);
                                        $stmt->bindValue(':schedule_id', $PATH[0]);
                                        $stmt->bindValue(':trigger', $_SESSION['UserName'] . ' - Manual Test Run - ' . date('H:i j M Y'));
                                        $stmt->bindValue(':triggered_on', phoromatic_server::current_time());
                                        $stmt->execute();
                                        $main .= '<h2 style="color: red;">Manual Test Run Triggered</h2>';
                                    } else {
                                        if (isset($_POST['skip_current_ticket'])) {
                                            $stmt = phoromatic_server::$db->prepare('INSERT INTO phoromatic_schedules_trigger_skips (AccountID, ScheduleID, Trigger) VALUES (:account_id, :schedule_id, :trigger)');
                                            $stmt->bindValue(':account_id', $_SESSION['AccountID']);
                                            $stmt->bindValue(':schedule_id', $PATH[0]);
                                            $stmt->bindValue(':trigger', date('Y-m-d'));
                                            $stmt->execute();
                                            $main .= '<h2 style="color: red;">Current Trigger To Be Ignored</h2>';
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                $main .= '<h1>' . $row['Title'] . '</h1>';
                $main .= '<h3>' . $row['Description'] . '</h3>';
                $main .= '<p>This schedule was last modified on <strong>' . date('j F Y \\a\\t H:i', strtotime($row['LastModifiedOn'])) . '</strong> by <strong>' . $row['LastModifiedBy'] . '</strong>.';
                if (!PHOROMATIC_USER_IS_VIEWER) {
                    $main .= '<p><a href="?sched/' . $PATH[0] . '">Edit Schedule</a> | ';
                    if ($row['State'] == 1) {
                        $main .= '<a href="?schedules/' . $PATH[0] . '/deactivate">Deactivate Schedule</a>';
                    } else {
                        $main .= '<a href="?schedules/' . $PATH[0] . '/activate">Activate Schedule</a>';
                    }
                    $main .= '</p>';
                }
                $main .= '<hr />';
                $main .= '<h2>Schedule</h2>';
                if (!empty($row['ActiveOn'])) {
                    $active_days = explode(',', $row['ActiveOn']);
                    $week = array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday');
                    foreach ($active_days as $i => &$day) {
                        if (!isset($week[$day])) {
                            unset($active_days[$i]);
                        } else {
                            $day = $week[$day];
                        }
                    }
                    switch (count($active_days)) {
                        case 2:
                            $day_show = implode(' and ', $active_days);
                            break;
                        default:
                            $day_show = implode(', ', $active_days);
                            break;
                    }
                    $main .= '<p>This test is scheduled to run every <strong>' . $day_show . '</strong> at <strong>' . str_replace('.', ':', $row['RunAt']) . '</strong>.</p>';
                } else {
                    $main .= '<p>This test schedule is not currently set to run a pre-defined time-based schedule.</p>';
                }
                if (!PHOROMATIC_USER_IS_VIEWER) {
                    $trigger_url = 'http://' . phoromatic_web_socket_server_ip() . '/event.php?type=trigger&user='******'UserName'] . '&public_key=' . $row['PublicKey'] . '&trigger=XXX';
                    $main .= '<p>This test schedule can be manually triggered to run at any time by calling <strong>' . $trigger_url . '</strong> where <em>XXX</em> is the trigger value to be used (if relevant, such as a time-stamp, Git/SVN commit number or hash, etc). There\'s also the option of sub-targeting system(s) part of this schedule. One option is appending <em>&sub_target_this_ip</em> if this URL is being called from one of the client test systems to only sub-target the triggered testing on that client, among other options.</p>';
                    $main .= '<p>If you wish to run this test schedule now, click the following button and the schedule will be run on all intended systems at their next earliest possible convenience.</p>';
                    $main .= '<p><form action="?schedules/' . $PATH[0] . '" name="manual_run" method="post">';
                    $main .= '<input type="hidden" name="do_manual_test_run" value="1" /><input type="submit" value="Run Test Schedule Now" onclick="return confirm(\'Run this test schedule now?\');" />';
                    $main .= '</form></p>';
                    $main .= '<p><form action="?schedules/' . $PATH[0] . '" name="skip_run" method="post">';
                    $main .= '<input type="hidden" name="skip_current_ticket" value="1" /><input type="submit" value="Skip Current Test Ticket" onclick="return confirm(\'Skip any currently active test ticket on all systems?\');" />';
                    $main .= '</form></p>';
                }
                $main .= '<hr />';
                $contexts = array('SetContextPreInstall' => 'Pre-Install', 'SetContextPostInstall' => 'Post-Install', 'SetContextPreRun' => 'Pre-Test-Run', 'SetContextPostRun' => 'Post-Test-Run');
                $scripts = 0;
                foreach ($contexts as $context => $v) {
                    if (isset($row[$context]) && !empty($row[$context]) && is_file(phoromatic_server::phoromatic_account_path($_SESSION['AccountID']) . 'context_' . $row[$context])) {
                        $scripts++;
                        $main .= '<h2>' . $v . ' Context Script</h2>';
                        $main .= '<blockquote>' . str_replace(PHP_EOL, '<br />', htmlentities(file_get_contents(phoromatic_server::phoromatic_account_path($_SESSION['AccountID']) . 'context_' . $row[$context]))) . '</blockquote>';
                    }
                }
                if ($scripts > 0) {
                    $main .= '<hr />';
                }
                $main .= '<h2>Tests To Run</h2>';
                $stmt = phoromatic_server::$db->prepare('SELECT * FROM phoromatic_schedules_tests WHERE AccountID = :account_id AND ScheduleID = :schedule_id ORDER BY TestProfile ASC');
                $stmt->bindValue(':account_id', $_SESSION['AccountID']);
                $stmt->bindValue(':schedule_id', $PATH[0]);
                $result = $stmt->execute();
                $test_count = 0;
                $main .= '<p>';
                while ($row = $result->fetchArray()) {
                    $test_count++;
                    $main .= $row['TestProfile'] . ($row['TestDescription'] != null ? ' - <em>' . $row['TestDescription'] . '</em>' : '') . (!PHOROMATIC_USER_IS_VIEWER ? ' <a href="?schedules/' . $PATH[0] . '/remove/' . base64_encode(implode(PHP_EOL, array($row['TestProfile'], $row['TestArguments']))) . '">Remove Test</a>' : null) . '<br />';
                    /*
                    if(!PHOROMATIC_USER_IS_VIEWER && isset($_REQUEST['make_version_lock_tests']))
                    {
                    	if(strpos($row['TestProfile'], '.') == false)
                    	{
                    		$test_profile = new pts_test_profile($row['TestProfile']);
                    		$full_identifier = $test_profile->get_identifier(true);
                    
                    		$stmt = phoromatic_server::$db->prepare('UPDATE phoromatic_schedules_tests SET TestProfile = :version_locked_tp WHERE AccountID = :account_id AND ScheduleID = :schedule_id AND TestProfile = :test');
                    		$stmt->bindValue(':account_id', $_SESSION['AccountID']);
                    		$stmt->bindValue(':schedule_id', $PATH[0]);
                    		$stmt->bindValue(':test', $row['TestProfile']);
                    		$stmt->bindValue(':version_locked_tp', $full_identifier);
                    		$result2 = $stmt->execute();
                    	}
                    }
                    */
                }
                $main .= '</p>';
                if ($test_count == 0) {
                    $main .= '<h3 style="text-transform: uppercase;">No tests have been added yet for this test schedule.</h3>';
                }
                if (!PHOROMATIC_USER_IS_VIEWER) {
                    $main .= '<hr /><h2>Add A Test</h2>';
                    $main .= '<form action="?schedules/' . $PATH[0] . '" name="add_test" id="add_test" method="post">';
                    $main .= '<select name="add_to_schedule_select_test" id="add_to_schedule_select_test" onchange="phoromatic_schedule_test_details(\'\');">';
                    $dc = pts_strings::add_trailing_slash(pts_client::parse_home_directory(pts_config::read_user_config('PhoronixTestSuite/Options/Installation/CacheDirectory', PTS_DOWNLOAD_CACHE_PATH)));
                    $dc_exists = is_file($dc . 'pts-download-cache.json');
                    foreach (pts_openbenchmarking::available_tests(false, true) as $test) {
                        $cache_checked = false;
                        if ($dc_exists) {
                            $cache_json = file_get_contents($dc . 'pts-download-cache.json');
                            $cache_json = json_decode($cache_json, true);
                            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;
                        }
                        $main .= '<option value="' . $test . '">' . $test . '</option>';
                    }
                    $main .= '</select>';
                    $main .= '<p><div id="test_details"></div></p>';
                    $main .= '</form>';
                }
                $systems_in_schedule = phoromatic_server::systems_associated_with_schedule($_SESSION['AccountID'], $PATH[0]);
                if (!empty($systems_in_schedule)) {
                    $main .= '<hr /><h2>Systems In Schedule</h2>';
                    if (!PHOROMATIC_USER_IS_VIEWER) {
                        $main .= '<p>To run this schedule on more systems, <a href="?sched/' . $PATH[0] . '">edit the schedule</a>.</p>';
                    }
                    $main .= '<div class="pts_phoromatic_info_box_area" style="margin: 0 10%;"><ul><li><h1>Systems</h1></li>';
                    foreach ($systems_in_schedule as $system_id) {
                        $row = phoromatic_server::get_system_details($_SESSION['AccountID'], $system_id);
                        $main .= '<a href="?systems/' . $row['SystemID'] . '"><li>' . $row['Title'] . '<br /><table><tr><td>' . $row['LocalIP'] . '</td><td><strong>' . $row['CurrentTask'] . '</strong></td><td><strong>Last Communication:</strong> ' . date('j F Y H:i', strtotime($row['LastCommunication'])) . '</td></tr></table></li></a>';
                    }
                    $main .= '</ul></div><hr />';
                }
                $stmt = phoromatic_server::$db->prepare('SELECT Trigger, TriggeredOn FROM phoromatic_schedules_triggers WHERE AccountID = :account_id AND ScheduleID = :schedule_id ORDER BY TriggeredOn DESC LIMIT 10');
                $stmt->bindValue(':account_id', $_SESSION['AccountID']);
                $stmt->bindValue(':schedule_id', $PATH[0]);
                $test_result_result = $stmt->execute();
                $test_result_row = $test_result_result->fetchArray();
                if ($test_result_row) {
                    $main .= '<div class="pts_phoromatic_info_box_area" style="margin: 0 10%;">';
                    $main .= '<ul><li><h1>Recent Triggers For This Schedule</h1></li>';
                    do {
                        $main .= '<a onclick=""><li>' . $test_result_row['Trigger'] . '<br /><table><tr><td>' . phoromatic_user_friendly_timedate($test_result_row['TriggeredOn']) . '</td><td><a href="?schedules/' . $PATH[0] . '/delete-trigger/' . base64_encode($test_result_row['Trigger']) . '">Remove Trigger</a></td></tr></table></li></a>';
                    } while ($test_result_row = $test_result_result->fetchArray());
                    $main .= '</ul>';
                    $main .= '</div>';
                }
                $stmt = phoromatic_server::$db->prepare('SELECT Title, SystemID, ScheduleID, PPRID, UploadTime FROM phoromatic_results WHERE AccountID = :account_id AND ScheduleID = :schedule_id ORDER BY UploadTime DESC');
                $stmt->bindValue(':account_id', $_SESSION['AccountID']);
                $stmt->bindValue(':schedule_id', $PATH[0]);
                $test_result_result = $stmt->execute();
                $test_result_row = $test_result_result->fetchArray();
                if ($test_result_row) {
                    $main .= '<div class="pts_phoromatic_info_box_area" style="margin: 0 10%;">';
                    $main .= '<ul><li><h1>Recent Test Results For This Schedule</h1></li>';
                    $results = 0;
                    do {
                        $oldest_upload_time = $test_result_row['UploadTime'];
                        if ($results > 100) {
                            continue;
                        }
                        $main .= '<a href="?result/' . $test_result_row['PPRID'] . '"><li>' . $test_result_row['Title'] . '<br /><table><tr><td>' . phoromatic_system_id_to_name($test_result_row['SystemID']) . '</td><td>' . phoromatic_user_friendly_timedate($test_result_row['UploadTime']) . '</td></tr></table></li></a>';
                        $results++;
                    } while ($test_result_row = $test_result_result->fetchArray());
                    $main .= '</ul>';
                    $main .= '</div>';
                }
                $num_results = phoromatic_results_for_schedule($PATH[0]);
                if ($num_results > 1) {
                    $main .= '<p>Jump to the latest results from the past: ';
                    $main .= '<select name="view_results_from_past" id="view_results_from_past" onchange="phoromatic_jump_to_results_from(\'' . $PATH[0] . '\', \'view_results_from_past\');">';
                    $oldest_upload_time = strtotime($oldest_upload_time);
                    $opts = array('Week' => 7, 'Three Weeks' => 21, 'Month' => 30, 'Quarter' => 90, 'Six Months' => 180, 'Year' => 365);
                    foreach ($opts as $str_name => $time_offset) {
                        if ($oldest_upload_time > time() - 86400 * $time_offset) {
                            break;
                        }
                        $main .= '<option value="' . $time_offset . '">' . $str_name . '</option>';
                    }
                    $main .= '<option value="all">All Results</option>';
                    $main .= '</select>';
                    $main .= '</p><hr />';
                }
                $main .= '<p><strong>' . $num_results . ' Test Results Available For This Schedule.</strong></p>';
            }
            echo phoromatic_webui_main($main, phoromatic_webui_right_panel_logged_in());
            echo phoromatic_webui_footer();
            return;
        }
        $main = '<h1>Test Schedules</h1>
			<p>Test schedules are used for tests that are intended to be run on a recurring basis -- either daily or other defined time period -- or whenever a trigger/event occurs, like a new Git commit to a software repository being tracked. Test schedules can be run on any given system(s)/group(s) and can be later edited.</p>';
        if (!PHOROMATIC_USER_IS_VIEWER) {
            $main .= '
				<hr />
				<h2>Create A Schedule</h2>
				<p><a href="?sched">Create a schedule</a> followed by adding tests/suites to run for that schedule on the selected systems.</p>';
        }
        $main .= '<hr /><h2>Current Schedules</h2>';
        $main .= '<div class="pts_phoromatic_info_box_area">
					<ul>
						<li><h1>Active Test Schedules</h1></li>';
        $stmt = phoromatic_server::$db->prepare('SELECT Title, ScheduleID, Description, RunTargetSystems, RunTargetGroups, RunAt, ActiveOn FROM phoromatic_schedules WHERE AccountID = :account_id AND State >= 1 ORDER BY Title ASC');
        $stmt->bindValue(':account_id', $_SESSION['AccountID']);
        $result = $stmt->execute();
        $row = $result->fetchArray();
        if ($row == false) {
            $main .= '<li class="light" style="text-align: center;">No Schedules Found</li>';
        } else {
            do {
                $stmt_tests = phoromatic_server::$db->prepare('SELECT COUNT(*) AS TestCount FROM phoromatic_schedules_tests WHERE AccountID = :account_id AND ScheduleID = :schedule_id ORDER BY TestProfile ASC');
                $stmt_tests->bindValue(':account_id', $_SESSION['AccountID']);
                $stmt_tests->bindValue(':schedule_id', $row['ScheduleID']);
                $result_tests = $stmt_tests->execute();
                $row_tests = $result_tests->fetchArray();
                $test_count = !empty($row_tests) ? $row_tests['TestCount'] : 0;
                $group_count = empty($row['RunTargetGroups']) ? 0 : count(explode(',', $row['RunTargetGroups']));
                $main .= '<a href="?schedules/' . $row['ScheduleID'] . '"><li>' . $row['Title'] . '<br /><table><tr><td>' . pts_strings::plural_handler(count(phoromatic_server::systems_associated_with_schedule($_SESSION['AccountID'], $row['ScheduleID'])), 'System') . '</td><td>' . pts_strings::plural_handler($group_count, 'Group') . '</td><td>' . pts_strings::plural_handler($test_count, 'Test') . '</td><td>' . pts_strings::plural_handler(phoromatic_results_for_schedule($row['ScheduleID']), 'Result') . ' Total</td><td>' . pts_strings::plural_handler(phoromatic_results_for_schedule($row['ScheduleID'], 'TODAY'), 'Result') . ' Today</td><td><strong>' . phoromatic_schedule_activeon_string($row['ActiveOn'], $row['RunAt']) . '</strong></td></tr></table></li></a>';
            } while ($row = $result->fetchArray());
        }
        $main .= '</ul>
			</div>';
        $main .= '<hr /><h2>Schedule Overview</h2>';
        $week = array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday');
        foreach ($week as $i => $day) {
            $stmt = phoromatic_server::$db->prepare('SELECT Title, ScheduleID, RunAt, RunTargetGroups, RunTargetSystems FROM phoromatic_schedules WHERE AccountID = :account_id AND State >= 1 AND ActiveOn LIKE :active_on ORDER BY RunAt,ActiveOn,Title ASC');
            $stmt->bindValue(':account_id', $_SESSION['AccountID']);
            $stmt->bindValue(':active_on', '%' . $i . '%');
            $result = $stmt->execute();
            $has_matched = false;
            while ($row = $result->fetchArray()) {
                if (!$has_matched) {
                    $main .= '<h3>' . $day . '</h3>' . PHP_EOL . '<p>';
                    $has_matched = true;
                }
                $main .= '<em>' . $row['RunAt'] . '</em> <a href="?schedules/' . $row['ScheduleID'] . '">' . $row['Title'] . '</a>';
                //$main .= $row['RunTargetSystems'] . ' ' . $row['RunTargetGroups'];
                $main .= '<br />';
            }
            if ($has_matched) {
                $main .= '</p>' . PHP_EOL;
            }
        }
        $main .= '<div class="pts_phoromatic_info_box_area">
					<ul>
						<li><h1>Deactivated Test Schedules</h1></li>';
        $stmt = phoromatic_server::$db->prepare('SELECT Title, ScheduleID, Description, RunTargetSystems, RunTargetGroups, RunAt, ActiveOn FROM phoromatic_schedules WHERE AccountID = :account_id AND State < 1 ORDER BY Title ASC');
        $stmt->bindValue(':account_id', $_SESSION['AccountID']);
        $result = $stmt->execute();
        $row = $result->fetchArray();
        if ($row == false) {
            $main .= '<li class="light" style="text-align: center;">No Schedules Found</li>';
        } else {
            do {
                $stmt_tests = phoromatic_server::$db->prepare('SELECT COUNT(*) AS TestCount FROM phoromatic_schedules_tests WHERE AccountID = :account_id AND ScheduleID = :schedule_id ORDER BY TestProfile ASC');
                $stmt_tests->bindValue(':account_id', $_SESSION['AccountID']);
                $stmt_tests->bindValue(':schedule_id', $row['ScheduleID']);
                $result_tests = $stmt_tests->execute();
                $row_tests = $result_tests->fetchArray();
                $test_count = !empty($row_tests) ? $row_tests['TestCount'] : 0;
                $group_count = empty($row['RunTargetGroups']) ? 0 : count(explode(',', $row['RunTargetGroups']));
                $main .= '<a href="?schedules/' . $row['ScheduleID'] . '"><li>' . $row['Title'] . '<br /><table><tr><td>' . pts_strings::plural_handler(count(phoromatic_server::systems_associated_with_schedule($_SESSION['AccountID'], $row['ScheduleID'])), 'System') . '</td><td>' . pts_strings::plural_handler($group_count, 'Group') . '</td><td>' . pts_strings::plural_handler($test_count, 'Test') . '</td><td>' . pts_strings::plural_handler(phoromatic_results_for_schedule($row['ScheduleID']), 'Result') . ' Total</td><td>' . pts_strings::plural_handler(phoromatic_results_for_schedule($row['ScheduleID'], 'TODAY'), 'Result') . ' Today</td><td><strong>' . phoromatic_schedule_activeon_string($row['ActiveOn'], $row['RunAt']) . '</strong></td></tr></table></li></a>';
            } while ($row = $result->fetchArray());
        }
        $main .= '</ul>
			</div>';
        echo '<div id="pts_phoromatic_main_area">' . $main . '</div>';
        echo phoromatic_webui_footer();
    }
Пример #9
0
 public static function run($r)
 {
     pts_openbenchmarking::refresh_repository_lists();
     pts_client::$display->generic_heading('Interactive Benchmarking');
     echo 'System Hardware:' . PHP_EOL . phodevi::system_hardware(true) . (phodevi::read_property('motherboard', 'serial-number') != null ? PHP_EOL . 'System Serial Number: ' . phodevi::read_property('motherboard', 'serial-number') : null) . PHP_EOL . PHP_EOL . PHP_EOL;
     $reboot_on_exit = false;
     do {
         $options = array('RUN_TEST' => 'Run A Test', 'RUN_SUITE' => 'Run A Suite [A Collection Of Tests]', 'RUN_SYSTEM_TEST' => 'Run Complex System Test', 'SHOW_INFO' => 'Show System Hardware / Software Information', 'SHOW_SENSORS' => 'Show Auto-Detected System Sensors', 'SET_RUN_COUNT' => 'Set Test Run Repetition');
         if (count(pts_client::saved_test_results()) > 0) {
             $options['BACKUP_RESULTS_TO_USB'] = 'Backup Results To Media Storage';
         }
         $options['EXIT'] = $reboot_on_exit ? 'Exit & Reboot' : 'Exit';
         $response = pts_user_io::prompt_text_menu('Select Task', $options, false, true);
         switch ($response) {
             case 'RUN_TEST':
                 $supported_tests = pts_openbenchmarking::available_tests();
                 $supported_tests = pts_types::identifiers_to_test_profile_objects($supported_tests, false, true);
                 $longest_title_length = 0;
                 foreach ($supported_tests as $i => &$test_profile) {
                     if ($test_profile->get_title() == null) {
                         unset($supported_tests[$i]);
                         continue;
                     }
                     $longest_title_length = max($longest_title_length, strlen($test_profile->get_title()));
                 }
                 $t = array();
                 foreach ($supported_tests as $i => &$test_profile) {
                     if ($test_profile instanceof pts_test_profile) {
                         $t[$test_profile->get_identifier()] = sprintf('%-' . ($longest_title_length + 1) . 'ls - %-10ls', $test_profile->get_title(), $test_profile->get_test_hardware_type());
                     }
                 }
                 $supported_tests = $t;
                 asort($supported_tests);
                 $tests_to_run = pts_user_io::prompt_text_menu('Select Test', $supported_tests, true, true);
                 $tests_to_run = explode(',', $tests_to_run);
                 pts_test_installer::standard_install($tests_to_run);
                 $run_manager = new pts_test_run_manager(false, 2);
                 $run_manager->standard_run($tests_to_run);
                 if ($run_manager != false) {
                     pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $run_manager->get_file_name() . '/index.html', null, true, true);
                 }
                 break;
             case 'RUN_SUITE':
                 $possible_suites = pts_openbenchmarking::available_suites();
                 foreach (array_map('strtolower', pts_types::subsystem_targets()) as $subsystem) {
                     array_push($possible_suites, 'pts/' . $subsystem);
                 }
                 $suites_to_run = pts_user_io::prompt_text_menu('Select Suite', $possible_suites, true);
                 foreach (explode(',', $suites_to_run) as $suite_to_run) {
                     pts_test_installer::standard_install($suite_to_run);
                     $run_manager = new pts_test_run_manager(false, 2);
                     $run_manager->standard_run($suite_to_run);
                 }
                 break;
             case 'SELECT_DRIVE_MOUNT':
                 self::select_drive_mount();
                 break;
             case 'RUN_SYSTEM_TEST':
                 pts_client::$display->generic_heading('System Test');
                 $system_tests = array('apache', 'c-ray', 'ramspeed', 'postmark');
                 pts_test_installer::standard_install($system_tests);
                 $run_manager = new pts_test_run_manager(false, 2);
                 $run_manager->standard_run($system_tests);
                 if ($run_manager != false) {
                     pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $run_manager->get_file_name() . '/index.html', null, true, true);
                 }
                 break;
             case 'SHOW_INFO':
                 pts_client::$display->generic_heading('System Software / Hardware Information');
                 echo 'Hardware:' . PHP_EOL . phodevi::system_hardware(true) . PHP_EOL . PHP_EOL;
                 echo 'Software:' . PHP_EOL . phodevi::system_software(true) . PHP_EOL . PHP_EOL;
                 break;
             case 'SHOW_SENSORS':
                 pts_client::$display->generic_heading('Detected System Sensors');
                 foreach (phodevi::supported_sensors() as $sensor) {
                     echo phodevi::sensor_name($sensor) . ': ' . phodevi::read_sensor($sensor) . ' ' . phodevi::read_sensor_unit($sensor) . PHP_EOL;
                 }
                 break;
             case 'SET_RUN_COUNT':
                 $run_count = pts_user_io::prompt_user_input('Set the minimum number of times each test should repeat', false);
                 putenv('FORCE_TIMES_TO_RUN=' . trim($run_count));
                 break;
             case 'BACKUP_RESULTS_TO_USB':
                 pts_client::$display->generic_heading('Backing Up Test Results');
                 foreach (pts_file_io::glob('/media/*') as $media_dir) {
                     if (!is_writable($media_dir)) {
                         echo PHP_EOL . $media_dir . ' is not writable.' . PHP_EOL;
                         continue;
                     }
                     echo PHP_EOL . 'Writing Test Results To: ' . $media_dir . PHP_EOL;
                     pts_file_io::copy(PTS_SAVE_RESULTS_PATH, $media_dir . '/');
                     break;
                 }
                 break;
         }
         echo PHP_EOL . PHP_EOL;
     } while ($response != 'EXIT');
     if ($reboot_on_exit) {
         if (is_dir('/media/pts-auto-mount')) {
             pts_file_io::delete('/media/pts-auto-mount/pts', null, true);
             exec('umount /media/pts-auto-mount 2>&1');
         }
         exec('reboot');
     }
 }
 public static function ob_cache_run()
 {
     pts_openbenchmarking::available_tests(true);
     pts_openbenchmarking::available_suites(true);
 }
 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;
 }
Пример #12
0
 public static function run($args)
 {
     echo PHP_EOL;
     if ($args[0] == 'pts/all') {
         $args = pts_openbenchmarking::available_tests(false);
     }
     foreach ($args as $arg) {
         $o = pts_types::identifier_to_object($arg);
         if ($o instanceof pts_test_suite) {
             pts_client::$display->generic_heading($o->get_title());
             echo 'Run Identifier: ' . $o->get_identifier() . PHP_EOL;
             echo 'Suite Version: ' . $o->get_version() . PHP_EOL;
             echo 'Maintainer: ' . $o->get_maintainer() . PHP_EOL;
             echo 'Suite Type: ' . $o->get_suite_type() . PHP_EOL;
             echo 'Unique Tests: ' . $o->get_unique_test_count() . PHP_EOL;
             echo 'Suite Description: ' . $o->get_description() . PHP_EOL;
             echo PHP_EOL;
             echo $o->pts_format_contained_tests_string();
             echo PHP_EOL;
         } else {
             if ($o instanceof pts_test_profile) {
                 $test_title = $o->get_title();
                 $test_version = $o->get_app_version();
                 if (!empty($test_version)) {
                     $test_title .= ' ' . $test_version;
                 }
                 pts_client::$display->generic_heading($test_title);
                 echo 'Run Identifier: ' . $o->get_identifier() . PHP_EOL;
                 echo 'Profile Version: ' . $o->get_test_profile_version() . PHP_EOL;
                 echo 'Maintainer: ' . $o->get_maintainer() . PHP_EOL;
                 echo 'Test Type: ' . $o->get_test_hardware_type() . PHP_EOL;
                 echo 'Software Type: ' . $o->get_test_software_type() . PHP_EOL;
                 echo 'License Type: ' . $o->get_license() . PHP_EOL;
                 echo 'Test Status: ' . $o->get_status() . PHP_EOL;
                 echo 'Project Web-Site: ' . $o->get_project_url() . PHP_EOL;
                 if ($o->get_estimated_run_time() > 1) {
                     echo 'Estimated Run-Time: ' . $o->get_estimated_run_time() . ' Seconds' . PHP_EOL;
                 }
                 $download_size = $o->get_download_size();
                 if (!empty($download_size)) {
                     echo 'Download Size: ' . $download_size . ' MB' . PHP_EOL;
                 }
                 $environment_size = $o->get_environment_size();
                 if (!empty($environment_size)) {
                     echo 'Environment Size: ' . $environment_size . ' MB' . PHP_EOL;
                 }
                 echo PHP_EOL . 'Description: ' . $o->get_description() . PHP_EOL;
                 if ($o->test_installation != false) {
                     $last_run = $o->test_installation->get_last_run_date();
                     $last_run = $last_run == '0000-00-00' ? 'Never' : $last_run;
                     $avg_time = $o->test_installation->get_average_run_time();
                     $avg_time = !empty($avg_time) ? pts_strings::format_time($avg_time, 'SECONDS') : 'N/A';
                     $latest_time = $o->test_installation->get_latest_run_time();
                     $latest_time = !empty($latest_time) ? pts_strings::format_time($latest_time, 'SECONDS') : 'N/A';
                     echo PHP_EOL . 'Test Installed: Yes' . PHP_EOL;
                     echo 'Last Run: ' . $last_run . PHP_EOL;
                     if ($last_run != 'Never') {
                         if ($o->test_installation->get_run_count() > 1) {
                             echo 'Average Run-Time: ' . $avg_time . PHP_EOL;
                         }
                         echo 'Latest Run-Time: ' . $latest_time . PHP_EOL;
                         echo 'Times Run: ' . $o->test_installation->get_run_count() . PHP_EOL;
                     }
                 } else {
                     echo PHP_EOL . 'Test Installed: No' . PHP_EOL;
                 }
                 $dependencies = $o->get_external_dependencies();
                 if (!empty($dependencies) && !empty($dependencies[0])) {
                     echo PHP_EOL . 'Software Dependencies:' . PHP_EOL;
                     echo pts_user_io::display_text_list($o->get_dependency_names());
                 }
                 echo PHP_EOL;
             } else {
                 if ($o instanceof pts_result_file) {
                     echo 'Title: ' . $o->get_title() . PHP_EOL . 'Identifier: ' . $o->get_identifier() . PHP_EOL;
                     echo PHP_EOL . 'Test Result Identifiers:' . PHP_EOL;
                     echo pts_user_io::display_text_list($o->get_system_identifiers());
                     $test_titles = array();
                     foreach ($o->get_result_objects() as $result_object) {
                         if ($result_object->test_profile->get_display_format() == 'BAR_GRAPH') {
                             array_push($test_titles, $result_object->test_profile->get_title());
                         }
                     }
                     if (count($test_titles) > 0) {
                         echo PHP_EOL . 'Contained Tests:' . PHP_EOL;
                         echo pts_user_io::display_text_list(array_unique($test_titles));
                     }
                     echo PHP_EOL;
                 } else {
                     if ($o instanceof pts_virtual_test_suite) {
                         pts_client::$display->generic_heading($o->get_title());
                         echo 'Virtual Suite Description: ' . $o->get_description() . PHP_EOL . PHP_EOL;
                         foreach ($o->get_contained_test_profiles() as $test_profile) {
                             echo '- ' . $test_profile . PHP_EOL;
                         }
                         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 run($r)
 {
     pts_client::$display->generic_heading('Available Tests');
     $available_tests = pts_openbenchmarking::available_tests(false);
     $available_suites = pts_openbenchmarking::available_suites(false);
     $test_count = count($available_tests);
     $suite_count = count($available_suites);
     $total_count = $test_count + $suite_count;
     $total_cache_count = 0;
     $total_cache_size = 0;
     if ($test_count == 0 || !pts_network::internet_support_available()) {
         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;
         return false;
     }
     $terminal_width = pts_client::terminal_width();
     // Cache test profiles
     foreach ($available_tests as $i => $identifier) {
         $repo = substr($identifier, 0, strpos($identifier, '/'));
         $test = substr($identifier, strlen($repo) + 1);
         $repo_index = pts_openbenchmarking::read_repository_index($repo);
         echo $i . '/' . $total_count . ': ' . ($repo_index['tests'][$test]['title'] != null ? $repo_index['tests'][$test]['title'] . ' [' . $repo_index['tests'][$test]['test_type'] . ']' : null) . PHP_EOL;
         foreach ($repo_index['tests'][$test]['versions'] as $version) {
             $qualified_identifier = $repo . '/' . $test . '-' . $version;
             echo $qualified_identifier;
             $success = pts_openbenchmarking::download_test_profile($repo . '/' . $test . '-' . $version);
             if ($success && is_file(PTS_OPENBENCHMARKING_SCRATCH_PATH . $qualified_identifier . '.zip')) {
                 $file_size = round(filesize(PTS_OPENBENCHMARKING_SCRATCH_PATH . $qualified_identifier . '.zip') / 1024, 2);
                 $info = $file_size . 'KB - ' . sha1_file(PTS_OPENBENCHMARKING_SCRATCH_PATH . $qualified_identifier . '.zip');
                 $r_size = $terminal_width - strlen($qualified_identifier) - 3 - strlen($info);
                 if ($r_size > 0) {
                     echo ' ' . str_repeat('.', $terminal_width - strlen($qualified_identifier) - 3 - strlen($info)) . ' ' . $info . PHP_EOL;
                 }
                 $total_cache_count++;
                 $total_cache_size += $file_size;
             }
         }
         echo PHP_EOL;
     }
     // Cache test suites
     foreach ($available_suites as $i => $identifier) {
         $repo = substr($identifier, 0, strpos($identifier, '/'));
         $test = substr($identifier, strlen($repo) + 1);
         $repo_index = pts_openbenchmarking::read_repository_index($repo);
         echo $i + $test_count . '/' . $total_count . ': ' . $repo_index['suites'][$test]['title'] . PHP_EOL;
         foreach ($repo_index['suites'][$test]['versions'] as $version) {
             $qualified_identifier = $repo . '/' . $test . '-' . $version;
             echo $qualified_identifier;
             $success = pts_openbenchmarking::download_test_suite($repo . '/' . $test . '-' . $version);
             if ($success && is_file(PTS_OPENBENCHMARKING_SCRATCH_PATH . $qualified_identifier . '.zip')) {
                 $file_size = round(filesize(PTS_OPENBENCHMARKING_SCRATCH_PATH . $qualified_identifier . '.zip') / 1024, 2);
                 $info = $file_size . 'KB - ' . sha1_file(PTS_OPENBENCHMARKING_SCRATCH_PATH . $qualified_identifier . '.zip');
                 $dot_size = $terminal_width - strlen($qualified_identifier) - 3 - strlen($info);
                 echo ' ' . str_repeat('.', $dot_size >= 0 ? $dot_size : 0) . ' ' . $info . PHP_EOL;
                 $total_cache_count++;
                 $total_cache_size += $file_size;
             }
         }
         echo PHP_EOL;
     }
     echo PHP_EOL . $total_cache_count . ' Files Cached' . PHP_EOL . $test_count . ' Test Profiles' . PHP_EOL . $suite_count . ' Test Suites' . PHP_EOL . $total_cache_size . 'KB Total Cache Size' . PHP_EOL . PHP_EOL;
 }
 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>';
 }
Пример #16
0
 public static function run($r)
 {
     $is_moscow = pts_flags::os_identifier_hash() == 'b28d6a7148b34595c5b397dfcf5b12ac7932b3dc';
     if ($is_moscow) {
         // Auto mount?
         $drives = pts_file_io::glob('/dev/sda*');
         sort($drives);
         if (false && count($drives) > 0 && !is_dir('/media/pts-auto-mount') && is_writable('/media/')) {
             $last_drive = array_pop($drives);
             echo PHP_EOL . 'Attempting to auto-mount drive: ' . $last_drive . PHP_EOL;
             mkdir('/media/pts-auto-mount');
             exec('mount ' . $last_drive . ' /media/pts-auto-mount');
             putenv('PTS_TEST_INSTALL_ROOT_PATH=/media/pts-auto-mount/');
         }
         // Auto save results
         $test_results_name = phodevi::read_property('motherboard', 'serial-number');
         if ($test_results_name == null) {
             $test_results_name = phodevi::read_name('motherboard');
         }
         if ($test_results_name == null) {
             $test_results_name = phodevi::read_property('system', 'vendor-identifier');
         }
         putenv('TEST_RESULTS_NAME=' . str_replace(' ', null, $test_results_name));
         putenv('TEST_RESULTS_IDENTIFIER=' . $test_results_name);
         putenv('TEST_RESULTS_DESCRIPTION=Tests using ' . phodevi::read_property('system', 'operating-system') . ' on ' . date('d F Y') . ' of ' . $test_results_name . '.');
         self::select_drive_mount();
     }
     pts_openbenchmarking::refresh_repository_lists();
     pts_client::$display->generic_heading('Interactive Benchmarking');
     echo 'System Hardware:' . PHP_EOL . phodevi::system_hardware(true) . (phodevi::read_property('motherboard', 'serial-number') != null ? PHP_EOL . 'System Serial Number: ' . phodevi::read_property('motherboard', 'serial-number') : null) . PHP_EOL . PHP_EOL . PHP_EOL;
     $reboot_on_exit = pts_flags::is_live_cd() && pts_client::user_home_directory() == '/root/';
     do {
         $options = array('RUN_TEST' => 'Run A Test', 'RUN_SUITE' => 'Run A Suite [A Collection Of Tests]', 'RUN_SYSTEM_TEST' => 'Run Complex System Test', 'SHOW_INFO' => 'Show System Hardware / Software Information', 'SHOW_SENSORS' => 'Show Auto-Detected System Sensors', 'SET_RUN_COUNT' => 'Set Test Run Repetition');
         if ($is_moscow) {
             unset($options['RUN_SUITE']);
             //	$options['SELECT_DRIVE_MOUNT'] = 'Select Disk Drive To Use For Testing';
         }
         if (count(pts_client::saved_test_results()) > 0) {
             $options['BACKUP_RESULTS_TO_USB'] = 'Backup Results To Media Storage';
         }
         $options['EXIT'] = $reboot_on_exit ? 'Exit & Reboot' : 'Exit';
         $response = pts_user_io::prompt_text_menu('Select Task', $options, false, true);
         switch ($response) {
             case 'RUN_TEST':
                 $supported_tests = pts_openbenchmarking::available_tests();
                 $supported_tests = pts_types::identifiers_to_test_profile_objects($supported_tests, false, true);
                 $longest_title_length = 0;
                 foreach ($supported_tests as $i => &$test_profile) {
                     if ($test_profile->get_title() == null || pts_test_run_manager::test_profile_system_compatibility_check($test_profile) == false) {
                         unset($supported_tests[$i]);
                         continue;
                     }
                     if ($is_moscow && pts_test_install_request::test_files_available_locally($test_profile) == false) {
                         // Don't show tests where files need to be downloaded
                         unset($supported_tests[$i]);
                         continue;
                     }
                     $longest_title_length = max($longest_title_length, strlen($test_profile->get_title()));
                 }
                 $t = array();
                 foreach ($supported_tests as $i => &$test_profile) {
                     if ($test_profile instanceof pts_test_profile) {
                         $t[$test_profile->get_identifier()] = sprintf('%-' . ($longest_title_length + 1) . 'ls - %-10ls', $test_profile->get_title(), $test_profile->get_test_hardware_type());
                     }
                 }
                 $supported_tests = $t;
                 asort($supported_tests);
                 $tests_to_run = pts_user_io::prompt_text_menu('Select Test', $supported_tests, true, true);
                 $tests_to_run = explode(',', $tests_to_run);
                 pts_test_installer::standard_install($tests_to_run);
                 $run_manager = pts_test_run_manager::standard_run($tests_to_run, pts_c::defaults_mode | pts_c::auto_mode);
                 if ($run_manager != false) {
                     pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $run_manager->get_file_name() . '/index.html', null, true, true);
                 }
                 break;
             case 'RUN_SUITE':
                 $possible_suites = pts_openbenchmarking::available_suites();
                 foreach (array_map('strtolower', pts_types::subsystem_targets()) as $subsystem) {
                     array_push($possible_suites, 'pts/' . $subsystem);
                 }
                 $suites_to_run = pts_user_io::prompt_text_menu('Select Suite', $possible_suites, true);
                 foreach (explode(',', $suites_to_run) as $suite_to_run) {
                     pts_test_installer::standard_install($suite_to_run);
                     pts_test_run_manager::standard_run($suite_to_run, pts_c::defaults_mode | pts_c::auto_mode);
                 }
                 break;
             case 'SELECT_DRIVE_MOUNT':
                 self::select_drive_mount();
                 break;
             case 'RUN_SYSTEM_TEST':
                 pts_client::$display->generic_heading('System Test');
                 $system_tests = array('apache', 'c-ray', 'ramspeed', 'postmark');
                 pts_test_installer::standard_install($system_tests);
                 $run_manager = pts_test_run_manager::standard_run($system_tests, pts_c::defaults_mode | pts_c::auto_mode);
                 if ($run_manager != false) {
                     pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $run_manager->get_file_name() . '/index.html', null, true, true);
                 }
                 break;
             case 'SHOW_INFO':
                 pts_client::$display->generic_heading('System Software / Hardware Information');
                 echo 'Hardware:' . PHP_EOL . phodevi::system_hardware(true) . PHP_EOL . PHP_EOL;
                 echo 'Software:' . PHP_EOL . phodevi::system_software(true) . PHP_EOL . PHP_EOL;
                 break;
             case 'SHOW_SENSORS':
                 pts_client::$display->generic_heading('Detected System Sensors');
                 foreach (phodevi::supported_sensors() as $sensor) {
                     echo phodevi::sensor_name($sensor) . ': ' . phodevi::read_sensor($sensor) . ' ' . phodevi::read_sensor_unit($sensor) . PHP_EOL;
                 }
                 break;
             case 'SET_RUN_COUNT':
                 $run_count = pts_user_io::prompt_user_input('Set the minimum number of times each test should repeat', false);
                 putenv('FORCE_TIMES_TO_RUN=' . trim($run_count));
                 break;
             case 'BACKUP_RESULTS_TO_USB':
                 pts_client::$display->generic_heading('Backing Up Test Results');
                 if ($is_moscow) {
                     $drives = pts_file_io::glob('/dev/sd*');
                     sort($drives);
                     if (count($drives) > 0 && is_writable('/media/')) {
                         $select_drive = pts_user_io::prompt_text_menu('Select Drive / Partition To Save Results', $drives);
                         echo PHP_EOL . 'Attempting to mount: ' . $select_drive . PHP_EOL;
                         mkdir('/media/00-results-backup');
                         exec('mount ' . $select_drive . ' /media/00-results-backup');
                     }
                 }
                 foreach (pts_file_io::glob('/media/*') as $media_dir) {
                     if (!is_writable($media_dir)) {
                         echo PHP_EOL . $media_dir . ' is not writable.' . PHP_EOL;
                         continue;
                     }
                     echo PHP_EOL . 'Writing Test Results To: ' . $media_dir . PHP_EOL;
                     pts_file_io::copy(PTS_SAVE_RESULTS_PATH, $media_dir . '/');
                     break;
                 }
                 if ($is_moscow && is_dir('/media/00-results-backup')) {
                     exec('umount /media/00-results-backup');
                     rmdir('/media/00-results-backup');
                 }
                 break;
         }
         echo PHP_EOL . PHP_EOL;
     } while ($response != 'EXIT');
     if ($reboot_on_exit) {
         if (is_dir('/media/pts-auto-mount')) {
             pts_file_io::delete('/media/pts-auto-mount/pts', null, true);
             exec('umount /media/pts-auto-mount 2>&1');
         }
         exec('reboot');
     }
 }