Best Phoronix-test-suite code snippet using pts_result_file.get_system_log_dir
pts_result_file.php
Source:pts_result_file.php
...142 {143 $composite_xml_dir = dirname($this->get_file_location());144 return empty($composite_xml_dir) || !is_dir($composite_xml_dir) ? false : $composite_xml_dir . '/';145 }146 public function get_system_log_dir($result_identifier = null, $dir_check = true)147 {148 $log_dir = dirname($this->get_file_location());149 if(empty($log_dir) || !is_dir($log_dir))150 {151 return false;152 }153 $sdir = $log_dir . '/system-logs/';154 if($result_identifier == null)155 {156 return $sdir;157 }158 else159 {160 $sdir = $sdir . pts_strings::simplify_string_for_file_handling($result_identifier) . '/';161 return !$dir_check || is_dir($sdir) ? $sdir : false;162 }163 }164 public function get_test_log_dir(&$result_object = null)165 {166 $log_dir = !empty($this->get_file_location()) ? dirname($this->get_file_location()) : '';167 if(empty($log_dir) || !is_dir($log_dir))168 {169 return false;170 }171 return $log_dir . '/test-logs/' . ($result_object != null ? $result_object->get_comparison_hash(true, false) . '/' : null);172 }173 public function get_test_installation_log_dir()174 {175 $log_dir = dirname($this->get_file_location());176 if(empty($log_dir) || !is_dir($log_dir))177 {178 return false;179 }180 return $log_dir . '/installation-logs/';181 }182 public function save()183 {184 if($this->get_file_location() && is_file($this->get_file_location()))185 {186 return file_put_contents($this->get_file_location(), $this->get_xml());187 }188 }189 public function get_last_modified()190 {191 return $this->last_modified;192 }193 public function validate()194 {195 $dom = new DOMDocument();196 $dom->loadXML($this->get_xml());197 return $dom->schemaValidate(pts_openbenchmarking::openbenchmarking_standards_path() . 'schemas/result-file.xsd');198 }199 public function __toString()200 {201 return $this->get_identifier();202 }203 protected static function clean_input($value)204 {205 return strip_tags($value);206 /*207 if(is_array($value))208 {209 return array_map(array($this, 'clean_input'), $value);210 }211 else212 {213 return strip_tags($value);214 }215 */216 }217 public function get_identifier()218 {219 return $this->save_identifier;220 }221 public function add_system($system)222 {223 if(!in_array($system, $this->systems))224 {225 $this->systems[] = $system;226 }227 }228 public function get_systems()229 {230 return $this->systems;231 }232 public function get_system_hardware()233 {234 // XXX this is deprecated235 $hw = array();236 foreach($this->systems as &$s)237 {238 $hw[] = $s->get_hardware();239 }240 return $hw;241 }242 public function get_system_software()243 {244 // XXX this is deprecated245 $sw = array();246 foreach($this->systems as &$s)247 {248 $sw[] = $s->get_software();249 }250 return $sw;251 }252 public function get_system_identifiers()253 {254 // XXX this is deprecated255 $ids = array();256 foreach($this->systems as &$s)257 {258 $ids[] = $s->get_identifier();259 }260 return $ids;261 }262 public function get_system_identifiers_by_date()263 {264 $by_date = array();265 foreach($this->get_systems() as $s)266 {267 $by_date[$s->get_identifier()] = strtotime($s->get_timestamp());268 }269 asort($by_date);270 return array_keys($by_date);271 }272 public function is_system_identifier_in_result_file($identifier)273 {274 foreach($this->systems as &$s)275 {276 if($s->get_identifier() == $identifier)277 {278 return true;279 }280 }281 return false;282 }283 public function system_logs_available()284 {285 $has_system_logs = false;286 $system_log_dir_or_zip = is_dir($this->get_system_log_dir(null, true)) || is_file($this->get_result_dir() . 'system-logs.zip');287 if($system_log_dir_or_zip)288 {289 if($this->get_system_count() == 1)290 {291 // If just one system in result file and there is a log, safe to assume it's for the associated run...292 $has_system_logs = true;293 }294 else295 {296 foreach($this->systems as &$s)297 {298 if($s->has_log_files())299 {300 $has_system_logs = true;301 break;302 }303 }304 }305 }306 return $has_system_logs;307 }308 public function identifiers_with_system_logs()309 {310 $identifiers = array();311 $system_log_dir = $this->get_system_log_dir(null, true);312 if($system_log_dir && is_dir($system_log_dir))313 {314 foreach(pts_file_io::glob($system_log_dir . '/*') as $identifier_dir)315 {316 $identifiers[] = basename($identifier_dir);317 }318 }319 else if($this->get_result_dir() && is_file($this->get_result_dir() . 'system-logs.zip'))320 {321 $zip = new ZipArchive();322 $res = $zip->open($this->get_result_dir() . 'system-logs.zip');323 if($res === true)324 {325 for($i = 0; $i < $zip->numFiles; $i++)326 {327 $index = explode('/', $zip->getNameIndex($i));328 if(!empty($index[1]) && !in_array($index[1], $identifiers))329 {330 $identifiers[] = $index[1];331 }332 }333 $zip->close();334 }335 }336 return $identifiers;337 }338 public function get_system_count()339 {340 return count($this->systems);341 }342 public function set_title($new_title)343 {344 if($new_title != null)345 {346 $this->title = $new_title;347 }348 }349 public function get_title()350 {351 return $this->title;352 }353 public function append_description($append_description)354 {355 if($append_description != null && strpos($this->description, $append_description) === false)356 {357 $this->description .= PHP_EOL . $append_description;358 }359 }360 public function set_description($new_description)361 {362 if($new_description != null)363 {364 $this->description = $new_description;365 }366 }367 public function get_description()368 {369 return $this->description;370 }371 public function set_notes($notes)372 {373 if($notes != null)374 {375 $this->notes = $notes;376 }377 }378 public function get_notes()379 {380 return $this->notes;381 }382 public function set_internal_tags($tags)383 {384 if($tags != null)385 {386 $this->internal_tags = $tags;387 }388 }389 public function get_internal_tags()390 {391 return $this->internal_tags;392 }393 public function set_reference_id($new_reference_id)394 {395 if($new_reference_id != null)396 {397 $this->reference_id = $new_reference_id;398 }399 }400 public function get_reference_id()401 {402 return $this->reference_id;403 }404 public function set_preset_environment_variables($env)405 {406 if($env != null)407 {408 $this->preset_environment_variables = $env;409 }410 }411 public function get_preset_environment_variables()412 {413 return $this->preset_environment_variables;414 }415 public function get_test_count()416 {417 return count($this->get_result_objects());418 }419 public function get_qualified_test_count()420 {421 $q_count = 0;422 foreach($this->get_result_objects() as $ro)423 {424 if($ro->test_profile->get_identifier() != null)425 {426 $q_count++;427 }428 }429 return $q_count;430 }431 public function has_matching_test_and_run_identifier(&$test_result, $run_identifier_to_check)432 {433 $found_match = false;434 $hash_to_check = $test_result->get_comparison_hash();435 foreach($this->get_result_objects() as $result_object)436 {437 if($hash_to_check == $result_object->get_comparison_hash())438 {439 if(in_array($run_identifier_to_check, $result_object->test_result_buffer->get_identifiers()) && $result_object->test_result_buffer->get_result_from_identifier($run_identifier_to_check) != '')440 {441 $found_match = true;442 }443 break;444 }445 }446 return $found_match;447 }448 public function get_contained_tests_hash($raw_output = true)449 {450 $result_object_hashes = $this->get_result_object_hashes();451 sort($result_object_hashes);452 return sha1(implode(',', $result_object_hashes), $raw_output);453 }454 public function get_result_object_hashes()455 {456 $object_hashes = array();457 foreach($this->get_result_objects() as $result_object)458 {459 $object_hashes[] = $result_object->get_comparison_hash();460 }461 return $object_hashes;462 }463 public function is_results_tracker()464 {465 // If there are more than five results and the only changes in the system identifier names are numeric changes, assume it's a tracker466 // i.e. different dates or different versions of a package being tested467 if($this->is_tracker === -1)468 {469 $identifiers = $this->get_system_identifiers();470 if(isset($identifiers[5]))471 {472 // dirty SHA1 hash check473 $is_sha1_hash = strlen($identifiers[0]) == 40 && strpos($identifiers[0], ' ') === false;474 $has_sha1_shorthash = false;475 foreach($identifiers as $i => &$identifier)476 {477 $has_sha1_shorthash = ($i == 0 || $has_sha1_shorthash) && isset($identifier[7]) && pts_strings::string_only_contains(substr($identifier, -8), pts_strings::CHAR_NUMERIC | pts_strings::CHAR_LETTER) && strpos($identifier, ' ') === false;478 $identifier = pts_strings::remove_from_string($identifier, pts_strings::CHAR_NUMERIC | pts_strings::CHAR_DASH | pts_strings::CHAR_DECIMAL);479 }480 $this->is_tracker = count(array_unique($identifiers)) <= 1 || $is_sha1_hash || $has_sha1_shorthash;481 if($this->is_tracker)482 {483 $hw = $this->get_system_hardware();484 if(isset($hw[1]) && count($hw) == count(array_unique($hw)))485 {486 // it can't be a results tracker if the hardware is always different487 $this->is_tracker = false;488 }489 }490 if($this->is_tracker == false)491 {492 // See if only numbers are changing between runs493 foreach($identifiers as $i => &$identifier)494 {495 if(($x = strpos($identifier, ': ')) !== false)496 {497 $identifier = substr($identifier, ($x + 2));498 }499 if($i > 0 && pts_strings::remove_from_string($identifier, pts_strings::CHAR_NUMERIC | pts_strings::CHAR_DECIMAL) != pts_strings::remove_from_string($identifiers[($i - 1)], pts_strings::CHAR_NUMERIC | pts_strings::CHAR_DECIMAL))500 {501 return false;502 }503 }504 $this->is_tracker = true;505 }506 }507 else508 {509 // Definitely not a tracker as not over 5 results510 $this->is_tracker = false;511 }512 }513 return $this->is_tracker;514 }515 public function is_multi_way_comparison($identifiers = false, $extra_attributes = null)516 {517 if(isset($extra_attributes['force_tracking_line_graph']))518 {519 // Phoromatic result tracker520 $is_multi_way = true;521 $this->is_multi_way_inverted = true;522 }523 else524 {525 $hw = null; // XXX: this isn't used anymore at least for now on system hardware526 if($identifiers == false)527 {528 $identifiers = $this->get_system_identifiers();529 }530 $is_multi_way = count($identifiers) < 2 ? false : pts_render::multi_way_identifier_check($identifiers, $hw, $this);531 $this->is_multi_way_inverted = $is_multi_way && $is_multi_way[1];532 }533 return $is_multi_way;534 }535 public function is_multi_way_inverted()536 {537 return $this->is_multi_way_inverted;538 }539 public function get_contained_test_profiles($unique = false)540 {541 $test_profiles = array();542 foreach($this->get_result_objects() as $object)543 {544 $test_profiles[] = $object->test_profile;545 }546 if($unique)547 {548 $test_profiles = array_unique($test_profiles);549 }550 return $test_profiles;551 }552 public function override_result_objects($result_objects)553 {554 $this->result_objects = $result_objects;555 }556 public function get_result($ch)557 {558 return isset($this->result_objects[$ch]) ? $this->result_objects[$ch] : false;559 }560 public function remove_result_object_by_id($index_or_indexes, $delete_child_objects = true)561 {562 $did_remove = false;563 foreach(pts_arrays::to_array($index_or_indexes) as $index)564 {565 if(isset($this->result_objects[$index]))566 {567 unset($this->result_objects[$index]);568 $did_remove = true;569 if($delete_child_objects)570 {571 foreach($this->get_relation_map($index) as $child_ro)572 {573 if(isset($this->result_objects[$child_ro]))574 {575 unset($this->result_objects[$child_ro]);576 }577 }578 }579 }580 }581 return $did_remove;582 }583 public function remove_noisy_results($noise_level_percent = 6)584 {585 foreach($this->result_objects as $i => &$ro)586 {587 if($ro->has_noisy_result($noise_level_percent))588 {589 $this->remove_result_object_by_id($i);590 }591 }592 }593 public function reduce_precision()594 {595 foreach($this->result_objects as $i => &$ro)596 {597 $ro->test_result_buffer->reduce_precision();598 }599 }600 public function update_annotation_for_result_object_by_id($index, $annotation)601 {602 if(isset($this->result_objects[$index]))603 {604 $this->result_objects[$index]->set_annotation($annotation);605 return true;606 }607 return false;608 }609 public function get_result_object_by_hash($h)610 {611 return isset($this->result_objects[$h]) ? $this->result_objects[$h] : false;612 }613 public function get_result_objects($select_indexes = -1)614 {615 if($select_indexes != -1 && $select_indexes !== null)616 {617 $objects = array();618 if($select_indexes == 'ONLY_CHANGED_RESULTS')619 {620 foreach($this->result_objects as &$result)621 {622 // Only show results where the variation was greater than or equal to 1%623 if(abs($result->largest_result_variation(0.01)) >= 0.01)624 {625 $objects[] = $result;626 }627 }628 }629 else630 {631 foreach(pts_arrays::to_array($select_indexes) as $index)632 {633 if(isset($this->result_objects[$index]))634 {635 $objects[] = $this->result_objects[$index];636 }637 }638 }639 return $objects;640 }641 $skip_objects = defined('SKIP_RESULT_OBJECTS') ? explode(',', SKIP_RESULT_OBJECTS) : false;642 if($skip_objects)643 {644 $ros = $this->result_objects;645 foreach($ros as $index => $ro)646 {647 foreach($skip_objects as $skip)648 {649 if(stripos($ro->test_profile->get_identifier(), $skip) !== false || stripos($ro->get_arguments_description(), $skip) !== false)650 {651 unset($ros[$index]);652 break;653 }654 }655 }656 return $ros;657 }658 return $this->result_objects;659 }660 public function to_json()661 {662 $file = $this->get_xml();663 $file = str_replace(array("\n", "\r", "\t"), '', $file);664 $file = trim(str_replace('"', "'", $file));665 $simple_xml = simplexml_load_string($file);666 return json_encode($simple_xml);667 }668 public function avoid_duplicate_identifiers()669 {670 // avoid duplicate test identifiers671 $identifiers = $this->get_system_identifiers();672 if(count($identifiers) < 2)673 {674 return;675 }676 foreach(pts_arrays::duplicates_in_array($identifiers) as $duplicate)677 {678 while($this->is_system_identifier_in_result_file($duplicate))679 {680 $i = 0;681 do682 {683 $i++;684 $new_identifier = $duplicate . ' #' . $i;685 }686 while($this->is_system_identifier_in_result_file($new_identifier));687 $this->rename_run($duplicate, $new_identifier, false);688 }689 }690 }691 public function rename_run($from, $to, $rename_logs = true)692 {693 $renamed = false;694 if($from == 'PREFIX')695 {696 foreach($this->systems as &$s)697 {698 $s->set_identifier($to . ': ' . $s->get_identifier());699 $renamed = true;700 }701 }702 else if($from == null)703 {704 if(count($this->systems) == 1)705 {706 foreach($this->systems as &$s)707 {708 $s->set_identifier($to);709 $renamed = true;710 break;711 }712 }713 }714 else715 {716 $found = false;717 foreach($this->systems as &$s)718 {719 if($s->get_identifier() == $from)720 {721 $found = true;722 $s->set_identifier($to);723 $renamed = true;724 break;725 }726 }727 if($found && $rename_logs && ($d = $this->get_system_log_dir($from, true)))728 {729 $d = dirname(dirname($d)) . '/';730 foreach(array('test-logs', 'system-logs', 'installation-logs') as $dir_name)731 {732 if(is_dir($d . $dir_name . '/' . $from))733 {734 rename($d . $dir_name . '/' . $from, $d . $dir_name . '/' . $to);735 }736 }737 }738 }739 foreach($this->result_objects as &$result)740 {741 $result->test_result_buffer->rename($from, $to);...
pts_openbenchmarking_upload.php
Source:pts_openbenchmarking_upload.php
...41 echo PHP_EOL . 'No network support available.' . PHP_EOL;42 return false;43 }44 $composite_xml = $result_file->get_xml();45 $system_log_dir = $result_file->get_system_log_dir();46 $upload_system_logs = false;47 if(is_dir($system_log_dir))48 {49 if(pts_config::read_bool_config('PhoronixTestSuite/Options/OpenBenchmarking/AlwaysUploadSystemLogs', 'FALSE'))50 {51 $upload_system_logs = true;52 }53 else if(PTS_IS_CLIENT && isset(pts_openbenchmarking_client::$client_settings['UploadSystemLogsByDefault']))54 {55 $upload_system_logs = pts_openbenchmarking_client::$client_settings['UploadSystemLogsByDefault'];56 }57 else if(is_dir($system_log_dir))58 {59 if($prompts == false)...
get_system_log_dir
Using AI Code Generation
1$rf = new pts_result_file('2.xml');2print_r($rf->get_system_log_dir());3$rf = new pts_result_file('3.xml');4print_r($rf->get_system_log_dir());5$rf = new pts_result_file('4.xml');6print_r($rf->get_system_log_dir());7$rf = new pts_result_file('5.xml');8print_r($rf->get_system_log_dir());9$rf = new pts_result_file('6.xml');10print_r($rf->get_system_log_dir());11$rf = new pts_result_file('7.xml');12print_r($rf->get_system_log_dir());13$rf = new pts_result_file('8.xml');14print_r($rf->get_system_log_dir());15$rf = new pts_result_file('9.xml');16print_r($rf->get_system_log_dir());17$rf = new pts_result_file('10.xml');18print_r($rf->get_system_log_dir());19$rf = new pts_result_file('11.xml');20print_r($rf->get_system_log_dir());21$rf = new pts_result_file('12.xml');22print_r($rf->get_system_log_dir());23$rf = new pts_result_file('13.xml');24print_r($rf->get_system_log_dir());
get_system_log_dir
Using AI Code Generation
1require_once('pts-core/pts_result_file.php');2$system_log_dir = pts_result_file::get_system_log_dir();3echo $system_log_dir;4require_once('pts-core/pts_result_file.php');5$system_log_dir = pts_result_file::get_system_log_dir();6echo $system_log_dir;7require_once('pts-core/pts_result_file.php');8$system_log_dir = pts_result_file::get_system_log_dir();9echo $system_log_dir;10require_once('pts-core/pts_result_file.php');11$system_log_dir = pts_result_file::get_system_log_dir();12echo $system_log_dir;13require_once('pts-core/pts_result_file.php');14$system_log_dir = pts_result_file::get_system_log_dir();15echo $system_log_dir;16require_once('pts-core/pts_result_file.php');17$system_log_dir = pts_result_file::get_system_log_dir();18echo $system_log_dir;19require_once('pts-core/pts_result_file.php');20$system_log_dir = pts_result_file::get_system_log_dir();21echo $system_log_dir;22require_once('pts-core/pts_result_file.php');23$system_log_dir = pts_result_file::get_system_log_dir();24echo $system_log_dir;25require_once('pts-core/pts_result_file.php');26$system_log_dir = pts_result_file::get_system_log_dir();27echo $system_log_dir;28require_once('pts-core/pts_result_file.php');
get_system_log_dir
Using AI Code Generation
1require_once('pts-core/pts-core.php');2$rf = new pts_result_file('result_file.xml');3$rf->get_system_log_dir();4require_once('pts-core/pts-core.php');5$rf = new pts_result_file('result_file.xml');6$rf->get_system_log_dir();7require_once('pts-core/pts-core.php');8$rf = new pts_result_file('result_file.xml');9$rf->get_system_log_dir();10require_once('pts-core/pts-core.php');11$rf = new pts_result_file('result_file.xml');12$rf->get_system_log_dir();13require_once('pts-core/pts-core.php');14$rf = new pts_result_file('result_file.xml');15$rf->get_system_log_dir();16require_once('pts-core/pts-core.php');17$rf = new pts_result_file('result_file.xml');18$rf->get_system_log_dir();19require_once('pts-core/pts-core.php');20$rf = new pts_result_file('result_file.xml');21$rf->get_system_log_dir();22require_once('pts-core/pts-core.php');23$rf = new pts_result_file('result_file.xml');24$rf->get_system_log_dir();25require_once('pts-core/pts-core.php');26$rf = new pts_result_file('result_file.xml');27$rf->get_system_log_dir();
get_system_log_dir
Using AI Code Generation
1require_once('pts_result_file.php');2$system_log_dir = pts_result_file::get_system_log_dir();3";4Example 2: get_result_file_dir() method5require_once('pts_result_file.php');6$result_file_dir = pts_result_file::get_result_file_dir();7";8Example 3: get_system_log() method9require_once('pts_result_file.php');10$system_log_file = pts_result_file::get_system_log('result_file_name');11";12Example 4: get_result_file() method13require_once('pts_result_file.php');14$result_file = pts_result_file::get_result_file('result_file_name');15";16Example 5: get_result_file_location() method
get_system_log_dir
Using AI Code Generation
1$system_log_dir = pts_result_file::get_system_log_dir();2$log_file_path = pts_result_file::get_log_file_path($system_log_dir);3pts_result_file_output::system_log_file($log_file_path);4$system_log_dir = pts_result_file::get_system_log_dir();5$log_file_path = pts_result_file::get_log_file_path($system_log_dir);6pts_result_file_output::system_log_file($log_file_path);7$system_log_dir = pts_result_file::get_system_log_dir();8$log_file_path = pts_result_file::get_log_file_path($system_log_dir);9pts_result_file_output::system_log_file($log_file_path);10$system_log_dir = pts_result_file::get_system_log_dir();11$log_file_path = pts_result_file::get_log_file_path($system_log_dir);12pts_result_file_output::system_log_file($log_file_path);13$system_log_dir = pts_result_file::get_system_log_dir();14$log_file_path = pts_result_file::get_log_file_path($system_log_dir);
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 get_system_log_dir 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!!