Best Phoronix-test-suite code snippet using must.motherboard_string
phodevi_motherboard.php
Source:phodevi_motherboard.php
...22 {23 switch($identifier)24 {25 case 'identifier':26 $property = new phodevi_device_property('motherboard_string', phodevi::smart_caching);27 break;28 case 'serial-number':29 $property = new phodevi_device_property('serial_number', phodevi::smart_caching);30 break;31 case 'power-mode':32 $property = new phodevi_device_property('power_mode', phodevi::smart_caching);33 break;34 case 'pci-devices':35 $property = new phodevi_device_property('pci_devices', phodevi::smart_caching);36 break;37 case 'usb-devices':38 $property = new phodevi_device_property('usb_devices', phodevi::std_caching);39 break;40 }41 return $property;42 }43 public static function usb_devices()44 {45 $usb = array();46 if(phodevi::is_linux())47 {48 foreach(pts_file_io::glob('/sys/bus/usb/devices/*-*/manufacturer') as $usb_dir)49 {50 $usb_dir = dirname($usb_dir) . '/';51 if(!is_file($usb_dir . 'product') || !is_file($usb_dir . 'idProduct') || !is_file($usb_dir . 'idVendor'))52 {53 continue;54 }55 $vendor = pts_strings::trim_search_query(pts_strings::strip_string(pts_file_io::file_get_contents($usb_dir . 'manufacturer')));56 $device = pts_strings::trim_search_query(pts_strings::strip_string(str_replace($vendor, null, pts_file_io::file_get_contents($usb_dir . 'product'))));57 $device = pts_strings::keep_in_string($device, pts_strings::CHAR_LETTER | pts_strings::CHAR_NUMERIC | pts_strings::CHAR_DECIMAL | pts_strings::CHAR_SPACE | pts_strings::CHAR_DASH | pts_strings::CHAR_UNDERSCORE | pts_strings::CHAR_COLON | pts_strings::CHAR_COMMA);58 if($vendor == null || $device == null || $vendor == 'Generic')59 {60 continue;61 }62 array_push($usb, array(63 'Class' => pts_file_io::file_get_contents($usb_dir . 'bDeviceClass'),64 'Vendor' => $vendor,65 'Device' => $device,66 'VendorID' => pts_file_io::file_get_contents($usb_dir . 'idVendor'),67 'DeviceID' => pts_file_io::file_get_contents($usb_dir . 'idProduct')68 ));69 }70 }71 return $usb;72 }73 public static function is_genuine($mobo)74 {75 return strpos($mobo, ' ') > 1 && !pts_strings::has_in_istring($mobo, array('Virtual', 'Bochs', '440BX', 'Megatrends', 'Award ', 'Software', 'Xen', 'HVM ', 'Notebook', 'OEM ', ' KVM', 'unknown')) && !is_numeric(substr($mobo, 0, strpos($mobo, ' ')));76 // pts_strings::string_contains($mobo, pts_strings::CHAR_NUMERIC);77 }78 public static function pci_devices()79 {80 $pci_devices = array();81 if(phodevi::is_linux() && isset(phodevi::$vfs->lspci))82 {83 $lspci = phodevi::$vfs->lspci;84 $lspci = explode("\n\n", $lspci);85 foreach($lspci as $o => &$lspci_section)86 {87 $lspci_section = explode("\n", $lspci_section);88 $formatted_section = array();89 foreach($lspci_section as $i => &$line)90 {91 $line = explode(':', $line);92 if(count($line) == 2 && in_array($line[0], array('Class', 'Vendor', 'Device', 'Driver', 'Rev', 'Module')))93 {94 $line[1] = trim($line[1]);95 if(($c = strrpos($line[1], ' [')) !== false)96 {97 $id = substr($line[1], ($c + 2));98 $id = '0x' . substr($id, 0, strpos($id, ']'));99 switch($line[0])100 {101 case 'Vendor':102 $formatted_section['VendorID'] = $id;103 break;104 case 'Device':105 $formatted_section['DeviceID'] = $id;106 break;107 }108 $line[1] = substr($line[1], 0, $c);109 }110 if($line[0] == 'Class')111 {112 switch($line[1])113 {114 case 'Ethernet controller':115 case 'Network controller':116 $line[1] = 'Network';117 break;118 case 'VGA compatible controller':119 $line[1] = 'GPU';120 break;121 case 'Audio device':122 case 'Multimedia audio controller':123 $line[1] = 'Audio';124 break;125 // case 'RAM memory':126 // case 'Host bridge':127 // $line[1] = 'Chipset';128 // break;129 default:130 $line[1] = null;131 break;132 }133 }134 else if($line[0] == 'Device' || $line[0] == 'Vendor')135 {136 $line[1] = pts_strings::trim_search_query(pts_strings::strip_string($line[1]));137 $line[1] = pts_strings::keep_in_string($line[1], pts_strings::CHAR_LETTER | pts_strings::CHAR_NUMERIC | pts_strings::CHAR_DECIMAL | pts_strings::CHAR_SPACE | pts_strings::CHAR_DASH | pts_strings::CHAR_UNDERSCORE | pts_strings::CHAR_COLON | pts_strings::CHAR_COMMA);138 }139 $formatted_section[$line[0]] = $line[1];140 }141 }142 if(count($formatted_section) > 0 && $formatted_section['Class'] != null)143 {144 array_push($pci_devices, $formatted_section);145 }146 }147 }148 return $pci_devices;149 }150 public static function parse_pci_device_data(&$lspci, &$dmesg, $ignore_external_pci_devices = false)151 {152 $pci_devices = explode(PHP_EOL . PHP_EOL, $lspci);153 $sanitized_devices = array();154 foreach($pci_devices as &$device)155 {156 $device .= PHP_EOL;157 $location = substr($device, 0, strpos($device, ' '));158 if(!strpos($location, ':') || !strpos($location, '.'))159 {160 // If it's not a valid PCI bus location (i.e. XX:YY.Z), it's probably not formatted well or wrong161 continue;162 }163 $class = substr($device, ($s = (strpos($device, '[') + 1)), (strpos($device, ']', $s) - $s));164 if(!(isset($class[3]) && !isset($class[4])))165 {166 // class must be 4 characters: 2 for class, 2 for sub-class167 continue;168 }169 // 0300 is GPUs170 if($ignore_external_pci_devices && in_array($class, array('0300')))171 {172 // Don't report external PCI devices173 continue;174 }175 $device_class = substr($class, 0, 2);176 $sub_class = substr($class, 2, 2);177 $device_name = substr($device, ($l = strpos($device, ']:') + 3), ($s = strpos($device, ':', $l)) - $l);178 $device_name = substr($device_name, 0, strrpos($device_name, ' ['));179 $device_name = str_replace('/', '-', str_replace(array('[AMD]', '[SiS]'), null, $device_name));180 $device_name = pts_strings::strip_string($device_name);181 if($device_name == null || strpos($device_name, ' ') === false)182 {183 // it must be junk not worth reporting184 continue;185 }186 $temp = substr($device, $s - 5);187 if($temp[0] != '[' || $temp[10] != ']')188 {189 continue;190 }191 $vendor_id = substr($temp, 1, 4);192 $device_id = substr($temp, 6, 4);193 $drivers = array();194 if(($s = strpos($device, 'Kernel driver in use:')) !== false)195 {196 $temp = substr($device, ($s = $s + 22), (strpos($device, PHP_EOL, $s) - $s));197 if($temp != null)198 {199 array_push($drivers, $temp);200 }201 }202 if(($s = strpos($device, 'Kernel modules:')) !== false)203 {204 $temp = substr($device, ($s = $s + 16), (strpos($device, PHP_EOL, $s) - $s));205 if($temp != null)206 {207 foreach(explode(' ', trim($temp)) as $temp)208 {209 $temp = str_replace(',', null, $temp);210 if($temp != null && !in_array($temp, $drivers))211 {212 array_push($drivers, $temp);213 }214 }215 }216 }217 if(empty($drivers))218 {219 // If there's no drivers, nothing to report220 continue;221 }222 if(!in_array($vendor_id . ':' . $device_id, array_keys($sanitized_devices)))223 {224 $dmesg_example = array();225 if($dmesg != null)226 {227 foreach($drivers as $driver)228 {229 $offset = 1;230 while($offset != false && ($offset = strpos($dmesg, $driver, $offset)) !== false)231 {232 $line = substr($dmesg, 0, strpos($dmesg, "\n", $offset));233 $line = substr($line, strrpos($line, "\n"));234 $line = trim(substr($line, strpos($line, '] ') + 2));235 if($line != null && !isset($line[128]))236 {237 array_push($dmesg_example, $line);238 }239 $offset = strpos($dmesg, "\n", ($offset + 1));240 }241 }242 }243 $sanitized_devices[$vendor_id . ':' . $device_id] = array(244 $vendor_id,245 $device_id,246 $device_name,247 $device_class,248 $sub_class,249 $drivers,250 trim($device),251 implode(PHP_EOL, $dmesg_example)252 );253 }254 }255 return $sanitized_devices;256 }257 public static function power_mode()258 {259 // Returns the power mode260 $return_status = null;261 if(phodevi::is_linux())262 {263 $sysfs_checked = false;264 foreach(pts_file_io::glob('/sys/class/power_supply/AC*/online') as $online)265 {266 if(pts_file_io::file_get_contents($online) == '0')267 {268 $return_status = 'This computer was running on battery power';269 break;270 }271 $sysfs_checked = true;272 }273 if(!$sysfs_checked)274 {275 // There likely was no sysfs power_supply support for that power adapter276 $power_state = phodevi_linux_parser::read_acpi('/ac_adapter/AC/state', 'state');277 if($power_state == 'off-line')278 {279 $return_status = 'This computer was running on battery power';280 }281 }282 }283 return $return_status;284 }285 public static function serial_number()286 {287 $serial = null;288 if(phodevi::is_linux())289 {290 $serial = phodevi_linux_parser::read_dmidecode('system', 'System Information', 'Serial Number', true, array());291 }292 return $serial;293 }294 public static function motherboard_string()295 {296 // Returns the motherboard / system model name or number297 $info = null;298 if(phodevi::is_macosx())299 {300 $info = phodevi_osx_parser::read_osx_system_profiler('SPHardwareDataType', 'ModelName');301 }302 else if(phodevi::is_solaris())303 {304 $manufacturer = phodevi_solaris_parser::read_sun_ddu_dmi_info(array('MotherBoardInformation,Manufacturer', 'SystemInformation,Manufacturer'));305 $product = phodevi_solaris_parser::read_sun_ddu_dmi_info(array('MotherBoardInformation,Product', 'SystemInformation,Product', 'SystemInformation,Model'));306 if(count($manufacturer) == 1 && count($product) == 1)307 {308 $info = $manufacturer[0] . ' ' . $product[0];...
motherboard_string
Using AI Code Generation
1require_once('must.php');2$must = new must();3echo $must->motherboard_string();4require_once('must.php');5$must = new must();6echo $must->motherboard_string();7require_once('must.php');8$must = new must();9echo $must->motherboard_string();
motherboard_string
Using AI Code Generation
1require_once 'must.php';2$must = new must();3echo $must->motherboard_string();4require_once 'must.php';5$must = new must();6echo $must->ram_string();7require_once 'must.php';8$must = new must();9echo $must->cpu_string();10require_once 'must.php';11$must = new must();12echo $must->gpu_string();13require_once 'must.php';14$must = new must();15echo $must->psu_string();16require_once 'must.php';17$must = new must();18echo $must->hdd_string();19require_once 'must.php';20$must = new must();21echo $must->ssd_string();22require_once 'must.php';23$must = new must();24echo $must->case_string();25require_once 'must.php';26$must = new must();27echo $must->fan_string();28require_once 'must.php';29$must = new must();30echo $must->cooler_string();31require_once 'must.php';32$must = new must();33echo $must->keyboard_string();34require_once 'must.php';35$must = new must();36echo $must->mouse_string();37require_once 'must.php';38$must = new must();39echo $must->monitor_string();40require_once 'must.php';
motherboard_string
Using AI Code Generation
1require_once 'motherboard.php';2$motherboard = new Motherboard();3echo $motherboard->motherboard_string();4require_once 'motherboard.php';5$motherboard = new Motherboard();6echo $motherboard->motherboard_string();
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 motherboard_string 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!!