How to use sw_desktop_environment method of phodevi_system class

Best Phoronix-test-suite code snippet using phodevi_system.sw_desktop_environment

phodevi_system.php

Source:phodevi_system.php Github

copy

Full Screen

...70 case 'opengl-vendor':71 $property = new phodevi_device_property('sw_opengl_vendor', phodevi::smart_caching);72 break;73 case 'desktop-environment':74 $property = new phodevi_device_property('sw_desktop_environment', phodevi::smart_caching);75 break;76 case 'operating-system':77 $property = new phodevi_device_property('sw_operating_system', phodevi::smart_caching);78 break;79 case 'os-version':80 $property = new phodevi_device_property('sw_os_version', phodevi::smart_caching);81 break;82 case 'kernel':83 $property = new phodevi_device_property('sw_kernel', phodevi::smart_caching);84 break;85 case 'kernel-architecture':86 $property = new phodevi_device_property('sw_kernel_architecture', phodevi::smart_caching);87 break;88 case 'kernel-date':89 $property = new phodevi_device_property('sw_kernel_date', phodevi::smart_caching);90 break;91 case 'kernel-string':92 $property = new phodevi_device_property('sw_kernel_string', phodevi::smart_caching);93 break;94 case 'kernel-parameters':95 $property = new phodevi_device_property('sw_kernel_parameters', phodevi::std_caching);96 break;97 case 'compiler':98 $property = new phodevi_device_property('sw_compiler', phodevi::std_caching);99 break;100 case 'system-layer':101 $property = new phodevi_device_property('sw_system_layer', phodevi::std_caching);102 break;103 case 'environment-variables':104 $property = new phodevi_device_property('sw_environment_variables', phodevi::std_caching);105 break;106 }107 return $property;108 }109 public static function sw_username()110 {111 // Gets the system user's name112 if(function_exists('posix_getpwuid') && function_exists('posix_getuid'))113 {114 $userinfo = posix_getpwuid(posix_getuid());115 $username = $userinfo['name'];116 }117 else118 {119 $username = trim(getenv('USERNAME'));120 }121 return $username;122 }123 public static function sw_system_layer()124 {125 $layer = null;126 if(phodevi::is_windows() && pts_client::executable_in_path('winecfg.exe') && ($wine = phodevi::read_property('system', 'wine-version')))127 {128 $layer = $wine;129 }130 else131 {132 // Report virtualization133 $layer = phodevi::read_property('system', 'virtualized-mode');134 }135 return $layer;136 }137 public static function sw_hostname()138 {139 $hostname = 'Unknown';140 if(($bin = pts_client::executable_in_path('hostname')))141 {142 $hostname = trim(shell_exec($bin . ' 2>&1'));143 }144 else if(phodevi::is_windows())145 {146 $hostname = getenv('USERDOMAIN');147 }148 return $hostname;149 }150 public static function sw_vendor_identifier()151 {152 // Returns the vendor identifier used with the External Dependencies and other distro-specific features153 $vendor = phodevi::is_linux() ? phodevi_linux_parser::read_lsb_distributor_id() : false;154 if(!$vendor)155 {156 $vendor = phodevi::read_property('system', 'operating-system');157 if(($spos = strpos($vendor, ' ')) > 1)158 {159 $vendor = substr($vendor, 0, $spos);160 }161 }162 return str_replace(array(' ', '/'), '', strtolower($vendor));163 }164 public static function sw_filesystem()165 {166 // Determine file-system type167 $fs = null;168 if(phodevi::is_macosx())169 {170 $fs = phodevi_osx_parser::read_osx_system_profiler('SPSerialATADataType', 'FileSystem');171 if($fs == null && pts_client::executable_in_path('mount'))172 {173 $mount = shell_exec('mount 2>&1');174 if(stripos($mount, ' on / (hfs, local, journaled)') !== false)175 {176 $fs = 'Journaled HFS+';177 }178 else if(stripos($mount, ' on / (hfs') !== false)179 {180 $fs = 'HFS+';181 }182 }183 }184 else if(phodevi::is_bsd())185 {186 if(pts_client::executable_in_path('mount'))187 {188 $mount = shell_exec('mount 2>&1');189 if(($start = strpos($mount, 'on / (')) != false)190 {191 // FreeBSD, DragonflyBSD mount formatting192 /*193 -bash-4.0$ mount194 ROOT on / (hammer, local)195 /dev/da0s1a on /boot (ufs, local)196 /pfs/@@-1:00001 on /var (null, local)197 /pfs/@@-1:00002 on /tmp (null, local)198 /pfs/@@-1:00003 on /usr (null, local)199 /pfs/@@-1:00004 on /home (null, local)200 /pfs/@@-1:00005 on /usr/obj (null, local)201 /pfs/@@-1:00006 on /var/crash (null, local)202 /pfs/@@-1:00007 on /var/tmp (null, local)203 procfs on /proc (procfs, local)204 */205 // TODO: improve this in case there are other partitions, etc206 $fs = substr($mount, $start + 6);207 $fs = substr($fs, 0, strpos($fs, ','));208 }209 else if(($start = strpos($mount, 'on / type')) != false)210 {211 // OpenBSD 5.0 formatting is slightly different from above FreeBSD example212 // TODO: improve this in case there are other partitions, etc213 $fs = substr($mount, $start + 10);214 $fs = substr($fs, 0, strpos($fs, ' '));215 }216 }217 }218 else if(phodevi::is_hurd())219 {220 // Very rudimentary Hurd filesystem detection support but works for at least a clean Debian GNU/Hurd EXT2 install221 if(pts_client::executable_in_path('mount'))222 {223 $mount = shell_exec('mount 2>&1');224 if(($start = strpos($mount, 'on / type')) != false)225 {226 $fs = substr($mount, $start + 10);227 $fs = substr($fs, 0, strpos($fs, ' '));228 if(substr($fs, -2) == 'fs')229 {230 $fs = substr($fs, 0, -2);231 }232 }233 }234 }235 else if(phodevi::is_linux() || phodevi::is_solaris())236 {237 $fs = trim(shell_exec('stat ' . pts_client::test_install_root_path() . ' -L -f -c %T 2> /dev/null'));238 switch($fs)239 {240 case 'ext2/ext3':241 if(isset(phodevi::$vfs->mounts))242 {243 $fstab = phodevi::$vfs->mounts;244 $fstab = str_replace('/boot ', 'IGNORE', $fstab);245 $using_ext2 = strpos($fstab, ' ext2') !== false;246 $using_ext3 = strpos($fstab, ' ext3') !== false;247 $using_ext4 = strpos($fstab, ' ext4') !== false;248 if(!$using_ext2 && !$using_ext3 && $using_ext4)249 {250 $fs = 'ext4';251 }252 else if(!$using_ext2 && !$using_ext4 && $using_ext3)253 {254 $fs = 'ext3';255 }256 else if(!$using_ext3 && !$using_ext4 && $using_ext2)257 {258 $fs = 'ext2';259 }260 else if(is_dir('/proc/fs/ext4/'))261 {262 $fs = 'ext4';263 }264 else if(is_dir('/proc/fs/ext3/'))265 {266 $fs = 'ext3';267 }268 }269 break;270 case 'Case-sensitive Journaled HFS+':271 $fs = 'HFS+';272 break;273 case 'MS-DOS FAT32':274 $fs = 'FAT32';275 break;276 case 'UFSD_NTFS_COMPR':277 $fs = 'NTFS';278 break;279 case 'ecryptfs':280 if(isset(phodevi::$vfs->mounts))281 {282 // An easy attempt to determine what file-system is underneath ecryptfs if being compared283 // For now just attempt to figure out the root file-system.284 if(($s = strrpos(phodevi::$vfs->mounts, ' / ')) !== false)285 {286 $s = substr(phodevi::$vfs->mounts, ($s + 3));287 $s = substr($s, 0, strpos($s, ' '));288 if($s != null && !isset($s[18]) && $s != 'rootfs'&& pts_strings::string_only_contains($s, pts_strings::CHAR_LETTER | pts_strings::CHAR_NUMERIC))289 {290 $fs = $s . ' (ecryptfs)';291 }292 }293 }294 break;295 default:296 if(substr($fs, 0, 9) == 'UNKNOWN (')297 {298 $magic_block = substr($fs, 9, -1);299 $known_magic_blocks = array(300 '0x9123683e' => 'Btrfs',301 '0x2fc12fc1' => 'zfs', // KQ Infotech ZFS302 '0x482b' => 'HFS+',303 '0x65735546' => 'FUSE',304 '0x565a4653' => 'ReiserFS',305 '0x52345362' => 'Reiser4',306 '0x3434' => 'NILFS2',307 '0x5346414f' => 'OpenAFS',308 '0x47504653' => 'GPFS',309 '0x5941ff53' => 'YAFFS',310 '0xff534d42' => 'CIFS',311 '0x24051905' => 'UBIFS',312 '0x1021994' => 'TMPFS',313 '0x73717368' => 'SquashFS',314 '0xc97e8168' => 'LogFS',315 '0x5346544E' => 'NTFS',316 '0xf15f' => 'eCryptfs',317 '0x61756673' => 'AuFS',318 '0xbd00bd0' => 'Lustre',319 '0xaad7aaea' => 'PanFS', // Panasas FS320 '0xf2f52010' => 'F2FS',321 '0xc36400' => 'CephFS',322 '0xca451a4e' => 'BcacheFS'323 );324 foreach($known_magic_blocks as $hex => $name)325 {326 if($magic_block == $hex)327 {328 $fs = $name;329 break;330 }331 }332 }333 break;334 }335 if(strpos($fs, 'UNKNOWN') !== false && isset(phodevi::$vfs->mounts))336 {337 $mounts = phodevi::$vfs->mounts;338 $fs_r = array();339 $fs_checks = array(340 'squashfs' => 'SquashFS',341 'aufs' => 'AuFS',342 'unionfs' => 'UnionFS'343 );344 foreach($fs_checks as $fs_module => $fs_name)345 {346 if(strpos($mounts, $fs_module) != false)347 {348 array_push($fs_r, $fs_name);349 }350 }351 if(count($fs_r) > 0)352 {353 $fs = implode(' + ', $fs_r);354 }355 }356 }357 else if(phodevi::is_windows())358 {359 return null;360 }361 if(empty($fs))362 {363 $fs = 'Unknown';364 }365 return $fs;366 }367 public static function sw_virtualized_mode()368 {369 // Reports if system is running virtualized370 $virtualized = null;371 $mobo = phodevi::read_name('motherboard');372 $gpu = phodevi::read_name('gpu');373 $cpu = phodevi::read_property('cpu', 'model');374 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'))375 {376 $virtualized = 'QEMU';377 if(strpos($cpu, 'QEMU Virtual') !== false)378 {379 $qemu_version = substr($cpu, (strrpos($cpu, ' ') + 1));380 if(pts_strings::is_version($qemu_version))381 {382 $virtualized .= ' ' . $qemu_version;383 }384 }385 }386 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))387 {388 $virtualized = 'VMware';389 }390 else if(stripos($gpu, 'VirtualBox') !== false || stripos(phodevi::read_name('motherboard'), 'VirtualBox') !== false)391 {392 $virtualized = 'VirtualBox';393 if($vbox_manage = pts_client::executable_in_path('VBoxManage'))394 {395 $vbox_manage = trim(shell_exec($vbox_manage . ' --version 2> /dev/null'));396 if(is_numeric(substr($vbox_manage, 0, 1)))397 {398 $virtualized .= ' ' . $vbox_manage;399 }400 }401 else if($modinfo = pts_client::executable_in_path('modinfo'))402 {403 $modinfo = trim(shell_exec('modinfo -F version vboxguest 2> /dev/null'));404 if($modinfo != null && pts_strings::is_version(str_ireplace(array('_', 'RC', 'beta'), null, $modinfo)))405 {406 $virtualized .= ' ' . $modinfo;407 }408 }409 }410 else if(is_file('/sys/class/dmi/id/sys_vendor') && pts_file_io::file_get_contents('/sys/class/dmi/id/sys_vendor') == 'Xen')411 {412 $virtualized = pts_file_io::file_get_contents('/sys/class/dmi/id/product_name');413 if(strpos($virtualized, 'Xen') === false)414 {415 $virtualized = 'Xen ' . $virtualized;416 }417 // version string418 $virtualized .= ' ' . pts_file_io::file_get_contents('/sys/class/dmi/id/product_version');419 // $virtualized should be then e.g. 'Xen HVM domU 4.1.1'420 }421 else if(stripos($gpu, 'Microsoft Hyper-V') !== false)422 {423 $virtualized = 'Microsoft Hyper-V Server';424 }425 else if(stripos($mobo, 'Parallels Software') !== false)426 {427 $virtualized = 'Parallels Virtualization';428 }429 else if(is_file('/sys/hypervisor/type'))430 {431 $type = pts_file_io::file_get_contents('/sys/hypervisor/type');432 $version = array();433 foreach(array('major', 'minor', 'extra') as $v)434 {435 if(is_file('/sys/hypervisor/version/' . $v))436 {437 $v = pts_file_io::file_get_contents('/sys/hypervisor/version/' . $v);438 }439 else440 {441 continue;442 }443 if($v != null)444 {445 if(!empty($version) && substr($v, 0, 1) != '.')446 {447 $v = '.' . $v;448 }449 array_push($version, $v);450 }451 }452 $virtualized = ucwords($type) . ' ' . implode('', $version) . ' Hypervisor';453 }454 if($systemd_virt = pts_client::executable_in_path('systemd-detect-virt'))455 {456 $systemd_virt = trim(shell_exec($systemd_virt . ' 2> /dev/null'));457 if($systemd_virt != null && $systemd_virt != 'none')458 {459 switch($systemd_virt)460 {461 case 'kvm':462 $systemd_virt = 'KVM';463 break;464 case 'oracle':465 $systemd_virt = 'Oracle';466 break;467 }468 if($virtualized != null && stripos($virtualized, $systemd_virt) === false && stripos($systemd_virt, $virtualized) === false)469 {470 $virtualized = $systemd_virt . ' ' . $virtualized;471 }472 else if($virtualized == null)473 {474 $virtualized = $systemd_virt;475 }476 }477 }478 return $virtualized;479 }480 public static function sw_environment_variables()481 {482 $check_variables = array('LIBGL', '__GL', 'DRI_');483 $to_report = array();484 if(stripos(phodevi::read_property('system', 'opengl-driver'), 'Mesa'))485 {486 array_push($check_variables, 'MESA', 'GALLIUM');487 }488 if(isset($_SERVER))489 {490 foreach($_SERVER as $name => &$value)491 {492 foreach($check_variables as $var)493 {494 if(stripos($name, $var) !== false && $name != '__GL_SYNC_TO_VBLANK')495 {496 array_push($to_report, $name . '=' . $value);497 break;498 }499 }500 }501 }502 return implode(' ', array_unique($to_report));503 }504 public static function sw_compiler()505 {506 // Returns version of the compiler (if present)507 $compilers = array();508 if($gcc = pts_client::executable_in_path('gcc'))509 {510 if(!is_link($gcc) || strpos(readlink($gcc), 'gcc') !== false)511 {512 // GCC513 // If it's a link, ensure that it's not linking to llvm/clang or something514 $version = trim(shell_exec('gcc -dumpversion 2>&1'));515 if(pts_strings::is_version($version))516 {517 $v = shell_exec('gcc -v 2>&1');518 if(($t = strrpos($v, $version . ' ')) !== false)519 {520 $v = substr($v, ($t + strlen($version) + 1));521 $v = substr($v, 0, strpos($v, ' '));522 if($v != null && is_numeric($v))523 {524 // On development versions the release date is expressed525 // e.g. gcc version 4.7.0 20120314 (prerelease) (GCC)526 $version .= ' ' . $v;527 }528 else529 {530 $v = shell_exec('gcc --version 2>&1');531 if(($t = strrpos($v, $version)) !== false)532 {533 $v = substr($v, $t);534 $v = substr($v, 0, strpos(str_replace(PHP_EOL, ' ', $v), ' '));535 if(($t = strpos($v, ')')) !== false)536 {537 $v = substr($v, 0, $t);538 }539 if(pts_strings::is_version($version))540 {541 $version = $v;542 }543 }544 }545 }546 $compilers['gcc'] = 'GCC ' . $version;547 }548 }549 }550 if(pts_client::executable_in_path('opencc'))551 {552 // Open64553 $compilers['opencc'] = 'Open64 ' . trim(shell_exec('opencc -dumpversion 2>&1'));554 }555 if(pts_client::executable_in_path('pathcc'))556 {557 // PathCC / EKOPath / PathScale Compiler Suite558 $compilers['pathcc'] = 'PathScale ' . trim(shell_exec('pathcc -dumpversion 2>&1'));559 }560 if(pts_client::executable_in_path('tcc'))561 {562 // TCC - Tiny C Compiler563 $tcc = explode(' ', trim(shell_exec('tcc -v 2>&1')));564 if($tcc[1] == 'version')565 {566 $compilers['opencc'] = 'TCC ' . $tcc[2];567 }568 }569 if(pts_client::executable_in_path('pcc'))570 {571 // PCC - Portable C Compiler572 $pcc = explode(' ', trim(shell_exec('pcc -version 2>&1')));573 if($pcc[0] == 'pcc')574 {575 $compilers['pcc'] = 'PCC ' . $pcc[1] . (is_numeric($pcc[2]) ? ' ' . $pcc[2] : null);576 }577 }578 if(pts_client::executable_in_path('pgcpp') || pts_client::executable_in_path('pgCC'))579 {580 // The Portland Group Compilers581 $compilers['pgcpp'] = 'PGI C-C++ Workstation';582 }583 if(pts_client::executable_in_path('clang'))584 {585 // Clang586 $compiler_info = shell_exec('clang --version 2> /dev/null');587 if(($cv_pos = stripos($compiler_info, 'clang version')) !== false)588 {589 // With Clang 3.0 and prior, the --version produces output where the first line is:590 // e.g. clang version 3.0 (branches/release_30 142590)591 $compiler_info = substr($compiler_info, ($cv_pos + 14));592 $clang_version = substr($compiler_info, 0, strpos($compiler_info, ' '));593 // XXX: the below check bypass now because e.g. Ubuntu appends '-ubuntuX', etc that breaks check594 if(pts_strings::is_version($clang_version) || true)595 {596 // Also see if there is a Clang SVN tag to fetch597 $compiler_info = substr($compiler_info, 0, strpos($compiler_info, PHP_EOL));598 if(($cv_pos = strpos($compiler_info, ')')) !== false)599 {600 $compiler_info = substr($compiler_info, 0, $cv_pos);601 $compiler_info = substr($compiler_info, (strrpos($compiler_info, ' ') + 1));602 if(is_numeric($compiler_info))603 {604 // Right now Clang/LLVM uses SVN system and their revisions are only numeric605 $clang_version .= ' (SVN ' . $compiler_info . ')';606 }607 }608 $compiler_info = 'Clang ' . $clang_version;609 }610 else611 {612 $compiler_info = null;613 }614 }615 else616 {617 $compiler_info = substr($compiler_info, 0, strpos($compiler_info, PHP_EOL));618 }619 // Clang620 if(empty($compiler_info) && stripos($compiler_info, 'not found'))621 {622 // At least with Clang ~3.0 the -dumpversion is reporting '4.2.1' ratherthan the useful information...623 // This is likely just for GCC command compatibility, so only use this as a fallback624 $compiler_info = 'Clang ' . trim(shell_exec('clang -dumpversion 2> /dev/null'));625 }626 $compilers['clang'] = $compiler_info;627 }628 if(($llvm_ld = pts_client::executable_in_path('llvm-link')) || ($llvm_ld = pts_client::executable_in_path('llvm-ld')))629 {630 // LLVM - Low Level Virtual Machine631 // Reading the version from llvm-ld (the LLVM linker) should be safe as well for finding out version of LLVM in use632 // As of LLVM 3.2svn, llvm-ld seems to be llvm-link633 $info = trim(shell_exec($llvm_ld . ' -version 2> /dev/null'));634 if(($s = strpos($info, 'version')) != false)635 {636 $info = substr($info, 0, strpos($info, PHP_EOL, $s));637 $info = substr($info, (strrpos($info, ' ') + 1));638 if(pts_strings::is_version(str_replace('svn', null, $info)))639 {640 $compilers['llvmc'] = 'LLVM ' . $info;641 }642 }643 }644 else if(pts_client::executable_in_path('llvm-config'))645 {646 // LLVM - Low Level Virtual Machine config647 $info = trim(shell_exec('llvm-config --version 2> /dev/null'));648 if(pts_strings::is_version(str_replace('svn', null, $info)))649 {650 $compilers['llvmc'] = 'LLVM ' . $info;651 }652 }653 else if(pts_client::executable_in_path('llvmc'))654 {655 // LLVM - Low Level Virtual Machine (llvmc)656 $info = trim(shell_exec('llvmc -version 2>&1'));657 if(($s = strpos($info, 'version')) != false)658 {659 $info = substr($info, 0, strpos($info, "\n", $s));660 $info = substr($info, strrpos($info, "\n"));661 $compilers['llvmc'] = trim($info);662 }663 }664 if(pts_client::executable_in_path('suncc'))665 {666 // Sun Studio / SunCC667 $info = trim(shell_exec('suncc -V 2>&1'));668 if(($s = strpos($info, 'Sun C')) != false)669 {670 $info = substr($info, $s);671 $info = substr($info, 0, strpos($info, "\n"));672 $compilers['suncc'] = $info;673 }674 }675 if(pts_client::executable_in_path('ioc'))676 {677 // Intel Offline Compiler (IOC) SDK for OpenCL678 // -v e.g. : Intel(R) SDK for OpenCL* - Offline Compiler 2012 Command-Line Client, version 1.0.2679 $info = trim(shell_exec('ioc -version 2>&1')) . ' ';680 if(($s = strpos($info, 'Offline Compiler ')) != false)681 {682 $compilers['ioc'] = 'Intel IOC SDK';683 $sv = substr($info, ($s + 17));684 $sv = substr($sv, 0, strpos($sv, ' '));685 if(is_numeric($sv))686 {687 $compilers['ioc'] .= ' ' . $sv;688 }689 if(($s = strpos($info, 'version ')) != false)690 {691 $sv = substr($info, ($s + 8));692 $sv = substr($sv, 0, strpos($sv, ' '));693 if(pts_strings::is_version($sv))694 {695 $compilers['ioc'] .= ' v' . $sv;696 }697 }698 }699 }700 if(pts_client::executable_in_path('icc'))701 {702 // Intel C++ Compiler703 $compilers['icc'] = 'ICC';704 }705 if(phodevi::is_macosx() && pts_client::executable_in_path('xcodebuild'))706 {707 $xcode = phodevi_osx_parser::read_osx_system_profiler('SPDeveloperToolsDataType', 'Xcode');708 $xcode = substr($xcode, 0, strpos($xcode, ' '));709 if($xcode)710 {711 $compilers['Xcode'] = 'Xcode ' . $xcode;712 }713 }714 if(($nvcc = pts_client::executable_in_path('nvcc')) || is_executable(($nvcc = '/usr/local/cuda/bin/nvcc')))715 {716 // Check outside of PATH too since by default the CUDA Toolkit goes to '/usr/local/cuda/' and relies upon user to update system717 // NVIDIA CUDA Compiler Driver718 $nvcc = shell_exec($nvcc . ' --version 2>&1');719 if(($s = strpos($nvcc, 'release ')) !== false)720 {721 $nvcc = str_replace(array(','), null, substr($nvcc, ($s + 8)));722 $nvcc = substr($nvcc, 0, strpos($nvcc, ' '));723 if(pts_strings::is_version($nvcc))724 {725 $compilers['CUDA'] = 'CUDA ' . $nvcc;726 }727 }728 }729 // Try to make the compiler that's used by default to appear first730 if(pts_client::read_env('CC') && isset($compilers[basename(pts_strings::first_in_string(pts_client::read_env('CC'), ' '))]))731 {732 $cc_env = basename(pts_strings::first_in_string(pts_client::read_env('CC'), ' '));733 $default_compiler = $compilers[$cc_env];734 unset($compilers[$cc_env]);735 array_unshift($compilers, $default_compiler);736 }737 else if(pts_client::executable_in_path('cc') && is_link(pts_client::executable_in_path('cc')))738 {739 $cc_link = basename(readlink(pts_client::executable_in_path('cc')));740 if(isset($compilers[$cc_link]))741 {742 $default_compiler = $compilers[$cc_link];743 unset($compilers[pts_client::read_env('CC')]);744 array_unshift($compilers, $default_compiler);745 }746 }747 return implode(' + ', array_unique($compilers));748 }749 public static function sw_kernel_string()750 {751 return trim(phodevi::read_property('system', 'kernel') . ' (' . phodevi::read_property('system', 'kernel-architecture') . ') ' . phodevi::read_property('system', 'kernel-date'));752 }753 public static function sw_kernel_date()754 {755 $date = null;756 $k = phodevi::read_property('system', 'kernel');757 if(strpos($k, '99') !== false || stripos($k, 'rc') !== false)758 {759 // For now at least only report kernel build date when it looks like it's a devel kernel760 $v = php_uname('v');761 if(($x = stripos($v, 'SMP ')) !== false)762 {763 $v = substr($v, ($x + 4));764 $date = strtotime($v);765 if($date != false)766 {767 $date = date('Ymd', $date);768 }769 }770 }771 return $date;772 }773 public static function sw_kernel()774 {775 return php_uname('r');776 }777 public static function sw_kernel_parameters()778 {779 $parameters = null;780 if(is_file('/proc/cmdline') && is_file('/proc/modules'))781 {782 $modules = array();783 foreach(explode(PHP_EOL, pts_file_io::file_get_contents('/proc/modules')) as $module_line)784 {785 $module_line = explode(' ', $module_line);786 if(isset($module_line[0]) && !empty($module_line[0]))787 {788 array_push($modules, $module_line[0]);789 }790 }791 if(!empty($modules))792 {793 $to_report = array();794 $cmdline = explode(' ', pts_file_io::file_get_contents('/proc/cmdline'));795 foreach($cmdline as $option)796 {797 if(($t = strpos($option, '.')) !== false)798 {799 if(in_array(substr($option, 0, $t), $modules))800 {801 array_push($to_report, $option);802 }803 }804 }805 if(!empty($to_report))806 {807 $parameters = implode(' ', $to_report);808 }809 }810 }811 return $parameters;812 }813 public static function sw_kernel_architecture()814 {815 // Find out the kernel archiecture816 if(phodevi::is_windows())817 {818 //$kernel_arch = strpos($_SERVER['PROCESSOR_ARCHITECTURE'], 64) !== false || strpos($_SERVER['PROCESSOR_ARCHITEW6432'], 64 != false) ? 'x86_64' : 'i686';819 if(isset($_SERVER['PROCESSOR_ARCHITEW6432']))820 {821 $kernel_arch = $_SERVER['PROCESSOR_ARCHITEW6432'] == 'AMD64' ? 'x86_64' : 'i686';822 }823 else824 {825 $kernel_arch = 'x86_64';826 }827 }828 else829 {830 $kernel_arch = php_uname('m');831 switch($kernel_arch)832 {833 case 'X86-64':834 case 'amd64':835 $kernel_arch = 'x86_64';836 break;837 case 'i86pc':838 case 'i586':839 case 'i686-AT386':840 $kernel_arch = 'i686';841 break;842 }843 }844 return $kernel_arch;845 }846 public static function sw_os_version()847 {848 // Returns OS version849 if(phodevi::is_macosx())850 {851 $os = phodevi_osx_parser::read_osx_system_profiler('SPSoftwareDataType', 'SystemVersion');852 853 $start_pos = strpos($os, '.');854 $end_pos = strrpos($os, '.');855 $start_pos = strrpos(substr($os, 0, $start_pos), ' ');856 $end_pos = strpos($os, ' ', $end_pos);857 858 $os_version = substr($os, $start_pos + 1, $end_pos - $start_pos);859 }860 else if(phodevi::is_linux())861 {862 $os_version = phodevi_linux_parser::read_lsb('Release');863 if($os_version == null)864 {865 if(is_readable('/etc/os-release'))866 $os_release = parse_ini_file('/etc/os-release');867 else if(is_readable('/usr/lib/os-release'))868 $os_release = parse_ini_file('/usr/lib/os-release');869 else870 $os_release = null;871 if(isset($os_release['VERSION_ID']) && !empty($os_release['VERSION_ID']))872 {873 $os_version = $os_release['VERSION_ID'];874 }875 else if(isset($os_release['VERSION']) && !empty($os_release['VERSION']))876 {877 $os_version = $os_release['VERSION'];878 }879 $os_version = pts_strings::keep_in_string($os_version, pts_strings::CHAR_LETTER | pts_strings::CHAR_NUMERIC | pts_strings::CHAR_DECIMAL | pts_strings::CHAR_SPACE | pts_strings::CHAR_DASH | pts_strings::CHAR_UNDERSCORE);880 }881 }882 else883 {884 $os_version = php_uname('r');885 }886 887 return $os_version;888 }889 public static function sw_operating_system()890 {891 if(!PTS_IS_CLIENT)892 {893 // TODO: Figure out why this function is sometimes called from OpenBenchmarking.org....894 return false;895 }896 // Determine the operating system release897 if(phodevi::is_linux())898 {899 $vendor = phodevi_linux_parser::read_lsb_distributor_id();900 if($vendor == null)901 {902 if(is_readable('/etc/os-release'))903 $os_release = parse_ini_file('/etc/os-release');904 else if(is_readable('/usr/lib/os-release'))905 $os_release = parse_ini_file('/usr/lib/os-release');906 else907 $os_release = null;908 if(isset($os_release['PRETTY_NAME']) && !empty($os_release['PRETTY_NAME']))909 {910 $vendor = $os_release['PRETTY_NAME'];911 }912 else if(isset($os_release['NAME']) && !empty($os_release['NAME']))913 {914 $vendor = $os_release['NAME'];915 }916 }917 if(($x = stripos($vendor, ' for ')) !== false)918 {919 $vendor = substr($vendor, 0, $x);920 }921 $vendor = str_replace(array(' Software'), null, $vendor);922 }923 else if(phodevi::is_hurd())924 {925 $vendor = php_uname('v');926 }927 else928 {929 $vendor = null;930 }931 $version = phodevi::read_property('system', 'os-version');932 if(!$vendor)933 {934 $os = null;935 // Try to detect distro for those not supplying lsb_release936 $files = pts_file_io::glob('/etc/*-version');937 for($i = 0; $i < count($files) && $os == null; $i++)938 {939 $file = file_get_contents($files[$i]);940 if(trim($file) != null)941 {942 $os = substr($file, 0, strpos($file, "\n"));943 }944 }945 946 if($os == null)947 {948 $files = pts_file_io::glob('/etc/*-release');949 for($i = 0; $i < count($files) && $os == null; $i++)950 {951 $file = file_get_contents($files[$i]);952 if(trim($file) != null)953 {954 $proposed_os = substr($file, 0, strpos($file, PHP_EOL));955 if(strpos($proposed_os, '=') == false)956 {957 $os = $proposed_os;958 }959 }960 else if($i == (count($files) - 1))961 {962 $os = ucwords(substr(($n = basename($files[$i])), 0, strpos($n, '-')));963 } 964 }965 }966 if($os == null && is_file('/etc/release'))967 {968 $file = file_get_contents('/etc/release');969 $os = substr($file, 0, strpos($file, "\n"));970 }971 if($os == null && is_file('/etc/palm-build-info'))972 {973 // Palm / webOS Support974 $os = phodevi_parser::parse_equal_delimited_file('/etc/palm-build-info', 'PRODUCT_VERSION_STRING');975 }976 if($os == null)977 {978 if(phodevi::is_windows())979 {980 $os = trim(exec('ver'));981 }982 if(is_file('/etc/debian_version'))983 {984 $os = 'Debian ' . php_uname('s') . ' ' . ucwords(pts_file_io::file_get_contents('/etc/debian_version'));985 }986 else987 {988 $os = php_uname('s');989 }990 }991 else if(strpos($os, ' ') === false)992 {993 // The OS string is only one word, likely a problem...994 if(is_file('/etc/arch-release') && stripos($os, 'Arch') === false)995 {996 // On at least some Arch installs (ARM) the file is empty so would have missed above check997 $os = trim('Arch Linux ' . $os);998 }999 }1000 }1001 else if(stripos($vendor, $version) === false)1002 {1003 $os = $vendor . ' ' . $version;1004 }1005 else1006 {1007 $os = $vendor;1008 }1009 if(($break_point = strpos($os, ':')) > 0)1010 {1011 $os = substr($os, $break_point + 1);1012 }1013 1014 if(phodevi::is_macosx())1015 {1016 $os = phodevi_osx_parser::read_osx_system_profiler('SPSoftwareDataType', 'SystemVersion');1017 }1018 if(($break_point = strpos($os, '(')) > 0)1019 {1020 $os = substr($os, 0, $break_point);1021 }1022 $os = trim($os);1023 return $os;1024 }1025 public static function sw_desktop_environment()1026 {1027 $desktop = null;1028 $desktop_environment = null;1029 $desktop_version = null;1030 $desktop_session = pts_client::read_env('DESKTOP_SESSION');1031 if(pts_client::is_process_running('gnome-shell'))1032 {1033 // GNOME 3.0 / GNOME Shell1034 $desktop_environment = 'GNOME Shell';1035 if(pts_client::executable_in_path('gnome-shell'))1036 {1037 $desktop_version = pts_strings::last_in_string(trim(shell_exec('gnome-shell --version 2> /dev/null')));1038 }1039 }...

Full Screen

Full Screen

sw_desktop_environment

Using AI Code Generation

copy

Full Screen

1$sw_desktop_environment = phodevi::read_property('system', 'sw_desktop_environment');2echo $sw_desktop_environment;3$sw_desktop_environment = phodevi::read_property('system', 'sw_desktop_environment');4echo $sw_desktop_environment;5$sw_desktop_environment = phodevi::read_property('system', 'sw_desktop_environment');6echo $sw_desktop_environment;7$sw_desktop_environment = phodevi::read_property('system', 'sw_desktop_environment');8echo $sw_desktop_environment;9$sw_desktop_environment = phodevi::read_property('system', 'sw_desktop_environment');10echo $sw_desktop_environment;11$sw_desktop_environment = phodevi::read_property('system', 'sw_desktop_environment');12echo $sw_desktop_environment;13$sw_desktop_environment = phodevi::read_property('system', 'sw_desktop_environment');14echo $sw_desktop_environment;15$sw_desktop_environment = phodevi::read_property('system', 'sw_desktop_environment');16echo $sw_desktop_environment;17$sw_desktop_environment = phodevi::read_property('system', 'sw_desktop_environment');18echo $sw_desktop_environment;19$sw_desktop_environment = phodevi::read_property('system', 'sw_desktop_environment');20echo $sw_desktop_environment;

Full Screen

Full Screen

sw_desktop_environment

Using AI Code Generation

copy

Full Screen

1$desktop_environment = phodevi::read_property('system', 'sw_desktop_environment');2echo 'Desktop Environment: ' . $desktop_environment;3$desktop_environment = phodevi::read_property('system', 'sw_desktop_environment');4echo 'Desktop Environment: ' . $desktop_environment;5$desktop_environment = phodevi::read_property('system', 'sw_desktop_environment');6echo 'Desktop Environment: ' . $desktop_environment;7$desktop_environment = phodevi::read_property('system', 'sw_desktop_environment');8echo 'Desktop Environment: ' . $desktop_environment;9$desktop_environment = phodevi::read_property('system', 'sw_desktop_environment');10echo 'Desktop Environment: ' . $desktop_environment;11$desktop_environment = phodevi::read_property('system', 'sw_desktop_environment');12echo 'Desktop Environment: ' . $desktop_environment;13$desktop_environment = phodevi::read_property('system', 'sw_desktop_environment');14echo 'Desktop Environment: ' . $desktop_environment;15$desktop_environment = phodevi::read_property('system', 'sw_desktop_environment');16echo 'Desktop Environment: ' . $desktop_environment;17$desktop_environment = phodevi::read_property('system', 'sw_desktop_environment');18echo 'Desktop Environment: ' . $desktop_environment;19$desktop_environment = phodevi::read_property('system', 'sw_desktop_environment');

Full Screen

Full Screen

sw_desktop_environment

Using AI Code Generation

copy

Full Screen

1$desktop = phodevi::read_property('system', 'sw_desktop_environment');2";3$desktop = phodevi::read_property('system', 'sw_desktop_environment');4";5$desktop = phodevi::read_property('system', 'sw_desktop_environment');6";7$desktop = phodevi::read_property('system', 'sw_desktop_environment');8";9$desktop = phodevi::read_property('system', 'sw_desktop_environment');10";11$desktop = phodevi::read_property('system', 'sw_desktop_environment');12";13$desktop = phodevi::read_property('system', 'sw_desktop_environment');14";15$desktop = phodevi::read_property('system', 'sw_desktop_environment');16";17$desktop = phodevi::read_property('system', 'sw_desktop_environment');18";19$desktop = phodevi::read_property('system', 'sw_desktop_environment');20";

Full Screen

Full Screen

sw_desktop_environment

Using AI Code Generation

copy

Full Screen

1require_once('phodevi.php');2$desktop = phodevi_system::sw_desktop_environment();3echo $desktop;4require_once('phodevi.php');5$desktop = phodevi_system::sw_desktop_environment();6echo $desktop;7require_once('phodevi.php');8$desktop = phodevi_system::sw_desktop_environment();9echo $desktop;10require_once('phodevi.php');11$desktop = phodevi_system::sw_desktop_environment();12echo $desktop;13require_once('phodevi.php');14$desktop = phodevi_system::sw_desktop_environment();15echo $desktop;16require_once('phodevi.php');17$desktop = phodevi_system::sw_desktop_environment();18echo $desktop;19require_once('phodevi.php');20$desktop = phodevi_system::sw_desktop_environment();21echo $desktop;22require_once('phodevi.php');23$desktop = phodevi_system::sw_desktop_environment();24echo $desktop;25require_once('phodevi.php');26$desktop = phodevi_system::sw_desktop_environment();27echo $desktop;28require_once('phodevi.php');29$desktop = phodevi_system::sw_desktop_environment();30echo $desktop;

Full Screen

Full Screen

sw_desktop_environment

Using AI Code Generation

copy

Full Screen

1$desktop_environment = phodevi_system::sw_desktop_environment();2echo $desktop_environment;3$desktop_environment = phodevi_system::sw_desktop_environment();4echo $desktop_environment;5$desktop_environment = phodevi_system::sw_desktop_environment();6echo $desktop_environment;7$desktop_environment = phodevi_system::sw_desktop_environment();8echo $desktop_environment;9$desktop_environment = phodevi_system::sw_desktop_environment();10echo $desktop_environment;11$desktop_environment = phodevi_system::sw_desktop_environment();12echo $desktop_environment;13$desktop_environment = phodevi_system::sw_desktop_environment();14echo $desktop_environment;15$desktop_environment = phodevi_system::sw_desktop_environment();16echo $desktop_environment;17$desktop_environment = phodevi_system::sw_desktop_environment();18echo $desktop_environment;19$desktop_environment = phodevi_system::sw_desktop_environment();20echo $desktop_environment;

Full Screen

Full Screen

sw_desktop_environment

Using AI Code Generation

copy

Full Screen

1$desktop_env = phodevi_system::sw_desktop_environment();2echo "Desktop Environment: " . $desktop_env;3$os = phodevi_system::sw_os();4echo "Operating System: " . $os;5$os_version = phodevi_system::sw_os_version();6echo "Operating System Version: " . $os_version;7$os_version_codename = phodevi_system::sw_os_version_codename();8echo "Operating System Version Codename: " . $os_version_codename;9$os_version_kernel = phodevi_system::sw_os_version_kernel();10echo "Operating System Version Kernel: " . $os_version_kernel;11$os_version_release = phodevi_system::sw_os_version_release();12echo "Operating System Version Release: " . $os_version_release;13$os_version_serial = phodevi_system::sw_os_version_serial();14echo "Operating System Version Serial: " . $os_version_serial;15$os_version_installation = phodevi_system::sw_os_version_installation();16echo "Operating System Version Installation: " . $os_version_installation;

Full Screen

Full Screen

sw_desktop_environment

Using AI Code Generation

copy

Full Screen

1require_once('/usr/share/php/phodevi/phodevi.php');2echo phodevi_system::sw_desktop_environment();3#0 {main}4$desktop = getenv("XDG_CURRENT_DESKTOP");5if ( $desktop == "GNOME" ) {6 $desktop = "GNOME";7} elseif ( $desktop == "KDE" ) {8 $desktop = "KDE";9} elseif ( $desktop == "Unity" ) {10 $desktop = "Unity";11} elseif ( $desktop == "XFCE" ) {12 $desktop = "XFCE";13} elseif ( $desktop == "LXDE" ) {14 $desktop = "LXDE";15} elseif ( $desktop == "MATE" ) {16 $desktop = "MATE";17} elseif ( $desktop == "Cinnamon" ) {18 $desktop = "Cinnamon";19} else {20 $desktop = "Unknown";21}22echo $desktop;23PHP Fatal error: Uncaught Error: Call to undefined function getenv() in /home/username/2.php:224#0 {main}25$desktop = getenv("XDG_CURRENT_DESKTOP");26if ( $desktop == "GNOME" ) {27 $desktop = "GNOME";28} elseif ( $desktop == "KDE" ) {29 $desktop = "KDE";30} elseif ( $desktop == "Unity" ) {31 $desktop = "Unity";32} elseif ( $desktop == "XFCE" ) {33 $desktop = "XFCE";34} elseif ( $desktop == "LXDE" )

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Phoronix-test-suite automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Trigger sw_desktop_environment code on LambdaTest Cloud Grid

Execute automation tests with sw_desktop_environment on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful