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 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;
 }
Пример #3
0
 public static function generate_analytical_batch_xml($analyze_file)
 {
     if ($analyze_file instanceof pts_result_file == false) {
         $analyze_file = new pts_result_file($analyze_file);
     }
     $result_file_writer = new pts_result_file_writer();
     $result_file_writer->add_result_file_meta_data($analyze_file);
     $result_file_writer->add_system_information_from_result_file($analyze_file);
     $test_result_manager = new pts_result_file_analyze_manager();
     $test_result_manager->add_test_result_set($analyze_file->get_result_objects());
     $result_file_writer->add_results_from_result_manager($test_result_manager);
     unset($test_result_manager);
     return $result_file_writer->get_xml();
 }
Пример #4
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;
     }
 }
 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');
 }