public static function what_provides($files_needed)
 {
     $packages_needed = array();
     foreach (pts_arrays::to_array($files_needed) as $file) {
         if (pts_client::executable_in_path('apt-file')) {
             if (!defined('APT_FILE_UPDATED')) {
                 shell_exec('apt-file update 2>&1');
                 define('APT_FILE_UPDATED', 1);
             }
             // Try appending common paths
             if (strpos($file, '.h') !== false) {
                 $apt_provides = self::run_apt_file_provides('/usr/include/' . $file);
                 if ($apt_provides != null) {
                     $packages_needed[$file] = $apt_provides;
                 }
             } else {
                 if (strpos($file, '.so') !== false) {
                     $apt_provides = self::run_apt_file_provides('/usr/lib/' . $file);
                     if ($apt_provides != null) {
                         $packages_needed[$file] = $apt_provides;
                     }
                 } else {
                     foreach (array('/usr/bin/', '/bin/', '/usr/sbin') as $possible_path) {
                         $apt_provides = self::run_apt_file_provides($possible_path . $file);
                         if ($apt_provides != null) {
                             $packages_needed[$file] = $apt_provides;
                             break;
                         }
                     }
                 }
             }
         }
     }
     return $packages_needed;
 }
 public static function read_hal_property($udi, $key)
 {
     $value = false;
     if (pts_client::executable_in_path('hal-get-property')) {
         foreach (pts_arrays::to_array($udi) as $udi_check) {
             $value = trim(shell_exec('hal-get-property --udi ' . $udi_check . ' --key ' . $key . ' 2> /dev/null'));
             if ($value != false) {
                 break;
             }
         }
     }
     return $value;
 }
 public static function read_sysctl($desc)
 {
     // Read sysctl, used by *BSDs
     $info = false;
     if (pts_client::executable_in_path('sysctl')) {
         $desc = pts_arrays::to_array($desc);
         for ($i = 0; $i < count($desc) && empty($info); $i++) {
             $output = shell_exec('sysctl ' . $desc[$i] . ' 2>&1');
             if ((($point = strpos($output, ':')) > 0 || ($point = strpos($output, '=')) > 0) && strpos($output, 'unknown oid') === false && strpos($output, 'is invalid') === false && strpos($output, 'not available') === false) {
                 $info = trim(substr($output, $point + 1));
             }
         }
     }
     return $info;
 }
 public static function run($r)
 {
     pts_client::$display->generic_heading('System 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;
     //
     // Processor Information
     //
     $cpu_flags = phodevi_cpu::get_cpu_flags();
     echo PHP_EOL . 'PROCESSOR:' . PHP_EOL . PHP_EOL;
     echo 'Core Count: ' . phodevi_cpu::cpuinfo_core_count() . PHP_EOL;
     echo 'Thread Count: ' . phodevi_cpu::cpuinfo_thread_count() . PHP_EOL;
     echo 'Cache Size: ' . phodevi_cpu::cpuinfo_cache_size() . ' KB' . PHP_EOL;
     echo 'Instruction Set Extensions: ' . phodevi_cpu::instruction_set_extensions() . PHP_EOL;
     echo 'AES Encryption: ' . ($cpu_flags & phodevi_cpu::get_cpu_feature_constant('aes') ? 'YES' : 'NO') . PHP_EOL;
     echo 'Energy Performance Bias: ' . ($cpu_flags & phodevi_cpu::get_cpu_feature_constant('epb') ? 'YES' : 'NO') . PHP_EOL;
     echo 'Virtualization: ' . (phodevi_cpu::virtualization_technology() ? phodevi_cpu::virtualization_technology() : 'NO') . PHP_EOL;
     // Other info
     foreach (pts_arrays::to_array(pts_test_run_manager::pull_test_notes(true)) as $test_note_head => $test_note) {
         echo ucwords(str_replace('-', ' ', $test_note_head)) . ': ' . $test_note . PHP_EOL;
     }
 }
 public static function what_provides($files_needed)
 {
     $packages_needed = array();
     foreach (pts_arrays::to_array($files_needed) as $file) {
         if (pts_client::executable_in_path('dnf')) {
             $dnf_provides = self::run_dnf_provides($file);
             if ($dnf_provides != null) {
                 $packages_needed[$file] = $dnf_provides;
             } else {
                 // Try appending common paths
                 if (strpos($file, '.h') !== false) {
                     $dnf_provides = self::run_dnf_provides('/usr/include/' . $file);
                     if ($dnf_provides != null) {
                         $packages_needed[$file] = $dnf_provides;
                     }
                 } else {
                     if (strpos($file, '.so') !== false) {
                         $dnf_provides = self::run_dnf_provides('/usr/lib/' . $file);
                         if ($dnf_provides != null) {
                             $packages_needed[$file] = $dnf_provides;
                         }
                     } else {
                         foreach (array('/usr/bin/', '/bin/', '/usr/sbin') as $possible_path) {
                             $dnf_provides = self::run_dnf_provides($possible_path . $file);
                             if ($dnf_provides != null) {
                                 $packages_needed[$file] = $dnf_provides;
                                 break;
                             }
                         }
                     }
                 }
             }
         }
     }
     return $packages_needed;
 }
 public static function read_sensors($attributes)
 {
     // Read LM_Sensors
     $value = false;
     if (isset(phodevi::$vfs->sensors)) {
         $sensors = phodevi::$vfs->sensors;
         $sensors_lines = explode("\n", $sensors);
         $attributes = pts_arrays::to_array($attributes);
         for ($j = 0; $j < count($attributes) && empty($value); $j++) {
             $attribute = $attributes[$j];
             for ($i = 0; $i < count($sensors_lines) && $value == false; $i++) {
                 $line = pts_strings::trim_explode(': ', $sensors_lines[$i]);
                 if (!isset($line[0])) {
                     continue;
                 }
                 $this_attribute = $line[0];
                 if ($this_attribute == $attribute) {
                     $this_remainder = trim(str_replace(array('+', '°'), ' ', $line[1]));
                     $this_value = substr($this_remainder, 0, strpos($this_remainder, ' '));
                     if (is_numeric($this_value) && $this_value > 0) {
                         $value = $this_value;
                     }
                 }
             }
         }
     }
     return $value;
 }
 public function get_result_objects($select_indexes = -1)
 {
     if ($this->result_objects == null) {
         $this->result_objects = array();
         foreach ($this->xml->Result as $result) {
             array_push($this->result_objects, $this->get_result_object($result));
         }
     }
     if ($select_indexes != -1 && $select_indexes !== null) {
         $objects = array();
         if ($select_indexes == 'ONLY_CHANGED_RESULTS') {
             foreach ($this->result_objects as &$result) {
                 // Only show results where the variation was greater than or equal to 1%
                 if (abs($result->largest_result_variation(0.01)) >= 0.01) {
                     array_push($objects, $result);
                 }
             }
         } else {
             foreach (pts_arrays::to_array($select_indexes) as $index) {
                 if (isset($this->result_objects[$index])) {
                     array_push($objects, $this->result_objects[$index]);
                 }
             }
         }
         return $objects;
     }
     return $this->result_objects;
 }
예제 #8
0
 public static function html_embed_code($file_name, $file_type = 'SVG', $attributes = null, $is_xsl = false)
 {
     $attributes = pts_arrays::to_array($attributes);
     $file_name = str_replace('BILDE_EXTENSION', strtolower($file_type), $file_name);
     switch ($file_type) {
         case 'SVG':
             $attributes['data'] = $file_name;
             if ($is_xsl) {
                 $html = '<object type="image/svg+xml">';
                 foreach ($attributes as $option => $value) {
                     $html .= '<xsl:attribute name="' . $option . '">' . $value . '</xsl:attribute>';
                 }
                 $html .= '</object>';
             } else {
                 $html = '<object type="image/svg+xml"';
                 foreach ($attributes as $option => $value) {
                     $html .= $option . '="' . $value . '" ';
                 }
                 $html .= '/>';
             }
             break;
         default:
             $attributes['src'] = $file_name;
             if ($is_xsl) {
                 $html = '<img>';
                 foreach ($attributes as $option => $value) {
                     $html .= '<xsl:attribute name="' . $option . '">' . $value . '</xsl:attribute>';
                 }
                 $html .= '</img>';
             } else {
                 $html = '<img ';
                 foreach ($attributes as $option => $value) {
                     $html .= $option . '="' . $value . '" ';
                 }
                 $html .= '/>';
             }
             break;
     }
     return $html;
 }
 public static function process_running_string($process_arr)
 {
     // Format a nice string that shows processes running
     $p = array();
     $p_string = null;
     $process_arr = pts_arrays::to_array($process_arr);
     foreach ($process_arr as $p_name => $p_processes) {
         foreach ($p_processes as $process) {
             if (pts_client::is_process_running($process)) {
                 $p[] = $p_name;
             }
         }
     }
     $p = array_keys(array_flip($p));
     if (($p_count = count($p)) > 0) {
         for ($i = 0; $i < $p_count; $i++) {
             $p_string .= $p[$i];
             if ($i != $p_count - 1 && $p_count > 2) {
                 $p_string .= ',';
             }
             $p_string .= ' ';
             if ($i == $p_count - 2) {
                 $p_string .= 'and ';
             }
         }
         $p_string .= $p_count == 1 ? 'was' : 'were';
         $p_string .= ' running on this system';
     }
     return $p_string;
 }
 public function remove_run($remove)
 {
     $remove = pts_arrays::to_array($remove);
     foreach ($this->systems as $i => &$s) {
         if (in_array($s->get_identifier(), $remove)) {
             unset($this->systems[$i]);
         }
     }
     foreach ($this->result_objects as &$result) {
         $result->test_result_buffer->remove($remove);
     }
 }
 public static function monitor_layout()
 {
     // Determine layout for multiple monitors
     $monitor_layout = array('CENTER');
     if (phodevi::read_property('monitor', 'count') > 1) {
         $xdpy_monitors = phodevi_parser::read_xdpy_monitor_info();
         $hit_0_0 = false;
         for ($i = 0; $i < count($xdpy_monitors); $i++) {
             $monitor_position = explode('@', $xdpy_monitors[$i]);
             $monitor_position = trim($monitor_position[1]);
             $monitor_position_x = substr($monitor_position, 0, strpos($monitor_position, ','));
             $monitor_position_y = substr($monitor_position, strpos($monitor_position, ',') + 1);
             if ($monitor_position == '0,0') {
                 $hit_0_0 = true;
             } else {
                 if ($monitor_position_x > 0 && $monitor_position_y == 0) {
                     array_push($monitor_layout, $hit_0_0 ? 'RIGHT' : 'LEFT');
                 } else {
                     if ($monitor_position_x == 0 && $monitor_position_y > 0) {
                         array_push($monitor_layout, $hit_0_0 ? 'LOWER' : 'UPPER');
                     }
                 }
             }
         }
         if (count($monitor_layout) == 1) {
             // Something went wrong with xdpy information, go to fallback support
             if (phodevi::is_ati_graphics() && phodevi::is_linux()) {
                 $amdpcsdb_monitor_layout = phodevi_linux_parser::read_amd_pcsdb('SYSTEM/BUSID-*/DDX,DesktopSetup');
                 $amdpcsdb_monitor_layout = pts_arrays::to_array($amdpcsdb_monitor_layout);
                 foreach ($amdpcsdb_monitor_layout as $card_monitor_configuration) {
                     switch ($card_monitor_configuration) {
                         case 'horizontal':
                             array_push($monitor_layout, 'RIGHT');
                             break;
                         case 'horizontal,reverse':
                             array_push($monitor_layout, 'LEFT');
                             break;
                         case 'vertical':
                             array_push($monitor_layout, 'ABOVE');
                             break;
                         case 'vertical,reverse':
                             array_push($monitor_layout, 'BELOW');
                             break;
                     }
                 }
             }
         }
     }
     return implode(',', $monitor_layout);
 }
 public function __construct($result_file, $selected_identifiers = null, $rename_identifier = null)
 {
     $this->result_file = $result_file;
     $this->selected_identifiers = $selected_identifiers != null ? pts_arrays::to_array($selected_identifiers) : null;
     $this->rename_identifier = $rename_identifier;
 }
예제 #13
0
 public static function gpu_model()
 {
     // Report graphics processor string
     $info = phodevi_parser::read_glx_renderer();
     $video_ram = phodevi::read_property('gpu', 'memory-capacity');
     if (phodevi::is_ati_graphics() && phodevi::is_linux()) {
         $crossfire_status = phodevi_linux_parser::read_amd_pcsdb('SYSTEM/Crossfire/chain/*,Enable');
         $crossfire_status = pts_arrays::to_array($crossfire_status);
         $crossfire_card_count = 0;
         for ($i = 0; $i < count($crossfire_status); $i++) {
             if ($crossfire_status[$i] == '0x00000001') {
                 $crossfire_card_count += 2;
                 // For now assume each chain is 2 cards, but proper way would be NumSlaves + 1
             }
         }
         $adapters = phodevi_linux_parser::read_amd_graphics_adapters();
         if (count($adapters) > 0) {
             $video_ram = $video_ram > 64 ? ' ' . $video_ram . 'MB' : null;
             // assume more than 64MB of vRAM
             if ($crossfire_card_count > 1 && $crossfire_card_count <= count($adapters)) {
                 $unique_adapters = array_unique($adapters);
                 if (count($unique_adapters) == 1) {
                     if (strpos($adapters[0], 'X2') > 0 && $crossfire_card_count > 1) {
                         $crossfire_card_count -= 1;
                     }
                     $info = $crossfire_card_count . ' x ' . $adapters[0] . $video_ram . ' CrossFire';
                 } else {
                     $info = implode(', ', $unique_adapters) . ' CrossFire';
                 }
             } else {
                 $info = $adapters[0] . $video_ram;
             }
         }
     } else {
         if (phodevi::is_macosx()) {
             $system_profiler_info = implode(' + ', phodevi_osx_parser::read_osx_system_profiler('SPDisplaysDataType', 'ChipsetModel', true));
             if (!empty($system_profiler_info)) {
                 $info = $system_profiler_info;
             }
         } else {
             if (phodevi::is_nvidia_graphics()) {
                 if ($info == null) {
                     if (pts_client::executable_in_path('nvidia-settings')) {
                         $nv_gpus = shell_exec('nvidia-settings -q gpus 2>&1');
                         // TODO: search for more than one GPU
                         $nv_gpus = substr($nv_gpus, strpos($nv_gpus, '[0]'));
                         $nv_gpus = substr($nv_gpus, strpos($nv_gpus, '(') + 1);
                         $nv_gpus = substr($nv_gpus, 0, strpos($nv_gpus, ')'));
                         if (stripos($nv_gpus, 'GeForce') !== false || stripos($nv_gpus, 'Quadro') !== false) {
                             $info = $nv_gpus;
                         }
                     }
                 }
                 $sli_mode = phodevi_parser::read_nvidia_extension('SLIMode');
                 if (!empty($sli_mode) && $sli_mode != 'Off') {
                     $info .= ' SLI';
                 }
             } else {
                 if (phodevi::is_solaris()) {
                     if (($cut = strpos($info, 'DRI ')) !== false) {
                         $info = substr($info, $cut + 4);
                     }
                     if (($cut = strpos($info, ' Chipset')) !== false) {
                         $info = substr($info, 0, $cut);
                     }
                     if ($info == false && isset(phodevi::$vfs->xorg_log)) {
                         $xorg_log = phodevi::$vfs->xorg_log;
                         if (($x = strpos($xorg_log, '(0): Chipset: ')) !== false) {
                             $xorg_log = substr($xorg_log, $x + 14);
                             $xorg_log = str_replace(array('(R)', '"'), null, substr($xorg_log, 0, strpos($xorg_log, PHP_EOL)));
                             if (($c = strpos($xorg_log, '[')) || ($c = strpos($xorg_log, '('))) {
                                 $xorg_log = substr($xorg_log, 0, $c);
                             }
                             if (phodevi::is_product_string($xorg_log)) {
                                 $info = $xorg_log;
                             }
                         }
                     }
                 } else {
                     if (phodevi::is_bsd()) {
                         $drm_info = phodevi_bsd_parser::read_sysctl('dev.drm.0.%desc');
                         if (!$drm_info) {
                             $drm_info = phodevi_bsd_parser::read_sysctl('dev.nvidia.0.%desc');
                         }
                         if (!$drm_info) {
                             $agp_info = phodevi_bsd_parser::read_sysctl('dev.agp.0.%desc');
                             if ($agp_info != false) {
                                 $info = $agp_info;
                             }
                         } else {
                             $info = $drm_info;
                         }
                         if ($info == null && isset(phodevi::$vfs->xorg_log)) {
                             $xorg_log = phodevi::$vfs->xorg_log;
                             if (($e = strpos($xorg_log, ' at 01@00:00:0')) !== false) {
                                 $xorg_log = substr($xorg_log, 0, $e);
                                 $info = substr($xorg_log, strrpos($xorg_log, 'Found ') + 6);
                             }
                         }
                     } else {
                         if (phodevi::is_windows()) {
                             $info = phodevi_windows_parser::read_cpuz('Display Adapters', 'Name');
                         }
                     }
                 }
             }
         }
     }
     if (empty($info) || strpos($info, 'Mesa ') !== false || strpos($info, 'Gallium ') !== false) {
         if (phodevi::is_windows() == false) {
             $info_pci = phodevi_linux_parser::read_pci('VGA compatible controller', false);
             if (!empty($info_pci)) {
                 $info = $info_pci;
                 if (strpos($info, 'Intel 2nd Generation Core Family') !== false || strpos($info, 'Gen Core') !== false) {
                     // Try to come up with a better non-generic string
                     $was_reset = false;
                     if (isset(phodevi::$vfs->xorg_log)) {
                         /*
                         $ cat /var/log/Xorg.0.log | grep -i Chipset
                         [     8.421] (II) intel: Driver for Intel Integrated Graphics Chipsets: i810,
                         [     8.421] (II) VESA: driver for VESA chipsets: vesa
                         [     8.423] (II) intel(0): Integrated Graphics Chipset: Intel(R) Sandybridge Mobile (GT2+)
                         [     8.423] (--) intel(0): Chipset: "Sandybridge Mobile (GT2+)"
                         */
                         $xorg_log = phodevi::$vfs->xorg_log;
                         if (($x = strpos($xorg_log, 'Integrated Graphics Chipset: ')) !== false) {
                             $xorg_log = substr($xorg_log, $x + 29);
                             $xorg_log = str_replace(array('(R)', '"'), null, substr($xorg_log, 0, strpos($xorg_log, PHP_EOL)));
                             if (stripos($xorg_log, 'Intel') === false) {
                                 $xorg_log = 'Intel ' . $xorg_log;
                             }
                             // if string is too long, likely not product
                             if (!isset($xorg_log[45])) {
                                 $info = $xorg_log;
                                 $was_reset = true;
                             }
                         } else {
                             if (($x = strpos($xorg_log, '(0): Chipset: ')) !== false) {
                                 $xorg_log = substr($xorg_log, $x + 14);
                                 $xorg_log = str_replace(array('(R)', '"'), null, substr($xorg_log, 0, strpos($xorg_log, PHP_EOL)));
                                 if (stripos($xorg_log, 'Intel') === false) {
                                     $xorg_log = 'Intel ' . $xorg_log;
                                 }
                                 // if string is too long, likely not product
                                 if (!isset($xorg_log[45])) {
                                     $info = $xorg_log;
                                     $was_reset = true;
                                 }
                             }
                         }
                     }
                     if ($was_reset == false && isset(phodevi::$vfs->i915_capabilities)) {
                         $i915_caps = phodevi::$vfs->i915_capabilities;
                         if (($x = strpos($i915_caps, 'gen: ')) !== false) {
                             $gen = substr($i915_caps, $x + 5);
                             $gen = substr($gen, 0, strpos($gen, PHP_EOL));
                             if (is_numeric($gen)) {
                                 $info = 'Intel Gen' . $gen;
                                 if (strpos($i915_caps, 'is_mobile: yes') !== false) {
                                     $info .= ' Mobile';
                                 }
                             }
                         }
                     }
                 }
             }
         }
         if (($start_pos = strpos($info, ' DRI ')) > 0) {
             $info = substr($info, $start_pos + 5);
         }
         if (empty($info) && isset(phodevi::$vfs->xorg_log)) {
             $log_parse = phodevi::$vfs->xorg_log;
             $log_parse = substr($log_parse, strpos($log_parse, 'Chipset') + 8);
             $log_parse = substr($log_parse, 0, strpos($log_parse, 'found'));
             if (strpos($log_parse, '(--)') === false && strlen(str_ireplace(array('ATI', 'NVIDIA', 'VIA', 'Intel'), '', $log_parse)) != strlen($log_parse)) {
                 $info = $log_parse;
             }
         }
         if (empty($info) && is_readable('/sys/class/graphics/fb0/name')) {
             switch (pts_file_io::file_get_contents('/sys/class/graphics/fb0/name')) {
                 case 'omapdrm':
                     $info = 'Texas Instruments OMAP';
                     // The OMAP DRM driver currently is for OMAP2/3/4 hardware
                     break;
                 case 'exynos':
                     $info = 'Samsung EXYNOS';
                     // The Exynos DRM driver
                     break;
                 case 'tegra_fb':
                     $info = 'NVIDIA TEGRA';
                     // The Exynos DRM driver
                     break;
                 default:
                     if (is_file('/dev/mali')) {
                         $info = 'ARM Mali';
                         // One of the ARM Mali models
                     }
                     break;
             }
         }
         if (substr($info, -1) == ')' && ($open_p = strrpos($info, '(')) != false) {
             $end_check = strpos($info, ' ', $open_p);
             $to_check = substr($info, $open_p + 1, $end_check - $open_p - 1);
             // Don't report card revision from PCI info
             if ($to_check == 'rev') {
                 $info = substr($info, 0, $open_p - 1);
             }
         }
     }
     if (($bracket_open = strpos($info, '[')) !== false) {
         // Report only the information inside the brackets if it's more relevant...
         // Mainly with Linux systems where the PCI information is reported like 'nVidia GF104 [GeForce GTX 460]'
         if (($bracket_close = strpos($info, ']', $bracket_open + 1)) !== false) {
             $inside_bracket = substr($info, $bracket_open + 1, $bracket_close - $bracket_open - 1);
             if (stripos($inside_bracket, 'Quadro') !== false || stripos($inside_bracket, 'GeForce') !== false) {
                 $info = $inside_bracket . ' ' . substr($info, $bracket_close + 1);
             } else {
                 if (stripos($inside_bracket, 'Radeon') !== false || stripos($inside_bracket, 'Fire') !== false || stripos($inside_bracket, 'Fusion') !== false) {
                     $info = $inside_bracket . ' ' . substr($info, $bracket_close + 1);
                 }
             }
         }
     }
     if (stripos($info, 'NVIDIA') === false && (stripos($info, 'Quadro') !== false || stripos($info, 'GeForce') !== false)) {
         $info = 'NVIDIA' . ' ' . $info;
     } else {
         if (stripos($info, 'ATI') === false && stripos($info, 'AMD') === false && (stripos($info, 'Radeon') !== false || stripos($info, 'Fire') !== false || stripos($info, 'Fusion') !== false)) {
             // Fire would be for FireGL or FirePro hardware
             $info = 'AMD ' . $info;
         }
     }
     if (phodevi::is_linux() && ($vendor = phodevi_linux_parser::read_pci_subsystem_value('VGA compatible controller')) != null && stripos($info, $vendor) === false && (stripos($info, 'AMD') !== false || stripos($info, 'NVIDIA') !== false)) {
         $info = $vendor . ' ' . $info;
     }
     if ($video_ram > 64 && strpos($info, $video_ram) == false) {
         $info .= ' ' . $video_ram . 'MB';
     }
     $clean_phrases = array('OpenGL Engine');
     $info = str_replace($clean_phrases, null, $info);
     return $info;
 }
 public static function attached_modules($process_name = null, $select_modules = false)
 {
     if ($process_name == null) {
         $attached = self::$modules;
     } else {
         if (isset(self::$module_process[$process_name])) {
             $attached = self::$module_process[$process_name];
         } else {
             $attached = array();
         }
     }
     if ($select_modules != false) {
         $all_attached = $attached;
         $attached = array();
         foreach (pts_arrays::to_array($select_modules) as $check_module) {
             if (in_array($check_module, $all_attached)) {
                 array_push($attached, $check_module);
             }
         }
     }
     return $attached;
 }
예제 #15
0
 public static function identifiers_to_objects($identifiers, &$archive_unknown_objects = false)
 {
     // Provide an array containing the location(s) of all test(s) for the supplied object name
     $objects = array();
     foreach (pts_arrays::to_array($identifiers) as $identifier_item) {
         if ($identifier_item instanceof pts_test_profile || $identifier_item instanceof pts_test_suite || $identifier_item instanceof pts_result_file) {
             array_push($objects, $identifier_item);
         } else {
             if (PTS_IS_CLIENT && $identifier_item instanceof pts_virtual_test_queue) {
                 // Object is a virtual suite
                 array_push($objects, $identifier_item);
             } else {
                 if ($tp_identifier = pts_test_profile::is_test_profile($identifier_item)) {
                     // Object is a test
                     array_push($objects, new pts_test_profile($tp_identifier));
                 } else {
                     if (pts_test_suite::is_suite($identifier_item)) {
                         // Object is a suite
                         array_push($objects, new pts_test_suite($identifier_item));
                     } else {
                         if (pts_result_file::is_test_result_file($identifier_item)) {
                             // Object is a saved results file
                             array_push($objects, new pts_result_file($identifier_item));
                         } else {
                             if (pts_openbenchmarking::is_openbenchmarking_result_id($identifier_item)) {
                                 // Object is an OpenBenchmarking.org result
                                 // Clone it locally so it's just handled like a pts_result_file
                                 $success = pts_openbenchmarking::clone_openbenchmarking_result($identifier_item);
                                 if ($success) {
                                     array_push($objects, new pts_result_file($identifier_item));
                                 }
                             } else {
                                 if (PTS_IS_CLIENT && pts_virtual_test_suite::is_virtual_suite($identifier_item)) {
                                     // Object is a virtual suite
                                     array_push($objects, new pts_virtual_test_suite($identifier_item));
                                 } else {
                                     if (pts_suite_nye_XmlReader::is_temporary_suite($identifier_item)) {
                                         // Object is a suite
                                         array_push($objects, new pts_test_suite($identifier_item));
                                     } else {
                                         if (is_array($archive_unknown_objects)) {
                                             // Unknown / nothing / broken
                                             array_push($archive_unknown_objects, $identifier_item);
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return $objects;
 }
 public function remove($remove)
 {
     $remove = pts_arrays::to_array($remove);
     foreach ($this->buffer_items as $i => &$buffer_item) {
         if (in_array($buffer_item->get_result_identifier(), $remove)) {
             unset($this->buffer_items[$i]);
         }
     }
 }
예제 #17
0
 public static function pts_timed_function($function, $time, $parameters = null)
 {
     if ($time < 0.5 && $time != -1 || $time > 300) {
         return;
     }
     //TODO improve accuracy by comparing time pre- and post- loop iteration
     if (function_exists('pcntl_fork')) {
         $pid = pcntl_fork();
         if ($pid != -1) {
             if ($pid) {
                 return $pid;
             } else {
                 $loop_continue = true;
                 /*
                 ML: I think this below check can be safely removed
                 $start_id = pts_unique_runtime_identifier();
                  && ($start_id == pts_unique_runtime_identifier() || $start_id == PTS_INIT_TIME)
                 */
                 while (pts_test_run_manager::test_run_process_active() !== -1 && is_file(PTS_USER_LOCK) && $loop_continue) {
                     //						if ($parameters == null || !is_array($parameters))
                     //						{
                     //							$parameters = array();
                     //						}
                     $parameter_array = pts_arrays::to_array($parameters);
                     call_user_func_array(array(self::module_name(), $function), $parameter_array);
                     if ($time > 0) {
                         sleep($time);
                     } else {
                         if ($time == -1) {
                             $loop_continue = false;
                         }
                     }
                 }
                 exit(0);
             }
         }
     } else {
         trigger_error('php-pcntl must be installed for the ' . self::module_name() . ' module.', E_USER_ERROR);
     }
 }
예제 #18
0
 public static function cpu_arch_compatible($check_against)
 {
     $compatible = true;
     $this_arch = phodevi::read_property('system', 'kernel-architecture');
     $check_against = pts_arrays::to_array($check_against);
     if (isset($this_arch[2]) && substr($this_arch, -2) == '86') {
         $this_arch = 'x86';
     }
     if (!in_array($this_arch, $check_against)) {
         $compatible = false;
     }
     return $compatible;
 }
 public static function create_compiler_mask(&$test_install_request)
 {
     if (phodevi::is_bsd()) {
         // XXX: Using the compiler-mask causes a number of tests to fail to properly install due to compiler issues with at least PC-BSD 10.0
         return false;
     }
     // or pass false to $test_install_request to bypass the test checks
     $compilers = array();
     $external_dependencies = $test_install_request != false ? $test_install_request->test_profile->get_external_dependencies() : false;
     if ($test_install_request === false || in_array('build-utilities', $external_dependencies)) {
         // Handle C/C++ compilers for this external dependency
         $compilers['CC'] = array(pts_strings::first_in_string(pts_client::read_env('CC'), ' '), 'gcc', 'clang', 'icc', 'pcc');
         $compilers['CXX'] = array(pts_strings::first_in_string(pts_client::read_env('CXX'), ' '), 'g++', 'clang++', 'cpp');
     }
     if ($test_install_request === false || in_array('fortran-compiler', $external_dependencies)) {
         // Handle Fortran for this external dependency
         $compilers['F9X'] = array(pts_strings::first_in_string(pts_client::read_env('F9X'), ' '), pts_strings::first_in_string(pts_client::read_env('F95'), ' '), 'gfortran', 'f90', 'f95', 'fortran');
     }
     if (empty($compilers)) {
         // If the test profile doesn't request a compiler external dependency, probably not compiling anything
         return false;
     }
     foreach ($compilers as $compiler_type => $possible_compilers) {
         // Compilers to check for, listed in order of priority
         $compiler_found = false;
         foreach ($possible_compilers as $i => $possible_compiler) {
             // first check to ensure not null sent to executable_in_path from env variable
             if ($possible_compiler && (($compiler_path = is_executable($possible_compiler)) || ($compiler_path = pts_client::executable_in_path($possible_compiler, 'ccache')))) {
                 // Replace the array of possible compilers with a string to the detected compiler executable
                 $compilers[$compiler_type] = $compiler_path;
                 $compiler_found = true;
                 break;
             }
         }
         if ($compiler_found == false) {
             unset($compilers[$compiler_type]);
         }
     }
     if (!empty($compilers)) {
         // Create a temporary directory that will be at front of PATH and serve for masking the actual compiler
         if ($test_install_request instanceof pts_test_install_request) {
             $mask_dir = pts_client::temporary_directory() . '/pts-compiler-mask-' . $test_install_request->test_profile->get_identifier_base_name() . $test_install_request->test_profile->get_test_profile_version() . '/';
         } else {
             $mask_dir = pts_client::temporary_directory() . '/pts-compiler-mask-' . rand(100, 999) . '/';
         }
         pts_file_io::mkdir($mask_dir);
         $compiler_extras = array('CC' => array('safeguard-names' => array('gcc', 'cc'), 'environment-variables' => 'CFLAGS'), 'CXX' => array('safeguard-names' => array('g++', 'c++'), 'environment-variables' => 'CXXFLAGS'), 'F9X' => array('safeguard-names' => array('gfortran', 'f95'), 'environment-variables' => 'F9XFLAGS'));
         foreach ($compilers as $compiler_type => $compiler_path) {
             $compiler_name = basename($compiler_path);
             $main_compiler = $mask_dir . $compiler_name;
             // take advantage of environment-variables to be sure they're found in the string
             $env_var_check = PHP_EOL;
             /*
             foreach(pts_arrays::to_array($compiler_extras[$compiler_type]['environment-variables']) as $env_var)
             {
             	// since it's a dynamic check in script could probably get rid of this check...
             	if(true || getenv($env_var))
             	{
             		$env_var_check .= 'if [[ $COMPILER_OPTIONS != "*$' . $env_var . '*" ]]' . PHP_EOL . 'then ' . PHP_EOL . 'COMPILER_OPTIONS="$COMPILER_OPTIONS $' . $env_var . '"' . PHP_EOL . 'fi' . PHP_EOL;
             	}
             }
             */
             // Write the main mask for the compiler
             file_put_contents($main_compiler, '#!/bin/bash' . PHP_EOL . 'COMPILER_OPTIONS="$@"' . PHP_EOL . $env_var_check . PHP_EOL . 'echo $COMPILER_OPTIONS >> ' . $mask_dir . $compiler_type . '-options-' . $compiler_name . PHP_EOL . $compiler_path . ' "$@"' . PHP_EOL);
             // Make executable
             chmod($main_compiler, 0755);
             // The two below code chunks ensure the proper compiler is always hit
             if ($test_install_request instanceof pts_test_install_request && !in_array($compiler_name, pts_arrays::to_array($compiler_extras[$compiler_type]['safeguard-names'])) && getenv($compiler_type) == false) {
                 // So if e.g. clang becomes the default compiler, since it's not GCC, it will ensure CC is also set to clang beyond the masking below
                 $test_install_request->special_environment_vars[$compiler_type] = $compiler_name;
             }
             // Just in case any test profile script is statically always calling 'gcc' or anything not CC, try to make sure it hits one of the safeguard-names so it redirects to the intended compiler under test
             foreach (pts_arrays::to_array($compiler_extras[$compiler_type]['safeguard-names']) as $safe_name) {
                 if (!is_file($mask_dir . $safe_name)) {
                     symlink($main_compiler, $mask_dir . $safe_name);
                 }
             }
         }
         if ($test_install_request instanceof pts_test_install_request) {
             $test_install_request->compiler_mask_dir = $mask_dir;
             // Appending the rest of the path will be done automatically within call_test_script
             $test_install_request->special_environment_vars['PATH'] = $mask_dir;
         }
         return $mask_dir;
     }
     return false;
 }
 public static function zip_archive_create($zip_file, $add_files)
 {
     if (!class_exists('ZipArchive')) {
         if (pts_client::executable_in_path('zip')) {
             if (is_array($add_files)) {
                 shell_exec('cd ' . dirname($add_files[0]) . ' && rm -f ' . $zip_file . ' && zip -r ' . $zip_file . ' ' . implode(' ', array_map('basename', $add_files)));
             } else {
                 shell_exec('cd ' . dirname($add_files) . ' && rm -f ' . $zip_file . ' && zip -r ' . $zip_file . ' ' . basename($add_files));
             }
             if (is_file($zip_file) && filesize($zip_file) > 0) {
                 return true;
             }
         }
         return false;
     }
     $zip = new ZipArchive();
     if ($zip->open($zip_file, ZIPARCHIVE::CREATE) !== true) {
         $success = false;
     } else {
         foreach (pts_arrays::to_array($add_files) as $add_file) {
             self::zip_archive_add($zip, $add_file, dirname($add_file));
         }
         $success = true;
     }
     return $success;
 }