How to use battery method of phodevi_system class

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

phodevi_system.php

Source:phodevi_system.php Github

copy

Full Screen

...50 'system-layer' => new phodevi_device_property('sw_system_layer', phodevi::no_caching),51 'environment-variables' => new phodevi_device_property('sw_environment_variables', phodevi::std_caching),52 'security-features' => new phodevi_device_property('sw_security_features', phodevi::std_caching),53 'kernel-extra-details' => new phodevi_device_property('sw_kernel_extra_details', phodevi::std_caching),54 'battery' => new phodevi_device_property('battery', phodevi::smart_caching),55 'platform-profile' => new phodevi_device_property('sw_platform_profile', phodevi::std_caching),56 );57 }58 public static function sw_username()59 {60 // Gets the system user's name61 if(function_exists('posix_getpwuid') && function_exists('posix_getuid'))62 {63 $userinfo = posix_getpwuid(posix_getuid());64 $username = $userinfo['name'];65 }66 else67 {68 $username = trim(getenv('USERNAME'));69 }70 return $username;71 }72 public static function sw_platform_profile()73 {74 $platform_profile = '';75 if(phodevi::is_linux())76 {77 if(is_file('/sys/firmware/acpi/platform_profile'))78 {79 $platform_profile = pts_file_io::file_get_contents('/sys/firmware/acpi/platform_profile');80 }81 }82 return $platform_profile;83 }84 public static function sw_kernel_extra_details()85 {86 $extra = array();87 if(phodevi::is_linux())88 {89 if(is_file('/sys/kernel/mm/transparent_hugepage/enabled'))90 {91 $thp_enabled = file_get_contents('/sys/kernel/mm/transparent_hugepage/enabled');92 if(($x = strpos($thp_enabled, '[')) !== false)93 {94 $thp_enabled = substr($thp_enabled, $x + 1);95 if(($x = strpos($thp_enabled, ']')) !== false)96 {97 $thp_enabled = trim(substr($thp_enabled, 0, $x));98 if(!empty($thp_enabled))99 {100 $extra[] = 'Transparent Huge Pages: ' . $thp_enabled;101 }102 }103 }104 }105 }106 return implode(' - ', $extra);107 }108 public static function sw_system_layer()109 {110 $layer = null;111 if(phodevi::is_windows() && pts_client::executable_in_path('winecfg.exe') && ($wine = phodevi::read_property('system', 'wine-version')))112 {113 $layer = $wine;114 }115 else if((getenv('USE_WINE') || getenv('WINE_VERSION') || self::$report_wine_override) && ($wine = phodevi::read_property('system', 'wine-version')))116 {117 $layer = $wine;118 }119 else120 {121 // Report virtualization122 $layer = phodevi::read_property('system', 'virtualized-mode');123 }124 if(empty($layer) && is_file('/proc/version'))125 {126 if(stripos(file_get_contents('/proc/version'), 'Microsoft') !== false && stripos(file_get_contents('/proc/mounts'), 'lxfs') !== false)127 {128 // Microsoft Windows Subsystem for Linux129 $layer = 'WSL';130 }131 }132 return $layer;133 }134 public static function sw_hostname()135 {136 $hostname = 'Unknown';137 if(($bin = pts_client::executable_in_path('hostname')))138 {139 $hostname = trim(shell_exec($bin . ' 2>&1'));140 }141 else if(phodevi::is_windows())142 {143 $hostname = getenv('USERDOMAIN');144 }145 return $hostname;146 }147 public static function sw_vendor_identifier()148 {149 // Returns the vendor identifier used with the External Dependencies and other distro-specific features150 $vendor = phodevi::is_linux() ? phodevi_linux_parser::read_lsb_distributor_id() : false;151 if(!$vendor)152 {153 $vendor = phodevi::read_property('system', 'operating-system');154 if(($spos = strpos($vendor, ' ')) > 1)155 {156 $vendor = substr($vendor, 0, $spos);157 }158 }159 return str_replace(array(' ', '/'), '', strtolower($vendor));160 }161 public static function sw_filesystem()162 {163 // Determine file-system type164 $fs = null;165 if(phodevi::is_macos())166 {167 $fs = phodevi_osx_parser::read_osx_system_profiler('SPSerialATADataType', 'FileSystem', false, array('MS-DOS FAT32'));168 if($fs == null && pts_client::executable_in_path('mount'))169 {170 $mount = shell_exec('mount 2>&1');171 if(stripos($mount, ' on / (hfs, local, journaled)') !== false)172 {173 $fs = 'Journaled HFS+';174 }175 else if(stripos($mount, ' on / (hfs') !== false)176 {177 $fs = 'HFS+';178 }179 else if(stripos($mount, ' on / (apfs') !== false)180 {181 $fs = 'APFS';182 }183 }184 }185 else if(phodevi::is_bsd())186 {187 if(pts_client::executable_in_path('mount'))188 {189 $mount = shell_exec('mount 2>&1');190 if(($start = strpos($mount, 'on / (')) != false)191 {192 // FreeBSD, DragonflyBSD mount formatting193 /*194 -bash-4.0$ mount195 ROOT on / (hammer, local)196 /dev/da0s1a on /boot (ufs, local)197 /pfs/@@-1:00001 on /var (null, local)198 /pfs/@@-1:00002 on /tmp (null, local)199 /pfs/@@-1:00003 on /usr (null, local)200 /pfs/@@-1:00004 on /home (null, local)201 /pfs/@@-1:00005 on /usr/obj (null, local)202 /pfs/@@-1:00006 on /var/crash (null, local)203 /pfs/@@-1:00007 on /var/tmp (null, local)204 procfs on /proc (procfs, local)205 */206 // TODO: improve this in case there are other partitions, etc207 $fs = substr($mount, $start + 6);208 $fs = substr($fs, 0, strpos($fs, ','));209 }210 else if(($start = strpos($mount, 'on / type')) != false)211 {212 // OpenBSD 5.0 formatting is slightly different from above FreeBSD example213 // TODO: improve this in case there are other partitions, etc214 $fs = substr($mount, $start + 10);215 $fs = substr($fs, 0, strpos($fs, ' '));216 }217 }218 }219 else if(phodevi::is_hurd())220 {221 // Very rudimentary Hurd filesystem detection support but works for at least a clean Debian GNU/Hurd EXT2 install222 if(pts_client::executable_in_path('mount'))223 {224 $mount = shell_exec('mount 2>&1');225 if(($start = strpos($mount, 'on / type')) != false)226 {227 $fs = substr($mount, $start + 10);228 $fs = substr($fs, 0, strpos($fs, ' '));229 if(substr($fs, -2) == 'fs')230 {231 $fs = substr($fs, 0, -2);232 }233 }234 }235 }236 else if(phodevi::is_linux() || phodevi::is_solaris())237 {238 $fs = trim(shell_exec('stat ' . pts_client::test_install_root_path() . ' -L -f -c %T 2> /dev/null'));239 switch($fs)240 {241 case 'ext2/ext3':242 if(isset(phodevi::$vfs->mounts))243 {244 $fstab = phodevi::$vfs->mounts;245 $fstab = str_replace('/boot ', 'IGNORE', $fstab);246 $using_ext2 = strpos($fstab, ' ext2') !== false;247 $using_ext3 = strpos($fstab, ' ext3') !== false;248 $using_ext4 = strpos($fstab, ' ext4') !== false;249 if(!$using_ext2 && !$using_ext3 && $using_ext4)250 {251 $fs = 'ext4';252 }253 else if(!$using_ext2 && !$using_ext4 && $using_ext3)254 {255 $fs = 'ext3';256 }257 else if(!$using_ext3 && !$using_ext4 && $using_ext2)258 {259 $fs = 'ext2';260 }261 else if(is_dir('/proc/fs/ext4/'))262 {263 $fs = 'ext4';264 }265 else if(is_dir('/proc/fs/ext3/'))266 {267 $fs = 'ext3';268 }269 }270 break;271 case 'Case-sensitive Journaled HFS+':272 $fs = 'HFS+';273 break;274 case 'MS-DOS FAT32':275 $fs = 'FAT32';276 break;277 case 'UFSD_NTFS_COMPR':278 $fs = 'NTFS';279 break;280 case 'ecryptfs':281 if(isset(phodevi::$vfs->mounts))282 {283 // An easy attempt to determine what file-system is underneath ecryptfs if being compared284 // For now just attempt to figure out the root file-system.285 if(($s = strrpos(phodevi::$vfs->mounts, ' / ')) !== false)286 {287 $s = substr(phodevi::$vfs->mounts, ($s + 3));288 $s = substr($s, 0, strpos($s, ' '));289 if($s != null && !isset($s[18]) && $s != 'rootfs'&& pts_strings::string_only_contains($s, pts_strings::CHAR_LETTER | pts_strings::CHAR_NUMERIC))290 {291 $fs = $s . ' (ecryptfs)';292 }293 }294 }295 break;296 default:297 if(substr($fs, 0, 9) == 'UNKNOWN (')298 {299 $magic_block = substr($fs, 9, -1);300 $known_magic_blocks = array(301 '0x9123683e' => 'Btrfs',302 '0x2fc12fc1' => 'zfs', // KQ Infotech ZFS303 '0x482b' => 'HFS+',304 '0x65735546' => 'FUSE',305 '0x565a4653' => 'ReiserFS',306 '0x52345362' => 'Reiser4',307 '0x3434' => 'NILFS2',308 '0x5346414f' => 'OpenAFS',309 '0x47504653' => 'GPFS',310 '0x5941ff53' => 'YAFFS',311 '0xff534d42' => 'CIFS',312 '0x24051905' => 'UBIFS',313 '0x1021994' => 'TMPFS',314 '0x73717368' => 'SquashFS',315 '0xc97e8168' => 'LogFS',316 '0x5346544E' => 'NTFS',317 '0xf15f' => 'eCryptfs',318 '0x61756673' => 'AuFS',319 '0xbd00bd0' => 'Lustre',320 '0xaad7aaea' => 'PanFS', // Panasas FS321 '0xf2f52010' => 'F2FS',322 '0xc36400' => 'CephFS',323 '0x53464846' => 'WSLFS',324 '0xca451a4e' => 'BcacheFS'325 );326 foreach($known_magic_blocks as $hex => $name)327 {328 if($magic_block == $hex)329 {330 $fs = $name;331 break;332 }333 }334 }335 break;336 }337 if(strpos($fs, 'UNKNOWN') !== false && isset(phodevi::$vfs->mounts))338 {339 $mounts = phodevi::$vfs->mounts;340 $fs_r = array();341 $fs_checks = array(342 'squashfs' => 'SquashFS',343 'aufs' => 'AuFS',344 'unionfs' => 'UnionFS',345 'overlay' => 'overlayfs',346 );347 foreach($fs_checks as $fs_module => $fs_name)348 {349 if(strpos($mounts, $fs_module) != false)350 {351 array_push($fs_r, $fs_name);352 }353 }354 if(count($fs_r) > 0)355 {356 $fs = implode(' + ', $fs_r);357 }358 }359 }360 else if(phodevi::is_windows())361 {362 // TODO could use better detection to verify if C: or the desired disk under test... but most of the time will be NTFS anyways363 $fs = filter_var(trim(shell_exec('powershell "(Get-WMIObject -Class Win32_Volume | Select DriveLetter,FreeSpace,Capacity,DeviceID,Label,@{Name=\"FileSystemType\";Expression={$_.\"FileSystem\"}})[1].FileSystemType"')), FILTER_UNSAFE_RAW, FILTER_FLAG_STRIP_HIGH);364 if(empty($fs) || $fs == 'Unknown' || $fs == 'FAT32')365 {366 $fs = filter_var(trim(shell_exec('powershell "(Get-WMIObject -Class Win32_Volume | Select DriveLetter,FreeSpace,Capacity,DeviceID,Label,@{Name=\"FileSystemType\";Expression={$_.\"FileSystem\"}})[0].FileSystemType"')),FILTER_UNSAFE_RAW, FILTER_FLAG_STRIP_HIGH);367 }368 // Fallback for Windows 8369 if(empty($fs) || $fs == 'Unknown' || $fs == 'FAT32' || stripos($fs, 'not'))370 {371 if(strpos(shell_exec('fsutil fsinfo volumeinfo C:'), 'NTFS') !== false)372 {373 $fs = 'NTFS';374 }375 }376 }377 if(empty($fs))378 {379 $fs = 'Unknown';380 }381 return $fs;382 }383 public static function sw_virtualized_mode()384 {385 // Reports if system is running virtualized386 $virtualized = null;387 $mobo = phodevi::read_name('motherboard');388 $gpu = phodevi::read_name('gpu');389 $cpu = phodevi::read_property('cpu', 'model');390 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'))391 {392 $virtualized = 'QEMU';393 if(strpos($cpu, 'QEMU Virtual') !== false)394 {395 $qemu_version = substr($cpu, (strrpos($cpu, ' ') + 1));396 if(pts_strings::is_version($qemu_version))397 {398 $virtualized .= ' ' . $qemu_version;399 }400 }401 }402 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))403 {404 $virtualized = 'VMware';405 }406 else if(stripos($gpu, 'VirtualBox') !== false || stripos(phodevi::read_name('motherboard'), 'VirtualBox') !== false)407 {408 $virtualized = 'VirtualBox';409 if($vbox_manage = pts_client::executable_in_path('VBoxManage'))410 {411 $vbox_manage = trim(shell_exec($vbox_manage . ' --version 2> /dev/null'));412 if(is_numeric(substr($vbox_manage, 0, 1)))413 {414 $virtualized .= ' ' . $vbox_manage;415 }416 }417 else if($modinfo = pts_client::executable_in_path('modinfo'))418 {419 $modinfo = trim(shell_exec('modinfo -F version vboxguest 2> /dev/null'));420 if($modinfo != null && pts_strings::is_version(str_ireplace(array('_', 'RC', 'beta'), '', $modinfo)))421 {422 $virtualized .= ' ' . $modinfo;423 }424 }425 }426 else if(is_file('/sys/class/dmi/id/sys_vendor') && pts_file_io::file_get_contents('/sys/class/dmi/id/sys_vendor') == 'Xen')427 {428 $virtualized = pts_file_io::file_get_contents('/sys/class/dmi/id/product_name');429 if(strpos($virtualized, 'Xen') === false)430 {431 $virtualized = 'Xen ' . $virtualized;432 }433 // version string434 $virtualized .= ' ' . pts_file_io::file_get_contents('/sys/class/dmi/id/product_version');435 // $virtualized should be then e.g. 'Xen HVM domU 4.1.1'436 }437 else if(stripos($gpu, 'Microsoft Hyper-V') !== false)438 {439 $virtualized = 'Microsoft Hyper-V Server';440 }441 else if(stripos($mobo, 'Parallels Software') !== false)442 {443 $virtualized = 'Parallels Virtualization';444 }445 else if(is_file('/sys/hypervisor/type'))446 {447 $type = pts_file_io::file_get_contents('/sys/hypervisor/type');448 $version = array();449 foreach(array('major', 'minor', 'extra') as $v)450 {451 if(is_file('/sys/hypervisor/version/' . $v))452 {453 $v = pts_file_io::file_get_contents('/sys/hypervisor/version/' . $v);454 }455 else456 {457 continue;458 }459 if($v != null)460 {461 if(!empty($version) && substr($v, 0, 1) != '.')462 {463 $v = '.' . $v;464 }465 array_push($version, $v);466 }467 }468 $virtualized = ucwords($type) . ' ' . implode('', $version) . ' Hypervisor';469 }470 if($systemd_virt = pts_client::executable_in_path('systemd-detect-virt'))471 {472 $systemd_virt = trim(shell_exec($systemd_virt . ' 2> /dev/null'));473 if($systemd_virt != null && $systemd_virt != 'none')474 {475 switch($systemd_virt)476 {477 case 'kvm':478 $systemd_virt = 'KVM';479 break;480 case 'oracle':481 $systemd_virt = 'Oracle';482 break;483 }484 if($virtualized != null && stripos($virtualized, $systemd_virt) === false && stripos($systemd_virt, $virtualized) === false)485 {486 $virtualized = $systemd_virt . ' ' . $virtualized;487 }488 else if($virtualized == null)489 {490 $virtualized = $systemd_virt;491 }492 }493 }494 if(empty($virtualized))495 {496 if(is_file('/.dockerenv'))497 {498 $virtualized = 'Docker';499 }500 else if(is_file('/dev/lxc/console'))501 {502 $virtualized = 'lxc';503 }504 }505 return $virtualized;506 }507 public static function sw_environment_variables()508 {509 $check_variables = array('LIBGL', '__GL', 'DRI_', 'DEBUG', 'FLAGS', 'PERF_', 'PERFTEST');510 $to_report = array();511 if(stripos(phodevi::read_property('system', 'opengl-driver'), 'Mesa'))512 {513 array_push($check_variables, 'MESA', 'GALLIUM');514 }515 if(isset($_SERVER))516 {517 foreach($_SERVER as $name => &$value)518 {519 foreach($check_variables as $var)520 {521 if(stripos($name, $var) !== false && $name != '__GL_SYNC_TO_VBLANK' && strpos($name, 'GJS') === false)522 {523 $value = trim($value);524 if(strpos($value, ' ') !== false)525 {526 $value = '"' . $value . '"';527 }528 array_push($to_report, $name . '=' . $value);529 break;530 }531 }532 }533 }534 return implode(' ', array_unique($to_report));535 }536 public static function sw_security_features()537 {538 $security = array();539 if(pts_client::executable_in_path('getenforce'))540 {541 $selinux = shell_exec('getenforce 2>&1');542 if(strpos($selinux, 'Enforcing') !== false)543 {544 $security[] = 'SELinux';545 }546 }547 // Meltdown / KPTI check548 if(phodevi::is_linux())549 {550 /* if(strpos(phodevi::$vfs->dmesg, 'page tables isolation: enabled') !== false)551 {552 // Kernel Page Table Isolation553 $security[] = 'KPTI';554 }555*/556 // Spectre557 foreach(pts_file_io::glob('/sys/devices/system/cpu/vulnerabilities/*') as $vuln)558 {559 $fc = file_get_contents($vuln);560 $fc = str_replace('Mitigation: ', 'Mitigation of ', $fc);561 $fc = str_replace('Speculative Store Bypass', 'SSB', $fc);562 if(!empty($fc))563 {564 $security[] = basename($vuln) . ': ' . $fc;565 }566 }567 }568 else if(phodevi::is_bsd())569 {570 // FreeBSD571 if(phodevi_bsd_parser::read_sysctl('vm.pmap.pti') == '1')572 {573 $security[] = 'KPTI';574 }575 if(phodevi_bsd_parser::read_sysctl('hw.ibrs_active') == '1')576 {577 $security[] = 'IBRS';578 }579 // DragonFlyBSD580 if(($spectre = phodevi_bsd_parser::read_sysctl('machdep.spectre_mitigation')) != '0' && $spectre != 'NONE' && !empty($spectre))581 {582 $security[] = 'Spectre ' . $spectre . ' Mitigation';583 }584 if(phodevi_bsd_parser::read_sysctl('machdep.meltdown_mitigation') == '1')585 {586 $security[] = 'Meltdown Mitigation';587 }588 }589 else if(phodevi::is_windows())590 {591 $mds_tool = getenv('USERPROFILE') . '\Downloads\mdstool-cli.exe';592 if(is_file($mds_tool))593 {594 $mds_output = preg_replace('#\\x1b[[][^A-Za-z]*[A-Za-z]#', '', shell_exec($mds_tool));595 //echo PHP_EOL;596 foreach(array('__user pointer sanitization: Disabled', 'Retpoline: Full', 'IBPB: Always', 'IBRS: Enabled', 'STIBP: Enabled', 'KPTI Enabled: Yes', 'PTE Inversion: Yes') as $check)597 {598 if(stripos($mds_output, $check) !== false)599 {600 $security[] = $check;601 }602 }603 }604 }605 return !empty($security) ? implode(' + ', $security) : null;606 }607 public static function sw_compiler()608 {609 // Returns version of the compiler (if present)610 $compilers = array();611 if($gcc = pts_client::executable_in_path('gcc'))612 {613 if(!is_link($gcc) || strpos(readlink($gcc), 'gcc') !== false)614 {615 // GCC616 // If it's a link, ensure that it's not linking to llvm/clang or something617 $version = trim(shell_exec('gcc -dumpversion 2>&1'));618 $v = shell_exec('gcc -v 2>&1');619 if(pts_strings::is_version($version))620 {621 if(($t = strrpos($v, $version . ' ')) !== false)622 {623 $v = substr($v, ($t + strlen($version) + 1));624 $v = substr($v, 0, strpos($v, ' '));625 if($v != null && is_numeric($v))626 {627 // On development versions the release date is expressed628 // e.g. gcc version 4.7.0 20120314 (prerelease) (GCC)629 $version .= ' ' . $v;630 }631 else632 {633 $v = shell_exec('gcc --version 2>&1');634 if(($t = strrpos($v, $version)) !== false)635 {636 $v = substr($v, $t);637 $v = substr($v, 0, strpos(str_replace(PHP_EOL, ' ', $v), ' '));638 if(($t = strpos($v, ')')) !== false)639 {640 $v = substr($v, 0, $t);641 }642 if(pts_strings::is_version($v))643 {644 $version = $v;645 }646 }647 }648 }649 $compilers['gcc'] = 'GCC ' . $version;650 }651 else if(($t = strpos($v, ' version ')) !== false)652 {653 $v = substr($v, ($t + strlen(' version ')));654 if(($t = strpos($v, ' (')) !== false)655 {656 $v = substr($v, 0, $t);657 $compilers['gcc'] = 'GCC ' . $v;658 }659 }660 }661 // sometimes "copyright" slips into version string662 if(isset($compilers['gcc']))663 {664 $compilers['gcc'] = str_replace('Copyright', '', $compilers['gcc']);665 }666 }667 if(pts_client::executable_in_path('pgcc'))668 {669 // NVIDIA PGI Compiler670 $compilers['pgcc'] = 'PGI Compiler';671 $v = trim(shell_exec('pgcc --version 2>&1'));672 $v = substr($v, strpos($v, 'pgcc ') + 5);673 $v = substr($v, 0, strpos($v, ' '));674 if(pts_strings::is_version(str_replace('-', '', $v)))675 {676 $compilers['pgcc'] .= ' ' . $v;677 }678 }679 if(pts_client::executable_in_path('pcc'))680 {681 // PCC - Portable C Compiler682 $pcc = explode(' ', trim(shell_exec('pcc -version 2>&1')));683 if($pcc[0] == 'pcc')684 {685 $compilers['pcc'] = 'PCC ' . $pcc[1] . (is_numeric($pcc[2]) ? ' ' . $pcc[2] : null);686 }687 }688 if(pts_client::executable_in_path('pgcpp') || pts_client::executable_in_path('pgCC'))689 {690 // The Portland Group Compilers691 $compilers['pgcpp'] = 'PGI C-C++ Workstation';692 }693 if(($clang = pts_client::executable_in_path('clang')))694 {695 // Clang696 $compiler_info = shell_exec(escapeshellarg($clang) . ' --version');697 if(($cv_pos = stripos($compiler_info, 'clang version')) !== false)698 {699 // With Clang 3.0 and prior, the --version produces output where the first line is:700 // e.g. clang version 3.0 (branches/release_30 142590)701 $compiler_info = substr($compiler_info, ($cv_pos + 14));702 $compiler_info = str_replace(PHP_EOL, ' ', $compiler_info);703 $clang_version = substr($compiler_info, 0, strpos($compiler_info, ' '));704 // XXX: the below check bypass now because e.g. Ubuntu appends '-ubuntuX', etc that breaks check705 if(pts_strings::is_version($clang_version) || true)706 {707 // Also see if there is a Clang SVN tag to fetch708 $compiler_info = substr($compiler_info, 0, strpos($compiler_info, PHP_EOL));709 if(($cv_pos = strpos($compiler_info, ')')) !== false)710 {711 $compiler_info = substr($compiler_info, 0, $cv_pos);712 $compiler_info = substr($compiler_info, (strrpos($compiler_info, ' ') + 1));713 if(is_numeric($compiler_info))714 {715 // Right now Clang/LLVM uses SVN system and their revisions are only numeric716 $clang_version .= ' (SVN ' . $compiler_info . ')';717 }718 }719 $compiler_info = 'Clang ' . $clang_version;720 }721 else722 {723 $compiler_info = null;724 }725 }726 else727 {728 $compiler_info = substr($compiler_info, 0, strpos($compiler_info, PHP_EOL));729 }730 // Clang731 if(empty($compiler_info) && stripos($compiler_info, 'not found'))732 {733 // At least with Clang ~3.0 the -dumpversion is reporting '4.2.1' ratherthan the useful information...734 // This is likely just for GCC command compatibility, so only use this as a fallback735 $compiler_info = 'Clang ' . trim(shell_exec('clang -dumpversion 2> /dev/null'));736 }737 $compilers['clang'] = $compiler_info;738 }739 // For now at least Intel oneAPI has symlink from clang to icpx so this below code isn't needed in such case740 if(!pts_client::executable_in_path('clang') && ($icpx = pts_client::executable_in_path('icpx')))741 {742 // Intel oneAPI DPC++/C++ Compiler743 $icpx = shell_exec(escapeshellarg($icpx) . ' --version');744 $icpx = substr($icpx, 0, strpos($icpx, PHP_EOL));745 if(stripos($icpx, 'oneAPI') !== false)746 {747 $icpx = str_ireplace(array('(R)'), '', $icpx);748 if(($x = strpos($icpx, ' (')) !== false)749 {750 $icpx = substr($icpx, 0, $x);751 }752 }753 $compilers['icpx'] = $icpx;754 }755 if(($llvm_ld = pts_client::executable_in_path('llvm-link')) || ($llvm_ld = pts_client::executable_in_path('llvm-ld')))756 {757 // LLVM - Low Level Virtual Machine758 // Reading the version from llvm-ld (the LLVM linker) should be safe as well for finding out version of LLVM in use759 // As of LLVM 3.2svn, llvm-ld seems to be llvm-link760 $info = trim(shell_exec($llvm_ld . ' -version 2> /dev/null'));761 if(($s = strpos($info, 'version')) != false)762 {763 $info = substr($info, 0, strpos($info, PHP_EOL, $s));764 $info = substr($info, (strrpos($info, ' ') + 1));765 if(pts_strings::is_version(str_replace('svn', '', $info)))766 {767 $compilers['llvmc'] = 'LLVM ' . $info;768 }769 }770 }771 else if(pts_client::executable_in_path('llvm-config'))772 {773 // LLVM - Low Level Virtual Machine config774 $info = trim(shell_exec('llvm-config --version 2> /dev/null'));775 if(pts_strings::is_version(str_replace('svn', '', $info)))776 {777 $compilers['llvmc'] = 'LLVM ' . $info;778 }779 }780 else if(pts_client::executable_in_path('llvmc'))781 {782 // LLVM - Low Level Virtual Machine (llvmc)783 $info = trim(shell_exec('llvmc -version 2>&1'));784 if(($s = strpos($info, 'version')) != false)785 {786 $info = substr($info, 0, strpos($info, "\n", $s));787 $info = substr($info, strrpos($info, "\n"));788 $compilers['llvmc'] = trim($info);789 }790 }791 if(pts_client::executable_in_path('suncc'))792 {793 // Sun Studio / SunCC794 $info = trim(shell_exec('suncc -V 2>&1'));795 if(($s = strpos($info, 'Sun C')) != false)796 {797 $info = substr($info, $s);798 $info = substr($info, 0, strpos($info, "\n"));799 $compilers['suncc'] = $info;800 }801 }802 if(pts_client::executable_in_path('ioc'))803 {804 // Intel Offline Compiler (IOC) SDK for OpenCL805 // -v e.g. : Intel(R) SDK for OpenCL* - Offline Compiler 2012 Command-Line Client, version 1.0.2806 $info = trim(shell_exec('ioc -version 2>&1')) . ' ';807 if(($s = strpos($info, 'Offline Compiler ')) != false)808 {809 $compilers['ioc'] = 'Intel IOC SDK';810 $sv = substr($info, ($s + 17));811 $sv = substr($sv, 0, strpos($sv, ' '));812 if(is_numeric($sv))813 {814 $compilers['ioc'] .= ' ' . $sv;815 }816 if(($s = strpos($info, 'version ')) != false)817 {818 $sv = substr($info, ($s + 8));819 $sv = substr($sv, 0, strpos($sv, ' '));820 if(pts_strings::is_version($sv))821 {822 $compilers['ioc'] .= ' v' . $sv;823 }824 }825 }826 }827 if(($icc = pts_client::executable_in_path('icc')) || ($icc = pts_client::executable_in_path('icpc')))828 {829 // Intel oneAPI DPC++/C++ Compiler830 $icc = shell_exec(escapeshellarg($icc) . ' --version');831 $icc = substr($icc, 0, strpos($icc, PHP_EOL));832 if(stripos($icc, 'icc') !== false)833 {834 $icc = str_ireplace(array('(R)', '(ICC)', '(C)'), '', $icc);835 if(($x = strpos($icpx, ' (')) !== false)836 {837 $icpx = substr($icc, 0, $x);838 }839 }840 $icc = str_replace('icc', 'ICC', $icc);841 $compilers['icc'] = $icc;842 }843 if(phodevi::is_macos() && pts_client::executable_in_path('xcodebuild'))844 {845 $xcode = phodevi_osx_parser::read_osx_system_profiler('SPDeveloperToolsDataType', 'Xcode');846 $xcode = substr($xcode, 0, strpos($xcode, ' '));847 if($xcode)848 {849 $compilers['Xcode'] = 'Xcode ' . $xcode;850 }851 }852 if(($nvcc = pts_client::executable_in_path('nvcc')) || is_executable(($nvcc = '/usr/local/cuda/bin/nvcc')))853 {854 // Check outside of PATH too since by default the CUDA Toolkit goes to '/usr/local/cuda/' and relies upon user to update system855 // NVIDIA CUDA Compiler Driver856 $nvcc = shell_exec($nvcc . ' --version 2>&1');857 if(($s = strpos($nvcc, 'release ')) !== false)858 {859 $nvcc = str_replace(array(','), '', substr($nvcc, ($s + 8)));860 $nvcc = substr($nvcc, 0, strpos($nvcc, ' '));861 if(pts_strings::is_version($nvcc))862 {863 $compilers['CUDA'] = 'CUDA ' . $nvcc;864 }865 }866 }867 // Try to make the compiler that's used by default to appear first868 if(pts_client::read_env('CC') && isset($compilers[basename(pts_strings::first_in_string(pts_client::read_env('CC'), ' '))]))869 {870 $cc_env = basename(pts_strings::first_in_string(pts_client::read_env('CC'), ' '));871 $default_compiler = $compilers[$cc_env];872 unset($compilers[$cc_env]);873 array_unshift($compilers, $default_compiler);874 }875 else if(pts_client::executable_in_path('cc') && is_link(pts_client::executable_in_path('cc')))876 {877 $cc_link = basename(readlink(pts_client::executable_in_path('cc')));878 if(isset($compilers[$cc_link]))879 {880 $default_compiler = $compilers[$cc_link];881 unset($compilers[pts_client::read_env('CC')]);882 array_unshift($compilers, $default_compiler);883 }884 }885 return implode(' + ', array_unique($compilers));886 }887 public static function sw_kernel_string()888 {889 return trim(phodevi::read_property('system', 'kernel') . ' (' . phodevi::read_property('system', 'kernel-architecture') . ') ' . phodevi::read_property('system', 'kernel-date'));890 }891 public static function sw_kernel_date()892 {893 $date = null;894 $k = phodevi::read_property('system', 'kernel');895 if(strpos($k, '99') !== false || stripos($k, 'rc') !== false)896 {897 // For now at least only report kernel build date when it looks like it's a devel kernel898 $v = php_uname('v');899 if(($x = stripos($v, 'SMP ')) !== false)900 {901 $v = substr($v, ($x + 4));902 $date = strtotime($v);903 if($date != false)904 {905 $date = date('Ymd', $date);906 }907 }908 }909 return $date;910 }911 public static function sw_kernel()912 {913 return php_uname('r');914 }915 public static function sw_kernel_parameters()916 {917 $parameters = null;918 if(is_file('/proc/cmdline') && is_file('/proc/modules'))919 {920 $modules = array();921 foreach(explode(PHP_EOL, pts_file_io::file_get_contents('/proc/modules')) as $module_line)922 {923 $module_line = explode(' ', $module_line);924 if(isset($module_line[0]) && !empty($module_line[0]))925 {926 array_push($modules, $module_line[0]);927 }928 }929 if(!empty($modules))930 {931 $to_report = array();932 $cmdline = explode(' ', pts_file_io::file_get_contents('/proc/cmdline'));933 foreach($cmdline as $option)934 {935 if(($t = strpos($option, '.')) !== false)936 {937 if(in_array(substr($option, 0, $t), $modules))938 {939 array_push($to_report, $option);940 }941 }942 }943 if(!empty($to_report))944 {945 $parameters = implode(' ', $to_report);946 }947 }948 }949 return $parameters;950 }951 public static function sw_kernel_architecture()952 {953 // Find out the kernel archiecture954 if(phodevi::is_windows())955 {956 //$kernel_arch = strpos($_SERVER['PROCESSOR_ARCHITECTURE'], 64) !== false || strpos($_SERVER['PROCESSOR_ARCHITEW6432'], 64 != false) ? 'x86_64' : 'i686';957 if(isset($_SERVER['PROCESSOR_ARCHITEW6432']))958 {959 $kernel_arch = $_SERVER['PROCESSOR_ARCHITEW6432'] == 'AMD64' ? 'x86_64' : 'i686';960 }961 else962 {963 $kernel_arch = 'x86_64';964 }965 }966 else967 {968 $kernel_arch = php_uname('m');969 switch($kernel_arch)970 {971 case 'X86-64':972 case 'amd64':973 $kernel_arch = 'x86_64';974 break;975 case 'i86pc':976 case 'i586':977 case 'i686-AT386':978 $kernel_arch = 'i686';979 break;980 }981 }982 return $kernel_arch;983 }984 public static function sw_os_version()985 {986 // Returns OS version987 if(phodevi::is_macos())988 {989 $os = phodevi_osx_parser::read_osx_system_profiler('SPSoftwareDataType', 'SystemVersion');990 991 $start_pos = strpos($os, '.');992 $end_pos = strrpos($os, '.');993 $start_pos = strrpos(substr($os, 0, $start_pos), ' ');994 $end_pos = strpos($os, ' ', $end_pos);995 996 $os_version = substr($os, $start_pos + 1, $end_pos - $start_pos);997 }998 else if(phodevi::is_linux())999 {1000 $os_version = phodevi_linux_parser::read_lsb('Release');1001 if($os_version == null)1002 {1003 if(is_readable('/etc/os-release'))1004 $os_release = parse_ini_file('/etc/os-release');1005 else if(is_readable('/usr/lib/os-release'))1006 $os_release = parse_ini_file('/usr/lib/os-release');1007 else1008 $os_release = null;1009 if(isset($os_release['VERSION_ID']) && !empty($os_release['VERSION_ID']))1010 {1011 $os_version = $os_release['VERSION_ID'];1012 }1013 else if(isset($os_release['VERSION']) && !empty($os_release['VERSION']))1014 {1015 $os_version = $os_release['VERSION'];1016 }1017 $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);1018 }1019 }1020 else if(phodevi::is_windows())1021 {1022 $os_version = phodevi_windows_parser::get_wmi_object('win32_operatingsystem', 'BuildNumber');1023 }1024 else1025 {1026 $os_version = php_uname('r');1027 }1028 1029 return $os_version;1030 }1031 public static function sw_operating_system()1032 {1033 if(!PTS_IS_CLIENT)1034 {1035 // TODO: Figure out why this function is sometimes called from OpenBenchmarking.org....1036 return false;1037 }1038 // Determine the operating system release1039 if(phodevi::is_linux())1040 {1041 $vendor = phodevi_linux_parser::read_lsb_distributor_id();1042 if($vendor == null)1043 {1044 if(is_readable('/etc/os-release'))1045 $os_release = parse_ini_file('/etc/os-release');1046 else if(is_readable('/usr/lib/os-release'))1047 $os_release = parse_ini_file('/usr/lib/os-release');1048 else1049 $os_release = null;1050 if(isset($os_release['PRETTY_NAME']) && !empty($os_release['PRETTY_NAME']))1051 {1052 $vendor = $os_release['PRETTY_NAME'];1053 }1054 else if(isset($os_release['NAME']) && !empty($os_release['NAME']))1055 {1056 $vendor = $os_release['NAME'];1057 }1058 $vendor = str_replace('é', 'e', $vendor);1059 }1060 if(($x = stripos($vendor, ' for ')) !== false)1061 {1062 $vendor = substr($vendor, 0, $x);1063 }1064 $vendor = str_replace(array(' Software'), '', $vendor);1065 }1066 else if(phodevi::is_hurd())1067 {1068 $vendor = php_uname('v');1069 }1070 else1071 {1072 $vendor = null;1073 }1074 $version = phodevi::read_property('system', 'os-version');1075 if(!$vendor)1076 {1077 $os = null;1078 // Try to detect distro for those not supplying lsb_release1079 $files = pts_file_io::glob('/etc/*-version');1080 for($i = 0; $i < count($files) && $os == null; $i++)1081 {1082 $file = file_get_contents($files[$i]);1083 if(trim($file) != null)1084 {1085 $os = substr($file, 0, strpos($file, "\n"));1086 }1087 }1088 1089 if($os == null)1090 {1091 $files = pts_file_io::glob('/etc/*-release');1092 for($i = 0; $i < count($files) && $os == null; $i++)1093 {1094 $file = file_get_contents($files[$i]);1095 if(trim($file) != null)1096 {1097 $proposed_os = substr($file, 0, strpos($file, PHP_EOL));1098 if(strpos($proposed_os, '=') == false)1099 {1100 $os = $proposed_os;1101 }1102 }1103 else if($i == (count($files) - 1))1104 {1105 $os = ucwords(substr(($n = basename($files[$i])), 0, strpos($n, '-')));1106 } 1107 }1108 }1109 if($os == null && is_file('/etc/release'))1110 {1111 $file = file_get_contents('/etc/release');1112 $os = substr($file, 0, strpos($file, "\n"));1113 }1114 if($os == null && is_file('/etc/palm-build-info'))1115 {1116 // Palm / webOS Support1117 $os = phodevi_parser::parse_equal_delimited_file('/etc/palm-build-info', 'PRODUCT_VERSION_STRING');1118 }1119 if($os == null)1120 {1121 if(is_file('/etc/debian_version'))1122 {1123 $os = 'Debian ' . php_uname('s') . ' ' . ucwords(pts_file_io::file_get_contents('/etc/debian_version'));1124 }1125 else1126 {1127 $os = php_uname('s');1128 }1129 }1130 else if(strpos($os, ' ') === false)1131 {1132 // The OS string is only one word, likely a problem...1133 if(is_file('/etc/arch-release') && stripos($os, 'Arch') === false)1134 {1135 // On at least some Arch installs (ARM) the file is empty so would have missed above check1136 $os = trim('Arch Linux ' . $os);1137 }1138 }1139 }1140 else if($version != null && stripos($vendor, $version) === false)1141 {1142 $os = $vendor . ' ' . $version;1143 }1144 else1145 {1146 $os = $vendor;1147 }1148 if(($break_point = strpos($os, ':')) > 0)1149 {1150 $os = substr($os, $break_point + 1);1151 }1152 1153 if(phodevi::is_macos())1154 {1155 $os = phodevi_osx_parser::read_osx_system_profiler('SPSoftwareDataType', 'SystemVersion');1156 }1157 else if(phodevi::is_windows())1158 {1159 $os = $info = phodevi_windows_parser::get_wmi_object('win32_operatingsystem', 'caption') . ' Build ' . phodevi::read_property('system', 'os-version');1160 if(strpos($os, 'Windows') === false)1161 {1162 $os = trim(exec('ver'));1163 }1164 } 1165 if(($break_point = strpos($os, '(')) > 0)1166 {1167 $os = substr($os, 0, $break_point);1168 }1169 $os = trim($os);1170 return $os;1171 }1172 public static function sw_desktop_environment()1173 {1174 $desktop = null;1175 $desktop_environment = null;1176 $desktop_version = null;1177 $desktop_session = pts_client::read_env('DESKTOP_SESSION');1178 if(pts_client::is_process_running('gnome-shell'))1179 {1180 // GNOME 3.0 / GNOME Shell1181 $desktop_environment = 'GNOME Shell';1182 if(pts_client::executable_in_path('gnome-shell'))1183 {1184 $desktop_version = pts_strings::last_in_string(trim(shell_exec('gnome-shell --version 2> /dev/null')));1185 }1186 }1187 else if(pts_client::is_process_running('gnome-panel') || $desktop_session == 'gnome')1188 {1189 // GNOME1190 $desktop_environment = 'GNOME';1191 if(pts_client::executable_in_path('gnome-about'))1192 {1193 $desktop_version = pts_strings::last_in_string(trim(shell_exec('gnome-about --version 2> /dev/null')));1194 }1195 else if(pts_client::executable_in_path('gnome-session'))1196 {1197 $desktop_version = pts_strings::last_in_string(trim(shell_exec('gnome-session --version 2> /dev/null')));1198 }1199 }1200 else if(pts_client::is_process_running('unity-2d-panel') || $desktop_session == 'ubuntu-2d')1201 {1202 // Canonical / Ubuntu Unity 2D Desktop1203 $desktop_environment = 'Unity 2D';1204 if(pts_client::executable_in_path('unity'))1205 {1206 $desktop_version = pts_strings::last_in_string(trim(shell_exec('unity --version 2> /dev/null')));1207 }1208 }1209 else if(pts_client::is_process_running('unity-panel-service') || $desktop_session == 'ubuntu')1210 {1211 // Canonical / Ubuntu Unity Desktop1212 $desktop_environment = 'Unity';1213 if(pts_client::executable_in_path('unity'))1214 {1215 $desktop_version = pts_strings::last_in_string(trim(shell_exec('unity --version 2> /dev/null')));1216 }1217 }1218 else if($desktop_session == 'mate')1219 {1220 $desktop_environment = 'MATE';1221 if(pts_client::executable_in_path('mate-about'))1222 {1223 $desktop_version = pts_strings::last_in_string(trim(shell_exec('mate-about --version 2> /dev/null')));1224 }1225 }1226 else if(($kde5 = pts_client::is_process_running('plasmashell')))1227 {1228 // KDE 5.x1229 $desktop_environment = 'KDE Plasma';1230 $desktop_version = pts_strings::last_in_string(trim(shell_exec('plasmashell --version 2> /dev/null')));1231 }1232 else if(($kde5 = pts_client::is_process_running('kded5')))1233 {1234 // KDE 5.x1235 $desktop_environment = 'KDE Frameworks';1236 if(pts_client::executable_in_path('kdeinit5'))1237 {1238 $desktop_version = pts_strings::last_in_string(trim(shell_exec('kdeinit5 --version 2> /dev/null')));1239 }1240 }1241 else if(($dde = pts_client::is_process_running('dde-desktop')))1242 {1243 // KDE 5.x1244 $desktop_environment = 'Deepin Desktop Environment';1245 $desktop_version = null; // TODO XXX1246 }1247 else if(($kde4 = pts_client::is_process_running('kded4')) || pts_client::is_process_running('kded'))1248 {1249 // KDE 4.x1250 $desktop_environment = 'KDE';1251 $kde_output = trim(shell_exec(($kde4 ? 'kde4-config' : 'kde-config') . ' --version 2>&1'));1252 $kde_lines = explode("\n", $kde_output);1253 for($i = 0; $i < count($kde_lines) && empty($desktop_version); $i++)1254 {1255 $line_segments = pts_strings::colon_explode($kde_lines[$i]);1256 if(in_array($line_segments[0], array('KDE', 'KDE Development Platform')) && isset($line_segments[1]))1257 {1258 $v = trim($line_segments[1]);1259 if(($cut = strpos($v, ' ')) > 0)1260 {1261 $v = substr($v, 0, $cut);1262 }1263 $desktop_version = $v;1264 }1265 }1266 }1267 else if(pts_client::is_process_running('chromeos-wm'))1268 {1269 $chrome_output = trim(shell_exec('chromeos-wm -version'));1270 if($chrome_output == 'chromeos-wm')1271 {1272 // No version actually reported1273 $chrome_output = 'Chrome OS';1274 }1275 $desktop_environment = $chrome_output;1276 }1277 else if(pts_client::is_process_running('lxqt-panel') || $desktop_session == 'lxqt')1278 {1279 //$lx_output = trim(shell_exec('lxqt-panel --version'));1280 //$version = substr($lx_output, strpos($lx_output, ' ') + 1);1281 $desktop_environment = 'LXQt';1282 if(pts_client::executable_in_path('lxqt-about'))1283 {1284 $desktop_version = pts_strings::last_in_string(trim(shell_exec('lxqt-about --version | grep liblxqt 2> /dev/null')));1285 }1286 }1287 else if(pts_client::is_process_running('lxsession') || $desktop_session == 'lxde')1288 {1289 $lx_output = trim(shell_exec('lxpanel --version 2>&1'));1290 $version = substr($lx_output, strpos($lx_output, ' ') + 1);1291 $desktop_environment = 'LXDE';1292 $desktop_version = $version;1293 }1294 else if(pts_client::is_process_running('lumina-desktop'))1295 {1296 // Lumina Desktop Environment1297 $desktop_environment = 'Lumina';1298 $desktop_version = str_replace('"', '', trim(shell_exec('lumina-desktop --version 2>&1')));1299 }1300 else if(pts_client::is_process_running('xfce4-session') || pts_client::is_process_running('xfce-mcs-manager') || $desktop_session == 'xfce')1301 {1302 // Xfce 4.x1303 $desktop_environment = 'Xfce';1304 $xfce_output = trim(shell_exec('xfce4-session-settings --version 2>&1'));1305 if(($open = strpos($xfce_output, '(Xfce')) > 0)1306 {1307 $xfce_output = substr($xfce_output, strpos($xfce_output, ' ', $open) + 1);1308 $desktop_version = substr($xfce_output, 0, strpos($xfce_output, ')'));1309 }1310 }1311 else if(pts_client::is_process_running('sugar-session'))1312 {1313 // Sugar Desktop Environment (namely for OLPC)1314 $desktop_environment = 'Sugar';1315 $desktop_version = null; // TODO: where can the Sugar version be figured out?1316 }1317 else if(pts_client::is_process_running('openbox'))1318 {1319 $desktop_environment = 'Openbox';1320 $openbox_output = trim(shell_exec('openbox --version 2>&1'));1321 if(($openbox_d = stripos($openbox_output, 'Openbox ')) !== false)1322 {1323 $openbox_output = substr($openbox_output, ($openbox_d + 8));1324 $desktop_version = substr($openbox_output, 0, strpos($openbox_output, PHP_EOL));1325 }1326 }1327 else if(pts_client::is_process_running('cinnamon'))1328 {1329 $desktop_environment = 'Cinnamon';1330 $desktop_version = pts_strings::last_in_string(trim(shell_exec('cinnamon --version 2> /dev/null')));1331 }1332 else if(pts_client::is_process_running('sway'))1333 {1334 $desktop_environment = 'Sway';1335 $desktop_version = pts_strings::last_in_string(trim(shell_exec('sway --version 2> /dev/null')));1336 }1337 else if(pts_client::is_process_running('enlightenment'))1338 {1339 $desktop_environment = 'Enlightenment';1340 $desktop_version = null; // No known -v / --version command on any Enlightenment component1341 }1342 else if(pts_client::is_process_running('consort-panel'))1343 {1344 $desktop_environment = 'Consort';1345 $desktop_version = null; // TODO: Haven't tested Consort Desktop yet1346 }1347 else if(pts_client::is_process_running('razor-desktop'))1348 {1349 $desktop_environment = 'Razor-qt';1350 $desktop_version = null; // TODO: Figure out how to determine razor version1351 }1352 else if(pts_client::is_process_running('icewm'))1353 {1354 $desktop_environment = 'IceWM';1355 $desktop_version = null;1356 }1357 else if(pts_client::is_process_running('budgie-panel') || $desktop_session == 'budgie-desktop')1358 {1359 // Budgie1360 $desktop_environment = 'Budgie';1361 }1362 if(!empty($desktop_environment))1363 {1364 $desktop = $desktop_environment;1365 if(!empty($desktop_version) && pts_strings::is_version($desktop_version))1366 {1367 $desktop .= ' ' . $desktop_version;1368 }1369 }1370 return $desktop;1371 }1372 public static function sw_display_server()1373 {1374 $display_servers = array();1375 if(phodevi::is_windows())1376 {1377 // TODO: determine what to do for Windows support1378 }1379 else1380 {1381 if(pts_client::is_process_running('weston'))1382 {1383 $info = 'Wayland Weston';1384 $vinfo = trim(shell_exec('weston --version 2>&1'));1385 if(pts_strings::last_in_string($vinfo) && pts_strings::is_version(pts_strings::last_in_string($vinfo)))1386 {1387 $info .= ' ' . pts_strings::last_in_string($vinfo);1388 }1389 array_push($display_servers, $info);1390 }1391 if(pts_client::is_process_running('unity-system-compositor'))1392 {1393 $unity_system_comp = trim(str_replace('unity-system-compositor', '', shell_exec('unity-system-compositor --version 2>&1')));1394 if(pts_strings::is_version($unity_system_comp))1395 {1396 array_push($display_servers, 'Unity-System-Compositor ' . $unity_system_comp);1397 }1398 }1399 $xorg_log = isset(phodevi::$vfs->xorg_log) ? phodevi::$vfs->xorg_log : false;1400 if($xorg_log && ($x = strpos($xorg_log, 'X.Org X Server ')) !== false)1401 {1402 $xorg_log = substr($xorg_log, ($x + strlen('X.Org X Server ')));1403 $xorg_log = substr($xorg_log, 0, strpos($xorg_log, PHP_EOL));1404 if(pts_strings::is_version($xorg_log))1405 {1406 array_push($display_servers, 'X Server ' . $xorg_log);1407 }1408 }1409 else if(($x_bin = (is_executable('/usr/libexec/Xorg.bin') ? '/usr/libexec/Xorg.bin' : false)) || ($x_bin = pts_client::executable_in_path('Xorg')) || ($x_bin = pts_client::executable_in_path('X')))1410 {1411 // Find graphics subsystem version1412 $info = shell_exec($x_bin . ' ' . (phodevi::is_solaris() ? ':0' : '') . ' -version 2>&1');1413 $pos = (($p = strrpos($info, 'Release Date')) !== false ? $p : strrpos($info, 'Build Date'));1414 $info = trim(substr($info, 0, $pos));1415 if($pos === false || getenv('DISPLAY') == false)1416 {1417 $version = null;1418 }1419 else if(($pos = strrpos($info, '(')) === false && strrpos($info, 'Server') === false)1420 {1421 $version = trim(substr($info, strrpos($info, ' ')));1422 }1423 else1424 {1425 $version = trim(substr($info, strrpos($info, 'Server') + 6));1426 if(!pts_strings::is_version($version))1427 {1428 $version = null;1429 }1430 }1431 array_push($display_servers, trim('X Server ' . $version));1432 }1433 if(pts_client::is_process_running('surfaceflinger'))1434 {1435 array_push($display_servers, 'SurfaceFlinger');1436 }1437 if(pts_client::is_process_running('gnome-shell-wayland'))1438 {1439 array_push($display_servers, 'GNOME Shell Wayland');1440 }1441 if(getenv('WAYLAND_DISPLAY') != false)1442 {1443 array_push($display_servers, 'Wayland');1444 }1445 }1446 return implode(' + ', $display_servers);1447 }1448 public static function sw_display_driver($with_version = true)1449 {1450 if(phodevi::is_windows())1451 {1452 $windows_driver = phodevi_windows_parser::get_wmi_object('Win32_VideoController', 'DriverVersion');1453 if(($nvidia_smi = pts_client::executable_in_path('nvidia-smi')))1454 {1455 $smi_output = shell_exec(escapeshellarg($nvidia_smi) . ' -q -d CLOCK');1456 if(($v = stripos($smi_output, 'Driver Version')) !== false)1457 {1458 $nv_version = substr($smi_output, strpos($smi_output, ':', $v) + 1);1459 $nv_version = trim(substr($nv_version, 0, strpos($nv_version, "\n")));1460 if(pts_strings::is_version($nv_version))1461 {1462 $windows_driver = $nv_version . ' (' . $windows_driver . ')';1463 }1464 }1465 }1466 return $windows_driver;1467 }1468 $display_driver = phodevi::read_property('system', 'dri-display-driver');1469 $driver_version = null;1470 if(empty($display_driver) || $display_driver == 'NVIDIA')1471 {1472 if(phodevi::is_nvidia_graphics() || is_file('/proc/driver/nvidia/version'))1473 {1474 $display_driver = 'NVIDIA';1475 if(($nvs_value = phodevi_parser::read_nvidia_extension('NvidiaDriverVersion')))1476 {1477 $driver_version = $nvs_value;1478 }1479 else1480 {1481 // NVIDIA's binary driver appends their driver version on the end of the OpenGL version string1482 $glxinfo = phodevi_parser::software_glxinfo_version();1483 if(($pos = strpos($glxinfo, 'NVIDIA ')) != false)1484 {1485 $driver_version = substr($glxinfo, ($pos + 7));1486 }1487 }1488 }1489 else if((phodevi::is_mesa_graphics() || phodevi::is_bsd()) && stripos(phodevi::read_property('gpu', 'model'), 'NVIDIA') !== false)1490 {1491 if(is_file('/sys/class/drm/version'))1492 {1493 // If there's DRM loaded and NVIDIA, it should be Nouveau1494 $display_driver = 'nouveau';1495 }1496 }1497 }1498 // XXX: As of PTS 10.2.1, commented out due to xorg logs growing too big on recent Ubuntu/bug causing slow perf1499 if(false && !empty($display_driver))1500 {1501 $driver_version = phodevi_parser::read_xorg_module_version($display_driver . '_drv');1502 if($driver_version == false || $driver_version == '1.0.0')1503 {1504 switch($display_driver)1505 {1506 case 'amd':1507 // See if it's radeon driver1508 $driver_version = phodevi_parser::read_xorg_module_version('radeon_drv');1509 if($driver_version != false)1510 {1511 $display_driver = 'radeon';1512 }1513 // See if it's the newer AMDGPU driver1514 $driver_version = phodevi_parser::read_xorg_module_version('amdgpu_drv');1515 if($driver_version != false)1516 {1517 $display_driver = 'amdgpu';1518 }1519 break;1520 case 'vmwgfx':1521 // See if it's VMware driver1522 $driver_version = phodevi_parser::read_xorg_module_version('vmware_drv');1523 if($driver_version != false)1524 {1525 $display_driver = 'vmware';1526 }1527 break;1528 case 'radeon':1529 // RadeonHD driver also reports DRI driver as 'radeon', so try reading that instead1530 $driver_version = phodevi_parser::read_xorg_module_version('radeonhd_drv');1531 if($driver_version != false)1532 {1533 $display_driver = 'radeonhd';1534 }1535 $driver_version = phodevi_parser::read_xorg_module_version('amdgpu_drv');1536 if($driver_version != false)1537 {1538 $display_driver = 'amdgpu';1539 }1540 break;1541 case 'nvidia':1542 case 'NVIDIA':1543 case 'nouveau':1544 // NVIDIA's binary driver usually ends up reporting 1.0.01545 if(($nvs_value = phodevi_parser::read_nvidia_extension('NvidiaDriverVersion')))1546 {1547 $display_driver = 'NVIDIA';1548 $driver_version = $nvs_value;1549 }1550 else1551 {1552 // NVIDIA's binary driver appends their driver version on the end of the OpenGL version string1553 $glxinfo = phodevi_parser::software_glxinfo_version();1554 if(($pos = strpos($glxinfo, 'NVIDIA ')) != false)1555 {1556 $display_driver = 'NVIDIA';1557 $driver_version = substr($glxinfo, ($pos + 7));1558 }1559 }1560 break;1561 default:1562 if(is_readable('/sys/class/graphics/fb0/name'))1563 {1564 // This path works for at least finding NVIDIA Tegra 2 DDX (via tegra_fb)1565 $display_driver = file_get_contents('/sys/class/graphics/fb0/name');1566 $display_driver = str_replace(array('drm', '_fb'), '', $display_driver);1567 $driver_version = phodevi_parser::read_xorg_module_version($display_driver . '_drv');1568 }1569 break;1570 }1571 }1572 if($driver_version == false)1573 {1574 // If the version is empty, chances are the DDX driver string is incorrect1575 $display_driver = null;1576 // See if the VESA or fbdev driver is in use1577 foreach(array('modesetting', 'fbdev', 'vesa') as $drv)1578 {1579 $drv_version = phodevi_parser::read_xorg_module_version($drv . '_drv');1580 if($drv_version)1581 {1582 $display_driver = $drv;1583 $driver_version = $drv_version;1584 break;1585 }1586 }1587 }1588 }1589 if(!empty($driver_version) && $with_version && $driver_version != '0.0.0')1590 {1591 $display_driver .= ' ' . $driver_version;1592 }1593 return $display_driver;1594 }1595 public static function sw_opengl_driver()1596 {1597 // OpenGL version1598 $info = null;1599 if(phodevi::is_windows())1600 {1601 $info = null; // TODO: Windows support1602 }1603 else if(pts_client::executable_in_path('nvidia-settings'))1604 {1605 $info = phodevi_parser::read_nvidia_extension('OpenGLVersion');1606 }1607 if($info == null)1608 {1609 $info = phodevi_parser::software_glxinfo_version();1610 if($info && ($pos = strpos($info, ' ')) != false && strpos($info, 'Mesa') === false)1611 {1612 $info = substr($info, 0, $pos);1613 }1614 $renderer = phodevi_parser::read_glx_renderer();1615 if($renderer && ($s = strpos($renderer, 'Gallium')) !== false)1616 {1617 $gallium = substr($renderer, $s);1618 $gallium = substr($gallium, 0, strpos($gallium, ' ', strpos($gallium, '.')));1619 $info .= ' ' . $gallium . '';1620 }1621 if($renderer && ($s = strpos($renderer, 'LLVM ')) !== false)1622 {1623 $llvm = substr($renderer, $s);1624 $llvm = substr($llvm, 0, strpos($llvm, ')'));1625 $info .= ' (' . $llvm . ')';1626 }1627 }1628 return $info;1629 }1630 public static function sw_vulkan_driver()1631 {1632 // Vulkan driver/version1633 $info = null;1634 if(isset(phodevi::$vfs->vulkaninfo))1635 {1636 if(($pos = strpos(phodevi::$vfs->vulkaninfo, 'Vulkan API Version:')) !== false)1637 {1638 $info = substr(phodevi::$vfs->vulkaninfo, $pos + 20);1639 $info = trim(substr($info, 0, strpos($info, "\n")));1640 }1641 else if(($pos = strpos(phodevi::$vfs->vulkaninfo, 'apiVersion')) !== false)1642 {1643 $apiv = substr(phodevi::$vfs->vulkaninfo, $pos);1644 $apiv = trim(substr($apiv, 0, strpos($apiv, ")\n")));1645 $apiv = trim(substr($apiv, strpos($apiv, '(') + 1));1646 if(pts_strings::is_version($apiv))1647 {1648 $info = $apiv;1649 }1650 }1651 }1652 /*1653 if($info == null)1654 {1655 // A less than ideal fallback for some detection now1656 foreach(array_merge(pts_file_io::glob('/etc/vulkan/icd.d/*.json'), pts_file_io::glob('/usr/share/vulkan/icd.d/*.json')) as $icd_json)1657 {1658 $icd_json = json_decode(file_get_contents($icd_json), true);1659 if(isset($icd_json['ICD']['api_version']) && !empty($icd_json['ICD']['api_version']))1660 {1661 $info = trim($icd_json['ICD']['api_version']);1662 break;1663 }1664 }1665 }1666 */1667 return $info;1668 }1669 public static function sw_opencl_driver()1670 {1671 // OpenCL driver/version1672 $info = array();1673 if(isset(phodevi::$vfs->clinfo))1674 {1675 $sea = phodevi::$vfs->clinfo;1676 while(($pos = strpos($sea, 'Platform Version')) != false)1677 {1678 $sea = substr($sea, $pos + 18);1679 $info[] = trim(substr($sea, 0, strpos($sea, "\n")));1680 }1681 }1682 return implode(' + ', $info);1683 }1684 public static function sw_opengl_vendor()1685 {1686 // OpenGL version1687 $info = null;1688 if(pts_client::executable_in_path('glxinfo'))1689 {1690 $info = shell_exec('glxinfo 2>&1 | grep vendor');1691 if($info && ($pos = strpos($info, 'OpenGL vendor string:')) !== false)1692 {1693 $info = substr($info, $pos + 22);1694 $info = trim(substr($info, 0, strpos($info, "\n")));1695 }1696 }1697 else if(is_readable('/dev/nvidia0'))1698 {1699 $info = 'NVIDIA';1700 }1701 else if(is_readable('/sys/module/fglrx/initstate') && pts_file_io::file_get_contents('/sys/module/fglrx/initstate') == 'live')1702 {1703 $info = 'ATI';1704 }1705 else if(is_readable('/dev/dri/card0'))1706 {1707 $info = 'Mesa';1708 }1709 else if(phodevi::is_bsd() && phodevi_bsd_parser::read_sysctl('dev.nvidia.0.%driver'))1710 {1711 $info = 'NVIDIA';1712 }1713 return $info;1714 }1715 public static function sw_compiler_build_configuration($compiler)1716 {1717 $cc = shell_exec($compiler . ' -v 2>&1');1718 if(($t = stripos($cc, 'Configured with: ')) !== false)1719 {1720 $cc = substr($cc, ($t + 18));1721 $cc = substr($cc, 0, strpos($cc, PHP_EOL));1722 $cc = explode(' ', $cc);1723 array_shift($cc); // this should just be the configure call (i.e. ../src/configure)1724 $drop_arguments = array(1725 '--with-pkgversion=',1726 '--with-bugurl=',1727 '--prefix=',1728 '--program-suffix=',1729 '--libexecdir=',1730 '--infodir=',1731 '--libdir=',1732 '--with-cloog=',1733 '--with-isl=',1734 '--with-java-home=',1735 '--manddir=',1736 '--with-ecj-jar=',1737 '--with-jvm-jar-dir=',1738 '--with-jvm-root-dir=',1739 '--with-sysroot=',1740 '--with-gxx-include-dir=',1741 '--with-system-zlib',1742 '--enable-linker-build-id',1743 '--without-included-gettext'1744 );1745 foreach($cc as $i => $argument)1746 {1747 $arg_length = strlen($argument);1748 if($argument[0] != '-')1749 {1750 unset($cc[$i]);1751 }1752 else1753 {1754 foreach($drop_arguments as $check_to_drop)1755 {1756 $len = strlen($check_to_drop);1757 if($len <= $arg_length && substr($argument, 0, $len) == $check_to_drop)1758 {1759 unset($cc[$i]);1760 }1761 }1762 }1763 }1764 sort($cc);1765 $cc = implode(' ', $cc);1766 }1767 else if(($t = stripos($cc, 'clang')) !== false)1768 {1769 $cc = null;1770 // Clang doesn't report "configured with" but has other useful tid-bits...1771 if(($c = pts_client::executable_in_path('llvm-ld')) || ($c = pts_client::executable_in_path('llvm-link')))1772 {1773 $llvm_ld = shell_exec($c . ' -version 2>&1');1774 /*1775 EXAMPLE OUTPUT:1776 LLVM (http://llvm.org/):1777 LLVM version 3.1svn1778 Optimized build.1779 Built Mar 23 2012 (08:53:34).1780 Default target: x86_64-unknown-linux-gnu1781 Host CPU: corei7-avx1782 */1783 if(stripos($llvm_ld, 'build') && (stripos($llvm_ld, 'host') || stripos($llvm_ld, 'target')))1784 {1785 $llvm_ld = explode(PHP_EOL, $llvm_ld);1786 if(stripos($llvm_ld[0], 'http://'))1787 {1788 array_shift($llvm_ld);1789 }1790 if(stripos($llvm_ld[0], 'version'))1791 {1792 array_shift($llvm_ld);1793 }1794 foreach($llvm_ld as $i => &$line)1795 {1796 $line = trim($line);1797 if(substr($line, -1) == '.')1798 {1799 $line = substr($line, 0, -1);1800 }1801 if($line == null)1802 {1803 unset($llvm_ld[$i]);1804 }1805 }1806 $cc = implode('; ', $llvm_ld);1807 }1808 }1809 }1810 else1811 {1812 $cc = null;1813 }1814 return $cc;1815 }1816 public static function sw_dri_display_driver()1817 {1818 $dri_driver = false;1819 if(is_file('/proc/driver/nvidia/version'))1820 {1821 $dri_driver = 'nvidia';1822 }1823 else if(is_file('/sys/class/drm/card0/device/vendor'))1824 {1825 $vendor_id = pts_file_io::file_get_contents('/sys/class/drm/card0/device/vendor');1826 switch($vendor_id)1827 {1828 case 0x1002:1829 $dri_driver = 'radeon';1830 break;1831 case 0x8086:1832 $dri_driver = 'intel';1833 break;1834 case 0x10de:1835 // NVIDIA1836 $dri_driver = 'nouveau';1837 break;1838 }1839 }1840 return $dri_driver;1841 }1842 public static function sw_java_version()1843 {1844 $java_version = trim(shell_exec('java -version 2>&1'));1845 if(strpos($java_version, 'not found') == false && (stripos($java_version, 'Java') !== false || stripos($java_version, 'jdk') !== false))1846 {1847 $java_version = explode("\n", $java_version);1848 if(($cut = count($java_version) - 2) > 0)1849 {1850 $v = $java_version[$cut];1851 }1852 else1853 {1854 $v = array_pop($java_version);1855 }1856 $java_version = trim($v);1857 }1858 else1859 {1860 $java_version = null;1861 }1862 return $java_version;1863 }1864 public static function sw_python_version()1865 {1866 $python_version = null;1867 if(($p = pts_client::executable_in_path('python')) != false)1868 {1869 $python_version = trim(shell_exec(escapeshellarg($p) . ' -V 2>&1'));1870 }1871 if(($p = pts_client::executable_in_path('python3')) != false)1872 {1873 $python3_version = trim(shell_exec(escapeshellarg($p) . ' -V 2>&1'));1874 if($python3_version != $python_version)1875 {1876 $python_version .= ($python_version != null ? ' + ' : null) . $python3_version;1877 }1878 }1879 return $python_version;1880 }1881 public static function sw_wine_version()1882 {1883 $wine_version = null;1884 if((($use_wine = getenv('USE_WINE')) !== false || ($use_wine = getenv('WINE_VERSION')) !== false) && (is_executable($use_wine) || ($use_wine = pts_client::executable_in_path($use_wine)) !== false))1885 {1886 $wine_version = trim(shell_exec($use_wine . ' --version 2>&1'));1887 }1888 else if(pts_client::executable_in_path('wine') != false)1889 {1890 $wine_version = trim(shell_exec('wine --version 2>&1'));1891 }1892 else if(pts_client::executable_in_path('winecfg.exe') != false && pts_client::read_env('WINE_VERSION'))1893 {1894 $wine_version = trim(pts_client::read_env('WINE_VERSION'));1895 if(stripos($wine_version, 'wine') === false)1896 {1897 $wine_version = 'wine-' . $wine_version;1898 }1899 }1900 return $wine_version;1901 }1902 public static function battery()1903 {1904 $batteries = array();1905 if(phodevi::is_linux())1906 {1907 foreach(pts_file_io::glob('/sys/class/power_supply/BAT*/model_name') as $bat_path)1908 {1909 $bat_model = pts_file_io::file_get_contents($bat_path);1910 $bat_dir = dirname($bat_path);1911 $bat_manufacturer = is_file($bat_dir . '/manufacturer') ? pts_file_io::file_get_contents($bat_dir . '/manufacturer') : null;1912 if(!empty($bat_model))1913 {1914 $batteries[] = trim($bat_manufacturer . ' ' . $bat_model);1915 }1916 }...

Full Screen

Full Screen

battery

Using AI Code Generation

copy

Full Screen

1$phodevi = new phodevi_system();2$phodevi->battery();3$phodevi = new phodevi_system();4$phodevi->battery();5$phodevi = new phodevi_system();6$phodevi->battery();7$phodevi = new phodevi_system();8$phodevi->battery();9$phodevi = new phodevi_system();10$phodevi->battery();11$phodevi = new phodevi_system();12$phodevi->battery();13$phodevi = new phodevi_system();14$phodevi->battery();15$phodevi = new phodevi_system();16$phodevi->battery();17$phodevi = new phodevi_system();18$phodevi->battery();19$phodevi = new phodevi_system();20$phodevi->battery();21$phodevi = new phodevi_system();22$phodevi->battery();23$phodevi = new phodevi_system();24$phodevi->battery();25$phodevi = new phodevi_system();26$phodevi->battery();

Full Screen

Full Screen

battery

Using AI Code Generation

copy

Full Screen

1$phodevi = new phodevi_system();2$phodevi->battery();3$phodevi = new phodevi();4$phodevi->battery();5$phodevi = new phodevi();6$phodevi->battery();7$phodevi = new phodevi();8$phodevi->battery();9$phodevi = new phodevi();10$phodevi->battery();11$phodevi = new phodevi();12$phodevi->battery();13$phodevi = new phodevi();14$phodevi->battery();15$phodevi = new phodevi();16$phodevi->battery();17$phodevi = new phodevi();18$phodevi->battery();19$phodevi = new phodevi();20$phodevi->battery();21$phodevi = new phodevi();22$phodevi->battery();23$phodevi = new phodevi();24$phodevi->battery();25$phodevi = new phodevi();26$phodevi->battery();27$phodevi = new phodevi();28$phodevi->battery();

Full Screen

Full Screen

battery

Using AI Code Generation

copy

Full Screen

1$phodevi = new phodevi_system();2$phodevi->set_battery();3echo $phodevi->get_battery();4echo $phodevi->get_battery_percentage();5echo $phodevi->get_battery_time();6echo $phodevi->get_battery_state();7$phodevi = new phodevi();8$phodevi->set_battery();9echo $phodevi->get_battery();10echo $phodevi->get_battery_percentage();11echo $phodevi->get_battery_time();12echo $phodevi->get_battery_state();13$phodevi = new phodevi();14$phodevi->set_battery();15echo $phodevi->get_battery();16echo $phodevi->get_battery_percentage();17echo $phodevi->get_battery_time();18echo $phodevi->get_battery_state();19$phodevi = new phodevi();20$phodevi->set_battery();21echo $phodevi->get_battery();22echo $phodevi->get_battery_percentage();23echo $phodevi->get_battery_time();24echo $phodevi->get_battery_state();25$phodevi = new phodevi();26$phodevi->set_battery();27echo $phodevi->get_battery();28echo $phodevi->get_battery_percentage();29echo $phodevi->get_battery_time();30echo $phodevi->get_battery_state();31$phodevi = new phodevi();32$phodevi->set_battery();33echo $phodevi->get_battery();34echo $phodevi->get_battery_percentage();35echo $phodevi->get_battery_time();36echo $phodevi->get_battery_state();37$phodevi = new phodevi();38$phodevi->set_battery();39echo $phodevi->get_battery();40echo $phodevi->get_battery_percentage();

Full Screen

Full Screen

battery

Using AI Code Generation

copy

Full Screen

1$system = new phodevi_system();2$system->battery();3echo $system->battery['state'];4echo $system->battery['percentage'];5echo $system->battery['time'];6echo $system->battery['remaining'];7echo $system->battery['remaining_seconds'];8echo $system->battery['remaining_minutes'];9echo $system->battery['remaining_hours'];10echo $system->battery['remaining_days'];11echo $system->battery['remaining_weeks'];12echo $system->battery['remaining_months'];13echo $system->battery['remaining_years'];14echo $system->battery['remaining_decades'];15echo $system->battery['remaining_centuries'];16echo $system->battery['remaining_millenia'];17echo $system->battery['remaining_millennia'];

Full Screen

Full Screen

battery

Using AI Code Generation

copy

Full Screen

1require_once('phodevi_system.php');2$phodevi = new phodevi_system();3$phodevi->battery();4';5';6';7$phodevi->cpu();8';9';10';11$phodevi->memory();12';13';14';15$phodevi->motherboard();16';17';18$phodevi->network();19';20';21$phodevi->os();22';23';24';25';26';27';28$phodevi->video();29';30';31';

Full Screen

Full Screen

battery

Using AI Code Generation

copy

Full Screen

1require_once 'phodevi_system.php';2$system = new phodevi_system();3$system->set_battery_status();4echo $system->get_battery_status();5require_once 'phodevi_system.php';6$system = new phodevi_system();7$system->set_battery_status();8echo $system->get_battery_status();9require_once 'phodevi_system.php';10$system = new phodevi_system();11$system->set_battery_status();12echo $system->get_battery_status();13require_once 'phodevi_system.php';14$system = new phodevi_system();15$system->set_battery_status();16echo $system->get_battery_status();17require_once 'phodevi_system.php';18$system = new phodevi_system();19$system->set_battery_status();20echo $system->get_battery_status();21require_once 'phodevi_system.php';22$system = new phodevi_system();23$system->set_battery_status();24echo $system->get_battery_status();25require_once 'phodevi_system.php';26$system = new phodevi_system();27$system->set_battery_status();28echo $system->get_battery_status();29require_once 'phodevi_system.php';30$system = new phodevi_system();31$system->set_battery_status();32echo $system->get_battery_status();33require_once 'phodevi_system.php';34$system = new phodevi_system();35$system->set_battery_status();36echo $system->get_battery_status();37require_once 'phodevi_system.php';38$system = new phodevi_system();

Full Screen

Full Screen

battery

Using AI Code Generation

copy

Full Screen

1require_once('phodevi.php');2$phodevi = new phodevi();3$phodevi->set_system('battery');4$phodevi->set_system('battery', 'BAT1');5$phodevi->set_system('battery', 'BAT1', 'charge');6$phodevi->set_system('battery', 'BAT1', 'charge', 'percent');7$phodevi->set_system('battery', 'BAT1', 'charge', 'percent', 'int');8$phodevi->set_system('battery', 'BAT1', 'charge', 'percent', 'int', 'array');9$phodevi->set_system('battery', 'BAT1', 'charge', 'percent', 'int', 'array', 'BAT1');10$phodevi->set_system('battery', 'BAT1', 'charge', 'percent', 'int', 'array', 'BAT1', 'charge');11$phodevi->set_system('battery', 'BAT1', 'charge', 'percent', 'int', 'array', 'BAT1', 'charge', 'percent');12$phodevi->set_system('battery', 'BAT1', 'charge', 'percent', 'int', 'array', 'BAT1', 'charge', 'percent', 'int');13$phodevi->set_system('battery', 'BAT1', 'charge', 'percent', 'int', 'array', 'BAT1', 'charge', 'percent', 'int', 'BAT1');14$phodevi->set_system('battery', 'BAT1', 'charge', 'percent', 'int', 'array', 'BAT1', 'charge', 'percent', 'int', 'BAT1', 'charge');15$phodevi->set_system('battery', 'BAT1', 'charge', 'percent', 'int', 'array', 'BAT1', 'charge', 'percent', 'int', 'BAT1', 'charge', 'percent');16$phodevi->set_system('battery', 'BAT1', 'charge', 'percent', 'int', 'array', 'BAT1', 'charge', 'percent', 'int', 'BAT1', 'charge', 'percent', 'int');17require_once('phodevi.php');18$phodevi = new phodevi();

Full Screen

Full Screen

battery

Using AI Code Generation

copy

Full Screen

1$psys = new phodevi_system();2$batt = $psys->battery();3echo $batt['level'];4echo $batt['state'];5echo $batt['time'];6$psen = new phodevi_sensor();7$batt = $psen->battery();8echo $batt['level'];9echo $batt['state'];10echo $batt['time'];11$phodevi = new phodevi();12$batt = $phodevi->battery();13echo $batt['level'];14echo $batt['state'];15echo $batt['time'];16$batt = phodevi::battery();17echo $batt['level'];18echo $batt['state'];19echo $batt['time'];20battery: 100% (Full)

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.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful