public static function run($args)
 {
     $result = $args[0];
     $result_file = new pts_result_file($result);
     $result_file_identifiers = $result_file->get_system_identifiers();
     if (count($result_file_identifiers) < 2) {
         echo PHP_EOL . 'There are not multiple test runs in this result file.' . PHP_EOL;
         return false;
     }
     $extract_selects = array();
     echo PHP_EOL . 'Enter The New Order To Display The New Results, From Left To Right.' . PHP_EOL;
     do {
         $extract_identifier = pts_user_io::prompt_text_menu('Select the test run to be showed next', $result_file_identifiers);
         array_push($extract_selects, new pts_result_merge_select($result, $extract_identifier));
         $old_identifiers = $result_file_identifiers;
         $result_file_identifiers = array();
         foreach ($old_identifiers as $identifier) {
             if ($identifier != $extract_identifier) {
                 array_push($result_file_identifiers, $identifier);
             }
         }
     } while (count($result_file_identifiers) > 0);
     $ordered_result = pts_merge::merge_test_results_array($extract_selects);
     pts_client::save_test_result($args[0] . '/composite.xml', $ordered_result);
     pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $args[0] . '/index.html');
 }
 public static function run($r)
 {
     $result = $r[0];
     $result_file = new pts_result_file($result);
     $result_file_identifiers = $result_file->get_system_identifiers();
     if (count($result_file_identifiers) < 2) {
         echo PHP_EOL . 'There are not multiple test runs in this result file.' . PHP_EOL;
         return false;
     }
     $remove_identifiers = explode(',', pts_user_io::prompt_text_menu('Select the test run(s) to remove', $result_file_identifiers, true));
     $keep_identifiers = array();
     foreach ($result_file_identifiers as $identifier) {
         if (!in_array($identifier, $remove_identifiers)) {
             array_push($keep_identifiers, $identifier);
         }
     }
     foreach (array('test-logs', 'system-logs', 'installation-logs') as $dir_name) {
         foreach ($remove_identifiers as $remove_identifier) {
             if (is_dir(PTS_SAVE_RESULTS_PATH . $r[0] . '/' . $dir_name . '/' . $remove_identifier)) {
                 pts_file_io::delete(PTS_SAVE_RESULTS_PATH . $r[0] . '/' . $dir_name . '/' . $remove_identifier, null, true);
             }
         }
     }
     $extract_select = new pts_result_merge_select($result, $keep_identifiers);
     $extract_result = pts_merge::merge_test_results($extract_select);
     pts_client::save_test_result($r[0] . '/composite.xml', $extract_result);
     pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $r[0] . '/index.html');
 }
 public static function run($args)
 {
     $result_file = new pts_result_file($args[0]);
     $result_file_identifiers = $result_file->get_system_identifiers();
     if (count($result_file_identifiers) < 2) {
         echo PHP_EOL . 'There are not multiple test runs in this result file.' . PHP_EOL;
         return false;
     }
     echo PHP_EOL . 'Enter The New Order To Display The New Results, From Left To Right.' . PHP_EOL;
     $sorted_identifiers = array();
     do {
         $extract_identifier = pts_user_io::prompt_text_menu('Select the test run to be showed next', $result_file_identifiers);
         $sorted_identifiers[] = $extract_identifier;
         $old_identifiers = $result_file_identifiers;
         $result_file_identifiers = array();
         foreach ($old_identifiers as $identifier) {
             if ($identifier != $extract_identifier) {
                 $result_file_identifiers[] = $identifier;
             }
         }
     } while (count($result_file_identifiers) > 0);
     $result_file->reorder_runs($sorted_identifiers);
     pts_client::save_test_result($result_file->get_file_location(), $result_file->get_xml());
     pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $args[0] . '/index.html');
 }
 public static function run($r)
 {
     $identifier = $r[0];
     $test_xml_files = pts_file_io::glob(PTS_SAVE_RESULTS_PATH . $identifier . '/test-*.xml');
     if (count($test_xml_files) == 0) {
         echo PHP_EOL . 'No test XML data was found.' . PHP_EOL;
         return false;
     }
     pts_client::save_test_result($identifier . '/composite.xml', pts_merge::merge_test_results_array($test_xml_files));
     pts_client::regenerate_graphs($identifier, 'The ' . $identifier . ' result file XML has been rebuilt.');
 }
 public static function run($args)
 {
     $result_files = array();
     foreach ($args as $id) {
         $xml = pts_openbenchmarking::clone_openbenchmarking_result($id, true);
         if ($xml) {
             $result_file = new pts_result_file($xml);
             pts_client::save_test_result($id . '/composite.xml', $result_file->get_xml(), true);
             echo PHP_EOL . 'Result Saved To: ' . PTS_SAVE_RESULTS_PATH . $id . '/composite.xml' . PHP_EOL;
         }
     }
 }
 public static function run($args)
 {
     $result_files = array();
     foreach ($args as $id) {
         $xml = pts_openbenchmarking::clone_openbenchmarking_result($id, true);
         array_push($result_files, new pts_result_file($xml));
     }
     $writer = new pts_result_file_writer(null);
     pts_merge::merge_test_results_process($writer, $result_files);
     pts_client::save_test_result($args[0] . '/composite.xml', $writer->get_xml(), true);
     echo PHP_EOL . 'Result Saved To: ' . PTS_SAVE_RESULTS_PATH . $args[0] . '/composite.xml' . PHP_EOL;
 }
 public static function run($args)
 {
     $base_file = $args[0];
     do {
         $rand_file = rand(1000, 9999);
         $save_to = 'analyze-' . $rand_file . '/';
     } while (is_dir(PTS_SAVE_RESULTS_PATH . $save_to));
     $save_to .= 'composite.xml';
     // Analyze Results
     $SAVED_RESULTS = pts_merge::generate_analytical_batch_xml($base_file);
     pts_client::save_test_result($save_to, $SAVED_RESULTS);
     echo 'Results Saved To: ' . PTS_SAVE_RESULTS_PATH . $save_to . PHP_EOL . PHP_EOL;
     pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . dirname($save_to) . '/index.html');
 }
 public static function run($args)
 {
     $result_file = new pts_result_file($args[0]);
     $result_file_identifiers = $result_file->get_system_identifiers();
     if (count($result_file_identifiers) < 2) {
         echo PHP_EOL . 'There are not multiple test runs in this result file.' . PHP_EOL;
         return false;
     }
     $extract_selects = array();
     echo PHP_EOL . 'Automatically sorting the results...' . PHP_EOL;
     sort($result_file_identifiers);
     $result_file->reorder_runs($result_file_identifiers);
     pts_client::save_test_result($result_file->get_file_location(), $result_file->get_xml());
     pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $args[0] . '/index.html');
 }
 public static function run($r)
 {
     $result = $r[0];
     $result_file = new pts_result_file($result);
     $result_file_identifiers = $result_file->get_system_identifiers();
     $rename_identifier = pts_user_io::prompt_text_menu('Select the test run to rename', $result_file_identifiers);
     $rename_identifier_new = pts_user_io::prompt_user_input('Enter the new identifier');
     foreach (array('test-logs', 'system-logs', 'installation-logs') as $dir_name) {
         if (is_dir(PTS_SAVE_RESULTS_PATH . $r[0] . '/' . $dir_name . '/' . $rename_identifier)) {
             rename(PTS_SAVE_RESULTS_PATH . $r[0] . '/' . $dir_name . '/' . $rename_identifier, PTS_SAVE_RESULTS_PATH . $r[0] . '/' . $dir_name . '/' . $rename_identifier_new);
         }
     }
     $result_file->rename_run($rename_identifier, $rename_identifier_new);
     pts_client::save_test_result($result_file->get_file_location(), $result_file->get_xml());
     pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $r[0] . '/index.html');
 }
 public static function run($r)
 {
     $result_file = new pts_result_file($r[0]);
     $result_title = $result_file->get_title();
     echo PHP_EOL . 'Current Result Title: ' . $result_title . PHP_EOL;
     $new_title = pts_user_io::prompt_user_input('Enter New Title');
     if (!empty($new_title)) {
         $result_file->set_title($new_title);
     }
     $result_description = $result_file->get_description();
     echo PHP_EOL . 'Current Result Description: ' . $result_description . PHP_EOL;
     $new_description = pts_user_io::prompt_user_input('Enter New Description');
     if (!empty($new_description)) {
         $result_file->set_description($new_description);
     }
     pts_client::save_test_result($result_file->get_file_location(), $result_file->get_xml());
     pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $r[0] . '/index.html');
 }
 public static function run($args)
 {
     $result = $args[0];
     $result_file = new pts_result_file($result);
     $result_file_identifiers = $result_file->get_system_identifiers();
     if (count($result_file_identifiers) < 2) {
         echo PHP_EOL . 'There are not multiple test runs in this result file.' . PHP_EOL;
         return false;
     }
     $extract_selects = array();
     echo PHP_EOL . 'Automatically sorting the results...' . PHP_EOL;
     sort($result_file_identifiers);
     foreach ($result_file_identifiers as $identifier) {
         array_push($extract_selects, new pts_result_merge_select($result, $identifier));
     }
     $ordered_result = pts_merge::merge_test_results_array($extract_selects);
     pts_client::save_test_result($args[0] . '/composite.xml', $ordered_result);
     pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $args[0] . '/index.html');
 }
 public static function run($args)
 {
     $result_file = new pts_result_file($args[0]);
     $result_file_identifiers = $result_file->get_system_identifiers();
     if (count($result_file_identifiers) < 2) {
         echo PHP_EOL . 'There are not multiple test runs in this result file.' . PHP_EOL;
         return false;
     }
     $extract_identifiers = pts_strings::comma_explode(pts_user_io::prompt_text_menu('Select the test run(s) to extract', $result_file_identifiers, true));
     $remove_identifiers = array_diff($result_file_identifiers, $extract_identifiers);
     $result_file->remove_run($remove_identifiers);
     do {
         echo PHP_EOL . 'Enter new result file to extract to: ';
         $extract_to = pts_user_io::read_user_input();
         $extract_to = pts_test_run_manager::clean_save_name($extract_to);
     } while (empty($extract_to));
     pts_client::save_test_result($extract_to . '/composite.xml', $result_file->get_xml());
     pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $extract_to . '/index.html');
 }
 public static function run($r)
 {
     $result_file = new pts_result_file($r[0]);
     $result_file_identifiers = $result_file->get_system_identifiers();
     if (count($result_file_identifiers) < 2) {
         echo PHP_EOL . 'There are not multiple test runs in this result file.' . PHP_EOL;
         return false;
     }
     $remove_identifiers = explode(',', pts_user_io::prompt_text_menu('Select the test run(s) to remove', $result_file_identifiers, true));
     $result_file->remove_run($remove_identifiers);
     $result_dir = dirname($result_file->get_file_location()) . '/';
     foreach (array('test-logs', 'system-logs', 'installation-logs') as $dir_name) {
         foreach ($remove_identifiers as $remove_identifier) {
             if (is_dir($result_dir . $dir_name . '/' . $remove_identifier)) {
                 pts_file_io::delete($result_dir . $dir_name . '/' . $remove_identifier, null, true);
             }
         }
     }
     pts_client::save_test_result($result_file->get_file_location(), $result_file->get_xml());
     pts_client::display_web_page($result_dir . '/index.html');
 }
 public static function run($r)
 {
     $result_file = new pts_result_file($r[0]);
     $result_title = $result_file->get_title();
     echo PHP_EOL . 'Current Result Title: ' . $result_title . PHP_EOL;
     $new_title = pts_user_io::prompt_user_input('Enter New Title');
     if (!empty($new_title)) {
         $result_title = $new_title;
     }
     $result_description = $result_file->get_description();
     echo PHP_EOL . 'Current Result Description: ' . $result_description . PHP_EOL;
     $new_description = pts_user_io::prompt_user_input('Enter New Description');
     if (!empty($new_description)) {
         $result_description = $new_description;
     }
     $result_file_writer = new pts_result_file_writer();
     $result_file_writer->add_result_file_meta_data($result_file, null, $new_title, $new_description);
     $result_file_writer->add_system_information_from_result_file($result_file);
     $result_file_writer->add_results_from_result_file($result_file);
     pts_client::save_test_result($r[0] . '/composite.xml', $result_file_writer->get_xml());
     pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $r[0] . '/index.html');
 }
 public static function run($r)
 {
     $result_files_to_merge = array();
     foreach ($r as $result_file) {
         if (pts_types::is_result_file($result_file)) {
             array_push($result_files_to_merge, $result_file);
         }
     }
     if (count($result_files_to_merge) < 2) {
         echo PHP_EOL . 'At least two saved result names must be supplied.';
         return false;
     }
     do {
         $rand_file = rand(1000, 9999);
         $merge_to_file = 'merge-' . $rand_file . '/';
     } while (is_dir(PTS_SAVE_RESULTS_PATH . $merge_to_file));
     $merge_to_file .= 'composite.xml';
     // Merge Results
     $merged_results = call_user_func(array('pts_merge', 'merge_test_results_array'), $result_files_to_merge);
     pts_client::save_test_result($merge_to_file, $merged_results);
     echo 'Merged Results Saved To: ' . PTS_SAVE_RESULTS_PATH . $merge_to_file . PHP_EOL . PHP_EOL;
     pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . dirname($merge_to_file) . '/index.html');
 }
 public static function run($args)
 {
     $result = $args[0];
     $result_file = new pts_result_file($result);
     $result_file_identifiers = $result_file->get_system_identifiers();
     if (count($result_file_identifiers) < 2) {
         echo PHP_EOL . 'There are not multiple test runs in this result file.' . PHP_EOL;
         return false;
     }
     $extract_identifiers = pts_strings::comma_explode(pts_user_io::prompt_text_menu('Select the test run(s) to extract', $result_file_identifiers, true));
     $extract_selects = array();
     foreach ($extract_identifiers as $extract_identifier) {
         array_push($extract_selects, new pts_result_merge_select($result, $extract_identifier));
     }
     do {
         echo PHP_EOL . 'Enter new result file to extract to: ';
         $extract_to = pts_user_io::read_user_input();
         $extract_to = pts_test_run_manager::clean_save_name($extract_to);
     } while (empty($extract_to) || pts_result_file::is_test_result_file($extract_to));
     $extract_result = call_user_func_array(array('pts_merge', 'merge_test_results'), $extract_selects);
     pts_client::save_test_result($extract_to . '/composite.xml', $extract_result);
     pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $extract_to . '/index.html');
 }
 public static function run($r)
 {
     $result = $r[0];
     $result_file = new pts_result_file($result);
     $result_file_identifiers = $result_file->get_system_identifiers();
     $rename_identifier = pts_user_io::prompt_text_menu('Select the test run to rename', $result_file_identifiers);
     $rename_identifier_new = pts_user_io::prompt_user_input('Enter the new identifier');
     $merge_selects = array();
     foreach ($result_file_identifiers as $identifier) {
         $this_merge_select = new pts_result_merge_select($result, $identifier);
         if ($identifier == $rename_identifier && $rename_identifier != $rename_identifier_new) {
             $this_merge_select->rename_identifier($rename_identifier_new);
         }
         array_push($merge_selects, $this_merge_select);
     }
     foreach (array('test-logs', 'system-logs', 'installation-logs') as $dir_name) {
         if (is_dir(PTS_SAVE_RESULTS_PATH . $r[0] . '/' . $dir_name . '/' . $rename_identifier)) {
             rename(PTS_SAVE_RESULTS_PATH . $r[0] . '/' . $dir_name . '/' . $rename_identifier, PTS_SAVE_RESULTS_PATH . $r[0] . '/' . $dir_name . '/' . $rename_identifier_new);
         }
     }
     $extract_result = pts_merge::merge_test_results_array($merge_selects);
     pts_client::save_test_result($r[0] . '/composite.xml', $extract_result);
     pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $r[0] . '/index.html');
 }
