public static function run($r)
 {
     $to_run = array();
     foreach (pts_types::identifiers_to_test_profile_objects($r, false, true) as $test_profile) {
         pts_arrays::unique_push($to_run, $test_profile);
     }
     pts_test_run_manager::standard_run($to_run);
 }
 public function __construct($result_file)
 {
     $result_object = null;
     parent::__construct($result_object, $result_file);
     // System Identifiers
     if ($result_file->is_multi_way_comparison()) {
         // Multi way comparisons currently render the overview graph as blank
         $this->skip_graph = true;
         return;
     }
     $this->system_identifiers = $result_file->get_system_identifiers();
     if (count($this->system_identifiers) < 2) {
         // No point in generating this when there is only one identifier
         $this->skip_graph = true;
         return;
     }
     $result_objects = array();
     $test_titles = array();
     foreach ($result_file->get_result_objects() as $result_object) {
         if ($result_object->test_profile->get_display_format() == 'BAR_GRAPH') {
             array_push($result_objects, $result_object);
             array_push($test_titles, $result_object->test_profile->get_title());
             foreach ($result_object->test_result_buffer->buffer_items as &$buffer_item) {
                 pts_arrays::unique_push($this->graph_identifiers, $buffer_item->get_result_identifier());
             }
         }
     }
     $result_object_count = count($result_objects);
     if ($result_object_count < 3) {
         // No point in generating this if there aren't many tests
         $this->skip_graph = true;
         return;
     }
     $result_file->override_result_objects($result_objects);
     // Test Titles
     $this->i['identifier_size'] = 6.5;
     $this->i['graph_width'] = 1000;
     list($longest_title_width, $longest_title_height) = pts_svg_dom::estimate_text_dimensions(pts_strings::find_longest_string($test_titles), $this->i['identifier_size']);
     $this->i['left_start'] += 20;
     $this->graphs_per_row = min(count($this->system_identifiers) > 10 ? 6 : 10, floor(($this->i['graph_width'] - $this->i['left_start'] - $this->i['left_end_right']) / ($longest_title_width + 4)));
     $this->graph_item_width = floor(($this->i['graph_width'] - $this->i['left_start'] - $this->i['left_end_right']) / $this->graphs_per_row);
     $this->graph_row_count = ceil($result_object_count / $this->graphs_per_row);
     $this->i['top_start'] += 20 + count($this->system_identifiers) / 3 * $this->i['identifier_size'];
     $height = $this->i['top_start'] + $this->graph_row_count * ($this->graph_row_height + 15);
     $this->graph_title = $result_file->get_title();
     $this->graph_y_title = null;
     $this->i['graph_proportion'] = 'HIB';
     $this->i['show_background_lines'] = true;
     $this->update_graph_dimensions($this->i['graph_width'], $height, true);
     $this->result_file = $result_file;
     return true;
 }
 public function add_test_profile($test_profile)
 {
     $added = false;
     if (($e = pts_client::read_env('SKIP_TESTS')) != false && (in_array($test_profile->get_identifier(false), pts_strings::comma_explode($e)) || in_array($test_profile->get_identifier(true), pts_strings::comma_explode($e)))) {
         //pts_client::$display->test_install_error($test_profile->get_identifier() . ' is being skipped from installation.');
     } else {
         if (($e = pts_client::read_env('SKIP_TESTING_SUBSYSTEMS')) != false && in_array(strtolower($test_profile->get_test_hardware_type()), pts_strings::comma_explode(strtolower($e)))) {
             //pts_client::$display->test_install_error($test_profile->get_identifier() . ' is being skipped from installation.');
         } else {
             $added = pts_arrays::unique_push($this->tests_to_install, new pts_test_install_request($test_profile));
         }
     }
     return $added;
 }
 public static function __pre_run_process(&$test_run_manager)
 {
     self::$result_identifier = $test_run_manager->get_results_identifier();
     self::$individual_monitoring = pts_module::read_variable('MONITOR_INDIVIDUAL') !== '0';
     self::$to_monitor = array();
     $to_show = pts_strings::comma_explode(pts_module::read_variable('MONITOR'));
     if (pts_module::read_variable('PERFORMANCE_PER_WATT')) {
         // We need to ensure the system power consumption is being tracked to get performance-per-Watt
         pts_arrays::unique_push($to_show, 'sys.power');
         self::$individual_monitoring = true;
         echo PHP_EOL . 'To Provide Performance-Per-Watt Outputs.' . PHP_EOL;
     }
     $monitor_all = in_array('all', $to_show);
     foreach (phodevi::supported_sensors() as $sensor) {
         if ($monitor_all || in_array(phodevi::sensor_identifier($sensor), $to_show) || in_array('all.' . $sensor[0], $to_show)) {
             array_push(self::$to_monitor, $sensor);
             pts_module::save_file('logs/' . phodevi::sensor_identifier($sensor));
         }
     }
     if (in_array('i915_energy', $to_show) && is_readable('/sys/kernel/debug/dri/0/i915_energy')) {
         // For now the Intel monitoring is a special case separate from the rest
         // of the unified sensor monitoring since we're not polling it every time but just pre/post test.
         self::$monitor_i915_energy = true;
     }
     if (count(self::$to_monitor) > 0) {
         echo PHP_EOL . 'Sensors To Be Logged:';
         foreach (self::$to_monitor as &$sensor) {
             echo PHP_EOL . '   - ' . phodevi::sensor_name($sensor);
         }
         echo PHP_EOL;
         if (pts_module::read_variable('MONITOR_INTERVAL') != null) {
             $proposed_interval = pts_module::read_variable('MONITOR_INTERVAL');
             if (is_numeric($proposed_interval) && $proposed_interval >= 1) {
                 self::$sensor_monitoring_frequency = $proposed_interval;
             }
         }
         // Pad some idling sensor results at the start
         sleep(self::$sensor_monitoring_frequency * 8);
     }
     pts_module::pts_timed_function('pts_monitor_update', self::$sensor_monitoring_frequency);
 }
