Ejemplo n.º 1
0
 public static function user_run_save_variables()
 {
     static $runtime_variables = null;
     if ($runtime_variables == null) {
         $runtime_variables = array('VIDEO_RESOLUTION' => phodevi::read_property('gpu', 'screen-resolution-string'), 'VIDEO_CARD' => phodevi::read_name('gpu'), 'VIDEO_DRIVER' => phodevi::read_property('system', 'display-driver-string'), 'OPENGL_DRIVER' => str_replace('(', '', phodevi::read_property('system', 'opengl-driver')), 'OPERATING_SYSTEM' => phodevi::read_property('system', 'operating-system'), 'PROCESSOR' => phodevi::read_name('cpu'), 'MOTHERBOARD' => phodevi::read_name('motherboard'), 'CHIPSET' => phodevi::read_name('chipset'), 'KERNEL_VERSION' => phodevi::read_property('system', 'kernel'), 'COMPILER' => phodevi::read_property('system', 'compiler'), 'HOSTNAME' => phodevi::read_property('system', 'hostname'));
     }
     return $runtime_variables;
 }
 public static function test_profile_system_compatibility_check(&$test_profile, $report_errors = false)
 {
     $valid_test_profile = true;
     $test_type = $test_profile->get_test_hardware_type();
     $skip_tests = pts_client::read_env('SKIP_TESTS') ? pts_strings::comma_explode(pts_client::read_env('SKIP_TESTS')) : false;
     $skip_test_subsystems = pts_client::read_env('SKIP_TESTING_SUBSYSTEMS') ? pts_strings::comma_explode(strtolower(pts_client::read_env('SKIP_TESTING_SUBSYSTEMS'))) : false;
     $display_driver = phodevi::read_property('system', 'display-driver');
     $gpu = phodevi::read_name('gpu');
     if ($test_profile->is_supported(false) == false) {
         $valid_test_profile = false;
     } else {
         if ($test_type == 'Graphics' && pts_client::read_env('DISPLAY') == false && pts_client::read_env('WAYLAND_DISPLAY') == false && phodevi::is_windows() == false && phodevi::is_macosx() == false) {
             $report_errors && pts_client::$display->test_run_error('No display server was found, cannot run ' . $test_profile);
             $valid_test_profile = false;
         } else {
             if ($test_type == 'Graphics' && in_array($display_driver, array('vesa', 'nv', 'cirrus')) && stripos($gpu, 'LLVM') === false) {
                 // These display drivers end up being in known configurations without 3D hardware support so unless an LLVM-based string is reported as the GPU, don't advertise 3D tests
                 $report_errors && pts_client::$display->test_run_error('3D acceleration support not available, cannot run ' . $test_profile);
                 $valid_test_profile = false;
             } else {
                 if ($test_type == 'Disk' && stripos(phodevi::read_property('system', 'filesystem'), 'SquashFS') !== false) {
                     $report_errors && pts_client::$display->test_run_error('Running on a RAM-based live file-system, cannot run ' . $test_profile);
                     $valid_test_profile = false;
                 } else {
                     if (pts_client::read_env('NO_' . strtoupper($test_type) . '_TESTS') || $skip_tests && (in_array($test_profile, $skip_tests) || in_array($test_type, $skip_tests) || in_array($test_profile->get_identifier(false), $skip_tests) || in_array($test_profile->get_identifier_base_name(), $skip_tests))) {
                         $report_errors && pts_client::$display->test_run_error('Due to a pre-set environmental variable, skipping ' . $test_profile);
                         $valid_test_profile = false;
                     } else {
                         if ($skip_test_subsystems && in_array(strtolower($test_profile->get_test_hardware_type()), $skip_test_subsystems)) {
                             $report_errors && pts_client::$display->test_run_error('Due to a pre-set environmental variable, skipping ' . $test_profile);
                             $valid_test_profile = false;
                         } else {
                             if ($test_profile->is_root_required() && $this->batch_mode && phodevi::is_root() == false) {
                                 $report_errors && pts_client::$display->test_run_error('Cannot run ' . $test_profile . ' in batch mode as root access is required.');
                                 $valid_test_profile = false;
                             }
                         }
                     }
                 }
             }
         }
     }
     if ($valid_test_profile == false && pts_client::read_env('SKIP_ALL_TEST_SUPPORT_CHECKS')) {
         $report_errors && pts_client::$display->test_run_error('SKIP_ALL_TEST_SUPPORT_CHECKS is set for ' . $test_profile . '.');
         $valid_test_profile = true;
     }
     return $valid_test_profile;
 }
