How to use is_version method of pts_strings class

Best Phoronix-test-suite code snippet using pts_strings.is_version

phodevi_system.php

Source:phodevi_system.php Github

copy

Full Screen

...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 }1040 else if(pts_client::is_process_running('gnome-panel') || $desktop_session == 'gnome')1041 {1042 // GNOME1043 $desktop_environment = 'GNOME';1044 if(pts_client::executable_in_path('gnome-about'))1045 {1046 $desktop_version = pts_strings::last_in_string(trim(shell_exec('gnome-about --version 2> /dev/null')));1047 }1048 else if(pts_client::executable_in_path('gnome-session'))1049 {1050 $desktop_version = pts_strings::last_in_string(trim(shell_exec('gnome-session --version 2> /dev/null')));1051 }1052 }1053 else if(pts_client::is_process_running('unity-2d-panel') || $desktop_session == 'ubuntu-2d')1054 {1055 // Canonical / Ubuntu Unity 2D Desktop1056 $desktop_environment = 'Unity 2D';1057 if(pts_client::executable_in_path('unity'))1058 {1059 $desktop_version = pts_strings::last_in_string(trim(shell_exec('unity --version 2> /dev/null')));1060 }1061 }1062 else if(pts_client::is_process_running('unity-panel-service') || $desktop_session == 'ubuntu')1063 {1064 // Canonical / Ubuntu Unity Desktop1065 $desktop_environment = 'Unity';1066 if(pts_client::executable_in_path('unity'))1067 {1068 $desktop_version = pts_strings::last_in_string(trim(shell_exec('unity --version 2> /dev/null')));1069 }1070 }1071 else if($desktop_session == 'mate')1072 {1073 $desktop_environment = 'MATE';1074 if(pts_client::executable_in_path('mate-about'))1075 {1076 $desktop_version = pts_strings::last_in_string(trim(shell_exec('mate-about --version 2> /dev/null')));1077 }1078 }1079 else if(($kde5 = pts_client::is_process_running('kded5')))1080 {1081 // KDE 5.x1082 $desktop_environment = 'KDE Frameworks 5';1083 $desktop_version = null; // TODO XXX1084 }1085 else if(($dde = pts_client::is_process_running('dde-desktop')))1086 {1087 // KDE 5.x1088 $desktop_environment = 'Deepin Desktop Environment';1089 $desktop_version = null; // TODO XXX1090 }1091 else if(($kde4 = pts_client::is_process_running('kded4')) || pts_client::is_process_running('kded'))1092 {1093 // KDE 4.x1094 $desktop_environment = 'KDE';1095 $kde_output = trim(shell_exec(($kde4 ? 'kde4-config' : 'kde-config') . ' --version 2>&1'));1096 $kde_lines = explode("\n", $kde_output);1097 for($i = 0; $i < count($kde_lines) && empty($desktop_version); $i++)1098 {1099 $line_segments = pts_strings::colon_explode($kde_lines[$i]);1100 if(in_array($line_segments[0], array('KDE', 'KDE Development Platform')) && isset($line_segments[1]))1101 {1102 $v = trim($line_segments[1]);1103 if(($cut = strpos($v, ' ')) > 0)1104 {1105 $v = substr($v, 0, $cut);1106 }1107 $desktop_version = $v;1108 }1109 }1110 }1111 else if(pts_client::is_process_running('chromeos-wm'))1112 {1113 $chrome_output = trim(shell_exec('chromeos-wm -version'));1114 if($chrome_output == 'chromeos-wm')1115 {1116 // No version actually reported1117 $chrome_output = 'Chrome OS';1118 }1119 $desktop_environment = $chrome_output;1120 }1121 else if(pts_client::is_process_running('lxsession') || $desktop_session == 'lxde')1122 {1123 $lx_output = trim(shell_exec('lxpanel --version'));1124 $version = substr($lx_output, strpos($lx_output, ' ') + 1);1125 $desktop_environment = 'LXDE';1126 $desktop_version = $version;1127 }1128 else if(pts_client::is_process_running('xfce4-session') || pts_client::is_process_running('xfce-mcs-manager') || $desktop_session == 'xfce')1129 {1130 // Xfce 4.x1131 $desktop_environment = 'Xfce';1132 $xfce_output = trim(shell_exec('xfce4-session-settings --version 2>&1'));1133 if(($open = strpos($xfce_output, '(Xfce')) > 0)1134 {1135 $xfce_output = substr($xfce_output, strpos($xfce_output, ' ', $open) + 1);1136 $desktop_version = substr($xfce_output, 0, strpos($xfce_output, ')'));1137 }1138 }1139 else if(pts_client::is_process_running('sugar-session'))1140 {1141 // Sugar Desktop Environment (namely for OLPC)1142 $desktop_environment = 'Sugar';1143 $desktop_version = null; // TODO: where can the Sugar version be figured out?1144 }1145 else if(pts_client::is_process_running('openbox'))1146 {1147 $desktop_environment = 'Openbox';1148 $openbox_output = trim(shell_exec('openbox --version 2>&1'));1149 if(($openbox_d = stripos($openbox_output, 'Openbox ')) !== false)1150 {1151 $openbox_output = substr($openbox_output, ($openbox_d + 8));1152 $desktop_version = substr($openbox_output, 0, strpos($openbox_output, PHP_EOL));1153 }1154 }1155 else if(pts_client::is_process_running('cinnamon'))1156 {1157 $desktop_environment = 'Cinnamon';1158 $desktop_version = pts_strings::last_in_string(trim(shell_exec('cinnamon --version 2> /dev/null')));1159 }1160 else if(pts_client::is_process_running('enlightenment'))1161 {1162 $desktop_environment = 'Enlightenment';1163 $desktop_version = null; // No known -v / --version command on any Enlightenment component1164 }1165 else if(pts_client::is_process_running('consort-panel'))1166 {1167 $desktop_environment = 'Consort';1168 $desktop_version = null; // TODO: Haven't tested Consort Desktop yet1169 }1170 else if(pts_client::is_process_running('razor-desktop'))1171 {1172 $desktop_environment = 'Razor-qt';1173 $desktop_version = null; // TODO: Figure out how to determine razor version1174 }1175 else if(pts_client::is_process_running('icewm'))1176 {1177 $desktop_environment = 'IceWM';1178 $desktop_version = null;1179 }1180 if(!empty($desktop_environment))1181 {1182 $desktop = $desktop_environment;1183 if(!empty($desktop_version) && pts_strings::is_version($desktop_version))1184 {1185 $desktop .= ' ' . $desktop_version;1186 }1187 }1188 return $desktop;1189 }1190 public static function sw_display_server()1191 {1192 $display_servers = array();1193 if(phodevi::is_windows())1194 {1195 // TODO: determine what to do for Windows support1196 }1197 else1198 {1199 if(pts_client::is_process_running('weston'))1200 {1201 $info = 'Wayland Weston';1202 $vinfo = trim(shell_exec('weston --version 2>&1'));1203 if(pts_strings::last_in_string($vinfo) && pts_strings::is_version(pts_strings::last_in_string($vinfo)))1204 {1205 $info .= ' ' . pts_strings::last_in_string($vinfo);1206 }1207 array_push($display_servers, $info);1208 }1209 if(pts_client::is_process_running('unity-system-compositor'))1210 {1211 $unity_system_comp = trim(str_replace('unity-system-compositor', null, shell_exec('unity-system-compositor --version 2>&1')));1212 if(pts_strings::is_version($unity_system_comp))1213 {1214 array_push($display_servers, 'Unity-System-Compositor ' . $unity_system_comp);1215 }1216 }1217 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')))1218 {1219 // Find graphics subsystem version1220 $info = shell_exec($x_bin . ' ' . (phodevi::is_solaris() ? ':0' : '') . ' -version 2>&1');1221 $pos = (($p = strrpos($info, 'Release Date')) !== false ? $p : strrpos($info, 'Build Date'));1222 $info = trim(substr($info, 0, $pos));1223 if($pos === false || getenv('DISPLAY') == false)1224 {1225 $info = null;1226 }...

Full Screen

Full Screen

is_version

Using AI Code Generation

copy

Full Screen

1if(pts_strings::is_version('2.0.0'))2{3 echo 'Version is 2.0.0' . PHP_EOL;4}5{6 echo 'Version is not 2.0.0' . PHP_EOL;7}8if(pts_strings::is_version('2.0.0', '>='))9{10 echo 'Version is 2.0.0 or greater' . PHP_EOL;11}12{13 echo 'Version is not 2.0.0 or greater' . PHP_EOL;14}15if(pts_strings::is_version('2.0.0', '!='))16{17 echo 'Version is not 2.0.0' . PHP_EOL;18}19{20 echo 'Version is 2.0.0' . PHP_EOL;21}22if(pts_strings::is_version('2.0.0', '<'))23{24 echo 'Version is less than 2.0.0' . PHP_EOL;25}26{27 echo 'Version is not less than 2.0.0' . PHP_EOL;28}29if(pts_strings::is_version('2.0.0', '>'))30{31 echo 'Version is greater than 2.0.0' . PHP_EOL;32}33{34 echo 'Version is not greater than 2.0.0' . PHP_EOL;35}36if(pts_strings::is_version('2.0.0', '<='))37{38 echo 'Version is less than or equal to 2.0.0' . PHP_EOL;39}40{41 echo 'Version is not less than or equal to 2.0.0' . PHP_EOL;42}43if(pts_strings::is_version('2.0.0', '>='))44{45 echo 'Version is greater than or equal to 2.0.0' . PHP_EOL;46}47{

Full Screen

Full Screen

is_version

Using AI Code Generation

copy

Full Screen

1if(pts_strings::is_version('1.0.1'))2{3 echo 'Version is 1.0.1';4}5{6 echo 'Version is not 1.0.1';7}8if(pts_strings::is_version('1.0.1', '1.0.0'))9{10 echo 'Version is 1.0.1';11}12{13 echo 'Version is not 1.0.1';14}15if(pts_strings::is_version('1.0.1', '1.0.0', '1.0.2'))16{17 echo 'Version is 1.0.1';18}19{20 echo 'Version is not 1.0.1';21}22if(pts_strings::is_version('1.0.1', '1.0.0', '1.0.2', '1.1.0'))23{24 echo 'Version is 1.0.1';25}26{27 echo 'Version is not 1.0.1';28}29if(pts_strings::is_version('1.0.1', '1.0.0', '1.0.2', '1.1.0', '1.1.1'))30{31 echo 'Version is 1.0.1';32}33{34 echo 'Version is not 1.0.1';35}36if(pts_strings::is_version('1.0.1', '1.0.0', '1.0.2', '1.1.0', '1.1.1', '1.2.0'))37{38 echo 'Version is 1.0.1';39}40{41 echo 'Version is not 1.0.1';42}43if(pts_strings::is_version('1.0.1', '1.0.0', '1.0.2',

Full Screen

Full Screen

is_version

Using AI Code Generation

copy

Full Screen

1if(pts_strings::is_version('1.2.3'))2{3echo "Version is 1.2.3";4}5{6echo "Version is not 1.2.3";7}8if(pts_strings::is_version('1.2.3', '1.2.3'))9{10echo "Version is 1.2.3";11}12{13echo "Version is not 1.2.3";14}15if(pts_strings::is_version('1.2.3', '1.2.3', '1.2.3'))16{17echo "Version is 1.2.3";18}19{20echo "Version is not 1.2.3";21}22if(pts_strings::is_version('1.2.3', '1.2.3', '1.2.3', '1.2.3'))23{24echo "Version is 1.2.3";25}26{27echo "Version is not 1.2.3";28}29if(pts_strings::is_version('1.2.3', '1.2.3', '1.2.3', '1.2.3', '1.2.3'))30{31echo "Version is 1.2.3";32}33{34echo "Version is not 1.2.3";35}

Full Screen

Full Screen

is_version

Using AI Code Generation

copy

Full Screen

1$php_version = phpversion();2if(pts_strings::is_version($php_version, '5.3.0'))3{4 echo 'PHP Version is 5.3.0 or greater';5}6{7 echo 'PHP Version is less than 5.3.0';8}9$php_version = phpversion();10if(pts_strings::is_version($php_version, '5.3.0', '<'))11{12 echo 'PHP Version is less than 5.3.0';13}14{15 echo 'PHP Version is 5.3.0 or greater';16}17$php_version = phpversion();18if(pts_strings::is_version($php_version, '5.3.0', '<='))19{20 echo 'PHP Version is less than or equal to 5.3.0';21}22{23 echo 'PHP Version is greater than 5.3.0';24}25$php_version = phpversion();26if(pts_strings::is_version($php_version, '5.3.0', '>='))27{28 echo 'PHP Version is greater than or equal to 5.3.0';29}30{31 echo 'PHP Version is less than 5.3.0';32}33$php_version = phpversion();34if(pts_strings::is_version($php_version, '5.3.0', '!='))35{36 echo 'PHP Version is not equal to 5.3.0';37}38{39 echo 'PHP Version is equal to 5.3.0';40}41$php_version = phpversion();42if(pts_strings::is_version

Full Screen

Full Screen

is_version

Using AI Code Generation

copy

Full Screen

1$version = '1.2.3';2if(pts_strings::is_version($version))3{4 echo $version . ' is a version';5}6{7 echo $version . ' is not a version';8}

Full Screen

Full Screen

is_version

Using AI Code Generation

copy

Full Screen

1if(pts_strings::is_version('1.0.0'))2echo 'Version is 1.0.0';3echo 'Version is not 1.0.0';4if(pts_strings::is_version('1.0.0', '1.0.0'))5echo 'Version is 1.0.0';6echo 'Version is not 1.0.0';7if(pts_strings::is_version('1.0.0', '1.0.0', '1.0.0'))8echo 'Version is 1.0.0';9echo 'Version is not 1.0.0';10if(pts_strings::is_version('1.0.0', '1.0.0', '1.0.1'))11echo 'Version is 1.0.0';12echo 'Version is not 1.0.0';13if(pts_strings::is_version('1.0.0', '1.0.0', '1.0.0', '1.0.1'))14echo 'Version is 1.0.0';15echo 'Version is not 1.0.0';16if(pts_strings::is_version('1.0.0', '1.0.0', '1.0.0', '1.0.0'))17echo 'Version is 1.0.0';18echo 'Version is not 1.0.0';19if(pts_strings::is_version('1.0.0', '1.0.0', '1.0.0', '1.0.0', '1.0.1'))20echo 'Version is 1.0.0';21echo 'Version is not 1.0.0';22if(pts_strings::is_version('1.0.0', '1.0.0', '1.0.0', '1.0.0', '1.0.0'))

Full Screen

Full Screen

is_version

Using AI Code Generation

copy

Full Screen

1require_once('pts-core.php');2if(pts_strings::is_version('1.0.0', '1.0.1'))3 echo '1.0.0 is less than 1.0.1';4 echo '1.0.0 is not less than 1.0.1';5require_once('pts-core.php');6if(pts_strings::is_version('1.0.1', '1.0.0'))7 echo '1.0.1 is greater than 1.0.0';8 echo '1.0.1 is not greater than 1.0.0';9require_once('pts-core.php');10if(pts_strings::is_version('1.0.0', '1.0.0'))11 echo '1.0.0 is equal to 1.0.0';12 echo '1.0.0 is not equal to 1.0.0';13require_once('pts-core.php');14if(pts_strings::is_version('1.0.0', '1.0.0', '=='))15 echo '1.0.0 is equal to 1.0.0';16 echo '1.0.0 is not equal to 1.0.0';17require_once('pts-core.php');18if(pts_strings::is_version('1.0.0', '1.0.1', '!='))19 echo '1.0.0 is not equal to 1.0.1';20 echo '1.0.0 is equal to 1.0.1';21require_once('pts-core.php');22if(pts_strings::is_version('1.0.0', '1.0.1', '>='))23 echo '1.0.0 is greater than or equal to 1.0.1';

Full Screen

Full Screen

is_version

Using AI Code Generation

copy

Full Screen

1if(pts_strings::is_version(PHP_VERSION, '5.2.0'))2{3 echo 'PHP version is 5.2.0 or higher';4}5{6 echo 'PHP version is lower than 5.2.0';7}8if(pts_strings::is_version(PHP_VERSION, '5.2.0', '>='))9{10 echo 'PHP version is 5.2.0 or higher';11}12{13 echo 'PHP version is lower than 5.2.0';14}15if(pts_strings::is_version(PHP_VERSION, '5.2.0', '<'))16{17 echo 'PHP version is lower than 5.2.0';18}19{20 echo 'PHP version is 5.2.0 or higher';21}22if(pts_strings::is_version(PHP_VERSION, '5.2.0', '<='))23{24 echo 'PHP version is lower than 5.2.0';25}26{27 echo 'PHP version is 5.2.0 or higher';28}29if(pts_strings::is_version(PHP_VERSION, '5.2.0', '!='))30{31 echo 'PHP version is lower than 5.2.0';32}33{34 echo 'PHP version is 5.2.0 or higher';35}36if(pts_strings::is_version(PHP_VERSION, '5.2.0', '=='))37{38 echo 'PHP version is 5.2.0';39}

Full Screen

Full Screen

is_version

Using AI Code Generation

copy

Full Screen

1if(pts_strings::is_version("1.0"))2{3echo "It is a version number";4}5{6echo "It is not a version number";7}8if(pts_strings::is_version("1.0.1"))9{10echo "It is a version number";11}12{13echo "It is not a version number";14}15if(pts_strings::is_version("

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