예제 #5
0
 protected static function report_test_notes_to_graph(&$graph, &$result_object)
 {
     // do some magic here to report any test notes....
     $json = array();
     $unique_compiler_data = array();
     foreach ($result_object->test_result_buffer->get_buffer_items() as $buffer_item) {
         $result_json = $buffer_item->get_result_json();
         if (!empty($result_json)) {
             $json[$buffer_item->get_result_identifier()] = $result_json;
             if (isset($result_json['compiler-options']) && !empty($result_json['compiler-options'])) {
                 pts_arrays::unique_push($unique_compiler_data, $result_json['compiler-options']);
             }
         }
         // report against graph with $graph->addTestNote($note, $hover_title = null);
     }
     if (empty($json)) {
         // no JSON data being reported to look at...
         return false;
     }
     if (isset($unique_compiler_data[0]['compiler-type']) && isset($unique_compiler_data[0]['compiler'])) {
         $compiler_options_string = '(' . strtoupper($unique_compiler_data[0]['compiler-type']) . ') ' . $unique_compiler_data[0]['compiler'] . ' options: ';
     } else {
         $compiler_options_string = null;
     }
     switch (count($unique_compiler_data)) {
         case 0:
             break;
         case 1:
             if ($unique_compiler_data[0]['compiler-options'] != null) {
                 $graph->addTestNote($compiler_options_string . $unique_compiler_data[0]['compiler-options'], $unique_compiler_data[0]['compiler-options']);
             }
             break;
         default:
             $diff = call_user_func_array('array_diff', $unique_compiler_data);
             if (count($diff) == 1) {
                 $key = array_keys($diff);
                 $key = array_pop($key);
             }
             if (isset($key) && isset($diff[$key])) {
                 $unique_compiler_data = array();
                 foreach ($json as $identifier => &$data) {
                     if (isset($data['compiler-options'][$key])) {
                         $d = explode(' ', $data['compiler-options'][$key]);
                         if (!in_array($d, $unique_compiler_data)) {
                             $unique_compiler_data[$identifier] = $d;
                         }
                     }
                 }
                 if (empty($unique_compiler_data)) {
                     break;
                 }
                 if ($key == 'compiler-options') {
                     $intersect = count($unique_compiler_data) == 1 ? reset($unique_compiler_data) : call_user_func_array('array_intersect', $unique_compiler_data);
                     $graph->addTestNote($compiler_options_string . implode(' ', $intersect));
                 }
                 if (count($unique_compiler_data) > 1) {
                     foreach ($json as $identifier => &$data) {
                         if (isset($data['compiler-options'][$key])) {
                             $options = explode(' ', $data['compiler-options'][$key]);
                             $diff = implode(' ', array_diff($options, $intersect));
                             if ($diff) {
                                 $graph->addGraphIdentifierNote($identifier, $diff);
                             }
                         }
                     }
                 }
             }
             break;
     }
     foreach ($json as $identifier => &$data) {
         // TODO XXX: Ultimately merge this data into the SE +/- line...
         if (isset($data['min-result'])) {
             if (isset($data['max-result'])) {
                 $graph->addGraphIdentifierNote($identifier, 'MIN: ' . $data['min-result'] . ' / MAX: ' . $data['max-result']);
             } else {
                 $graph->addGraphIdentifierNote($identifier, 'MIN: ' . $data['min-result']);
             }
         }
         if (isset($data['install-footnote']) && $data['install-footnote'] != null) {
             $graph->addTestNote($identifier . ': ' . $data['install-footnote']);
             //$graph->addGraphIdentifierNote($identifier, $data['install-footnote']);
         }
     }
 }