Esempio n. 18
0
 public static function save_result_file(&$result_file_writer, $save_name)
 {
     // Save the test file
     // TODO: clean this up with pts_client::save_test_result
     $j = 1;
     while (is_file(PTS_SAVE_RESULTS_PATH . $save_name . '/test-' . $j . '.xml')) {
         $j++;
     }
     $real_name = $save_name . '/test-' . $j . '.xml';
     pts_client::save_test_result($real_name, $result_file_writer->get_xml());
     if (!is_file(PTS_SAVE_RESULTS_PATH . $save_name . '/composite.xml')) {
         pts_client::save_test_result($save_name . '/composite.xml', file_get_contents(PTS_SAVE_RESULTS_PATH . $real_name), true, $result_file_writer->get_result_identifier());
     } else {
         // Merge Results
         $merged_results = pts_merge::merge_test_results(file_get_contents(PTS_SAVE_RESULTS_PATH . $save_name . '/composite.xml'), file_get_contents(PTS_SAVE_RESULTS_PATH . $real_name));
         pts_client::save_test_result($save_name . '/composite.xml', $merged_results, true, $result_file_writer->get_result_identifier());
     }
     return $real_name;
 }
 public function post_execution_process()
 {
     if ($this->do_save_results()) {
         if ($this->result_file->get_test_count() == 0 && $this->is_new_result_file) {
             pts_file_io::delete(PTS_SAVE_RESULTS_PATH . $this->get_file_name());
             return false;
         }
         pts_file_io::delete(PTS_SAVE_RESULTS_PATH . $this->get_file_name() . '/test-logs/active/', null, true);
         if ($this->is_new_result_file || $this->result_already_contains_identifier() == false) {
             // nothing to do here now
         }
         echo PHP_EOL;
         pts_module_manager::module_process('__event_results_process', $this);
         pts_client::save_test_result($this->get_file_name() . '/composite.xml', $this->result_file->get_xml(), true, $this->results_identifier);
         pts_module_manager::module_process('__event_results_saved', $this);
         //echo PHP_EOL . 'Results Saved To: ; . PTS_SAVE_RESULTS_PATH . $this->get_file_name() . ;/composite.xml' . PHP_EOL;
         if (!$this->auto_mode) {
             if ($this->batch_mode) {
                 if ($this->batch_mode['OpenBrowser']) {
                     pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $this->get_file_name() . '/index.html', null, true, true);
                 }
             } else {
                 pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $this->get_file_name() . '/index.html', null, true, false);
             }
         }
         if ($this->allow_sharing_of_results && pts_network::internet_support_available()) {
             if ($this->auto_upload_to_openbenchmarking || pts_openbenchmarking_client::auto_upload_results() || pts_config::read_bool_config('PhoronixTestSuite/Options/Testing/AlwaysUploadResultsToOpenBenchmarking', 'FALSE')) {
                 $upload_results = true;
             } else {
                 if ($this->batch_mode) {
                     $upload_results = $this->batch_mode['UploadResults'];
                 } else {
                     if (!$this->auto_mode) {
                         $upload_results = pts_user_io::prompt_bool_input('Would you like to upload the results to OpenBenchmarking.org', true);
                     } else {
                         $upload_results = false;
                     }
                 }
             }
             if ($upload_results) {
                 $this->openbenchmarking_results_data = pts_openbenchmarking::upload_test_result($this, true);
                 if ($this->get_results_url()) {
                     if (!$this->auto_mode && !$this->batch_mode && pts_openbenchmarking_client::auto_upload_results() == false) {
                         pts_client::display_web_page($this->get_results_url(), 'Do you want to launch OpenBenchmarking.org', true);
                     }
                 } else {
                     echo PHP_EOL . 'Results Failed To Upload.' . PHP_EOL;
                 }
             }
         }
     }
 }
 public static function clone_openbenchmarking_result(&$id, $return_xml = false)
 {
     if (!pts_network::internet_support_available()) {
         return false;
     }
     $json_response = pts_openbenchmarking::make_openbenchmarking_request('clone_openbenchmarking_result', array('i' => $id));
     $json_response = json_decode($json_response, true);
     $valid = false;
     if (is_array($json_response) && isset($json_response['openbenchmarking']['result']['composite_xml'])) {
         $composite_xml = $json_response['openbenchmarking']['result']['composite_xml'];
         $result_file = new pts_result_file($composite_xml);
         $result_file_writer = new pts_result_file_writer();
         $result_file_writer->add_result_file_meta_data($result_file, $id);
         $result_file_writer->add_system_information_from_result_file($result_file);
         $result_file_writer->add_results_from_result_file($result_file);
         //$id = strtolower($id);
         $valid = $return_xml ? $result_file_writer->get_xml() : pts_client::save_test_result($id . '/composite.xml', $result_file_writer->get_xml(), true);
         if (PTS_IS_CLIENT && $json_response['openbenchmarking']['result']['system_logs_available']) {
             // Fetch the system logs and toss them into the results directory system-logs/
             pts_openbenchmarking::clone_openbenchmarking_result_system_logs($id, pts_client::setup_test_result_directory($id), $json_response['openbenchmarking']['result']['system_logs_available']);
         }
     } else {
         if (PTS_IS_CLIENT && isset($json_response['openbenchmarking']['result']['error'])) {
             trigger_error($json_response['openbenchmarking']['result']['error'], E_USER_ERROR);
         }
     }
     return $valid;
 }
 public static function run($args)
 {
     $result = $args[0];
     $result_file = new pts_result_file($result);
     $result_file_identifiers = $result_file->get_system_identifiers();
     if (count($result_file_identifiers) < 2) {
         echo PHP_EOL . 'There are not multiple test runs in this result file.' . PHP_EOL;
         return false;
     }
     $base_identifier = pts_user_io::prompt_text_menu('Select the base test run', $result_file_identifiers);
     $base_select = new pts_result_merge_select($result, $base_identifier);
     $compare_identifier = pts_user_io::prompt_text_menu('Select the test run to compare', $result_file_identifiers);
     $compare_select = new pts_result_merge_select($result, $compare_identifier);
     do {
         $extract_to = 'iqc-analyze-' . rand(100, 999);
     } while (is_dir(PTS_SAVE_RESULTS_PATH . $extract_to));
     $extract_result = pts_merge::merge_test_results($base_select, $compare_select);
     pts_client::save_test_result($extract_to . '/composite.xml', $extract_result);
     $compare_file = new pts_result_file($extract_to);
     $result_file_writer = new pts_result_file_writer('Image Delta');
     foreach ($compare_file->get_result_objects() as $result_object) {
         if ($result_object->test_profile->get_display_format() != 'IMAGE_COMPARISON') {
             continue;
         }
         $base_result = null;
         $compare_result = null;
         foreach ($result_object->test_result_buffer->get_buffer_items() as $buffer_item) {
             if ($buffer_item->get_result_identifier() == $base_identifier && $base_result == null) {
                 $base_result = $buffer_item->get_result_value();
             } else {
                 if ($buffer_item->get_result_identifier() == $compare_identifier && $compare_result == null) {
                     $compare_result = $buffer_item->get_result_value();
                 }
             }
             if ($compare_result != null && $base_result != null) {
                 break;
             }
         }
         if ($compare_result == null || $base_result == null) {
             continue;
         }
         $base_img = imagecreatefromstring(base64_decode($base_result));
         $compare_img = imagecreatefromstring(base64_decode($compare_result));
         $delta_img = imagecreatefromstring(base64_decode($compare_result));
         $img_width = imagesx($base_img);
         $img_height = imagesy($base_img);
         $img_changed = false;
         for ($x = 0; $x < $img_width; $x++) {
             for ($y = 0; $y < $img_height; $y++) {
                 $base_image_color = pts_image::rgb_gd_color_at($base_img, $x, $y);
                 $compare_image_color = pts_image::rgb_gd_color_at($compare_img, $x, $y);
                 if ($base_image_color == $compare_image_color || pts_image::rgb_int_diff($base_image_color, $compare_image_color) < 9) {
                     if ($cords = pts_image::color_pixel_delta($base_img, $compare_img, $x, $y)) {
                         $pixel_rgb = pts_image::rgb_gd_color_at($delta_img, $cords[0], $cords[1]);
                         $color_invert = imagecolorresolve($delta_img, 255 - $pixel_rgb[0], 255 - $pixel_rgb[1], 255 - $pixel_rgb[2]);
                         imagesetpixel($delta_img, $x, $y, $color_invert);
                         $img_changed = true;
                     }
                 }
             }
         }
         if ($img_changed) {
             imagepng($delta_img, PTS_SAVE_RESULTS_PATH . $extract_to . '/scratch.png');
             $result_value = base64_encode(file_get_contents(PTS_SAVE_RESULTS_PATH . $extract_to . '/scratch.png', FILE_BINARY));
             pts_file_io::unlink(PTS_SAVE_RESULTS_PATH . $extract_to . '/scratch.png');
             $result_file_writer->add_result_from_result_object_with_value_string($result_object, $result_value);
         }
     }
     pts_client::save_result_file($result_file_writer, $extract_to);
     pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $extract_to . '/composite.xml');
 }
 public static function run($r)
 {
     $compare_tests = array();
     $compare_subsystems = array();
     foreach ($r as $test_object) {
         $test_object = pts_types::identifier_to_object($test_object);
         if ($test_object instanceof pts_test_profile) {
             array_push($compare_tests, $test_object->get_identifier(false));
             if (!isset($compare_subsystems[$test_object->get_test_hardware_type()])) {
                 $compare_subsystems[$test_object->get_test_hardware_type()] = 1;
             } else {
                 $compare_subsystems[$test_object->get_test_hardware_type()] += 1;
             }
         }
     }
     if (empty($compare_tests)) {
         $subsystem_under_test = pts_user_io::prompt_text_menu('Sub-System To Test', array('Processor', 'Graphics', 'Disk'));
     } else {
         arsort($compare_subsystems);
         $compare_subsystems = array_keys($compare_subsystems);
         $subsystem_under_test = array_shift($compare_subsystems);
     }
     $system_info = array_merge(phodevi::system_hardware(false), phodevi::system_software(false));
     $to_include = array();
     $to_exclude = array();
     if (isset($system_info[$subsystem_under_test])) {
         $compare_component = $system_info[$subsystem_under_test];
     } else {
         return;
     }
     switch ($subsystem_under_test) {
         case 'Processor':
             self::system_component_to_format($system_info, $to_include, array('OS', 'Compiler', 'Kernel', 'Motherboard'), true);
             break;
         case 'Graphics':
             self::system_component_to_format($system_info, $to_include, array('OS', 'Display Driver', 'OpenGL', 'Processor', 'Kernel', 'Desktop'), true);
             break;
         case 'OS':
             self::system_component_to_format($system_info, $to_include, array('Processor', 'Motherboard', 'Graphics', 'Disk'), true);
             self::system_component_to_format($system_info, $to_exclude, array('OS'));
             break;
         case 'Disk':
             self::system_component_to_format($system_info, $to_include, array('Processor', 'OS', 'Chipset', 'Motherboard', 'Kernel'), true);
             break;
     }
     $payload = array('subsystem_under_test' => $subsystem_under_test, 'component_under_test' => $compare_component, 'include_components' => implode(',', $to_include), 'exclude_components' => implode(',', $to_exclude), 'include_tests' => implode(',', $compare_tests));
     echo PHP_EOL . 'Querying test data from OpenBenchmarking.org...' . PHP_EOL;
     $json = pts_openbenchmarking::make_openbenchmarking_request('auto_generate_comparison', $payload);
     $json = json_decode($json, true);
     if (isset($json['auto_compare']['public_ids']) && isset($json['auto_compare']['count']) && $json['auto_compare']['count'] > 0) {
         echo 'Found ' . $json['auto_compare']['count'] . ' comparable results on OpenBenchmarking.org with a ' . $json['auto_compare']['accuracy'] . '% accuracy.' . PHP_EOL;
         $compare_results = array();
         foreach ($json['auto_compare']['public_ids'] as $public_id) {
             $result_xml = pts_openbenchmarking::clone_openbenchmarking_result($public_id, true);
             if ($result_xml) {
                 $result_file = new pts_result_file($result_xml);
                 $result_objects = $result_file->get_result_objects();
                 foreach ($result_objects as $i => &$result_object) {
                     if (!empty($compare_tests)) {
                         if (!in_array($result_object->test_profile->get_identifier(false), $compare_tests)) {
                             unset($result_objects[$i]);
                         }
                     } else {
                         if ($result_object->test_profile->get_test_hardware_type() != $subsystem_under_test) {
                             unset($result_objects[$i]);
                         }
                     }
                 }
                 if (count($result_objects) == 0) {
                     continue;
                 }
                 $result_file->override_result_objects($result_objects);
                 array_push($compare_results, $result_file);
             }
         }
         if (count($compare_results) > 0) {
             $result_xml = pts_merge::merge_test_results_array($compare_results);
             if (count($compare_results) > 2) {
                 $result_file = new pts_result_file($result_xml);
                 $result_objects = $result_file->get_result_objects();
                 $system_count = $result_file->get_system_count();
                 $result_count = count($result_objects);
                 $result_match_count = array();
                 if ($result_count > 3) {
                     foreach ($result_objects as $i => &$result_object) {
                         $result_match_count[$i] = $result_object->test_result_buffer->get_count();
                     }
                     arsort($result_match_count);
                     $biggest_size = pts_arrays::first_element($result_match_count);
                     if ($biggest_size == $system_count || $biggest_size > 3) {
                         foreach ($result_match_count as $key => $value) {
                             if ($value < 2) {
                                 unset($result_objects[$key]);
                             }
                         }
                     }
                     $result_file->override_result_objects($result_objects);
                     $result_xml = pts_merge::merge_test_results_array(array($result_file));
                 }
             }
             pts_client::save_test_result('auto-comparison/composite.xml', $result_xml);
         }
     }
     pts_test_installer::standard_install(array('auto-comparison'));
     pts_test_run_manager::standard_run(array('auto-comparison'));
 }
Esempio n. 23
0
 public static function clone_phoromatic_server_result($args)
 {
     self::setup_server_addressing();
     $id = $args[0];
     $server_response = phoromatic::upload_to_remote_server(array('r' => 'clone_result', 'i' => $id));
     $server_response = json_decode($server_response, true);
     if (isset($server_response['phoromatic']['result']['composite_xml']) && !empty($server_response['phoromatic']['result']['composite_xml'])) {
         $composite_xml = base64_decode($server_response['phoromatic']['result']['composite_xml']);
         $result_file = new pts_result_file($composite_xml);
         // TODO XXX: Add system log downloading support
         $result_file_writer = new pts_result_file_writer();
         $result_file_writer->add_result_file_meta_data($result_file, $id);
         $result_file_writer->add_system_information_from_result_file($result_file);
         $result_file_writer->add_results_from_result_file($result_file);
         pts_client::save_test_result($id . '/composite.xml', $result_file_writer->get_xml(), true);
         echo PHP_EOL . 'Result File Saved As: ' . $id . PHP_EOL . PHP_EOL;
     } else {
         echo PHP_EOL . 'No Phoromatic result found.' . PHP_EOL;
     }
 }