public static function init()
 {
     self::$flags = 0;
     self::$os_identifier_sha1 = sha1(phodevi::read_property('system', 'vendor-identifier'));
     self::$is_live_cd = 1 << 1;
     self::$no_network_communication = 1 << 2;
     self::$no_openbenchmarking_reporting = 1 << 3;
     self::$user_agreement_skip = 1 << 4;
     self::$skip_md5_checks = 1 << 5;
     self::$remove_test_on_completion = 1 << 6;
     self::$no_phodevi_cache = 1 << 7;
     self::$no_external_dependencies = 1 << 8;
     self::$upload_to_openbenchmarking = 1 << 9;
     switch (self::$os_identifier_sha1) {
         case 'b28d6a7148b34595c5b397dfcf5b12ac7932b3dc':
             // Moscow 2011-04 client
             self::$flags = self::$is_live_cd | self::$no_network_communication | self::$no_openbenchmarking_reporting | self::$user_agreement_skip | self::$skip_md5_checks | self::$remove_test_on_completion;
             break;
     }
     if (pts_client::read_env('NO_FILE_HASH_CHECKS') != false || pts_client::read_env('NO_MD5_CHECKS') != false) {
         self::$flags |= self::$skip_md5_checks;
     }
     if (pts_config::read_bool_config('PhoronixTestSuite/Options/Testing/RemoveTestInstallOnCompletion', 'FALSE')) {
         self::$flags |= self::$remove_test_on_completion;
     }
     if (pts_config::read_bool_config('PhoronixTestSuite/Options/Testing/AlwaysUploadResultsToOpenBenchmarking', 'FALSE')) {
         self::$flags |= self::$upload_to_openbenchmarking;
     }
     if (pts_client::read_env('NO_PHODEVI_CACHE') != false) {
         self::$flags |= self::$no_phodevi_cache;
     }
     if (pts_client::read_env('NO_EXTERNAL_DEPENDENCIES') != false || pts_client::read_env('SKIP_EXTERNAL_DEPENDENCIES') == 1) {
         // NO_EXTERNAL_DEPENDENCIES was deprecated in PTS 3.6 and replaced by more versatile SKIP_EXTERNAL_DEPENDENCIES
         self::$flags |= self::$no_external_dependencies;
     }
 }
 protected static function download_test_files(&$test_install_request, $download_location = false)
 {
     // Download needed files for a test
     if ($test_install_request->get_download_object_count() == 0) {
         return true;
     }
     $identifier = $test_install_request->test_profile->get_identifier();
     pts_client::$display->test_install_downloads($test_install_request);
     if ($download_location == false) {
         $download_location = $test_install_request->test_profile->get_install_dir();
     }
     pts_file_io::mkdir($download_location);
     $module_pass = array($identifier, $test_install_request->get_download_objects());
     pts_module_manager::module_process('__pre_test_download', $module_pass);
     foreach ($test_install_request->get_download_objects() as $download_package) {
         $package_filename = $download_package->get_filename();
         $download_destination = $download_location . $package_filename;
         $download_destination_temp = $download_destination . '.pts';
         if ($download_package->get_download_location_type() == null) {
             // Attempt a possible last-minute look-aside copy cache in case a previous test in the install queue downloaded this file already
             $lookaside_copy = pts_test_install_manager::file_lookaside_test_installations($download_package);
             if ($lookaside_copy) {
                 if ($download_package->get_filesize() == 0) {
                     $download_package->set_filesize(filesize($lookaside_copy));
                 }
                 $download_package->set_download_location('LOOKASIDE_DOWNLOAD_CACHE', array($lookaside_copy));
             }
         }
         switch ($download_package->get_download_location_type()) {
             case 'IN_DESTINATION_DIR':
                 pts_client::$display->test_install_download_file('FILE_FOUND', $download_package);
                 continue;
             case 'REMOTE_DOWNLOAD_CACHE':
                 $download_tries = 0;
                 do {
                     foreach ($download_package->get_download_location_path() as $remote_download_cache_file) {
                         pts_client::$display->test_install_download_file('DOWNLOAD_FROM_CACHE', $download_package);
                         pts_network::download_file($remote_download_cache_file, $download_destination_temp);
                         if (!is_file($download_destination_temp) || filesize($download_destination_temp) == 0) {
                             self::test_install_error(null, $test_install_request, 'The file failed to download from the cache.');
                             pts_file_io::unlink($download_destination_temp);
                             break;
                         } else {
                             if ($download_package->check_file_hash($download_destination_temp)) {
                                 rename($download_destination_temp, $download_destination);
                                 break;
                             } else {
                                 self::test_install_error(null, $test_install_request, 'The check-sum of the downloaded file failed.');
                                 pts_file_io::unlink($download_destination_temp);
                             }
                         }
                     }
                     $download_tries++;
                 } while (!is_file($download_destination) && $download_tries < 2);
                 if (is_file($download_destination)) {
                     continue;
                 }
             case 'MAIN_DOWNLOAD_CACHE':
             case 'LOCAL_DOWNLOAD_CACHE':
             case 'LOOKASIDE_DOWNLOAD_CACHE':
                 $download_cache_file = pts_arrays::last_element($download_package->get_download_location_path());
                 if (is_file($download_cache_file)) {
                     if (pts_config::read_bool_config('PhoronixTestSuite/Options/Installation/SymLinkFilesFromCache', 'FALSE') && $download_package->get_download_location_type() != 'LOOKASIDE_DOWNLOAD_CACHE' || pts_flags::is_live_cd()) {
                         // For look-aside copies never symlink (unless a pre-packaged LiveCD) in case the other test ends up being un-installed
                         // SymLinkFilesFromCache is disabled by default
                         pts_client::$display->test_install_download_file('LINK_FROM_CACHE', $download_package);
                         symlink($download_cache_file, $download_destination);
                     } else {
                         // File is to be copied
                         // Try up to two times to copy a file
                         $attempted_copies = 0;
                         do {
                             pts_client::$display->test_install_download_file('COPY_FROM_CACHE', $download_package);
                             // $context = stream_context_create();
                             // stream_context_set_params($context, array('notification' => array('pts_network', 'stream_status_callback')));
                             // TODO: get the context working correctly for this copy()
                             copy($download_cache_file, $download_destination_temp);
                             pts_client::$display->test_install_progress_completed();
                             // Verify that the file was copied fine
                             if ($download_package->check_file_hash($download_destination_temp)) {
                                 rename($download_destination_temp, $download_destination);
                                 break;
                             } else {
                                 self::test_install_error(null, $test_install_request, 'The check-sum of the copied file failed.');
                                 pts_file_io::unlink($download_destination_temp);
                             }
                             $attempted_copies++;
                         } while ($attempted_copies < 2);
                     }
                     if (is_file($download_destination)) {
                         continue;
                     }
                 }
             default:
                 $package_urls = $download_package->get_download_url_array();
                 // Download the file
                 if (!is_file($download_destination) && count($package_urls) > 0 && $package_urls[0] != null) {
                     $fail_count = 0;
                     do {
                         if (pts_network::internet_support_available()) {
                             if (pts_c::$test_flags ^ pts_c::batch_mode && pts_c::$test_flags ^ pts_c::auto_mode && pts_config::read_bool_config('PhoronixTestSuite/Options/Installation/PromptForDownloadMirror', 'FALSE') && count($package_urls) > 1) {
                                 // Prompt user to select mirror
                                 do {
                                     echo PHP_EOL . 'Available Download Mirrors:' . PHP_EOL . PHP_EOL;
                                     $url = pts_user_io::prompt_text_menu('Select Preferred Mirror', $package_urls, false);
                                 } while (pts_strings::is_url($url) == false);
                             } else {
                                 // Auto-select mirror
                                 shuffle($package_urls);
                                 do {
                                     $url = array_pop($package_urls);
                                 } while (pts_strings::is_url($url) == false && !empty($package_urls));
                             }
                             pts_client::$display->test_install_download_file('DOWNLOAD', $download_package);
                             $download_start = time();
                             pts_network::download_file($url, $download_destination_temp);
                             $download_end = time();
                         } else {
                             self::test_install_error(null, $test_install_request, 'Internet support is needed and it\'s disabled or not available.');
                             return false;
                         }
                         if ($download_package->check_file_hash($download_destination_temp)) {
                             // Download worked
                             if (is_file($download_destination_temp)) {
                                 rename($download_destination_temp, $download_destination);
                             }
                             if ($download_package->get_filesize() > 0 && $download_end != $download_start) {
                                 pts_download_speed_manager::update_download_speed_average($download_package->get_filesize(), $download_end - $download_start);
                             }
                         } else {
                             // Download failed
                             if (is_file($download_destination_temp) && filesize($download_destination_temp) < 500 && (stripos(file_get_contents($download_destination_temp), 'not found') !== false || strpos(file_get_contents($download_destination_temp), 404) !== false)) {
                                 self::test_install_error(null, $test_install_request, 'File Not Found: ' . $url);
                                 $md5_failed = false;
                             } else {
                                 if (is_file($download_destination_temp) && filesize($download_destination_temp) > 0) {
                                     self::test_install_error(null, $test_install_request, 'Checksum Failed: ' . $url);
                                     $md5_failed = true;
                                 } else {
                                     self::test_install_error(null, $test_install_request, 'Download Failed: ' . $url);
                                     $md5_failed = false;
                                 }
                             }
                             pts_file_io::unlink($download_destination_temp);
                             $fail_count++;
                             if ($fail_count > 3) {
                                 $try_again = false;
                             } else {
                                 if (count($package_urls) > 0 && $package_urls[0] != null) {
                                     self::test_install_error(null, $test_install_request, 'Attempting to download from alternate mirror.');
                                     $try_again = true;
                                 } else {
                                     if (pts_c::$test_flags & pts_c::batch_mode || pts_c::$test_flags & pts_c::auto_mode) {
                                         $try_again = false;
                                     } else {
                                         if ($md5_failed) {
                                             $try_again = pts_user_io::prompt_bool_input('Try downloading the file again', true, 'TRY_DOWNLOAD_AGAIN');
                                         } else {
                                             $try_again = false;
                                         }
                                     }
                                     if ($try_again) {
                                         array_push($package_urls, $url);
                                     }
                                 }
                             }
                             if (!$try_again) {
                                 //self::test_install_error(null, $test_install_request, 'Download of Needed Test Dependencies Failed!');
                                 return false;
                             }
                         }
                     } while (!is_file($download_destination));
                 }
                 pts_module_manager::module_process('__interim_test_download', $module_pass);
         }
     }
     pts_module_manager::module_process('__post_test_download', $identifier);
     return true;
 }
 public static function auto_process_test_option($test_identifier, $option_identifier, &$option_names, &$option_values, &$option_messages)
 {
     // Some test items have options that are dynamically built
     switch ($option_identifier) {
         case 'auto-resolution':
             // Base options off available screen resolutions
             if (count($option_names) == 1 && count($option_values) == 1) {
                 if (PTS_IS_CLIENT && pts_flags::is_live_cd() && !defined('PHOROMATIC_SERVER')) {
                     // Just use the stock resolution when operating from a LiveCD
                     $available_video_modes = array(phodevi::read_property('gpu', 'screen-resolution'));
                 } else {
                     if (PTS_IS_CLIENT && phodevi::read_property('gpu', 'screen-resolution') && phodevi::read_property('gpu', 'screen-resolution') != array(-1, -1) && !defined('PHOROMATIC_SERVER')) {
                         $available_video_modes = phodevi::read_property('gpu', 'available-modes');
                     } else {
                         $available_video_modes = array();
                     }
                 }
                 if (empty($available_video_modes)) {
                     // Use hard-coded defaults
                     $available_video_modes = array(array(800, 600), array(1024, 768), array(1280, 768), array(1280, 960), array(1280, 1024), array(1366, 768), array(1400, 1050), array(1600, 900), array(1680, 1050), array(1600, 1200), array(1920, 1080), array(2560, 1600), array(3840, 2160));
                 }
                 $format_name = $option_names[0];
                 $format_value = $option_values[0];
                 $option_names = array();
                 $option_values = array();
                 foreach ($available_video_modes as $video_mode) {
                     $this_name = str_replace('$VIDEO_WIDTH', $video_mode[0], $format_name);
                     $this_name = str_replace('$VIDEO_HEIGHT', $video_mode[1], $this_name);
                     $this_value = str_replace('$VIDEO_WIDTH', $video_mode[0], $format_value);
                     $this_value = str_replace('$VIDEO_HEIGHT', $video_mode[1], $this_value);
                     array_push($option_names, $this_name);
                     array_push($option_values, $this_value);
                 }
             }
             break;
         case 'auto-disk-partitions':
         case 'auto-disk-mount-points':
             // Base options off available disk partitions
             if (PTS_IS_CLIENT == false) {
                 echo 'ERROR: This option is not supported in this configuration.';
                 return;
             }
             /*if(phodevi::is_linux())
             		{
             			$all_devices = array_merge(pts_file_io::glob('/dev/hd*'), pts_file_io::glob('/dev/sd*'));
             		}
             		else if(phodevi::is_bsd())
             		{
             			$all_devices = array_merge(pts_file_io::glob('/dev/ad*'), pts_file_io::glob('/dev/ada*'));
             		}
             		else
             		{
             			$all_devices = array();
             		}*/
             $all_devices = array_merge(pts_file_io::glob('/dev/hd*'), pts_file_io::glob('/dev/sd*'), pts_file_io::glob('/dev/md*'));
             foreach ($all_devices as &$device) {
                 if (!is_numeric(substr($device, -1))) {
                     unset($device);
                 }
             }
             $all_devices = array_merge($all_devices, pts_file_io::glob('/dev/mapper/*'));
             $option_values = array();
             foreach ($all_devices as $partition) {
                 array_push($option_values, $partition);
             }
             if ($option_identifier == 'auto-disk-mount-points') {
                 $partitions_d = $option_values;
                 $option_values = array();
                 $option_names = array();
                 $mounts = is_file('/proc/mounts') ? file_get_contents('/proc/mounts') : null;
                 array_push($option_values, '');
                 array_push($option_names, 'Default Test Directory');
                 if (pts_flags::is_live_cd() == false) {
                     foreach ($partitions_d as $partition_d) {
                         $mount_point = substr($a = substr($mounts, strpos($mounts, $partition_d) + strlen($partition_d) + 1), 0, strpos($a, ' '));
                         if (is_dir($mount_point) && is_writable($mount_point) && !in_array($mount_point, array('/boot', '/boot/efi'))) {
                             array_push($option_values, $mount_point);
                             array_push($option_names, $mount_point);
                             // ' [' . $partition_d . ']'
                         }
                     }
                 }
             } else {
                 $option_names = $option_values;
             }
             break;
         case 'auto-disks':
             // Base options off attached disks
             if (PTS_IS_CLIENT == false) {
                 echo 'ERROR: This option is not supported in this configuration.';
                 return;
             }
             $all_devices = array_merge(pts_file_io::glob('/dev/hd*'), pts_file_io::glob('/dev/sd*'), pts_file_io::glob('/dev/md*'));
             foreach ($all_devices as &$device) {
                 if (is_numeric(substr($device, -1))) {
                     unset($device);
                 }
             }
             $option_values = array();
             foreach ($all_devices as $disk) {
                 array_push($option_values, $disk);
             }
             $option_names = $option_values;
             break;
         case 'auto-removable-media':
             if (PTS_IS_CLIENT == false) {
                 echo 'ERROR: This option is not supported in this configuration.';
                 return;
             }
             foreach (array_merge(pts_file_io::glob('/media/*/'), pts_file_io::glob('/Volumes/*/')) as $media_check) {
                 if (is_dir($media_check) && is_writable($media_check)) {
                     array_push($option_names, $media_check);
                     array_push($option_values, $media_check);
                 }
             }
             break;
         case 'auto-file-select':
             if (PTS_IS_CLIENT == false) {
                 echo 'ERROR: This option is not supported in this configuration.';
                 return;
             }
             $names = $option_names;
             $values = $option_values;
             $option_names = array();
             $option_values = array();
             for ($i = 0; $i < count($names) && $i < count($values); $i++) {
                 if (is_file($values[$i])) {
                     array_push($option_names, $names[$i]);
                     array_push($option_values, $values[$i]);
                 }
             }
             break;
         case 'auto-directory-select':
             if (PTS_IS_CLIENT == false) {
                 echo 'ERROR: This option is not supported in this configuration.';
                 return;
             }
             $names = $option_names;
             $values = $option_values;
             $option_names = array();
             $option_values = array();
             for ($i = 0; $i < count($names) && $i < count($values); $i++) {
                 if (is_dir($values[$i]) && is_writable($removable_media[$i])) {
                     array_push($option_names, $names[$i]);
                     array_push($option_values, $values[$i]);
                 }
             }
             break;
     }
 }
 public static function cleanup_tests_to_run(&$to_run_objects)
 {
     $skip_tests = ($e = pts_client::read_env('SKIP_TESTS')) ? pts_strings::comma_explode($e) : false;
     $tests_verified = array();
     $tests_missing = array();
     foreach ($to_run_objects as &$run_object) {
         if ($skip_tests && (in_array($run_object->get_identifier(false), $skip_tests) || $run_object instanceof pts_test_profile && in_array($run_object->get_identifier_base_name(), $skip_tests))) {
             pts_client::$display->generic_sub_heading('Skipping: ' . $run_object->get_identifier());
             continue;
         } else {
             if ($run_object instanceof pts_test_profile) {
                 if ($run_object->get_title() == null) {
                     pts_client::$display->generic_sub_heading('Not A Test: ' . $run_object);
                     continue;
                 } else {
                     if ($run_object->is_supported(false) == false) {
                         continue;
                     }
                     if ($run_object->is_test_installed() == false) {
                         // Check to see if older version of test is currently installed
                         // TODO: show change-log between installed versions and upstream
                         array_push($tests_missing, $run_object);
                         continue;
                     }
                 }
             } else {
                 if ($run_object instanceof pts_result_file) {
                     $num_installed = 0;
                     foreach ($run_object->get_contained_test_profiles() as $test_profile) {
                         if ($test_profile == null || $test_profile->get_identifier() == null || $test_profile->is_supported(false) == false) {
                             continue;
                         } else {
                             if ($test_profile->is_test_installed() == false) {
                                 array_push($tests_missing, $test_profile);
                             } else {
                                 $num_installed++;
                             }
                         }
                     }
                     if ($num_installed == 0) {
                         continue;
                     }
                 } else {
                     if ($run_object instanceof pts_test_suite || $run_object instanceof pts_virtual_test_suite || $run_object instanceof pts_virtual_test_queue) {
                         if ($run_object->is_core_version_supported() == false) {
                             pts_client::$display->generic_sub_heading($run_object->get_title() . ' is a suite not supported by this version of the Phoronix Test Suite.');
                             continue;
                         }
                         $num_installed = 0;
                         foreach ($run_object->get_contained_test_profiles() as $test_profile) {
                             if ($test_profile == null || $test_profile->get_identifier() == null || $test_profile->is_supported(false) == false) {
                                 continue;
                             }
                             if ($test_profile->is_test_installed() == false) {
                                 array_push($tests_missing, $test_profile);
                             } else {
                                 $num_installed++;
                             }
                         }
                         if ($num_installed == 0) {
                             continue;
                         }
                     } else {
                         pts_client::$display->generic_sub_heading('Not Recognized: ' . $run_object);
                         continue;
                     }
                 }
             }
         }
         array_push($tests_verified, $run_object);
     }
     $to_run_objects = $tests_verified;
     if (count($tests_missing) > 0 && !defined('PHOROMATIC_PROCESS')) {
         $tests_missing = array_unique($tests_missing);
         if (count($tests_missing) == 1) {
             trigger_error($tests_missing[0] . ' is not installed.', E_USER_ERROR);
             // PHP_EOL . 'To install, run: phoronix-test-suite install ' . $tests_missing[0]
         } else {
             $message = PHP_EOL . PHP_EOL . 'Multiple tests are not installed:' . PHP_EOL . PHP_EOL;
             $message .= pts_user_io::display_text_list($tests_missing);
             //$message .= PHP_EOL . 'To install, run: phoronix-test-suite install ' . implode(' ', $tests_missing) . PHP_EOL . PHP_EOL;
             echo $message;
         }
         if ((pts_c::$test_flags & pts_c::batch_mode) == false && (pts_c::$test_flags & pts_c::auto_mode) == false && pts_flags::is_live_cd() == false && pts_client::current_command() != 'benchmark') {
             $stop_and_install = pts_user_io::prompt_bool_input('Would you like to stop and install these tests now', true);
             if ($stop_and_install) {
                 pts_test_installer::standard_install($tests_missing, pts_c::$test_flags);
                 self::cleanup_tests_to_run($to_run_objects);
             }
         }
     }
     return true;
 }
 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');
     }
 }