How to use get_test_log_dir method of pts_result_file class

Best Phoronix-test-suite code snippet using pts_result_file.get_test_log_dir

pts_result_file.php

Source:pts_result_file.php Github

copy

Full Screen

...162 $sdir = $sdir . pts_strings::simplify_string_for_file_handling($result_identifier) . '/';163 return !$dir_check || is_dir($sdir) ? $sdir : false;164 }165 }166 public function get_test_log_dir(&$result_object = null)167 {168 $log_dir = dirname($this->get_file_location());169 if(empty($log_dir) || !is_dir($log_dir))170 {171 return false;172 }173 return $log_dir . '/test-logs/' . ($result_object != null ? $result_object->get_comparison_hash(true, false) . '/' : null);174 }175 public function get_test_installation_log_dir()176 {177 $log_dir = dirname($this->get_file_location());178 if(empty($log_dir) || !is_dir($log_dir))179 {180 return false;181 }182 return $log_dir . '/installation-logs/';183 }184 public function save()185 {186 if($this->get_file_location() && is_file($this->get_file_location()))187 {188 return file_put_contents($this->get_file_location(), $this->get_xml());189 }190 }191 public function get_last_modified()192 {193 return $this->last_modified;194 }195 public function validate()196 {197 $dom = new DOMDocument();198 $dom->loadXML($this->get_xml());199 return $dom->schemaValidate(pts_openbenchmarking::openbenchmarking_standards_path() . 'schemas/result-file.xsd');200 }201 public function __toString()202 {203 return $this->get_identifier();204 }205 protected static function clean_input($value)206 {207 return strip_tags($value);208 /*209 if(is_array($value))210 {211 return array_map(array($this, 'clean_input'), $value);212 }213 else214 {215 return strip_tags($value);216 }217 */218 }219 public function default_result_folder_path()220 {221 return PTS_SAVE_RESULTS_PATH . $this->save_identifier . '/';222 }223 public function get_identifier()224 {225 return $this->save_identifier;226 }227 public function read_extra_attribute($key)228 {229 return isset($this->extra_attributes[$key]) ? $this->extra_attributes[$key] : false;230 }231 public function set_extra_attribute($key, $value)232 {233 $this->extra_attributes[$key] = $value;234 }235 public function add_system($system)236 {237 if(!in_array($system, $this->systems))238 {239 $this->systems[] = $system;240 }241 }242 public function add_system_direct($identifier, $hw = null, $sw = null, $json = null, $user = null, $notes = null, $timestamp = null, $version = null)243 {244 $this->systems[] = new pts_result_file_system($identifier, $hw, $sw, $json, $user, $notes, $timestamp, $version, $this);245 }246 public function get_systems()247 {248 return $this->systems;249 }250 public function get_system_hardware()251 {252 // XXX this is deprecated253 $hw = array();254 foreach($this->systems as &$s)255 {256 $hw[] = $s->get_hardware();257 }258 return $hw;259 }260 public function get_system_software()261 {262 // XXX this is deprecated263 $sw = array();264 foreach($this->systems as &$s)265 {266 $sw[] = $s->get_software();267 }268 return $sw;269 }270 public function get_system_identifiers()271 {272 // XXX this is deprecated273 $ids = array();274 foreach($this->systems as &$s)275 {276 $ids[] = $s->get_identifier();277 }278 return $ids;279 }280 public function is_system_identifier_in_result_file($identifier)281 {282 foreach($this->systems as &$s)283 {284 if($s->get_identifier() == $identifier)285 {286 return true;287 }288 }289 return false;290 }291 public function system_logs_available()292 {293 foreach($this->systems as &$s)294 {295 if($s->has_log_files())296 {297 return true;298 }299 }300 return false;301 }302 public function get_system_count()303 {304 return count($this->systems);305 }306 public function set_title($new_title)307 {308 if($new_title != null)309 {310 $this->title = $new_title;311 }312 }313 public function get_title()314 {315 return $this->title;316 }317 public function append_description($append_description)318 {319 if($append_description != null && strpos($this->description, $append_description) === false)320 {321 $this->description .= PHP_EOL . $append_description;322 }323 }324 public function set_description($new_description)325 {326 if($new_description != null)327 {328 $this->description = $new_description;329 }330 }331 public function get_description()332 {333 return $this->description;334 }335 public function set_notes($notes)336 {337 if($notes != null)338 {339 $this->notes = $notes;340 }341 }342 public function get_notes()343 {344 return $this->notes;345 }346 public function set_internal_tags($tags)347 {348 if($tags != null)349 {350 $this->internal_tags = $tags;351 }352 }353 public function get_internal_tags()354 {355 return $this->internal_tags;356 }357 public function set_reference_id($new_reference_id)358 {359 if($new_reference_id != null)360 {361 $this->reference_id = $new_reference_id;362 }363 }364 public function get_reference_id()365 {366 return $this->reference_id;367 }368 public function set_preset_environment_variables($env)369 {370 if($env != null)371 {372 $this->preset_environment_variables = $env;373 }374 }375 public function get_preset_environment_variables()376 {377 return $this->preset_environment_variables;378 }379 public function get_test_count()380 {381 return count($this->get_result_objects());382 }383 public function get_qualified_test_count()384 {385 $q_count = 0;386 foreach($this->get_result_objects() as $ro)387 {388 if($ro->test_profile->get_identifier() != null)389 {390 $q_count++;391 }392 }393 return $q_count;394 }395 public function has_matching_test_and_run_identifier(&$test_result, $run_identifier_to_check)396 {397 $found_match = false;398 $hash_to_check = $test_result->get_comparison_hash();399 foreach($this->get_result_objects() as $result_object)400 {401 if($hash_to_check == $result_object->get_comparison_hash())402 {403 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) != '')404 {405 $found_match = true;406 }407 break;408 }409 }410 return $found_match;411 }412 public function get_contained_tests_hash($raw_output = true)413 {414 $result_object_hashes = $this->get_result_object_hashes();415 sort($result_object_hashes);416 return sha1(implode(',', $result_object_hashes), $raw_output);417 }418 public function get_result_object_hashes()419 {420 $object_hashes = array();421 foreach($this->get_result_objects() as $result_object)422 {423 $object_hashes[] = $result_object->get_comparison_hash();424 }425 return $object_hashes;426 }427 public function is_results_tracker()428 {429 // If there are more than five results and the only changes in the system identifier names are numeric changes, assume it's a tracker430 // i.e. different dates or different versions of a package being tested431 if($this->is_tracker === -1)432 {433 $identifiers = $this->get_system_identifiers();434 if(isset($identifiers[5]))435 {436 // dirty SHA1 hash check437 $is_sha1_hash = strlen($identifiers[0]) == 40 && strpos($identifiers[0], ' ') === false;438 $has_sha1_shorthash = false;439 foreach($identifiers as $i => &$identifier)440 {441 $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;442 $identifier = pts_strings::remove_from_string($identifier, pts_strings::CHAR_NUMERIC | pts_strings::CHAR_DASH | pts_strings::CHAR_DECIMAL);443 }444 $this->is_tracker = count(array_unique($identifiers)) <= 1 || $is_sha1_hash || $has_sha1_shorthash;445 if($this->is_tracker)446 {447 $hw = $this->get_system_hardware();448 if(isset($hw[1]) && count($hw) == count(array_unique($hw)))449 {450 // it can't be a results tracker if the hardware is always different451 $this->is_tracker = false;452 }453 }454 if($this->is_tracker == false)455 {456 // See if only numbers are changing between runs457 foreach($identifiers as $i => &$identifier)458 {459 if(($x = strpos($identifier, ': ')) !== false)460 {461 $identifier = substr($identifier, ($x + 2));462 }463 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))464 {465 return false;466 }467 }468 $this->is_tracker = true;469 }470 }471 else472 {473 // Definitely not a tracker as not over 5 results474 $this->is_tracker = false;475 }476 }477 return $this->is_tracker;478 }479 public function is_multi_way_comparison($identifiers = false, $extra_attributes = null)480 {481 if(isset($extra_attributes['force_tracking_line_graph']))482 {483 // Phoromatic result tracker484 $is_multi_way = true;485 $this->is_multi_way_inverted = true;486 }487 else488 {489 $hw = null; // XXX: this isn't used anymore at least for now on system hardware490 if($identifiers == false)491 {492 $identifiers = $this->get_system_identifiers();493 }494 $is_multi_way = count($identifiers) < 2 ? false : pts_render::multi_way_identifier_check($identifiers, $hw, $this);495 $this->is_multi_way_inverted = $is_multi_way && $is_multi_way[1];496 }497 return $is_multi_way;498 }499 public function invert_multi_way_invert()500 {501 $this->is_multi_way_inverted = !$this->is_multi_way_inverted;502 }503 public function is_multi_way_inverted()504 {505 return $this->is_multi_way_inverted;506 }507 public function get_contained_test_profiles($unique = false)508 {509 $test_profiles = array();510 foreach($this->get_result_objects() as $object)511 {512 $test_profiles[] = $object->test_profile;513 }514 if($unique)515 {516 $test_profiles = array_unique($test_profiles);517 }518 return $test_profiles;519 }520 public function override_result_objects($result_objects)521 {522 $this->result_objects = $result_objects;523 }524 public function get_result($ch)525 {526 return isset($this->result_objects[$ch]) ? $this->result_objects[$ch] : false;527 }528 public function remove_result_object_by_id($index_or_indexes, $delete_child_objects = true)529 {530 $did_remove = false;531 foreach(pts_arrays::to_array($index_or_indexes) as $index)532 {533 if(isset($this->result_objects[$index]))534 {535 unset($this->result_objects[$index]);536 $did_remove = true;537 if($delete_child_objects)538 {539 foreach($this->get_relation_map($index) as $child_ro)540 {541 if(isset($this->result_objects[$child_ro]))542 {543 unset($this->result_objects[$child_ro]);544 }545 }546 }547 }548 }549 return $did_remove;550 }551 public function remove_noisy_results($noise_level_percent = 6)552 {553 foreach($this->result_objects as $i => &$ro)554 {555 if($ro->has_noisy_result($noise_level_percent))556 {557 $this->remove_result_object_by_id($i);558 }559 }560 }561 public function reduce_precision()562 {563 foreach($this->result_objects as $i => &$ro)564 {565 $ro->test_result_buffer->reduce_precision();566 }567 }568 public function update_annotation_for_result_object_by_id($index, $annotation)569 {570 if(isset($this->result_objects[$index]))571 {572 $this->result_objects[$index]->set_annotation($annotation);573 return true;574 }575 return false;576 }577 public function get_result_object_by_hash($h)578 {579 return isset($this->result_objects[$h]) ? $this->result_objects[$h] : false;580 }581 public function get_result_objects($select_indexes = -1)582 {583 if($select_indexes != -1 && $select_indexes !== null)584 {585 $objects = array();586 if($select_indexes == 'ONLY_CHANGED_RESULTS')587 {588 foreach($this->result_objects as &$result)589 {590 // Only show results where the variation was greater than or equal to 1%591 if(abs($result->largest_result_variation(0.01)) >= 0.01)592 {593 $objects[] = $result;594 }595 }596 }597 else598 {599 foreach(pts_arrays::to_array($select_indexes) as $index)600 {601 if(isset($this->result_objects[$index]))602 {603 $objects[] = $this->result_objects[$index];604 }605 }606 }607 return $objects;608 }609 $skip_objects = defined('SKIP_RESULT_OBJECTS') ? explode(',', SKIP_RESULT_OBJECTS) : false;610 if($skip_objects)611 {612 $ros = $this->result_objects;613 foreach($ros as $index => $ro)614 {615 foreach($skip_objects as $skip)616 {617 if(stripos($ro->test_profile->get_identifier(), $skip) !== false || stripos($ro->get_arguments_description(), $skip) !== false)618 {619 unset($ros[$index]);620 break;621 }622 }623 }624 return $ros;625 }626 return $this->result_objects;627 }628 public function to_json()629 {630 $file = $this->get_xml();631 $file = str_replace(array("\n", "\r", "\t"), '', $file);632 $file = trim(str_replace('"', "'", $file));633 $simple_xml = simplexml_load_string($file);634 return json_encode($simple_xml);635 }636 public function avoid_duplicate_identifiers()637 {638 // avoid duplicate test identifiers639 $identifiers = $this->get_system_identifiers();640 if(count($identifiers) < 2)641 {642 return;643 }644 foreach(pts_arrays::duplicates_in_array($identifiers) as $duplicate)645 {646 while($this->is_system_identifier_in_result_file($duplicate))647 {648 $i = 0;649 do650 {651 $i++;652 $new_identifier = $duplicate . ' #' . $i;653 }654 while($this->is_system_identifier_in_result_file($new_identifier));655 $this->rename_run($duplicate, $new_identifier, false);656 }657 }658 }659 public function rename_run($from, $to, $rename_logs = true)660 {661 if($from == 'PREFIX')662 {663 foreach($this->systems as &$s)664 {665 $s->set_identifier($to . ': ' . $s->get_identifier());666 }667 }668 else if($from == null)669 {670 if(count($this->systems) == 1)671 {672 foreach($this->systems as &$s)673 {674 $s->set_identifier($to);675 break;676 }677 }678 }679 else680 {681 $found = false;682 foreach($this->systems as &$s)683 {684 if($s->get_identifier() == $from)685 {686 $found = true;687 $s->set_identifier($to);688 break;689 }690 }691 if($found && $rename_logs && ($d = $this->get_system_log_dir($from, true)))692 {693 $d = dirname(dirname($d)) . '/';694 foreach(array('test-logs', 'system-logs', 'installation-logs') as $dir_name)695 {696 if(is_dir($d . $dir_name . '/' . $from))697 {698 rename($d . $dir_name . '/' . $from, $d . $dir_name . '/' . $to);699 }700 }701 }702 }703 foreach($this->result_objects as &$result)704 {705 $result->test_result_buffer->rename($from, $to);706 }707 }708 public function reorder_runs($new_order)709 {710 foreach($new_order as $identifier)711 {712 foreach($this->systems as $i => $s)713 {714 if($s->get_identifier() == $identifier)715 {716 $c = $s;717 unset($this->systems[$i]);718 $this->systems[] = $c;719 break;720 }721 }722 }723 foreach($this->result_objects as &$result)724 {725 $result->test_result_buffer->reorder($new_order);726 }727 }728 public function remove_run($remove)729 {730 $remove = pts_arrays::to_array($remove);731 foreach($this->systems as $i => &$s)732 {733 if(in_array($s->get_identifier(), $remove))734 {735 unset($this->systems[$i]);736 }737 }738 foreach($this->result_objects as &$result)739 {740 $result->test_result_buffer->remove($remove);741 }742 }743 public function add_to_result_file(&$result_file, $only_merge_results_already_present = false)744 {745 foreach($result_file->get_systems() as $s)746 {747 if(!in_array($s, $this->systems))748 {749 $this->systems[] = $s;750 }751 }752 foreach($result_file->get_result_objects() as $result)753 {754 $this->add_result($result, $only_merge_results_already_present);755 }756 }757 public function result_hash_exists(&$result_object)758 {759 $ch = $result_object->get_comparison_hash(true, false);760 return isset($this->result_objects[$ch]) && isset($this->result_objects[$ch]->test_result_buffer);761 }762 public function add_result(&$result_object, $only_if_result_already_present = false)763 {764 if($result_object == null)765 {766 return false;767 }768 $ch = $result_object->get_comparison_hash(true, false);769 if(isset($this->result_objects[$ch]) && isset($this->result_objects[$ch]->test_result_buffer))770 {771 if($result_object->get_annotation() != null)772 {773 $this->result_objects[$ch]->append_annotation($result_object->get_annotation());774 }775 foreach($result_object->test_result_buffer->get_buffer_items() as $bi)776 {777 if($bi->get_result_value() === null)778 {779 continue;780 }781 $this->result_objects[$ch]->test_result_buffer->add_buffer_item($bi);782 }783 }784 else if($only_if_result_already_present == false)785 {786 $this->result_objects[$ch] = $result_object;787 }788 $parent = $result_object->get_parent_hash();789 if($parent)790 {791 if(!isset($this->ro_relation_map[$parent]))792 {793 $this->ro_relation_map[$parent] = array();794 }795 $this->ro_relation_map[$parent][] = $ch;796 }797 return $ch;798 }799 public function add_result_return_object(&$result_object, $only_if_result_already_present = false)800 {801 $ch = $this->add_result($result_object, $only_if_result_already_present);802 return isset($this->result_objects[$ch]) ? $this->result_objects[$ch] : false;803 }804 public function get_xml($to = null, $force_nice_formatting = false)805 {806 $xml_writer = new nye_XmlWriter(null, $force_nice_formatting);807 $xml_writer->addXmlNode('PhoronixTestSuite/Generated/Title', $this->get_title());808 $xml_writer->addXmlNode('PhoronixTestSuite/Generated/LastModified', date('Y-m-d H:i:s', pts_client::current_time()));809 $xml_writer->addXmlNode('PhoronixTestSuite/Generated/TestClient', pts_core::program_title(true));810 $xml_writer->addXmlNode('PhoronixTestSuite/Generated/Description', $this->get_description());811 $xml_writer->addXmlNodeWNE('PhoronixTestSuite/Generated/Notes', $this->get_notes());812 $xml_writer->addXmlNodeWNE('PhoronixTestSuite/Generated/InternalTags', $this->get_internal_tags());813 $xml_writer->addXmlNodeWNE('PhoronixTestSuite/Generated/ReferenceID', $this->get_reference_id());814 $xml_writer->addXmlNodeWNE('PhoronixTestSuite/Generated/PreSetEnvironmentVariables', $this->get_preset_environment_variables());815 // Write the system hardware/software information816 foreach($this->get_systems() as $s)817 {818 $xml_writer->addXmlNode('PhoronixTestSuite/System/Identifier', $s->get_identifier());819 $xml_writer->addXmlNode('PhoronixTestSuite/System/Hardware', $s->get_hardware());820 $xml_writer->addXmlNode('PhoronixTestSuite/System/Software', $s->get_software());821 $xml_writer->addXmlNode('PhoronixTestSuite/System/User', $s->get_username());822 $xml_writer->addXmlNode('PhoronixTestSuite/System/TimeStamp', $s->get_timestamp());823 $xml_writer->addXmlNode('PhoronixTestSuite/System/TestClientVersion', $s->get_client_version());824 $xml_writer->addXmlNode('PhoronixTestSuite/System/Notes', $s->get_notes());825 if(!defined('USER_PTS_CORE_VERSION') || USER_PTS_CORE_VERSION > 3722)826 {827 // Ensure that a supported result file schema is being written...828 // USER_PTS_CORE_VERSION is set by OpenBenchmarking.org so if the requested client is old, don't write this data to send back to their version829 $xml_writer->addXmlNodeWNE('PhoronixTestSuite/System/JSON', ($s->get_json() ? json_encode($s->get_json()) : null));830 }831 }832 // Write the results833 foreach($this->get_result_objects() as $result_object)834 {835 $buffer_items = $result_object->test_result_buffer->get_buffer_items();836 if(count($buffer_items) == 0)837 {838 continue;839 }840 $xml_writer->addXmlNode('PhoronixTestSuite/Result/Identifier', $result_object->test_profile->get_identifier());841 $xml_writer->addXmlNode('PhoronixTestSuite/Result/Title', $result_object->test_profile->get_title());842 $xml_writer->addXmlNode('PhoronixTestSuite/Result/AppVersion', $result_object->test_profile->get_app_version());843 $xml_writer->addXmlNode('PhoronixTestSuite/Result/Arguments', $result_object->get_arguments());844 $xml_writer->addXmlNode('PhoronixTestSuite/Result/Description', $result_object->get_arguments_description());845 $xml_writer->addXmlNode('PhoronixTestSuite/Result/Scale', $result_object->test_profile->get_result_scale());846 $xml_writer->addXmlNode('PhoronixTestSuite/Result/Proportion', $result_object->test_profile->get_result_proportion());847 $xml_writer->addXmlNode('PhoronixTestSuite/Result/DisplayFormat', $result_object->test_profile->get_display_format());848 $xml_writer->addXmlNodeWNE('PhoronixTestSuite/Result/Annotation', $result_object->get_annotation());849 $xml_writer->addXmlNodeWNE('PhoronixTestSuite/Result/Parent', $result_object->get_parent_hash());850 foreach($buffer_items as $i => &$buffer_item)851 {852 $xml_writer->addXmlNode('PhoronixTestSuite/Result/Data/Entry/Identifier', $buffer_item->get_result_identifier());853 $xml_writer->addXmlNode('PhoronixTestSuite/Result/Data/Entry/Value', $buffer_item->get_result_value());854 $xml_writer->addXmlNode('PhoronixTestSuite/Result/Data/Entry/RawString', $buffer_item->get_result_raw());855 if(!defined('USER_PTS_CORE_VERSION') || USER_PTS_CORE_VERSION > 3722)856 {857 // Ensure that a supported result file schema is being written...858 // USER_PTS_CORE_VERSION is set by OpenBenchmarking.org so if the requested client is old, don't write this data to send back to their version859 $xml_writer->addXmlNodeWNE('PhoronixTestSuite/Result/Data/Entry/JSON', ($buffer_item->get_result_json() ? json_encode($buffer_item->get_result_json()) : null));860 }861 }862 }863 return $to == null ? $xml_writer->getXML() : $xml_writer->saveXMLFile($to);864 }865 public function merge($result_merges_to_combine, $pass_attributes = 0, $add_prefix = null, $merge_meta = false, $only_prefix_on_collision = false)866 {867 if(!is_array($result_merges_to_combine) || empty($result_merges_to_combine))868 {869 return false;870 }871 foreach($result_merges_to_combine as $i => &$merge_select)872 {873 if(!($merge_select instanceof $merge_select))874 {875 $merge_select = new pts_result_merge_select($merge_select);876 }877 if(!is_file($merge_select->get_result_file()) && !($merge_select->get_result_file() instanceof pts_result_file))878 {879 if(defined('PTS_SAVE_RESULTS_PATH') && is_file(PTS_SAVE_RESULTS_PATH . $merge_select->get_result_file() . '/composite.xml'))880 {881 $merge_select->set_result_file(PTS_SAVE_RESULTS_PATH . $merge_select->get_result_file() . '/composite.xml');882 }883 else884 {885 unset($result_merges_to_combine[$i]);886 }887 }888 }889 if(empty($result_merges_to_combine))890 {891 return false;892 }893 foreach($result_merges_to_combine as &$merge_select)894 {895 if($merge_select->get_result_file() instanceof pts_result_file)896 {897 $result_file = $merge_select->get_result_file();898 }899 else900 {901 $result_file = new pts_result_file($merge_select->get_result_file(), true);902 }903 if($add_prefix)904 {905 if($only_prefix_on_collision)906 {907 $this_identifiers = $this->get_system_identifiers();908 foreach($result_file->systems as &$s)909 {910 if(in_array($s->get_identifier(), $this_identifiers))911 {912 $s->set_identifier($add_prefix . ': ' . $s->get_identifier());913 }914 }915 }916 else917 {918 $result_file->rename_run('PREFIX', $add_prefix);919 }920 }921 else if($merge_select->get_rename_identifier())922 {923 $result_file->rename_run(null, $merge_select->get_rename_identifier());924 }925 if($this->get_title() == null && $result_file->get_title() != null)926 {927 $this->set_title($result_file->get_title());928 }929 if($this->get_description() == null && $result_file->get_description() != null)930 {931 $this->set_description($result_file->get_description());932 }933 $this->add_to_result_file($result_file);934 if($merge_meta)935 {936 if($result_file->get_title() != null && stripos($this->get_title(), $result_file->get_title()) === false)937 {938 $this->set_title($this->get_title() . ', ' . $result_file->get_title());939 }940 if($result_file->get_description() != null && stripos($this->get_description(), $result_file->get_description()) === false)941 {942 $this->set_description($this->get_description() . PHP_EOL . PHP_EOL . $result_file->get_title() . ': ' . $result_file->get_description());943 }944 }945 unset($result_file);946 }947 }948 public function contains_system_hardware($search)949 {950 foreach($this->get_system_hardware() as $h)951 {952 if(stripos($h, $search) !== false)953 {954 return true;955 }956 }957 return false;958 }959 public function contains_system_software($search)960 {961 foreach($this->get_system_software() as $s)962 {963 if(stripos($s, $search) !== false)964 {965 return true;966 }967 }968 return false;969 }970 public function contains_test($search)971 {972 foreach($this->get_contained_test_profiles() as $test_profile)973 {974 if(stripos($test_profile->get_identifier(), $search) !== false || stripos($test_profile->get_title(), $search) !== false)975 {976 return true;977 }978 }979 return false;980 }981 public function sort_result_object_order_by_spread($asc = false)982 {983 uasort($this->result_objects, array('pts_result_file', 'result_spread_comparison'));984 if($asc == false)985 {986 $this->result_objects = array_reverse($this->result_objects, true);987 }988 }989 public static function result_spread_comparison($a, $b)990 {991 return strcmp($a->get_spread(), $b->get_spread());992 }993 public function sort_result_object_order_by_title($asc = true)994 {995 uasort($this->result_objects, array('pts_result_file', 'result_title_comparison'));996 if($asc == false)997 {998 $this->result_objects = array_reverse($this->result_objects, true);999 }1000 }1001 public static function result_title_comparison($a, $b)1002 {1003 return strcmp(strtolower($a->test_profile->get_title()) . ' ' . $a->test_profile->get_app_version(), strtolower($b->test_profile->get_title()) . ' ' . $b->test_profile->get_app_version());1004 }1005 public function sort_result_object_order_by_result_scale($asc = true)1006 {1007 uasort($this->result_objects, array('pts_result_file', 'result_scale_comparison'));1008 if($asc == false)1009 {1010 $this->result_objects = array_reverse($this->result_objects, true);1011 }1012 }1013 public static function result_scale_comparison($a, $b)1014 {1015 return strcmp($a->test_profile->get_result_proportion() . ' ' . strtolower($a->test_profile->get_result_scale()) . ' ' . $a->test_profile->get_identifier(), $b->test_profile->get_result_proportion() . ' ' . strtolower($b->test_profile->get_result_scale()) . ' ' . $a->test_profile->get_identifier());1016 }1017 public function get_test_run_times()1018 {1019 $run_times = array();1020 foreach($this->get_system_identifiers() as $si)1021 {1022 $run_times[$si] = 0;1023 }1024 foreach($this->result_objects as &$ro)1025 {1026 foreach($ro->get_run_times() as $si => $elapsed_time)1027 {1028 $run_times[$si] += $elapsed_time;1029 }1030 }1031 return $run_times;1032 }1033 public function sort_result_object_order_by_run_time($asc = false)1034 {1035 uasort($this->result_objects, array('pts_result_file', 'result_run_time_comparison'));1036 if($asc == false)1037 {1038 $this->result_objects = array_reverse($this->result_objects, true);1039 }1040 }1041 public static function result_run_time_comparison($a, $b)1042 {1043 $a = $a->get_run_time_avg();1044 $b = $b->get_run_time_avg();1045 if($a == $b)1046 {1047 return 0;1048 }1049 return $a < $b ? -1 : 1;1050 }1051 public function get_install_log_for_test(&$test_profile, $read_file = false, $cleanse_file = true)1052 {1053 // if $read_file is false, index will be returned. if $read_file is -2, will return whether log files simply exist1054 $files = array();1055 static $logs_exist_for_test; // caching helper1056 $test_file_name_chunk = $test_profile->get_identifier_simplified() . '.log';1057 if($read_file == -2 && isset($logs_exist_for_test[$test_file_name_chunk]))1058 {1059 return $logs_exist_for_test[$test_file_name_chunk];1060 }1061 if($this->get_test_installation_log_dir() && count($d = pts_file_io::glob($this->get_test_installation_log_dir() . '*/' . $test_file_name_chunk)) > 0)1062 {1063 $logs_exist_for_test[$test_file_name_chunk] = true;1064 if($read_file == -2)1065 {1066 return true;1067 }1068 foreach($d as $file)1069 {1070 $basename_file = basename(dirname($file));1071 if($read_file !== false && $basename_file == $read_file)1072 {1073 $file = file_get_contents($file);1074 return $cleanse_file ? phodevi_vfs::cleanse_file($file, $basename_file) : $file;1075 }1076 $files[] = $basename_file;1077 }1078 }1079 else if($this->get_result_dir() && is_file($this->get_result_dir() . 'installation-logs.zip') && extension_loaded('zip'))1080 {1081 $logs_exist_for_test[$test_file_name_chunk] = true;1082 if($read_file == -2)1083 {1084 // TODO: could make this more accurate to ensure a precise match, but could become expensive1085 return true;1086 }1087 $zip = new ZipArchive();1088 $res = $zip->open($this->get_result_dir() . 'installation-logs.zip');1089 if($res === true)1090 {1091 $search_for_file_name_length = strlen($test_file_name_chunk);1092 for($i = 0; $i < $zip->numFiles; $i++)1093 {1094 $index = $zip->getNameIndex($i);1095 if(isset($index[$search_for_file_name_length]) && substr($index, (0 - $search_for_file_name_length)) == $test_file_name_chunk)1096 {1097 $basename_file = basename(dirname($index));1098 if($basename_file != null)1099 {1100 if($read_file !== false && $basename_file == $read_file)1101 {1102 $c = $zip->getFromName($index);1103 $contents = $cleanse_file ? phodevi_vfs::cleanse_file($c, $basename_file) : $c;1104 $zip->close();1105 return $contents;1106 }1107 $files[] = $basename_file;1108 }1109 }1110 }1111 $zip->close();1112 }1113 }1114 $logs_exist_for_test[$test_file_name_chunk] = !empty($files);1115 if($read_file == -2)1116 {1117 return false;1118 }1119 return $read_file !== false ? false : $files;1120 }1121 public function get_test_run_log_for_result(&$result_object, $read_file = false, $cleanse_file = true)1122 {1123 // if $read_file is false, index will be returned. if $read_file is -2, will return whether log files simply exist1124 $files = array();1125 static $logs_exist_for_test; // caching helper1126 $ro_hash = $result_object->get_comparison_hash(true, false);1127 if($read_file == -2 && isset($logs_exist_for_test[$ro_hash]))1128 {1129 return $logs_exist_for_test[$ro_hash];1130 }1131 if(($test_log_dir = $this->get_test_log_dir($result_object)) && count($d = pts_file_io::glob($test_log_dir . '*.log')) > 0)1132 {1133 $logs_exist_for_test[$ro_hash] = true;1134 if($read_file == -2)1135 {1136 return true;1137 }1138 foreach($d as $file)1139 {1140 $basename_file = basename($file);1141 if($read_file !== false && $basename_file == $read_file)1142 {1143 $file = file_get_contents($file);1144 return $cleanse_file ? phodevi_vfs::cleanse_file($file, $basename_file) : $file;1145 }...

Full Screen

Full Screen

index.php

Source:index.php Github

copy

Full Screen

...211 {212 $result_file = new pts_result_file($_REQUEST['result_file_id']);213 if(($result_object = $result_file->get_result_object_by_hash($_REQUEST['result_object'])))214 {215 $test_log_dir = $result_file->get_test_log_dir($result_object);216 if($test_log_dir && count(pts_file_io::glob($test_log_dir . '*.log')) > 0)217 {218 echo '<div style="text-align: center;"><form action="' . CURRENT_URI . '" method="post"><select name="log_select" id="log_select">';219 foreach(pts_file_io::glob($test_log_dir . '*.log') as $log_file)220 {221 $b = basename($log_file, '.log');222 echo '<option value="' . $b . '"' . ($b == $_REQUEST['log_select'] ? 'selected="selected"' : null) . '>' . $b . '</option>';223 }224 echo '</select> &nbsp; <input type="submit" value="Show Log"></form></div><br /><hr />';225 if(isset($_REQUEST['log_select']) && is_file($test_log_dir . pts_strings::simplify_string_for_file_handling($_REQUEST['log_select']) . '.log'))226 {227 $show_log = $test_log_dir . pts_strings::simplify_string_for_file_handling($_REQUEST['log_select']) . '.log';228 }229 else...

Full Screen

Full Screen

get_test_log_dir

Using AI Code Generation

copy

Full Screen

1$test = new pts_result_file('test_result.xml');2echo $test->get_test_log_dir();3$test = new pts_result_file('test_result.xml');4echo $test->get_test_log_file();5$test = new pts_result_file('test_result.xml');6echo $test->get_test_log_file();7The get_test_log_file() method returns the path of the f

Full Screen

Full Screen

get_test_log_dir

Using AI Code Generation

copy

Full Screen

1include 'pts-core.php';2$test_result = new pts_result_file(get_test_log_dir('test-1'));3if(file_exists($test_result->get_file_location()))4{5 unlink($test_result->get_file_location());6 echo "File deleted successfully.";7}8{9 echo "File does not exists.";10}11Related Posts: PHP | file_exists() function12PHP | file() function13PHP | file_get_contents() function14PHP | file_put_contents() function15PHP | fileatime() function16PHP | filectime() function17PHP | fileinode() function18PHP | filemtime() function19PHP | filesize() function20PHP | filetype() function21PHP | flock() function22PHP | fnmatch() function23PHP | fopen() function24PHP | fpassthru() function25PHP | fputcsv() function26PHP | fputs() function27PHP | fread() function28PHP | fscanf() function29PHP | fseek() function30PHP | fstat() function31PHP | ftell() function32PHP | ftruncate() function33PHP | fwrite() function34PHP | glob() function35PHP | is_dir() function36PHP | is_executable() function37PHP | is_file() function38PHP | is_link() function39PHP | is_readable() function40PHP | is_uploaded_file() function41PHP | is_writable() function42PHP | is_writeable() function43PHP | link() function44PHP | linkinfo() function45PHP | lstat() function46PHP | mkdir() function47PHP | move_uploaded_file() function48PHP | parse_ini_file() function49PHP | parse_ini_string() function50PHP | pathinfo() function51PHP | pclose() function52PHP | popen() function53PHP | readfile() function54PHP | readlink() function55PHP | realpath() function56PHP | rewind() function57PHP | rmdir() function58PHP | set_file_buffer() function59PHP | stat() function60PHP | symlink() function61PHP | tempnam() function62PHP | tmpfile() function63PHP | touch() function

Full Screen

Full Screen

get_test_log_dir

Using AI Code Generation

copy

Full Screen

1include_once 'pts-core.php';2$result_file = new pts_result_file('/home/username/PhoronixTestSuite/Results/2011-04-06-1652-pts-2.0.0/results.xml');3echo $result_file->get_test_log_dir();4include_once 'pts-core.php';5$result_file = new pts_result_file('/home/username/PhoronixTestSuite/Results/2011-04-06-1652-pts-2.0.0/results.xml');6$test_log_dir = $result_file->get_test_log_dir();7$test_log_dir = $test_log_dir . 'test_log.txt';8echo $test_log_dir;9include_once 'pts-core.php';10$result_file = new pts_result_file('/home/username/PhoronixTestSuite/Results/2011-04-06-1652-pts-2.0.0/results.xml');11$test_log_dir = $result_file->get_test_log_dir();12$test_log_dir = $test_log_dir . 'test_log.txt';13$test_log_file = new pts_file_io($test_log_dir);14echo $test_log_file->read_to_string();15include_once 'pts-core.php';

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.

Run Phoronix-test-suite automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in pts_result_file

Trigger get_test_log_dir code on LambdaTest Cloud Grid

Execute automation tests with get_test_log_dir on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful