Best Phoronix-test-suite code snippet using phodevi_disk.extra_disk_details
phodevi_disk.php
Source:phodevi_disk.php
...34 case 'mount-options-string':35 $property = new phodevi_device_property('proc_mount_options_string', phodevi::no_caching);36 break;37 case 'extra-disk-details':38 $property = new phodevi_device_property('extra_disk_details', phodevi::no_caching);39 break;40 }41 return $property;42 }43 public static function device_notes()44 {45 $notes = array();46 if(($disk_scheduler = phodevi::read_property('disk', 'scheduler')) != null)47 {48 array_push($notes, 'Disk Scheduler: ' . $disk_scheduler);49 }50 return $notes;51 }52 public static function proc_mount_options($mount_point = null, $mounts = null)53 {54 $mount_options = false;55 if(phodevi::is_windows())56 {57 // TODO support Windows if relevant?58 // Currently this function hangs Windows client59 return $mount_options;60 }61 if($mount_point == null && PTS_IS_CLIENT)62 {63 $mount_point = pts_client::test_install_root_path();64 }65 if($mounts == null && isset(phodevi::$vfs->mounts))66 {67 $mounts = phodevi::$vfs->mounts;68 }69 do70 {71 $mount_point = dirname($mount_point);72 }73 while(($p = strrpos($mounts, ' ' . $mount_point . ' ')) === false && $mount_point != null && $mount_point != '/');74 if($p)75 {76 if(($x = strrpos($mounts, PHP_EOL, (0 - strlen($mounts) + $p))) !== false)77 {78 $mounts = trim(substr($mounts, $x));79 }80 if(($x = strpos($mounts, PHP_EOL)) !== false)81 {82 $mounts = substr($mounts, 0, $x);83 }84 $mounts = explode(' ', $mounts);85 if(isset($mounts[4]) && $mounts[1] == $mount_point && substr($mounts[0], 0, 1) == '/')86 {87 // Sort mount options alphabetically so it's easier to look at...88 $mounts[3] = explode(',', $mounts[3]);89 sort($mounts[3]);90 $mounts[3] = implode(',', $mounts[3]);91 $mount_options = array(92 'device' => $mounts[0],93 'mount-point' => $mounts[1],94 'file-system' => $mounts[2],95 'mount-options' => $mounts[3]96 );97 }98 }99 return $mount_options;100 }101 public static function proc_mount_options_string($mount_point = null, $mounts = null)102 {103 $mo = phodevi::read_property('disk', 'mount-options');104 if(isset($mo['mount-options']))105 {106 return $mo['mount-options'];107 }108 return null;109 }110 public static function is_genuine($disk)111 {112 return strpos($disk, ' ') > 1 && !pts_strings::has_in_istring($disk, array('VBOX', 'QEMU', 'Virtual'));113 // pts_strings::string_contains($mobo, pts_strings::CHAR_NUMERIC);114 }115 public static function hdd_string()116 {117 $disks = array();118 if(phodevi::is_macosx())119 {120 // TODO: Support reading non-SATA drives and more than one drive121 $capacity = phodevi_osx_parser::read_osx_system_profiler('SPSerialATADataType', 'Capacity');122 $model = phodevi_osx_parser::read_osx_system_profiler('SPSerialATADataType', 'Model');123 if(($cut = strpos($capacity, ' (')) !== false)124 {125 $capacity = substr($capacity, 0, $cut);126 }127 if(($cut = strpos($capacity, ' ')) !== false)128 {129 if(is_numeric(substr($capacity, 0, $cut)))130 {131 $capacity = floor(substr($capacity, 0, $cut)) . substr($capacity, $cut);132 }133 }134 $capacity = str_replace(' GB', 'GB', $capacity);135 if(!empty($capacity) && !empty($model))136 {137 $disks = array($capacity . ' ' . $model);138 }139 }140 else if(phodevi::is_bsd())141 {142 $i = 0;143 do144 {145 $disk = phodevi_bsd_parser::read_sysctl('dev.ad.' . $i . '.%desc');146 if($disk != false && strpos($disk, 'DVD') === false && strpos($disk, 'ATAPI') === false)147 {148 array_push($disks, $disk);149 }150 $i++;151 }152 while(($disk != false || $i < 9) && $i < 128);153 // On some systems, the first drive seems to be at dev.ad.8 rather than starting at dev.ad.0154 if(empty($disks) && pts_client::executable_in_path('camcontrol'))155 {156 $camcontrol = trim(shell_exec('camcontrol devlist 2>&1'));157 foreach(explode(PHP_EOL, $camcontrol) as $line)158 {159 if(substr($line, 0, 1) == '<' && ($model_end = strpos($line, '>')) !== false && strpos($line, 'DVD') === false && strpos($line, 'ATAPI') === false)160 {161 $disk = self::prepend_disk_vendor(substr($line, 1, ($model_end - 1)));162 array_push($disks, $disk);163 }164 }165 }166 }167 else if(phodevi::is_solaris())168 {169 if(is_executable('/usr/ddu/bin/i386/hd_detect'))170 {171 $hd_detect = explode(PHP_EOL, trim(shell_exec('/usr/ddu/bin/i386/hd_detect -l 2>&1')));172 foreach($hd_detect as $hd_line)173 {174 if(isset($hd_line) && ($hd_pos = strpos($hd_line, ':/')) != false)175 {176 $disk = trim(substr($hd_line, 0, $hd_pos));177 $disk = self::prepend_disk_vendor($disk);178 if($disk != 'blkdev')179 {180 array_push($disks, $disk);181 }182 }183 }184 }185 }186 else if(phodevi::is_linux())187 {188 $disks_formatted = array();189 $disks = array();190 foreach(array_merge(pts_file_io::glob('/sys/block/sd*'), pts_file_io::glob('/sys/block/mmcblk*'), pts_file_io::glob('/sys/block/nvme*')) as $sdx)191 {192 if(strpos($sdx, 'boot') !== false)193 {194 // Don't include devices like /sys/block/mmcblk0boot[0,1] as it's repeat of /sys/block/mmcblk0195 continue;196 }197 if((is_file($sdx . '/device/name') || is_file($sdx . '/device/model')) && is_file($sdx . '/size'))198 {199 $disk_size = pts_file_io::file_get_contents($sdx . '/size');200 $disk_model = pts_file_io::file_get_contents($sdx . (is_file($sdx . '/device/model') ? '/device/model' : '/device/name'));201 $disk_removable = pts_file_io::file_get_contents($sdx . '/removable');202 if($disk_removable == '1')203 {204 // Don't count removable disks205 continue;206 }207 $disk_size = round($disk_size * 512 / 1000000000) . 'GB';208 $disk_model = self::prepend_disk_vendor($disk_model);209 if(strpos($disk_model, $disk_size . ' ') === false && strpos($disk_model, ' ' . $disk_size) === false && $disk_size != '1GB')210 {211 $disk_model = $disk_size . ' ' . $disk_model;212 }213 if($disk_size > 0)214 {215 array_push($disks_formatted, $disk_model);216 }217 }218 }219 for($i = 0; $i < count($disks_formatted); $i++)220 {221 if(!empty($disks_formatted[$i]))222 {223 $times_found = 1;224 for($j = ($i + 1); $j < count($disks_formatted); $j++)225 {226 if($disks_formatted[$i] == $disks_formatted[$j])227 {228 $times_found++;229 $disks_formatted[$j] = '';230 }231 }232 $disk = ($times_found > 1 ? $times_found . ' x ' : null) . $disks_formatted[$i];233 array_push($disks, $disk);234 }235 }236 }237 if(count($disks) == 0)238 {239 $root_disk_size = ceil(disk_total_space('/') / 1073741824);240 $pts_disk_size = ceil(disk_total_space(pts_client::test_install_root_path()) / 1073741824);241 if($pts_disk_size > $root_disk_size)242 {243 $root_disk_size = $pts_disk_size;244 }245 if($root_disk_size > 1)246 {247 $disks = $root_disk_size . 'GB';248 }249 else250 {251 $disks = null;252 }253 }254 else255 {256 $disks = implode(' + ', $disks);257 }258 return $disks;259 }260 protected static function prepend_disk_vendor($disk_model)261 {262 if(isset($disk_model[4]))263 {264 $disk_manufacturer = null;265 $third_char = substr($disk_model, 2, 1);266 switch(substr($disk_model, 0, 2))267 {268 case 'WD':269 $disk_manufacturer = 'Western Digital';270 if(substr($disk_model, 0, 4) == 'WDC ')271 {272 $disk_model = substr($disk_model, 4);273 }274 break;275 case 'MK':276 $disk_manufacturer = 'Toshiba';277 break;278 case 'HD':279 if($third_char == 'T')280 {281 $disk_manufacturer = 'Hitachi';282 }283 break;284 case 'HT':285 $disk_manufacturer = 'Hitachi';286 break;287 case 'HM':288 case 'HN':289 // HM and HN appear to be Samsung series290 $disk_manufacturer = 'Samsung';291 break;292 case 'ST':293 if($third_char == 'T')294 {295 $disk_manufacturer = 'Super Talent';296 }297 else if($third_char != 'E')298 {299 $disk_manufacturer = 'Seagate';300 }301 break;302 }303 if($disk_manufacturer != null && strpos($disk_model, $disk_manufacturer) === false)304 {305 $disk_model = $disk_manufacturer . ' ' . $disk_model;306 }307 // OCZ SSDs aren't spaced308 $disk_model = str_replace('OCZ-', 'OCZ ', $disk_model);309 }310 return $disk_model;311 }312 public static function hdd_scheduler()313 {314 $scheduler = null;315 $device = self::proc_mount_options();316 $device = basename($device['device']);317 if(is_readable('/sys/block/' . ($d = pts_strings::keep_in_string($device, pts_strings::CHAR_LETTER)) . '/queue/scheduler'))318 {319 $scheduler = '/sys/block/' . $d . '/queue/scheduler';320 }321 else if(is_link(($device = '/dev/disk/by-uuid/' . $device)))322 {323 // Go from the disk UUID to the device324 $device = pts_strings::keep_in_string(basename(readlink($device)), pts_strings::CHAR_LETTER);325 if(is_readable('/sys/block/' . $device . '/queue/scheduler'))326 {327 $scheduler = '/sys/block/' . $device . '/queue/scheduler';328 }329 }330 else if(is_readable('/sys/block/sda/queue/scheduler'))331 {332 $scheduler = '/sys/block/sda/queue/scheduler';333 }334 if($scheduler)335 {336 $scheduler = pts_file_io::file_get_contents($scheduler);337 if(($s = strpos($scheduler, '[')) !== false && ($e = strpos($scheduler, ']', $s)) !== false)338 {339 $scheduler = strtoupper(substr($scheduler, ($s + 1), ($e - $s - 1)));340 }341 }342 return $scheduler;343 }344 public static function extra_disk_details()345 {346 $device = self::proc_mount_options();347 $mount_point = $device['mount-point'];348 $extra_details = null;349 if(strtolower($device['file-system']) == 'btrfs' && pts_client::executable_in_path('btrfs'))350 {351 $btrfs_fi_df = shell_exec('btrfs fi df ' . $mount_point . ' 2>&1');352 if(($f = strpos($btrfs_fi_df, 'Data, ')) !== false)353 {354 $btrfs_fi_df = substr($btrfs_fi_df, ($f + strlen('Data, ')));355 $btrfs_fi_df = substr($btrfs_fi_df, 0, strpos($btrfs_fi_df, ': '));356 if(strpos($btrfs_fi_df, 'RAID') !== false)357 {358 $extra_details = $btrfs_fi_df;...
extra_disk_details
Using AI Code Generation
1require_once 'phodevi.php';2$extra_disk_details = phodevi_disk::extra_disk_details();3print_r($extra_disk_details);4 (5 (6 (7 (8 (9 (10 (11 (12 (13 (
extra_disk_details
Using AI Code Generation
1$disk = new phodevi_disk();2$disk->extra_disk_details();3$disk = new phodevi_disk();4$disk->extra_disk_details();5$disk = new phodevi_disk();6$disk->extra_disk_details();7$disk = new phodevi_disk();8$disk->extra_disk_details();9$disk = new phodevi_disk();10$disk->extra_disk_details();11$disk = new phodevi_disk();12$disk->extra_disk_details();13$disk = new phodevi_disk();14$disk->extra_disk_details();15$disk = new phodevi_disk();16$disk->extra_disk_details();17$disk = new phodevi_disk();18$disk->extra_disk_details();19$disk = new phodevi_disk();20$disk->extra_disk_details();21$disk = new phodevi_disk();22$disk->extra_disk_details();23$disk = new phodevi_disk();24$disk->extra_disk_details();
extra_disk_details
Using AI Code Generation
1$disk = phodevi_disk::extra_disk_details('/dev/sda');2$disk = phodevi_disk::extra_disk_details('/dev/sda');3$disk = phodevi_disk::extra_disk_details('/dev/sda');4$disk = phodevi_disk::extra_disk_details('/dev/sda');5$disk = phodevi_disk::extra_disk_details('/dev/sda');6$disk = phodevi_disk::extra_disk_details('/dev/sda');7$disk = phodevi_disk::extra_disk_details('/dev/sda');8$disk = phodevi_disk::extra_disk_details('/dev/sda');9$disk = phodevi_disk::extra_disk_details('/dev/sda');10$disk = phodevi_disk::extra_disk_details('/dev/sda');11$disk = phodevi_disk::extra_disk_details('/dev/sda');12$disk = phodevi_disk::extra_disk_details('/dev/s
extra_disk_details
Using AI Code Generation
1include_once('phodevi.php');2$disks = phodevi::read_property('disk', 'extra_disk_details');3print_r($disks);4 (5 (6 (7 (8 (9 (10 (
extra_disk_details
Using AI Code Generation
1require_once('/usr/share/php/phodevi/disk.php');2$disk = new phodevi_disk();3$disk->extra_disk_details('sda', 'model');4require_once('/usr/share/php/phodevi/disk.php');5$disk = new phodevi_disk();6$disk->extra_disk_details('sda', 'model');7require_once('/usr/share/php/phodevi/disk.php');8$disk = new phodevi_disk();9$disk->extra_disk_details('sda', 'model');10require_once('/usr/share/php/phodevi/disk.php');11$disk = new phodevi_disk();12$disk->extra_disk_details('sda', 'model');13require_once('/usr/share/php/phodevi/disk.php');14$disk = new phodevi_disk();15$disk->extra_disk_details('sda', 'model');16require_once('/usr/share/php/phodevi/disk.php');17$disk = new phodevi_disk();18$disk->extra_disk_details('sda', 'model');19require_once('/usr/share/php/phodevi/disk.php');
extra_disk_details
Using AI Code Generation
1$disk = new phodevi_disk();2$disk->extra_disk_details('sda');3$disk = new phodevi_disk();4$disk->extra_disk_details('sdb');5$disk = new phodevi_disk();6$disk->extra_disk_details('sdc');7$disk = new phodevi_disk();8$disk->extra_disk_details('sdd');9$disk = new phodevi_disk();10$disk->extra_disk_details('sde');11$disk = new phodevi_disk();12$disk->extra_disk_details('sdf');13$disk = new phodevi_disk();14$disk->extra_disk_details('sdg');15$disk = new phodevi_disk();16$disk->extra_disk_details('sdh');
extra_disk_details
Using AI Code Generation
1$disk = new phodevi_disk();2$disk->extra_disk_details(true);3$disk = new phodevi_disk();4$disk->extra_disk_details(true, 'hda');5$disk->extra_disk_details(false, 'hda');6$disk = new phodevi_disk();7$disk->extra_disk_details(true);8$disk->extra_disk_details(false);9$disk = new phodevi_disk();10$disk->extra_disk_details(true, 'hda');11$disk->extra_disk_details(false, 'hda');12$disk = new phodevi_disk();13$disk->extra_disk_details(true, 'hda');14$disk->extra_disk_details(false, 'hda');15$disk = new phodevi_disk();16$disk->extra_disk_details(true, 'hda');17$disk->extra_disk_details(false, 'hda');18$disk = new phodevi_disk();19$disk->extra_disk_details(true, 'hda');20$disk->extra_disk_details(false, 'hda');21$disk = new phodevi_disk();22$disk->extra_disk_details(true, 'hda');23$disk->extra_disk_details(false, 'hda');24$disk = new phodevi_disk();25$disk->extra_disk_details(true, '
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Execute automation tests with extra_disk_details on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.
Test now for FreeGet 100 minutes of automation test minutes FREE!!