예제 #6
0
 public static function compact_result_file_test_object(&$mto, &$result_table = false, &$result_file, $extra_attributes = null)
 {
     $identifiers_inverted = $result_file && $result_file->is_multi_way_inverted();
     // TODO: this may need to be cleaned up, its logic is rather messy
     $condense_multi_way = isset($extra_attributes['condense_multi_way']);
     if (count($mto->test_profile->get_result_scale_offset()) > 0) {
         // It's already doing something
         return;
     }
     $scale_special = array();
     $days = array();
     $systems = array();
     $prev_date = null;
     $is_tracking = true;
     $sha1_short_count = 0;
     $buffer_count = $mto->test_result_buffer->get_count();
     if ($identifiers_inverted) {
         $system_index = 0;
         $date_index = 1;
     } else {
         $system_index = 1;
         $date_index = 0;
     }
     foreach ($mto->test_result_buffer->get_buffer_items() as $buffer_item) {
         $identifier = array_map('trim', explode(':', $buffer_item->get_result_identifier()));
         switch (count($identifier)) {
             case 2:
                 $system = $identifier[$system_index];
                 $date = $identifier[$date_index];
                 break;
             case 1:
                 $system = 0;
                 $date = $identifier[0];
                 break;
             default:
                 return;
                 break;
         }
         if (!isset($systems[$system])) {
             $systems[$system] = 0;
         }
         if (!isset($days[$date])) {
             $days[$date] = null;
         }
         if ($is_tracking) {
             // First do a dirty SHA1 hash check
             if (strlen($date) != 40 || strpos($date, ' ') !== false) {
                 if (($x = strpos($date, ' + ')) !== false) {
                     $date = substr($date, 0, $x);
                 }
                 // Check to see if only numeric changes are being made
                 $sha1_short_hash_ending = isset($date[7]) && ctype_alnum(substr($date, -8));
                 $date = str_replace('s', null, pts_strings::remove_from_string($date, pts_strings::CHAR_NUMERIC | pts_strings::CHAR_DASH | pts_strings::CHAR_DECIMAL));
                 if ($sha1_short_hash_ending) {
                     $sha1_short_count++;
                 }
                 if ($prev_date != null && $date != $prev_date && $sha1_short_hash_ending == false && $sha1_short_count < 3) {
                     $is_tracking = false;
                 }
                 $prev_date = $date;
             }
         }
     }
     if ($is_tracking) {
         $prev_date_r = explode(' ', $prev_date);
         if (count($prev_date_r) == 2 && ctype_alpha($prev_date_r[0])) {
             // This check should make it so when like testing every Ubuntu releases (Ubuntu 11.04, Ubuntu 11.10, etc) it's not in a line graph
             $is_tracking = false;
         }
     } else {
         if ($is_tracking == false && $sha1_short_count > 5) {
             // It's probably actually tracking..... based upon Stefan's Wine 1.4 example on 15 March 2012
             $is_tracking = true;
         }
     }
     foreach (array_keys($days) as $day_key) {
         $days[$day_key] = $systems;
     }
     $raw_days = $days;
     $json_days = $days;
     foreach ($mto->test_result_buffer->get_buffer_items() as $buffer_item) {
         $identifier = array_map('trim', explode(':', $buffer_item->get_result_identifier()));
         switch (count($identifier)) {
             case 2:
                 $system = $identifier[$system_index];
                 $date = $identifier[$date_index];
                 break;
             case 1:
                 $system = 0;
                 $date = $identifier[0];
                 break;
             default:
                 return;
                 break;
         }
         $days[$date][$system] = $buffer_item->get_result_value();
         $raw_days[$date][$system] = $buffer_item->get_result_raw();
         $json_days[$date][$system] = $buffer_item->get_result_json();
         if (!is_numeric($days[$date][$system])) {
             return;
         }
     }
     $mto->test_result_buffer = new pts_test_result_buffer();
     $day_keys = array_keys($days);
     if ($condense_multi_way) {
         $mto->set_used_arguments_description($mto->get_arguments_description() . ' | Composite Of: ' . implode(' - ', array_keys($days)));
         foreach (array_keys($systems) as $system_key) {
             $sum = 0;
             $count = 0;
             foreach ($day_keys as $day_key) {
                 $sum += $days[$day_key][$system_key];
                 $count++;
             }
             $mto->test_result_buffer->add_test_result($system_key, $sum / $count);
         }
     } else {
         $mto->test_profile->set_result_scale($mto->test_profile->get_result_scale() . ' | ' . implode(',', array_keys($days)));
         if ($is_tracking && $buffer_count < 16 && $result_file && pts_result_file_analyzer::analyze_result_file_intent($result_file) == false) {
             // It can't be a tracker if the result file is comparing hardware/software, etc
             $is_tracking = false;
         }
         switch ($mto->test_profile->get_display_format()) {
             //case 'HORIZONTAL_BOX_PLOT':
             //	$mto->test_profile->set_display_format('HORIZONTAL_BOX_PLOT_MULTI');
             //	break;
             case 'SCATTER_PLOT':
                 break;
             default:
                 $line_graph_type = 'LINE_GRAPH';
                 $mto->test_profile->set_display_format(!isset($extra_attributes['force_tracking_line_graph']) && (count($days) < 5 || $is_tracking == false && !isset($extra_attributes['force_line_graph_compact'])) ? 'BAR_ANALYZE_GRAPH' : $line_graph_type);
                 break;
         }
         foreach (array_keys($systems) as $system_key) {
             $results = array();
             $raw_results = array();
             $json_results = array();
             foreach ($day_keys as $day_key) {
                 array_push($results, $days[$day_key][$system_key]);
                 array_push($raw_results, $raw_days[$day_key][$system_key]);
                 pts_arrays::unique_push($json_results, $json_days[$day_key][$system_key]);
             }
             // TODO XXX: Make JSON data work for multi-way comparisons!
             if (count($json_results) == 1) {
                 $json = array_shift($json_results);
             } else {
                 $json = null;
             }
             $mto->test_result_buffer->add_test_result($system_key, implode(',', $results), implode(',', $raw_results), $json);
         }
     }
     if ($result_table !== false) {
         foreach (array_keys($systems) as $system_key) {
             foreach ($day_keys as $day_key) {
                 if (!isset($result_table[$system_key][$day_key])) {
                     $result_table[$system_key][$day_key] = array();
                 }
                 array_push($result_table[$system_key][$day_key], $days[$day_key][$system_key], $raw_days[$day_key][$system_key]);
             }
         }
     }
 }
    public static function render_page_process($PATH)
    {
        $main = null;
        if (isset($PATH[0])) {
            $upload_ids = explode(',', $PATH[0]);
            foreach ($upload_ids as $i => $upload_id) {
                if (isset($upload_id[5]) && substr($upload_id, 0, 2) == 'S:') {
                    $t = explode(':', $upload_id);
                    $stmt = phoromatic_server::$db->prepare('SELECT UploadID, UploadTime FROM phoromatic_results WHERE AccountID = :account_id AND ScheduleID = :schedule_id ORDER BY UploadTime DESC');
                    $stmt->bindValue(':account_id', $_SESSION['AccountID']);
                    $stmt->bindValue(':schedule_id', $t[1]);
                    $test_result_result = $stmt->execute();
                    $cutoff_time = is_numeric($t[2]) ? strtotime('today -' . $t[2] . ' days') : false;
                    while ($test_result_row = $test_result_result->fetchArray()) {
                        if ($cutoff_time !== false && strtotime($test_result_row['UploadTime']) < $cutoff_time) {
                            break;
                        }
                        $upload_ids[] = $test_result_row['UploadID'];
                    }
                    unset($upload_ids[$i]);
                }
            }
            $upload_ids = array_unique($upload_ids);
            $result_files = array();
            $display_rows = array();
            $system_types = array();
            $schedule_types = array();
            $trigger_types = array();
            $upload_times = array();
            $benchmark_tickets = array();
            $xml_result_hash = array();
            $tickets = array();
            foreach ($upload_ids as $id) {
                $result_share_opt = phoromatic_server::read_setting('force_result_sharing') ? '1 = 1' : 'AccountID = (SELECT AccountID FROM phoromatic_account_settings WHERE LetOtherGroupsViewResults = "1" AND AccountID = phoromatic_results.AccountID)';
                $stmt = phoromatic_server::$db->prepare('SELECT * FROM phoromatic_results WHERE PPRID = :pprid AND (AccountID = :account_id OR ' . $result_share_opt . ') LIMIT 1');
                $stmt->bindValue(':pprid', $id);
                $stmt->bindValue(':account_id', $_SESSION['AccountID']);
                $result = $stmt->execute();
                $row = $result->fetchArray();
                if (false && empty($row)) {
                    // TODO XXX
                    // XXX this code is ultimately dead
                    $stmt = phoromatic_server::$db->prepare('SELECT * FROM phoromatic_results WHERE AccountID = :account_id AND UploadID = :upload_id LIMIT 1');
                    $stmt->bindValue(':account_id', $_SESSION['AccountID']);
                    $stmt->bindValue(':upload_id', $id);
                    $result = $stmt->execute();
                    $row = $result->fetchArray();
                }
                if (empty($row)) {
                    continue;
                }
                $composite_xml = phoromatic_server::phoromatic_account_result_path($row['AccountID'], $row['UploadID']) . 'composite.xml';
                if (!is_file($composite_xml)) {
                    echo 'File Not Found: ' . $composite_xml;
                    return false;
                }
                $display_rows[$composite_xml] = $row;
                pts_arrays::unique_push($benchmark_tickets, $row['BenchmarkTicketID']);
                pts_arrays::unique_push($upload_times, $row['UploadTime']);
                pts_arrays::unique_push($xml_result_hash, $row['XmlUploadHash']);
                pts_arrays::unique_push($system_types, $row['SystemID']);
                pts_arrays::unique_push($schedule_types, $row['ScheduleID']);
                pts_arrays::unique_push($trigger_types, $row['Trigger']);
                pts_arrays::unique_push($tickets, $row['BenchmarkTicketID']);
                // Update view counter
                $stmt_view = phoromatic_server::$db->prepare('UPDATE phoromatic_results SET TimesViewed = (TimesViewed + 1) WHERE AccountID = :account_id AND UploadID = :upload_id');
                $stmt_view->bindValue(':account_id', $_SESSION['AccountID']);
                $stmt_view->bindValue(':upload_id', $row['UploadID']);
                $stmt_view->execute();
            }
            $result_file_title = null;
            if (count($system_types) == 1) {
                $result_file_title = phoromatic_system_id_to_name($system_types[0]) . ' Tests';
            }
            if (!empty($tickets) && $tickets[0] != null) {
                $system_name_format = 'ORIGINAL_DATA';
            } else {
                if (count($trigger_types) == 1 && $trigger_types[0] != null && $benchmark_tickets[0] != null && count($display_rows) > 1) {
                    $system_name_format = 'TRIGGER_AND_SYSTEM';
                } else {
                    if (empty($schedule_types[0])) {
                        $system_name_format = 'ORIGINAL_DATA';
                    } else {
                        if (count($display_rows) == 1) {
                            $system_name_format = 'SYSTEM_NAME';
                        } else {
                            if (count($schedule_types) == 1 && count($system_types) == 1) {
                                $system_name_format = 'TRIGGER';
                                $result_file_title = phoromatic_schedule_id_to_name($schedule_types[0]);
                            } else {
                                if (count($schedule_types) == 1) {
                                    $system_name_format = 'TRIGGER_AND_SYSTEM';
                                } else {
                                    if (false && count($trigger_types) == 1) {
                                        // TODO XXX: this approach yields garbage strings generally without refining the selector
                                        // i.e. first make sure all the schedules match or are comparable
                                        $system_name_format = 'SYSTEM_AND_SCHEDULE';
                                    } else {
                                        $system_name_format = null;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if (count($schedule_types) == 1 && $schedule_types[0] != 0) {
                self::$schedule_id = $schedule_types[0];
            }
            foreach ($display_rows as $composite_xml => $row) {
                //  $row['SystemID'] . ' ' . $row['ScheduleID'] . ' ' . $row['Trigger']
                switch ($system_name_format) {
                    case 'ORIGINAL_DATA':
                        $system_name = null;
                        break;
                    case 'SYSTEM_NAME':
                        $system_name = phoromatic_system_id_to_name($row['SystemID']);
                        break;
                    case 'TRIGGER':
                        $system_name = $row['Trigger'];
                        break;
                    case 'TRIGGER_AND_SYSTEM':
                        $system_name = phoromatic_system_id_to_name($row['SystemID']) . ': ' . $row['Trigger'];
                        break;
                    case 'SYSTEM_AND_SCHEDULE':
                        $system_name = phoromatic_schedule_id_to_name($row['ScheduleID']) . ': ' . $row['Trigger'];
                        break;
                    default:
                        $system_name = phoromatic_system_id_to_name($row['SystemID']) . ' - ' . phoromatic_schedule_id_to_name($row['ScheduleID']) . ' - ' . $row['Trigger'];
                }
                if ($system_name == null) {
                    $rf = new pts_result_file($composite_xml);
                    $identifiers = $rf->get_system_identifiers();
                    if (count($identifiers) == 1) {
                        $system_name = $identifiers[0];
                    }
                }
                $system_name = str_replace('.SYSTEM', phoromatic_system_id_to_name($row['SystemID']), $system_name);
                $system_name = str_replace('.GROUP', phoromatic_account_id_to_group_name($row['AccountID']), $system_name);
                $system_variables = explode(';', phoromatic_server::system_id_variables($row['SystemID'], $row['AccountID']));
                foreach ($system_variables as $var) {
                    $var = explode('=', $var);
                    if (count($var) == 2) {
                        $system_name = str_replace('.' . $var[0], $var[1], $system_name);
                    }
                }
                $result_files[] = new pts_result_merge_select($composite_xml, null, $system_name);
            }
            $result_file = new pts_result_file(null, true);
            $result_file->set_title('Phoromatic Results');
            if (!empty($result_files)) {
                $attributes = array('new_result_file_title' => $result_file_title);
                if (!empty($result_files)) {
                    $result_file->merge($result_files, $attributes);
                }
            }
            $extra_attributes = array();
            if (isset($_GET['upload_to_openbenchmarking'])) {
                $ob_url = pts_openbenchmarking_client::upload_test_result($result_file, false);
                if ($ob_url) {
                    header('Location: ' . $ob_url);
                }
            }
            $attribute_options = array('normalize_results' => 'normalize_result_buffer', 'sort_by_performance' => 'sort_result_buffer_values', 'sort_by_reverse' => 'reverse_result_buffer', 'sort_by_name' => 'sort_result_buffer', 'condense_comparison' => 'condense_multi_way', 'force_line_graph' => 'force_tracking_line_graph');
            $url_append = null;
            foreach ($attribute_options as $web_var => $attr_var) {
                if (isset($_REQUEST[$web_var])) {
                    $extra_attributes[$attr_var] = true;
                    $url_append .= '&' . $web_var . '=1';
                }
            }
            if (isset($_POST['transpose_comparison'])) {
                $result_file->invert_multi_way_invert();
            }
            $intent = null;
            if (isset($_GET['download']) && $_GET['download'] == 'csv') {
                $result_csv = pts_result_file_output::result_file_to_csv($result_file);
                header('Content-Description: File Transfer');
                header('Content-Type: application/csv');
                header('Content-Disposition: attachment; filename=phoromatic-result.csv');
                header('Expires: 0');
                header('Cache-Control: must-revalidate');
                header('Pragma: public');
                header('Content-Length: ' . strlen($result_csv));
                ob_clean();
                flush();
                echo $result_csv;
                return;
            } else {
                if (isset($_GET['download']) && $_GET['download'] == 'txt') {
                    $result_txt = pts_result_file_output::result_file_to_text($result_file);
                    header('Content-Description: File Transfer');
                    header('Content-Type: application/txt');
                    header('Content-Disposition: attachment; filename=phoromatic-result.txt');
                    header('Expires: 0');
                    header('Cache-Control: must-revalidate');
                    header('Pragma: public');
                    header('Content-Length: ' . strlen($result_txt));
                    ob_clean();
                    flush();
                    echo $result_txt;
                    return;
                } else {
                    if (isset($_GET['download']) && $_GET['download'] == 'pdf') {
                        ob_start();
                        $_REQUEST['force_format'] = 'PNG';
                        // Force to PNG renderer
                        $_REQUEST['svg_dom_gd_no_interlacing'] = true;
                        // Otherwise FPDF will fail
                        $tdir = pts_client::create_temporary_directory();
                        pts_client::generate_result_file_graphs($result_file, $tdir, $extra_attributes);
                        $pdf = new pts_pdf_template($result_file->get_title(), null);
                        $pdf->AddPage();
                        $pdf->Image(PTS_CORE_STATIC_PATH . 'images/pts-308x160.png', 69, 85, 73, 38);
                        $pdf->Ln(120);
                        $pdf->WriteStatementCenter('www.phoronix-test-suite.com');
                        $pdf->Ln(15);
                        $pdf->WriteBigHeaderCenter($result_file->get_title());
                        $pdf->WriteText($result_file->get_description());
                        $pdf->AddPage();
                        $pdf->Ln(15);
                        $pdf->SetSubject($result_file->get_title() . ' Benchmarks');
                        //$pdf->SetKeywords(implode(', ', $identifiers));
                        $pdf->WriteHeader('Test Systems:');
                        foreach ($result_file->get_systems() as $s) {
                            $pdf->WriteMiniHeader($s->get_identifier());
                            $pdf->WriteText($s->get_hardware());
                            $pdf->WriteText($s->get_software());
                        }
                        $pdf->AddPage();
                        $placement = 1;
                        $results = $result_file->get_result_objects();
                        for ($i = 1; $i <= count($results); $i++) {
                            if (is_file($tdir . 'result-graphs/' . $i . '.png')) {
                                $pdf->Ln(100);
                                $pdf->Image($tdir . 'result-graphs/' . $i . '.png', 50, 40 + ($placement - 1) * 120, 120);
                            }
                            if ($placement == 2) {
                                $placement = 0;
                                if ($i != count($results)) {
                                    $pdf->AddPage();
                                }
                            }
                            $placement++;
                        }
                        ob_get_clean();
                        $pdf->Output('phoromatic.pdf', 'I');
                        //pts_file_io::delete($tdir, null, true);
                        return;
                    } else {
                        if (isset($_GET['download']) && $_GET['download'] == 'xml') {
                            echo $result_file->get_xml();
                            return;
                        }
                    }
                }
            }
            $main .= '<h1>' . $result_file->get_title() . '</h1>';
            $main .= phoromatic_annotate_entry('RESULT', implode(',', $upload_ids), 'TOP');
            if ($result_file->get_system_count() == 1 || ($intent = pts_result_file_analyzer::analyze_result_file_intent($result_file, $intent, true))) {
                $table = new pts_ResultFileCompactSystemsTable($result_file, $intent);
            } else {
                $table = new pts_ResultFileSystemsTable($result_file);
            }
            $main .= '<p style="text-align: center; overflow: auto;" class="result_object">' . pts_render::render_graph_inline_embed($table, $result_file, $extra_attributes) . '</p>';
            $table = new pts_ResultFileTable($result_file, $intent);
            $main .= '<p style="text-align: center; overflow: auto;" class="result_object">' . pts_render::render_graph_inline_embed($table, $result_file, $extra_attributes) . '</p>';
            $main .= '<div id="pts_results_area">';
            foreach ($result_file->get_result_objects(isset($_POST['show_only_changed_results']) ? 'ONLY_CHANGED_RESULTS' : -1) as $i => $result_object) {
                $main .= '<h2><a name="r-' . $i . '"></a><a name="' . $result_object->get_comparison_hash(true, false) . '"></a>' . $result_object->test_profile->get_title() . '</h2>';
                $main .= phoromatic_annotate_entry('RESULT', implode(',', $upload_ids), $result_object->get_comparison_hash(true, false));
                $main .= '<p class="result_object">';
                $main .= pts_render::render_graph_inline_embed($result_object, $result_file, $extra_attributes);
                $main .= '</p>';
            }
            $main .= '</div>';
        } else {
            // No result
        }
        $right = null;
        if (self::$schedule_id && !empty(self::$schedule_id)) {
            $stmt = phoromatic_server::$db->prepare('SELECT * FROM phoromatic_schedules WHERE AccountID = :account_id AND ScheduleID = :schedule_id LIMIT 1');
            $stmt->bindValue(':account_id', $_SESSION['AccountID']);
            $stmt->bindValue(':schedule_id', self::$schedule_id);
            $result = $stmt->execute();
            $row = $result->fetchArray();
            if (!empty($row)) {
                $right .= '<h3><a href="?schedules/' . $row['ScheduleID'] . '">' . $row['Title'] . '</a></h3>';
                if (!empty($row['ActiveOn'])) {
                    $right .= '<p align="center"><strong>' . phoromatic_schedule_activeon_string($row['ActiveOn'], $row['RunAt']) . '</strong></p>';
                }
                $right .= '<p>Compare this result file to the latest results from the past: ';
                $right .= '<select name="view_results_from_past" id="view_results_from_past" onchange="phoromatic_jump_to_results_from(\'' . $row['ScheduleID'] . '\', \'view_results_from_past\', \'' . $PATH[0] . ',\');">';
                $oldest_upload_time = strtotime(phoromatic_oldest_result_for_schedule(self::$schedule_id));
                $opts = array('Week' => 7, 'Three Weeks' => 21, 'Month' => 30, 'Quarter' => 90, 'Six Months' => 180, 'Year' => 365);
                foreach ($opts as $str_name => $time_offset) {
                    if ($oldest_upload_time > time() - 86400 * $time_offset) {
                        break;
                    }
                    $right .= '<option value="' . $time_offset . '">' . $str_name . '</option>';
                }
                $right .= '<option value="all">All Results</option>';
                $right .= '</select>';
                $right .= '</p>';
            }
        }
        if (true) {
            $compare_results = array();
            $hash_matches = 0;
            $ticket_matches = 0;
            $stmt = phoromatic_server::$db->prepare('SELECT * FROM phoromatic_results WHERE AccountID = :account_id AND ComparisonHash = :comparison_hash AND PPRID NOT IN (:pprid) ORDER BY UploadTime DESC LIMIT 12');
            $stmt->bindValue(':account_id', $_SESSION['AccountID']);
            $stmt->bindValue(':comparison_hash', $result_file->get_contained_tests_hash(false));
            $stmt->bindValue(':pprid', implode(',', $upload_ids));
            $result = $stmt->execute();
            while ($row = $result->fetchArray()) {
                $compare_results[$row['PPRID']] = $row;
                $hash_matches++;
            }
            foreach ($benchmark_tickets as $ticket_id) {
                $stmt = phoromatic_server::$db->prepare('SELECT * FROM phoromatic_results WHERE AccountID = :account_id AND BenchmarkTicketID = :ticket_id AND PPRID NOT IN (:pprid) ORDER BY UploadTime DESC LIMIT 12');
                $stmt->bindValue(':account_id', $_SESSION['AccountID']);
                $stmt->bindValue(':ticket_id', $ticket_id);
                $stmt->bindValue(':pprid', implode(',', $upload_ids));
                $result = $stmt->execute();
                while ($row = $result->fetchArray()) {
                    $compare_results[$row['PPRID']] = $row;
                    $ticket_matches++;
                }
            }
            if (!empty($compare_results)) {
                $right .= '<hr /><h3>Compare Results</h3><form name="compare_similar_results" onsubmit="return false;">
						<input type="hidden" value="' . implode(',', $upload_ids) . '" id="compare_similar_results_this" />';
                foreach ($compare_results as &$row) {
                    $right .= '<p><input type="checkbox" value="' . $row['PPRID'] . '" name="compare_results" /> ' . $row['Title'] . '<br /><em>' . phoromatic_system_id_to_name($row['SystemID'], $row['AccountID']) . '</em></p>';
                }
                $right .= '<p><input type="submit" value="Compare Results" id="compare_results_submit" onclick="javascript:phoromatic_do_custom_compare_results(this); return false;" /></p></form>';
                if ($ticket_matches > 3) {
                    $right .= '<p><a href="/results/ticket/' . $ticket_id . '">Find All Matching Results</a>';
                } else {
                    if ($hash_matches > 3) {
                        $right .= '<p><a href="/results/hash/' . $result_file->get_contained_tests_hash(false) . '">Find All Matching Results</a>';
                    }
                }
            }
        }
        if (count($upload_ids) > 1) {
            $checkbox_options = array('normalize_results' => 'Normalize Results', 'sort_by_performance' => 'Sort Results By Performance', 'sort_by_name' => 'Reverse Result By Identifier', 'sort_by_reverse' => 'Reverse Result Order', 'show_only_changed_results' => 'Show Only Results With Result Variation', 'force_line_graph' => 'Force Line Graph');
            if ($result_file->is_multi_way_comparison()) {
                $checkbox_options['condense_comparison'] = 'Condense Comparison';
                $checkbox_options['transpose_comparison'] = 'Transpose Comparison';
            }
            $right .= '<form action="' . $_SERVER['REQUEST_URI'] . '" name="update_result_view" method="post"><hr /><h3>Result Analysis Options</h3><p align="left">' . PHP_EOL;
            foreach ($checkbox_options as $val => $name) {
                $right .= '<input type="checkbox" name="' . $val . '" value="1" ' . (isset($_POST[$val]) ? 'checked="checked" ' : null) . '/> ' . $name . '<br />';
            }
            $right .= '<br /><input type="submit" value="Refresh Results"></p></form>';
        }
        if (self::$schedule_id && !empty(self::$schedule_id) && $system_types[0] && $trigger_types[0]) {
            $stmt = phoromatic_server::$db->prepare('SELECT UserContextStep FROM phoromatic_system_context_logs WHERE AccountID = :account_id AND ScheduleID = :schedule_id AND SystemID = :system_id AND TriggerID = :trigger_id');
            $stmt->bindValue(':account_id', $_SESSION['AccountID']);
            $stmt->bindValue(':system_id', $system_types[0]);
            $stmt->bindValue(':schedule_id', self::$schedule_id);
            $stmt->bindValue(':trigger_id', $trigger_types[0]);
            $result = $stmt->execute();
            if ($row = $result->fetchArray()) {
                $right .= '<hr /><h3>User Context Logs</h3>';
                do {
                    $right .= '<p><a href="?logs/context/' . $system_types[0] . ',' . self::$schedule_id . ',' . base64_encode($trigger_types[0]) . '">' . $row['UserContextStep'] . '</a></p>';
                } while ($row = $result->fetchArray());
            }
        }
        $right .= '<hr /><h3>Result Export</h3>';
        $right .= '<p><a href="/public.php?t=result&ut=' . implode(',', $upload_ids) . $url_append . '">Public Viewer</a></p>';
        $right .= '<p><a href="?' . $_SERVER['QUERY_STRING'] . '/&download=pdf' . $url_append . '">Download As PDF</a></p>';
        $right .= '<p><a href="?' . $_SERVER['QUERY_STRING'] . '/&download=csv">Download As CSV</a></p>';
        $right .= '<p><a href="?' . $_SERVER['QUERY_STRING'] . '/&download=xml">Download As XML</a></p>';
        $right .= '<p><a href="?' . $_SERVER['QUERY_STRING'] . '/&download=txt">Download As TEXT</a></p>';
        $right .= '<p><a href="?' . $_SERVER['QUERY_STRING'] . '/&upload_to_openbenchmarking">Upload To OpenBenchmarking.org</a></p>';
        if (is_file(phoromatic_server::phoromatic_account_result_path($_SESSION['AccountID'], $row['UploadID']) . 'system-logs.zip')) {
            $right .= '<hr /><p><a href="?logs/system/' . $row['UploadID'] . '">View System Logs</a></p>';
        }
        echo phoromatic_webui_header_logged_in();
        echo phoromatic_webui_main($main, phoromatic_webui_right_panel_logged_in($right));
        echo phoromatic_webui_footer();
    }
 public static function generate_result_export_dump($account_id)
 {
     pts_file_io::mkdir(self::phoromatic_path() . 'result-export/');
     $export_path = self::phoromatic_path() . 'result-export/' . $account_id . '/';
     pts_file_io::mkdir($export_path);
     $stmt = phoromatic_server::$db->prepare('SELECT * FROM phoromatic_schedules WHERE AccountID = :account_id AND State = 1 AND (SELECT COUNT(*) FROM phoromatic_schedules_tests WHERE AccountID = :account_id AND ScheduleID = phoromatic_schedules.ScheduleID) > 0 AND (SELECT COUNT(*) FROM phoromatic_results WHERE AccountID = :account_id AND ScheduleID = phoromatic_schedules.ScheduleID) > 4 ORDER BY Title ASC');
     $stmt->bindValue(':account_id', $account_id);
     $result = $stmt->execute();
     $exported_result_index = array('phoromatic' => array());
     while ($result && ($row = $result->fetchArray())) {
         $id = str_replace(' ', '-', strtolower($row['Title']));
         $triggers = array();
         $stmt2 = phoromatic_server::$db->prepare('SELECT * FROM phoromatic_results WHERE AccountID = :account_id AND ScheduleID = :schedule_id ORDER BY UploadTime DESC');
         $stmt2->bindValue(':account_id', $row['AccountID']);
         $stmt2->bindValue(':schedule_id', $row['ScheduleID']);
         $result2 = $stmt2->execute();
         pts_file_io::mkdir($export_path);
         while ($result2 && ($row2 = $result2->fetchArray())) {
             $composite_xml = phoromatic_server::phoromatic_account_result_path($row2['AccountID'], $row2['UploadID']) . 'composite.xml';
             if (is_file($composite_xml)) {
                 pts_file_io::mkdir($export_path . $id . '/' . $row2['Trigger']);
                 pts_file_io::mkdir($export_path . $id . '/' . $row2['Trigger'] . '/' . phoromatic_server::system_id_to_name($row2['SystemID'], $row2['AccountID']));
                 copy($composite_xml, $export_path . $id . '/' . $row2['Trigger'] . '/' . phoromatic_server::system_id_to_name($row2['SystemID'], $row2['AccountID']) . '/composite.xml');
             }
             pts_arrays::unique_push($triggers, $row2['Trigger']);
         }
         $exported_result_index['phoromatic'][$id] = array('title' => $row['Title'], 'id' => $id, 'description' => $row['Description'], 'triggers' => $triggers);
     }
     $exported_result_index = json_encode($exported_result_index, JSON_PRETTY_PRINT);
     file_put_contents($export_path . '/export-index.json', $exported_result_index);
 }
 public function subsystems_under_test()
 {
     $subsystems_to_test = array();
     foreach ($this->tests_to_run as $test_run_request) {
         pts_arrays::unique_push($subsystems_to_test, $test_run_request->test_profile->get_test_hardware_type());
     }
     return $subsystems_to_test;
 }
예제 #10
0
 protected function generate_results_var()
 {
     if ($this->is_multi_way_comparison) {
         $this->results = array();
         foreach ($this->test_result->test_result_buffer->buffer_items as &$buffer_item) {
             $identifier = array_map('trim', explode(':', $buffer_item->get_result_identifier()));
             if (true) {
                 $identifier = array_reverse($identifier);
             }
             switch (count($identifier)) {
                 case 2:
                     $system = $identifier[0];
                     $date = $identifier[1];
                     break;
                 case 1:
                     $system = 0;
                     $date = $identifier[0];
                     break;
                 default:
                     continue;
                     break;
             }
             $buffer_item->reset_result_identifier($system);
             if (!isset($this->results[$date])) {
                 $this->results[$date] = array();
             }
             array_push($this->results[$date], $buffer_item);
             pts_arrays::unique_push($this->graph_identifiers, $system);
         }
         if (count($this->results) == 1) {
             $this->is_multi_way_comparison = false;
         }
     } else {
         $this->results = array($this->test_result->test_result_buffer->buffer_items);
         foreach ($this->test_result->test_result_buffer->buffer_items as &$buffer_item) {
             array_push($this->graph_identifiers, $buffer_item->get_result_identifier());
         }
     }
 }
 public static function generate_test_notes(&$test_result_objects)
 {
     // TODO XXX: Integrate with system table notes
     static $check_processes = null;
     $test_types = array();
     $test_tags = array();
     foreach ($test_result_objects as $test_result) {
         pts_arrays::unique_push($test_types, $test_result->test_profile->get_test_hardware_type());
         foreach ($test_result->test_profile->get_internal_tags() as $tag) {
             pts_arrays::unique_push($test_tags, $tag);
         }
     }
     if (in_array('Java', $test_tags)) {
         self::add_note(phodevi::read_property('system', 'java-version'));
     }
     if (in_array('Python', $test_tags)) {
         self::add_note(phodevi::read_property('system', 'python-version'));
     }
     if (in_array('Wine', $test_tags)) {
         self::add_note(phodevi::read_property('system', 'wine-version'));
     }
     if (in_array('OpenCL', $test_tags)) {
         $cores = phodevi::read_property('gpu', 'compute-cores');
         if ($cores > 0) {
             self::add_note('GPU Compute Cores: ' . $cores);
         }
     }
     /*
     if(phodevi::is_bsd() == false)
     {
     	if(empty($check_processes))
     	{
     		$check_processes = array(
     			'Compiz' => array('compiz', 'compiz.real'),
     			'Firefox' => array('firefox', 'mozilla-firefox', 'mozilla-firefox-bin'),
     			'Thunderbird' => array('thunderbird', 'mozilla-thunderbird', 'thunderbird-bin'),
     			'BOINC' => array('boinc', 'boinc_client')
     			);
     	}
     
     	self::add_note(self::process_running_string($check_processes));
     }
     */
     // Check if Security Enhanced Linux was enforcing, permissive, or disabled
     if (is_readable('/etc/sysconfig/selinux')) {
         if (stripos(file_get_contents('/etc/sysconfig/selinux'), 'selinux=disabled') === false) {
             self::add_note('SELinux: Enabled');
         }
     } else {
         if (isset(phodevi::$vfs->cmdline)) {
             if (stripos(phodevi::$vfs->cmdline, 'selinux=1') != false) {
                 self::add_note('SELinux: Enabled');
             }
         }
     }
     /*
     // Encrypted file-system?
     if(phodevi::is_linux() && is_readable('/sys/fs/ecryptfs/version'))
     {
     	self::add_note('eCryptfs was active.');
     }
     */
     self::add_note(phodevi::read_property('motherboard', 'power-mode'));
     if (in_array('Graphics', $test_types) || in_array('System', $test_types)) {
         $aa_level = phodevi::read_property('gpu', 'aa-level');
         $af_level = phodevi::read_property('gpu', 'af-level');
         if (!empty($aa_level)) {
             self::add_note('Antialiasing: ' . $aa_level);
         }
         if (!empty($af_level)) {
             self::add_note('Anisotropic Filtering: ' . $af_level);
         }
     }
     $notes_string = trim(implode('. ', self::$notes));
     if ($notes_string != null) {
         $notes_string .= '.';
     }
     self::$notes = array();
     return $notes_string;
 }
 protected function generate_results_var()
 {
     $this->results = array();
     if ($this->is_multi_way_comparison) {
         foreach ($this->test_result->test_result_buffer->buffer_items as $i => &$buffer_item) {
             if ($buffer_item->get_result_value() === null) {
                 unset($this->test_result->test_result_buffer->buffer_items[$i]);
                 continue;
             }
             $identifier = array_map('trim', explode(':', $buffer_item->get_result_identifier()));
             if ($this->i['multi_way_comparison_invert_default']) {
                 $identifier = array_reverse($identifier);
             }
             switch (count($identifier)) {
                 case 2:
                     $system = $identifier[0];
                     $date = $identifier[1];
                     break;
                 case 1:
                     $system = 0;
                     $date = $identifier[0];
                     break;
                 default:
                     continue;
                     break;
             }
             $buffer_item->reset_result_identifier($system);
             if (!isset($this->results[$date])) {
                 $this->results[$date] = array();
             }
             $this->results[$date][] = $buffer_item;
             pts_arrays::unique_push($this->graph_identifiers, $system);
         }
         if (count($this->results) == 1) {
             $this->is_multi_way_comparison = false;
         }
     } else {
         if (isset($this->test_result->test_result_buffer)) {
             foreach ($this->test_result->test_result_buffer->buffer_items as $i => &$buffer_item) {
                 if ($buffer_item->get_result_value() === null) {
                     unset($this->test_result->test_result_buffer->buffer_items[$i]);
                     continue;
                 }
                 $this->graph_identifiers[] = $buffer_item->get_result_identifier();
             }
             $this->results = array($this->test_result->test_result_buffer->buffer_items);
         }
     }
 }
예제 #13
0
 $schedule_types = array();
 $trigger_types = array();
 foreach ($result_ids as $upload_id) {
     $stmt = phoromatic_server::$db->prepare('SELECT * FROM phoromatic_results WHERE PPRID = :pprid LIMIT 1');
     $stmt->bindValue(':pprid', $upload_id);
     $result = $stmt->execute();
     $row = $result->fetchArray();
     $composite_xml = phoromatic_server::phoromatic_account_result_path($row['AccountID'], $row['UploadID']) . 'composite.xml';
     if (!is_file($composite_xml)) {
         echo 'File Not Found: ' . $composite_xml;
         return false;
     }
     $display_rows[$composite_xml] = $row;
     pts_arrays::unique_push($system_types, $row['SystemID']);
     pts_arrays::unique_push($schedule_types, $row['ScheduleID']);
     pts_arrays::unique_push($trigger_types, $row['Trigger']);
     // Update view counter
     $stmt_view = phoromatic_server::$db->prepare('UPDATE phoromatic_results SET TimesViewed = (TimesViewed + 1) WHERE AccountID = :account_id AND UploadID = :upload_id');
     $stmt_view->bindValue(':account_id', $account_id);
     $stmt_view->bindValue(':upload_id', $upload_id);
     $stmt_view->execute();
 }
 $result_file_title = null;
 if (empty($schedule_types[0])) {
     $system_name_format = 'ORIGINAL_DATA';
 } else {
     if (count($display_rows) == 1) {
         $system_name_format = 'SYSTEM_NAME';
     } else {
         if (count($schedule_types) == 1 && count($system_types) == 1) {
             $system_name_format = 'TRIGGER';
 private static function create_single_sensor_instance($sensor, $instance, $param)
 {
     if ($sensor[0] === 'cgroup') {
         $cgroup_controller = call_user_func(array($sensor[2], 'get_cgroup_controller'));
         pts_arrays::unique_push(self::$cgroup_enabled_controllers, $cgroup_controller);
         self::cgroup_create(self::$cgroup_name, $cgroup_controller);
         $param = self::$cgroup_name;
     }
     if (call_user_func(array($sensor[2], 'parameter_check'), $param) === true) {
         $sensor_object = new $sensor[2]($instance, $param);
         self::$to_monitor[] = $sensor_object;
         pts_module::save_file('logs/' . phodevi::sensor_object_identifier($sensor_object));
     }
 }