Ejemplo n.º 3
0
 public static function gpu_available_modes()
 {
     // XRandR available modes
     $current_resolution = phodevi::read_property('gpu', 'screen-resolution');
     $current_pixel_count = $current_resolution[0] * $current_resolution[1];
     $available_modes = array();
     $supported_ratios = array(1.6, 1.25, 1.33, 1.7, 1.71, 1.78);
     $ignore_modes = array(array(640, 400), array(720, 480), array(832, 624), array(960, 540), array(960, 600), array(896, 672), array(928, 696), array(960, 720), array(1152, 864), array(1280, 720), array(1360, 768), array(1776, 1000), array(1792, 1344), array(1800, 1440), array(1856, 1392), array(2048, 1536));
     if ($override_check = ($override_modes = getenv('OVERRIDE_VIDEO_MODES')) != false) {
         $override_modes = pts_strings::comma_explode($override_modes);
         for ($i = 0; $i < count($override_modes); $i++) {
             $override_modes[$i] = explode('x', $override_modes[$i]);
         }
     }
     // Attempt reading available modes from xrandr
     if (pts_client::executable_in_path('xrandr') && !phodevi::is_macosx()) {
         $xrandr_lines = array_reverse(explode("\n", shell_exec('xrandr 2>&1')));
         foreach ($xrandr_lines as $xrandr_mode) {
             if (($cut_point = strpos($xrandr_mode, '(')) > 0) {
                 $xrandr_mode = substr($xrandr_mode, 0, $cut_point);
             }
             $res = pts_strings::trim_explode('x', $xrandr_mode);
             if (count($res) == 2) {
                 $res[0] = substr($res[0], strrpos($res[0], ' '));
                 $res[1] = substr($res[1], 0, strpos($res[1], ' '));
                 if (is_numeric($res[0]) && is_numeric($res[1])) {
                     $m = array($res[0], $res[1]);
                     if (!in_array($m, $available_modes)) {
                         // Don't repeat modes
                         array_push($available_modes, $m);
                     }
                 }
             }
         }
     }
     if (count($available_modes) <= 2) {
         // Fallback to providing stock modes
         $stock_modes = array(array(800, 600), array(1024, 768), array(1280, 800), array(1280, 1024), array(1400, 900), array(1400, 1050), array(1600, 900), array(1680, 1050), array(1600, 1200), array(1920, 1080), array(1920, 1200), array(2560, 1600), array(3840, 2160));
         $available_modes = array();
         for ($i = 0; $i < count($stock_modes); $i++) {
             if ($stock_modes[$i][0] <= $current_resolution[0] && $stock_modes[$i][1] <= $current_resolution[1]) {
                 array_push($available_modes, $stock_modes[$i]);
             }
         }
     }
     if (!in_array(phodevi::read_property('gpu', 'screen-resolution'), $available_modes)) {
         array_push($available_modes, phodevi::read_property('gpu', 'screen-resolution'));
     }
     foreach ($available_modes as $mode_index => $mode) {
         $this_ratio = pts_math::set_precision($mode[0] / $mode[1], 2);
         if ($override_check && !in_array($mode, $override_modes)) {
             // Using override modes and this mode is not present
             unset($available_modes[$mode_index]);
         } else {
             if ($current_pixel_count > 614400 && $mode[0] * $mode[1] < 480000 && stripos(phodevi::read_name('gpu'), 'llvmpipe') === false) {
                 // For displays larger than 1024 x 600, drop modes below 800 x 600 unless llvmpipe is being used
                 unset($available_modes[$mode_index]);
             } else {
                 if ($current_pixel_count > 480000 && !in_array($this_ratio, $supported_ratios)) {
                     // For displays larger than 800 x 600, ensure reading from a supported ratio
                     unset($available_modes[$mode_index]);
                 } else {
                     if (in_array($mode, $ignore_modes)) {
                         // Mode is to be ignored
                         unset($available_modes[$mode_index]);
                     }
                 }
             }
         }
     }
     // Sort available modes in order
     $unsorted_modes = $available_modes;
     $available_modes = array();
     $mode_pixel_counts = array();
     foreach ($unsorted_modes as $this_mode) {
         if (count($this_mode) == 2) {
             array_push($mode_pixel_counts, $this_mode[0] * $this_mode[1]);
         }
     }
     // Sort resolutions by true pixel count resolution
     sort($mode_pixel_counts);
     foreach ($mode_pixel_counts as &$mode_pixel_count) {
         foreach ($unsorted_modes as $mode_index => $mode) {
             if ($mode[0] * $mode[1] == $mode_pixel_count) {
                 array_push($available_modes, $mode);
                 unset($unsorted_modes[$mode_index]);
                 break;
             }
         }
     }
     if (count($available_modes) == 0 && $override_check) {
         // Write in the non-standard modes that were overrode
         foreach ($override_modes as $mode) {
             if (is_array($mode) && count($mode) == 2) {
                 array_push($available_modes, $mode);
             }
         }
     }
     return $available_modes;
 }
 public static function sw_virtualized_mode()
 {
     // Reports if system is running virtualized
     $virtualized = null;
     $mobo = phodevi::read_name('motherboard');
     $gpu = phodevi::read_name('gpu');
     $cpu = phodevi::read_property('cpu', 'model');
     if (strpos($cpu, 'QEMU') !== false || is_readable('/sys/class/dmi/id/bios_vendor') && pts_file_io::file_get_contents('/sys/class/dmi/id/bios_vendor') == 'QEMU') {
         $virtualized = 'QEMU';
         if (strpos($cpu, 'QEMU Virtual') !== false) {
             $qemu_version = substr($cpu, strrpos($cpu, ' ') + 1);
             if (pts_strings::is_version($qemu_version)) {
                 $virtualized .= ' ' . $qemu_version;
             }
         }
     } else {
         if (stripos($gpu, 'VMware') !== false || is_readable('/sys/class/dmi/id/product_name') && stripos(pts_file_io::file_get_contents('/sys/class/dmi/id/product_name'), 'VMware') !== false) {
             $virtualized = 'VMware';
         } else {
             if (stripos($gpu, 'VirtualBox') !== false || stripos(phodevi::read_name('motherboard'), 'VirtualBox') !== false) {
                 $virtualized = 'VirtualBox';
                 if ($vbox_manage = pts_client::executable_in_path('VBoxManage')) {
                     $vbox_manage = trim(shell_exec($vbox_manage . ' --version 2> /dev/null'));
                     if (is_numeric(substr($vbox_manage, 0, 1))) {
                         $virtualized .= ' ' . $vbox_manage;
                     }
                 } else {
                     if ($modinfo = pts_client::executable_in_path('modinfo')) {
                         $modinfo = trim(shell_exec('modinfo -F version vboxguest 2> /dev/null'));
                         if ($modinfo != null && pts_strings::is_version(str_ireplace(array('_', 'RC', 'beta'), null, $modinfo))) {
                             $virtualized .= ' ' . $modinfo;
                         }
                     }
                 }
             } else {
                 if (is_file('/sys/class/dmi/id/sys_vendor') && pts_file_io::file_get_contents('/sys/class/dmi/id/sys_vendor') == 'Xen') {
                     $virtualized = pts_file_io::file_get_contents('/sys/class/dmi/id/product_name');
                     if (strpos($virtualized, 'Xen') === false) {
                         $virtualized = 'Xen ' . $virtualized;
                     }
                     // version string
                     $virtualized .= ' ' . pts_file_io::file_get_contents('/sys/class/dmi/id/product_version');
                     // $virtualized should be then e.g. 'Xen HVM domU 4.1.1'
                 } else {
                     if (stripos($gpu, 'Microsoft Hyper-V') !== false) {
                         $virtualized = 'Microsoft Hyper-V Server';
                     } else {
                         if (stripos($mobo, 'Parallels Software') !== false) {
                             $virtualized = 'Parallels Virtualization';
                         } else {
                             if (is_file('/sys/hypervisor/type')) {
                                 $type = pts_file_io::file_get_contents('/sys/hypervisor/type');
                                 $version = array();
                                 foreach (array('major', 'minor', 'extra') as $v) {
                                     if (is_file('/sys/hypervisor/version/' . $v)) {
                                         $v = pts_file_io::file_get_contents('/sys/hypervisor/version/' . $v);
                                     } else {
                                         continue;
                                     }
                                     if ($v != null) {
                                         if (!empty($version) && substr($v, 0, 1) != '.') {
                                             $v = '.' . $v;
                                         }
                                         array_push($version, $v);
                                     }
                                 }
                                 $virtualized = ucwords($type) . ' ' . implode('', $version) . ' Hypervisor';
                             }
                         }
                     }
                 }
             }
         }
     }
     if ($systemd_virt = pts_client::executable_in_path('systemd-detect-virt')) {
         $systemd_virt = trim(shell_exec($systemd_virt . ' 2> /dev/null'));
         if ($systemd_virt != null && $systemd_virt != 'none') {
             switch ($systemd_virt) {
                 case 'kvm':
                     $systemd_virt = 'KVM';
                     break;
                 case 'oracle':
                     $systemd_virt = 'Oracle';
                     break;
             }
             if ($virtualized != null && stripos($virtualized, $systemd_virt) === false && stripos($systemd_virt, $virtualized) === false) {
                 $virtualized = $systemd_virt . ' ' . $virtualized;
             } else {
                 if ($virtualized == null) {
                     $virtualized = $systemd_virt;
                 }
             }
         }
     }
     return $virtualized;
 }
Ejemplo n.º 5
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');
     }
 }