public static function run($r)
 {
     $result_file = new pts_result_file($r[0]);
     $result_output = pts_result_file_output::result_file_to_csv($result_file);
     // To save the result:
     $file = pts_core::user_home_directory() . $r[0] . '.csv';
     file_put_contents($file, $result_output);
     echo $result_output;
 }
 public static function run($r)
 {
     $_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($r[0], $tdir);
     $result_file = new pts_result_file($r[0]);
     $pdf_file = pts_core::user_home_directory() . $r[0] . '.pdf';
     $pdf_output = pts_result_file_output::result_file_to_pdf($result_file, $pdf_file, 'F');
     echo PHP_EOL . 'Saved To: ' . $pdf_file . PHP_EOL;
 }
 public function __construct($xsl_binding = null, $nice_formatting = true)
 {
     $this->dom = new DOMDocument('1.0');
     $this->dom->formatOutput = PTS_IS_CLIENT && $nice_formatting;
     //$this->dom->preserveWhiteSpace = false;
     $this->items = array();
     if (PTS_IS_CLIENT) {
         $pts_comment = $this->dom->createComment(pts_core::program_title(false));
         $this->dom->appendChild($pts_comment);
     }
     if ($xsl_binding != null) {
         $xslt = $this->dom->createProcessingInstruction('xml-stylesheet', 'type="text/xsl" href="' . $xsl_binding . '"');
         $this->dom->appendChild($xslt);
     }
 }
Ejemplo n.º 4
0
 public static function run($r)
 {
     echo PHP_EOL . pts_core::program_title(true) . PHP_EOL . PHP_EOL;
     echo pts_documentation::basic_description() . PHP_EOL . PHP_EOL . 'View the included PDF / HTML documentation or visit http://www.phoronix-test-suite.com/ for full details.' . PHP_EOL;
     $options = pts_documentation::client_commands_array();
     foreach ($options as $section => &$contents) {
         if (empty($contents)) {
             continue;
         }
         echo PHP_EOL . strtoupper($section) . PHP_EOL . PHP_EOL;
         sort($contents);
         foreach ($contents as &$option) {
             echo '   ' . trim($option[0] . ' ' . implode(' ', $option[1])) . PHP_EOL;
         }
     }
     echo PHP_EOL;
 }
Ejemplo n.º 5
0
 public function __construct($width, $height)
 {
     $dom = new DOMImplementation();
     $dtd = $dom->createDocumentType('svg', '-//W3C//DTD SVG 1.1//EN', 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd');
     $this->dom = $dom->createDocument(null, null, $dtd);
     $this->dom->formatOutput = PTS_IS_CLIENT && PTS_IS_DEV_BUILD;
     $pts_comment = $this->dom->createComment(pts_core::program_title(false) . ' [ http://www.phoronix-test-suite.com/ ]');
     $this->dom->appendChild($pts_comment);
     $this->svg = $this->dom->createElementNS('http://www.w3.org/2000/svg', 'svg');
     $this->svg->setAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
     $this->svg->setAttribute('version', '1.1');
     $this->svg->setAttribute('font-family', 'sans-serif, droid-sans, helvetica, verdana, tahoma');
     $this->svg->setAttribute('viewbox', '0 0 ' . $width . ' ' . $height);
     $this->svg->setAttribute('width', $width);
     $this->svg->setAttribute('height', $height);
     $this->svg->setAttribute('preserveAspectRatio', 'xMinYMin meet');
     $this->width = $width;
     $this->height = $height;
     $this->dom->appendChild($this->svg);
 }
    public static function run($r)
    {
        if (pts_client::create_lock(PTS_USER_PATH . 'phoromatic_server_lock') == false) {
            trigger_error('The Phoromatic Server is already running.', E_USER_ERROR);
            return false;
        }
        pts_file_io::unlink(getenv('PTS_EXT_LAUNCH_SCRIPT_DIR') . '/phoromatic-server-launcher');
        if (PHP_VERSION_ID < 50400) {
            echo 'Running an unsupported PHP version. PHP 5.4+ is required to use this feature.' . PHP_EOL . PHP_EOL;
            return false;
        }
        if (!function_exists('socket_create_listen')) {
            echo 'PHP Sockets support is needed to use the Phoromatic Server.' . PHP_EOL . PHP_EOL;
            return false;
        }
        $server_launcher = '#!/bin/sh' . PHP_EOL;
        $web_port = 0;
        $remote_access = pts_config::read_user_config('PhoronixTestSuite/Options/Server/RemoteAccessPort', 'RANDOM');
        $fp = false;
        $errno = null;
        $errstr = null;
        if ($remote_access == 'RANDOM') {
            do {
                if ($fp) {
                    fclose($fp);
                }
                $remote_access = rand(8000, 8999);
            } while (($fp = fsockopen('127.0.0.1', $remote_access, $errno, $errstr, 5)) != false);
            echo 'Port ' . $remote_access . ' chosen as random port for this instance. Change the default port via the Phoronix Test Suite user configuration file.' . PHP_EOL;
        }
        $remote_access = is_numeric($remote_access) && $remote_access > 1 ? $remote_access : false;
        $blocked_ports = array(2049, 3659, 4045, 6000, 9000);
        if ($remote_access) {
            // ALLOWING SERVER TO BE REMOTELY ACCESSIBLE
            $server_ip = '0.0.0.0';
            if (($fp = fsockopen('127.0.0.1', $remote_access, $errno, $errstr, 5)) != false) {
                fclose($fp);
                trigger_error('Port ' . $remote_access . ' is already in use by another server process. Close that process or change the Phoronix Test Suite server port via' . pts_config::get_config_file_location() . ' to proceed.', E_USER_ERROR);
                return false;
            } else {
                $web_port = $remote_access;
                $web_socket_port = pts_config::read_user_config('PhoronixTestSuite/Options/Server/WebSocketPort', '');
                while ($web_socket_port == null || !is_numeric($web_socket_port) || ($fp = fsockopen('127.0.0.1', $web_socket_port, $errno, $errstr, 5)) != false) {
                    if ($fp) {
                        fclose($fp);
                    }
                    $web_socket_port = rand(8000, 8999);
                }
            }
        } else {
            echo PHP_EOL . PHP_EOL . 'You must first configure the remote web / Phoromatic settings via:' . PHP_EOL . '    ' . pts_config::get_config_file_location() . PHP_EOL . PHP_EOL . 'The RemoteAccessPort should be a network port to use for HTTP communication while WebSocketPort should be set to another available network port. Set to RANDOM if wishing to use randomly chosen available ports.' . PHP_EOL . PHP_EOL;
            return false;
        }
        if (!extension_loaded('sqlite3')) {
            echo PHP_EOL . PHP_EOL . 'PHP SQLite3 support must first be enabled before accessing the Phoromatic server (e.g. installing the php5-sqlite or php-pdo package depending on the distribution).' . PHP_EOL . PHP_EOL;
            return false;
        }
        // Setup server logger
        define('PHOROMATIC_SERVER', true);
        // Just create the logger so now it will flush it out
        $pts_logger = new pts_logger();
        $pts_logger->clear_log();
        echo pts_core::program_title(true) . ' starting Phoromatic Server' . PHP_EOL;
        $pts_logger->log(pts_core::program_title(true) . ' starting Phoromatic Server on ' . pts_network::get_local_ip());
        echo 'Phoronix Test Suite User-Data Directory Path: ' . PTS_USER_PATH . PHP_EOL;
        echo 'Phoronix Test Suite Configuration File: ' . pts_config::get_config_file_location() . PHP_EOL;
        echo 'Phoromatic Server Log File: ' . $pts_logger->get_log_file_location() . PHP_EOL;
        $pts_logger->log('PTS_USER_PATH = ' . PTS_USER_PATH);
        $pts_logger->log('PTS_DOWNLOAD_CACHE_PATH = ' . PTS_DOWNLOAD_CACHE_PATH);
        $pts_logger->log('XML Configuration File = ' . pts_config::get_config_file_location());
        // WebSocket Server Setup
        $server_launcher .= 'export PTS_WEB_PORT=' . $web_port . PHP_EOL;
        $server_launcher .= 'export PTS_WEBSOCKET_PORT=' . $web_socket_port . PHP_EOL;
        $server_launcher .= 'export PTS_WEBSOCKET_SERVER=PHOROMATIC' . PHP_EOL;
        $server_launcher .= 'export PTS_NO_FLUSH_LOGGER=1' . PHP_EOL;
        $server_launcher .= 'export PTS_PHOROMATIC_SERVER=1' . PHP_EOL;
        $server_launcher .= 'export PTS_PHOROMATIC_LOG_LOCATION=' . $pts_logger->get_log_file_location() . PHP_EOL;
        $server_launcher .= 'cd ' . getenv('PTS_DIR') . ' && PTS_MODE="CLIENT" ' . getenv('PHP_BIN') . ' pts-core/phoronix-test-suite.php start-ws-server &' . PHP_EOL;
        $server_launcher .= 'websocket_server_pid=$!' . PHP_EOL;
        $pts_logger->log('Starting WebSocket process on port ' . $web_socket_port);
        $server_launcher .= 'cd ' . getenv('PTS_DIR') . ' && PTS_MODE="CLIENT" ' . getenv('PHP_BIN') . ' pts-core/phoronix-test-suite.php start-phoromatic-event-server &' . PHP_EOL;
        $server_launcher .= 'event_server_pid=$!' . PHP_EOL;
        // HTTP Server Setup
        if (false && pts_client::executable_in_path('nginx') && is_file('/run/php-fpm/php-fpm.pid')) {
            // NGINX
            $nginx_conf = 'error_log /tmp/error.log;
			pid /tmp/nginx.pid;
			worker_processes 1;

			events {
			  worker_connections 1024;
			}

			http {
			  client_body_temp_path /tmp/client_body;
			  fastcgi_temp_path /tmp/fastcgi_temp;
			  proxy_temp_path /tmp/proxy_temp;
			  scgi_temp_path /tmp/scgi_temp;
			  uwsgi_temp_path /tmp/uwsgi_temp;
			  tcp_nopush on;
			  tcp_nodelay on;
			  keepalive_timeout 180;
			  types_hash_max_size 2048;
			  include /etc/nginx/mime.types;
			  index index.php;

			  server {
			    listen ' . $web_port . ';
			    listen [::]:' . $web_port . ' default ipv6only=on;
			    access_log /tmp/access.log;
			    error_log /tmp/error.log;
			    root ' . PTS_CORE_PATH . 'phoromatic/public_html;
				index index.php;
			      try_files $uri $uri/ /index.php;
				location / {
				autoindex on;
				}
				location ~ \\.php$ {
				     include        /etc/nginx/fastcgi_params;
				     fastcgi_param  SCRIPT_FILENAME  $document_root/$fastcgi_script_name;
				     fastcgi_split_path_info ^(.+\\.php)(/.+)$;
				     fastcgi_pass   127.0.0.1:9000;
				     fastcgi_index  index.php;
				}
			  }
			}';
            $nginx_conf_file = tempnam(PTS_USER_PATH, 'nginx_conf_');
            file_put_contents($nginx_conf_file, $nginx_conf);
            $server_launcher .= 'nginx -c ' . $nginx_conf_file . PHP_EOL . 'rm -f ' . $nginx_conf_file . PHP_EOL;
        } else {
            if (($mongoose = pts_client::executable_in_path('mongoose')) && ($php_cgi = pts_client::executable_in_path('php-cgi'))) {
                // Mongoose Embedded Web Server
                $server_launcher .= $mongoose . ' -p ' . $web_port . ' -r ' . PTS_CORE_PATH . 'phoromatic/public_html/ -I ' . $php_cgi . ' -i index.php > /dev/null 2>> $PTS_PHOROMATIC_LOG_LOCATION &' . PHP_EOL;
                //2> /dev/null
            } else {
                if (strpos(getenv('PHP_BIN'), 'hhvm')) {
                    echo PHP_EOL . 'Unfortunately, the HHVM built-in web server has abandoned upstream. Users will need to use the PHP binary or other alternatives.' . PHP_EOL . PHP_EOL;
                    return;
                } else {
                    // PHP Web Server
                    $server_launcher .= getenv('PHP_BIN') . ' -S ' . $server_ip . ':' . $web_port . ' -t ' . PTS_CORE_PATH . 'phoromatic/public_html/ > /dev/null 2>> $PTS_PHOROMATIC_LOG_LOCATION &' . PHP_EOL;
                    //2> /dev/null
                }
            }
        }
        $server_launcher .= 'http_server_pid=$!' . PHP_EOL;
        $server_launcher .= 'sleep 1' . PHP_EOL;
        $server_launcher .= 'echo "The Phoromatic Web Interface Is Accessible At: http://localhost:' . $web_port . '"' . PHP_EOL;
        $pts_logger->log('Starting HTTP process @ http://localhost:' . $web_port);
        // Avahi for zeroconf network discovery support
        if (pts_config::read_user_config('PhoronixTestSuite/Options/Server/AdvertiseServiceZeroConf', 'TRUE')) {
            if (is_dir('/etc/avahi/services') && is_writable('/etc/avahi/services')) {
                file_put_contents('/etc/avahi/services/phoromatic-server.service', '<?xml version="1.0" standalone=\'no\'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
  <name replace-wildcards="yes">phoromatic-server-%h</name>
  <service>
    <type>_http._tcp</type>
    <port>' . $web_port . '</port>
  </service>
</service-group>');
            } else {
                if (pts_client::executable_in_path('avahi-publish')) {
                    $hostname = phodevi::read_property('system', 'hostname');
                    $hostname = $hostname == null ? rand(0, 99) : $hostname;
                    $server_launcher .= 'avahi-publish -s phoromatic-server-' . $hostname . ' _http._tcp ' . $web_port . ' "Phoronix Test Suite Phoromatic" > /dev/null 2> /dev/null &' . PHP_EOL;
                    $server_launcher .= 'avahi_publish_pid=$!' . PHP_EOL;
                }
            }
        }
        // Wait for input to shutdown process..
        if (!PTS_IS_DAEMONIZED_SERVER_PROCESS) {
            $server_launcher .= PHP_EOL . 'echo -n "Press [ENTER] to kill server..."' . PHP_EOL;
            $server_launcher .= PHP_EOL . 'read var_name';
        } else {
            $server_launcher .= PHP_EOL . 'while [ ! -f "/var/lib/phoronix-test-suite/end-phoromatic-server" ];';
            $server_launcher .= PHP_EOL . 'do';
            $server_launcher .= PHP_EOL . 'sleep 1';
            $server_launcher .= PHP_EOL . 'done';
            $server_launcher .= PHP_EOL . 'rm -f /var/lib/phoronix-test-suite/end-phoromatic-server' . PHP_EOL;
        }
        // Shutdown / Kill Servers
        $server_launcher .= PHP_EOL . 'kill $http_server_pid';
        $server_launcher .= PHP_EOL . 'kill $websocket_server_pid';
        $server_launcher .= PHP_EOL . 'kill $event_server_pid';
        if (is_writable('/etc/avahi/services') && is_file('/etc/avahi/services/phoromatic-server.service')) {
            $server_launcher .= PHP_EOL . 'rm -f /etc/avahi/services/phoromatic-server.service';
        } else {
            $server_launcher .= PHP_EOL . 'kill $avahi_publish_pid';
        }
        $server_launcher .= PHP_EOL . 'rm -f ~/.phoronix-test-suite/run-lock*';
        file_put_contents(getenv('PTS_EXT_LAUNCH_SCRIPT_DIR') . '/phoromatic-server-launcher', $server_launcher);
    }
Ejemplo n.º 7
0
	Copyright (C) 2014 - 2015, Phoronix Media
	Copyright (C) 2014 - 2015, Michael Larabel

	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
if (isset($_GET['phoromatic_info'])) {
    define('PHOROMATIC_SERVER', true);
    //ini_set('memory_limit', '64M');
    define('PTS_MODE', 'WEB_CLIENT');
    define('PTS_AUTO_LOAD_OBJECTS', true);
    error_reporting(E_ALL);
    include '../../pts-core.php';
    pts_core::init();
    $json_info = array('http_server' => isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : null, 'pts' => pts_core::program_title(), 'pts_core' => PTS_CORE_VERSION, 'ws_port' => getenv('PTS_WEBSOCKET_PORT'), 'download_cache' => '/download-cache.php', 'openbenchmarking_cache' => '/openbenchmarking-cache.php');
    echo json_encode($json_info);
    pts_logger::add_to_log($_SERVER['REMOTE_ADDR'] . ' requested the Phoromatic Server deployment details');
} else {
    include '../../pts-core.php';
    echo pts_core::program_title(true) . ' Phoromatic Server [' . $_SERVER['SERVER_SOFTWARE'] . ']';
}
 protected function process_data(&$user, &$msg)
 {
     $decoded_msg = $this->decode_data($user, $msg);
     //echo 'DECODED: '; var_dump($decoded_msg);
     //echo 'DECODED MSG: ' . $decoded_msg . PHP_EOL;
     foreach (explode(' ;; ', $decoded_msg) as $single_msg) {
         $json = json_decode($single_msg, true);
         if ($json && isset($json['phoromatic']['event'])) {
             switch ($json['phoromatic']['event']) {
                 case 'ping':
                     $j['phoromatic']['event'] = 'pong';
                     $j['phoromatic']['time'] = time();
                     $this->send_json_data($user->socket, $j);
                     break;
                 case 'pts-version':
                     $j['phoromatic']['event'] = 'pts-version';
                     $j['phoromatic']['response'] = pts_core::program_title(true);
                     $this->send_json_data($user->socket, $j);
                     break;
                 case 'core-version':
                     $version = PTS_CORE_VERSION;
                     $this->send_data($user->socket, $version);
                     break;
                 case 'download-cache':
                     $dc = json_decode(file_get_contents(phoromatic_server::find_download_cache()), true);
                     $j['phoromatic']['event'] = 'download-cache';
                     $j['phoromatic']['download-cache'] = $dc;
                     $this->send_json_data($user->socket, $j);
                     break;
                 case 'check':
                     $j['phoromatic']['event'] = 'check';
                     $j['phoromatic']['task'] = 'quit-testing';
                     $this->send_json_data($user->socket, $j);
                     break;
             }
         }
     }
 }
 public function generic_heading($string, $ending_line_break = true)
 {
     static $shown_pts = false;
     if ($shown_pts == false) {
         $string = pts_core::program_title() . PHP_EOL . $string;
         $shown_pts = true;
     }
     if (!empty($string)) {
         echo PHP_EOL;
         foreach (pts_strings::trim_explode(PHP_EOL, $string) as $line_count => $line_string) {
             // ($line_count > 0 ? $this->tab : null) .
             echo $line_string . PHP_EOL;
         }
         if ($ending_line_break) {
             echo PHP_EOL;
         }
     }
 }
Ejemplo n.º 10
0
 public static function environmental_variables()
 {
     // The PTS environmental variables passed during the testing process, etc
     static $env_variables = null;
     if ($env_variables == null) {
         $env_variables = array('PTS_VERSION' => PTS_VERSION, 'PTS_CODENAME' => PTS_CODENAME, 'PTS_DIR' => PTS_PATH, 'PHP_BIN' => PHP_BIN, 'NUM_CPU_CORES' => phodevi::read_property('cpu', 'core-count'), 'NUM_CPU_NODES' => phodevi::read_property('cpu', 'node-count'), 'NUM_CPU_JOBS' => phodevi::read_property('cpu', 'core-count') * 2, 'SYS_MEMORY' => phodevi::read_property('memory', 'capacity'), 'VIDEO_MEMORY' => phodevi::read_property('gpu', 'memory-capacity'), 'VIDEO_WIDTH' => pts_arrays::first_element(phodevi::read_property('gpu', 'screen-resolution')), 'VIDEO_HEIGHT' => pts_arrays::last_element(phodevi::read_property('gpu', 'screen-resolution')), 'VIDEO_MONITOR_COUNT' => phodevi::read_property('monitor', 'count'), 'VIDEO_MONITOR_LAYOUT' => phodevi::read_property('monitor', 'layout'), 'VIDEO_MONITOR_SIZES' => phodevi::read_property('monitor', 'modes'), 'OPERATING_SYSTEM' => phodevi::read_property('system', 'vendor-identifier'), 'OS_VERSION' => phodevi::read_property('system', 'os-version'), 'OS_ARCH' => phodevi::read_property('system', 'kernel-architecture'), 'OS_TYPE' => phodevi::operating_system(), 'THIS_RUN_TIME' => PTS_INIT_TIME, 'DEBUG_REAL_HOME' => pts_core::user_home_directory());
         if (!pts_client::executable_in_path('cc') && pts_client::executable_in_path('gcc') && getenv('CC') == false) {
             // This helps some test profiles build correctly if they don't do a cc check internally
             $env_variables['CC'] = 'gcc';
         }
     }
     return $env_variables;
 }
 public function generic_heading($string)
 {
     static $shown_pts = false;
     if ($shown_pts == false) {
         $string = pts_core::program_title() . PHP_EOL . $string;
     }
     echo self::string_header($string, '=');
 }
Ejemplo n.º 12
0
    public static function render_page_process($PATH)
    {
        echo '<div style="background: #CCC; padding: 10px; margin: 10px 20px;">Thanks for trying out the Phoronix Test Suite GUI. With Phoronix Test Suite 5.0 the GUI is still considered in an <strong>experimental / tech preview state</strong>. The GUI should be more end-user friendly and reach feature parity with the command-line interface in forthcoming releases. Your feedback is appreciated on the GUI while the command-line interface continues to be our primary focus along with remotely-managed enterprise features like <a href="http://www.phoromatic.com/">Phoromatic</a> and <a href="http://openbenchmarking.org/">OpenBenchmarking.org</a>. <a href="/early">Read more details on the GUI</a>.</div>';
        echo '<h1>' . pts_core::program_title(false) . '</h1>';
        echo '<div id="pts_side_pane">';
        $hw_component_modal = array('CPU' => phodevi::read_property('cpu', 'model'), 'Motherboard' => phodevi::read_property('motherboard', 'identifier'), 'Memory' => phodevi::read_property('memory', 'identifier'), 'Disk' => phodevi::read_property('disk', 'identifier'), 'GPU' => phodevi::read_property('gpu', 'model'));
        echo '<ul>';
        foreach ($hw_component_modal as $type => $component) {
            echo '<a href="/?component/' . $type . '"><li>' . $component . '</li></a>';
        }
        echo '</ul>';
        echo '<hr />';
        $sw_component_modal = array(1 => phodevi::read_property('system', 'operating-system'), 2 => phodevi::read_property('system', 'kernel-string'), 3 => phodevi::read_property('system', 'display-driver-string'), 4 => phodevi::read_property('system', 'opengl-driver'), 5 => phodevi::read_property('system', 'compiler'));
        echo '<ul>';
        foreach ($sw_component_modal as $type => $component) {
            echo '<a href="/?component/Software"><li>' . $component . '</li></a>';
        }
        echo '</ul>';
        echo '<div class="pts_pane_window"><strong>OpenBenchmarking.org</strong><br />Log-in to gain access to additional features.</div>';
        echo '<ul>';
        echo '<a href="/?settings"><li>Software Settings</li></a>';
        echo '<a href="/?about"><li>About The Phoronix Test Suite</li></a>';
        echo '</ul>';
        echo '</div>';
        echo '<div id="pts_search_bar">';
        echo 'SEARCH: <input type="text" size="30" id="pts_search" name="search" onkeydown="if(event.keyCode == 13) { if(document.getElementById(\'pts_search\').value.length < 3) { alert(\'Please enter a longer search query.\'); return false; } else { window.location.href = \'/?search/\' + document.getElementById(\'pts_search\').value; } return false; }" />';
        echo '</div>';
        // Graphs
        echo '<div id="svg_graphs" style="margin: 10px 0; text-align: right;"></div>';
        echo '<div style="overflow: hidden;">';
        echo '<div class="pts_list_box">';
        $results = pts_tests::test_results_by_date();
        $result_count = count($results);
        $results = array_slice($results, 0, 10, true);
        echo '<ol>';
        echo '<li><u>Recent Benchmark Results</u></li>';
        foreach ($results as $result) {
            $result_file = new pts_result_file($result);
            echo '<a href="?result/' . $result . '"><li>' . $result_file->get_title() . '</li></a>';
        }
        echo '<a href="?results"><li><strong>' . $result_count . ' Results Saved</strong></li></a>';
        echo '</ol>';
        echo '</div>';
        echo '<div class="pts_list_box">';
        $tests = pts_openbenchmarking_client::recently_updated_tests(10);
        echo '<ol>';
        echo '<li><u>Recently Updated Tests</u></li>';
        foreach ($tests as $test) {
            $test_profile = new pts_test_profile($test);
            echo '<a href="?test/' . $test . '"><li>' . $test_profile->get_title() . '</li></a>';
        }
        echo '<a href="?tests"><li><strong>' . pts_openbenchmarking_client::tests_available() . ' Tests Available</strong></li></a>';
        echo '</ol>';
        echo '</div>';
        echo '<div class="pts_list_box">';
        $tests = pts_openbenchmarking_client::popular_tests(10);
        echo '<ol>';
        echo '<li><u>Most Popular Tests</u></li>';
        foreach ($tests as $test) {
            $test_profile = new pts_test_profile($test);
            echo '<a href="?test/' . $test . '"><li>' . $test_profile->get_title() . '</li></a>';
        }
        echo '<a href="?tests"><li><strong>' . pts_openbenchmarking_client::tests_available() . ' Tests Available</strong></li></a>';
        echo '</ol>';
        echo '</div>';
        echo '</div>';
        echo '<script text="text/javascript">

			pts_web_socket.add_onopen_event("user-svg-system-graphs");
			setInterval(function(){if(pts_web_socket.is_connected()) { pts_web_socket.send("user-svg-system-graphs"); }},1000);
			pts_web_socket.add_onmessage_event("svg_graphs", "update_svg_graph_space");
		</script>';
    }
 public static function run($r)
 {
     pts_client::$display->generic_heading('Random Test Execution');
     $allow_new_tests_to_be_installed = pts_user_io::prompt_bool_input('Allow new tests to be installed', true);
     $allow_new_dependencies_to_be_installed = $allow_new_tests_to_be_installed ? pts_user_io::prompt_bool_input('Allow new test external dependencies to be installed', false) : false;
     $limit_test_subsystem = pts_user_io::prompt_bool_input('Limit tests to a given subsystem', false);
     $limit_test_subsystem = $limit_test_subsystem ? pts_user_io::prompt_text_menu('Select subsystem(s) to test', pts_types::subsystem_targets(), true) : false;
     $upload_to_openbenchmarking = pts_user_io::prompt_bool_input('Auto-upload test results to OpenBenchmarking.org', true);
     while (1) {
         $to_test = array();
         if ($limit_test_subsystem) {
             foreach (explode(',', $limit_test_subsystem) as $test_type) {
                 $tests = pts_openbenchmarking_client::popular_tests(-1, $test_type);
                 $to_test = array_merge($to_test, $tests);
             }
             if (empty($to_test)) {
                 pts_client::$display->generic_sub_heading('No tests could be found to run.');
                 return false;
             }
             shuffle($to_test);
             $to_test = array_slice($to_test, 0, rand(1, 12));
         } else {
             if (rand(1, 6) == 2) {
                 $ob_ids = pts_openbenchmarking_client::popular_openbenchmarking_results();
                 $ob_type = rand(0, 1) == 1 ? 'recent_popular_results' : 'recent_results';
                 if (isset($ob_ids[$ob_type]) && !empty($ob_ids[$ob_type])) {
                     shuffle($ob_ids[$ob_type]);
                     $to_test = array(array_pop($ob_ids[$ob_type]));
                 }
             }
         }
         if (empty($to_test)) {
             // Randomly pick some installed tests
             $installed_tests = pts_tests::installed_tests();
             if ($installed_tests > 3) {
                 shuffle($installed_tests);
                 $to_test = array_slice($installed_tests, 0, rand(1, 8));
             }
             if (!isset($to_test[2]) && $allow_new_tests_to_be_installed) {
                 $available_tests = pts_openbenchmarking::available_tests();
                 shuffle($available_tests);
                 $to_test = array_merge($to_test, array_slice($available_tests, 0, rand(1, 10)));
             }
         }
         if (empty($to_test)) {
             pts_client::$display->generic_sub_heading('No tests could be found to run.');
             return false;
         }
         echo PHP_EOL;
         pts_client::$display->generic_sub_heading('Tests To Run: ' . implode(', ', $to_test));
         // QUERY FROM OB
         $random_titles = array(phodevi::read_property('cpu', 'model') . ' Benchmarks', phodevi::read_property('system', 'operating-system') . ' Benchmarks', phodevi::read_property('system', 'operating-system') . ' Performance', phodevi::read_property('cpu', 'model') . ' Performance', phodevi::read_property('cpu', 'model') . ' + ' . phodevi::read_property('gpu', 'model') . ' + ' . phodevi::read_property('motherboard', 'identifier'), phodevi::read_property('motherboard', 'identifier') . ' On ' . phodevi::read_property('system', 'operating-system'), phodevi::read_property('cpu', 'model') . ' On ' . phodevi::read_property('system', 'operating-system'), phodevi::read_property('system', 'kernel') . ' + ' . phodevi::read_property('system', 'operating-system') . ' Tests');
         shuffle($random_titles);
         $title = array_pop($random_titles);
         if ($limit_test_subsystem) {
             $subsystems_to_test = explode(',', $limit_test_subsystem);
             $subsystems_to_avoid = array_diff(pts_types::subsystem_targets(), $subsystems_to_test);
             pts_client::pts_set_environment_variable('SKIP_TESTING_SUBSYSTEMS', implode(',', $subsystems_to_avoid));
         }
         if ($allow_new_tests_to_be_installed) {
             pts_test_installer::standard_install($to_test, false, true, $allow_new_dependencies_to_be_installed);
         }
         $batch_mode_settings = array('UploadResults' => false, 'SaveResults' => true, 'PromptForTestDescription' => false, 'RunAllTestCombinations' => false, 'PromptSaveName' => false, 'PromptForTestIdentifier' => false, 'OpenBrowser' => false);
         if ($upload_to_openbenchmarking) {
             $batch_mode_settings['UploadResults'] = true;
             pts_openbenchmarking_client::override_client_setting('UploadSystemLogsByDefault', true);
         }
         pts_test_run_manager::set_batch_mode($batch_mode_settings);
         $test_run_manager = new pts_test_run_manager($batch_mode_settings, 2);
         if ($test_run_manager->initial_checks($to_test) != false) {
             if ($test_run_manager->load_tests_to_run($to_test)) {
                 // SETUP
                 $test_run_manager->auto_save_results($title, null, 'Various open-source benchmarks by the ' . pts_core::program_title(true) . '.', true);
                 $test_run_manager->auto_generate_results_identifier();
                 echo PHP_EOL;
                 pts_client::$display->generic_sub_heading('Result File: ' . $test_run_manager->get_file_name());
                 pts_client::$display->generic_sub_heading('Result Identifier: ' . $test_run_manager->get_results_identifier());
                 // BENCHMARK
                 $test_run_manager->pre_execution_process();
                 $test_run_manager->call_test_runs();
                 $test_run_manager->post_execution_process();
                 pts_client::remove_saved_result_file($test_run_manager->get_file_name());
             }
         }
         echo PHP_EOL;
         sleep(30);
     }
 }
Ejemplo n.º 14
0
 public static function stream_context_create($parameters = null, $proxy_address = false, $proxy_port = false, $http_timeout = -1)
 {
     if (!is_array($parameters)) {
         $parameters = array();
     }
     if ($proxy_address == false && $proxy_port == false && self::$network_proxy) {
         $proxy_address = self::$network_proxy['address'];
         $proxy_port = self::$network_proxy['port'];
     }
     if ($proxy_address != false && $proxy_port != false && is_numeric($proxy_port)) {
         $parameters['http']['proxy'] = 'tcp://' . $proxy_address . ':' . $proxy_port;
         $parameters['http']['request_fulluri'] = true;
     }
     if (is_numeric($http_timeout) && $http_timeout > 1) {
         $parameters['http']['timeout'] = $http_timeout;
     } else {
         $parameters['http']['timeout'] = self::$network_timeout;
     }
     $parameters['http']['user_agent'] = pts_core::codename(true);
     $parameters['http']['header'] = "Content-Type: application/x-www-form-urlencoded\r\n";
     $stream_context = stream_context_create($parameters);
     return $stream_context;
 }
 public function Footer()
 {
     if ($this->PageNo() == 1) {
         return;
     }
     $this->SetY(-10);
     $this->SetFont('Arial', 'B', 7);
     $this->SetTextColor(0, 0, 0);
     $this->Cell(0, 0, pts_core::program_title(), 0, 0, 'L');
     $this->Cell(0, 0, 'www.phoronix-test-suite.com', 0, 0, 'R', true, 'http://www.phoronix-test-suite.com/');
 }
Ejemplo n.º 16
0
 public static function parse_for_home_directory($path)
 {
     // Find home directory if needed
     if (strpos($path, '~/') !== false) {
         $path = str_replace('~/', pts_core::user_home_directory(), $path);
     }
     return pts_strings::add_trailing_slash($path);
 }
Ejemplo n.º 17
0
 public static function run($r)
 {
     echo PHP_EOL . pts_core::program_title(true) . PHP_EOL;
 }
 protected function process_data(&$user, &$msg)
 {
     $decoded_msg = $this->decode_data($user, $msg);
     //echo 'DECODED MSG: ' . $decoded_msg . PHP_EOL;
     foreach (explode(' ;; ', $decoded_msg) as $single_msg) {
         //echo strstr($single_msg . ' ', ' ', true) . PHP_EOL;
         $args = trim(strstr($single_msg, ' '));
         switch (strstr($single_msg . ' ', ' ', true)) {
             case 'search':
                 $this->search_pts($user, $args);
             case 'result_file':
                 foreach (explode(',', $args) as $result) {
                     if ($result == null) {
                         continue;
                     }
                     $result_file = new pts_result_file($result);
                     $json['pts']['msg']['name'] = 'result_file';
                     $json['pts']['msg']['result'] = $result;
                     $json['pts']['msg']['result_file'] = base64_encode($result_file->to_json());
                     $this->send_json_data($user->socket, $json);
                 }
                 break;
             case 'results_by_date':
                 $results = pts_tests::test_results_by_date();
                 $json['pts']['msg']['name'] = 'results_by_date';
                 $json['pts']['msg']['result_count'] = count($results);
                 $json['pts']['msg']['results'] = base64_encode(json_encode($results));
                 $this->send_json_data($user->socket, $json);
                 break;
             case 'results_grouped_by_date':
                 $results = pts_tests::test_results_by_date();
                 $json['pts']['msg']['name'] = 'results_grouped_by_date';
                 $json['pts']['msg']['result_count'] = count($results);
                 $sections = array(mktime(date('H'), date('i') - 10, 0, date('n'), date('j')) => 'Just Now', mktime(0, 0, 0, date('n'), date('j')) => 'Today', mktime(0, 0, 0, date('n'), date('j') - date('N') + 1) => 'This Week', mktime(0, 0, 0, date('n'), 1) => 'This Month', mktime(0, 0, 0, date('n') - 1, 1) => 'Last Month', mktime(0, 0, 0, 1, 1) => 'This Year', mktime(0, 0, 0, 1, 1, date('Y') - 1) => 'Last Year');
                 $section = current($sections);
                 foreach ($results as $result_time => &$result) {
                     if ($result_time < key($sections)) {
                         while ($result_time < key($sections) && $section !== false) {
                             $section = next($sections);
                         }
                         if ($section === false) {
                             break;
                         }
                     }
                     if (!isset($json['pts']['msg']['results'][current($sections)])) {
                         $json['pts']['msg']['results'][current($sections)] = array();
                     }
                     if ($result != null) {
                         $json['pts']['msg']['results'][current($sections)][] = $result;
                     }
                 }
                 $this->send_json_data($user->socket, $json);
                 break;
             case 'user-svg-system-graphs':
                 //	pts_client::timed_function(array($this, 'generate_system_svg_graphs'), array($user), 1, array($this, 'sensor_logging_continue'), array($user));
                 $this->generate_system_svg_graphs($user, $args);
                 break;
             case 'user-large-svg-system-graphs':
                 //	pts_client::timed_function(array($this, 'generate_system_svg_graphs'), array($user), 1, array($this, 'sensor_logging_continue'), array($user));
                 $this->generate_large_system_svg_graphs($user, $args);
                 break;
             case 'tests-by-popularity':
                 $args = explode(' ', $args);
                 $limit = isset($args[0]) && is_numeric($args[0]) ? $args[0] : 10;
                 $test_type = isset($args[1]) && $args[1] != null ? $args[1] : null;
                 $tests = pts_openbenchmarking_client::popular_tests($limit, $test_type);
                 $json['pts']['msg']['name'] = 'tests_by_popularity';
                 $json['pts']['msg']['test_count'] = count($tests);
                 $json['pts']['msg']['test_type'] = $test_type;
                 $json['pts']['msg']['tests'] = array();
                 $json['pts']['msg']['test_profiles'] = array();
                 foreach ($tests as $test) {
                     $json['pts']['msg']['tests'][] = $test;
                     $tp = new pts_test_profile($test);
                     $json['pts']['msg']['test_profiles'][] = base64_encode($tp->to_json());
                 }
                 $this->send_json_data($user->socket, $json);
                 break;
             case 'available-system-logs':
                 if ($this->phodevi_vfs instanceof phodevi_vfs) {
                     $json['pts']['msg']['name'] = 'available_system_logs';
                     $json['pts']['msg']['logs'] = $this->phodevi_vfs->list_cache_nodes($args);
                     $this->send_json_data($user->socket, $json);
                 }
                 break;
             case 'fetch-system-log':
                 if ($this->phodevi_vfs instanceof phodevi_vfs && $args != null && $this->phodevi_vfs->cache_isset_names($args)) {
                     $json['pts']['msg']['name'] = 'fetch_system_log';
                     $json['pts']['msg']['log_name'] = $args;
                     $json['pts']['msg']['log'] = base64_encode($this->phodevi_vfs->__get($args));
                     $this->send_json_data($user->socket, $json);
                 }
                 break;
             case 'pts-version':
                 $json['pts']['msg']['name'] = 'pts_version';
                 $json['pts']['msg']['version'] = pts_core::program_title(true);
                 $this->send_json_data($user->socket, $json);
                 break;
             case 'core-version':
                 $version = PTS_CORE_VERSION;
                 $this->send_data($user->socket, $version);
                 break;
             case 'run-benchmark-queue':
                 // BENCHMARK
                 //$this->run_benchmark($user, $args);
                 pts_client::fork(array($this, 'run_benchmark'), array($user, $args));
                 break;
         }
     }
 }
 public static function run($r)
 {
     $pdf = new pts_pdf_template(pts_core::program_title(false), 'Test Client Documentation');
     $html_doc = new pts_html_template(pts_core::program_title(false), 'Test Client Documentation');
     $pdf->AddPage();
     $pdf->Image(PTS_CORE_STATIC_PATH . 'images/pts-308x160.png', 69, 85, 73, 38, 'PNG', 'http://www.phoronix-test-suite.com/');
     $pdf->Ln(120);
     $pdf->WriteStatement('www.phoronix-test-suite.com', 'C', 'http://www.phoronix-test-suite.com/');
     $pdf->Ln(15);
     $pdf->WriteBigHeaderCenter(pts_core::program_title(true));
     $pdf->WriteHeaderCenter('User Manual');
     //$pdf->WriteText($result_file->get_description());
     $pts_options = pts_documentation::client_commands_array();
     // Write the test options HTML
     $dom = new DOMDocument();
     $html = $dom->createElement('html');
     $dom->appendChild($html);
     $head = $dom->createElement('head');
     $title = $dom->createElement('title', 'User Options');
     $head->appendChild($title);
     $html->appendChild($head);
     $body = $dom->createElement('body');
     $html->appendChild($body);
     $p = $dom->createElement('p', 'The following options are currently supported by the Phoronix Test Suite client. A list of available options can also be found by running ');
     $em = $dom->createElement('em', 'phoronix-test-suite help.');
     $p->appendChild($em);
     $phr = $dom->createElement('hr');
     $p->appendChild($phr);
     $body->appendChild($p);
     foreach ($pts_options as $section => &$contents) {
         if (empty($contents)) {
             continue;
         }
         $header = $dom->createElement('h1', $section);
         $body->appendChild($header);
         sort($contents);
         foreach ($contents as &$option) {
             $sub_header = $dom->createElement('h3', $option[0]);
             $em = $dom->CreateElement('em', '  ' . implode(' ', $option[1]));
             $sub_header->appendChild($em);
             $body->appendChild($sub_header);
             $p = $dom->createElement('p', $option[2]);
             $body->appendChild($p);
         }
     }
     $dom->saveHTMLFile(PTS_PATH . 'documentation/stubs/00_user_options.html');
     // Write the module options HTML
     $dom = new DOMDocument();
     $html = $dom->createElement('html');
     $dom->appendChild($html);
     $head = $dom->createElement('head');
     $title = $dom->createElement('title', 'Module Options');
     $head->appendChild($title);
     $html->appendChild($head);
     $body = $dom->createElement('body');
     $html->appendChild($body);
     $p = $dom->createElement('p', 'The following list is the modules included with the Phoronix Test Suite that are intended to extend the functionality of pts-core. Some of these options have commands that can be run directly in a similiar manner to the other Phoronix Test Suite user commands. Some modules are just meant to be loaded directly by adding the module name to the LoadModules tag in ~/.phoronix-test-suite/user-config.xml or via the PTS_MODULES environmental variable. A list of available modules is also available by running ');
     $em = $dom->createElement('em', 'phoronix-test-suite list-modules.');
     $p->appendChild($em);
     $phr = $dom->createElement('hr');
     $p->appendChild($phr);
     $body->appendChild($p);
     foreach (pts_module_manager::available_modules(true) as $module) {
         pts_module_manager::load_module($module);
         $header = $dom->createElement('h2', pts_module_manager::module_call($module, 'module_name'));
         $body->appendChild($header);
         $desc = $dom->createElement('p', pts_module_manager::module_call($module, 'module_description'));
         $body->appendChild($desc);
         $all_options = pts_module_manager::module_call($module, 'user_commands');
         if (count($all_options) > 0) {
             //	$sub_header = $dom->createElement('h3', 'Module Commands');
             //	$body->appendChild($sub_header);
             foreach ($all_options as $key => $option) {
                 $p = $dom->createElement('p', 'phoronix-test-suite ' . $module . '.' . str_replace('_', '-', $key));
                 $body->appendChild($p);
             }
         }
         $vars = pts_module_manager::module_call($module, 'module_environmental_variables');
         if (is_array($vars) && count($vars) > 0) {
             $p = $dom->createElement('p', 'This module utilizes the following environmental variables: ' . implode(', ', $vars) . '.');
             $body->appendChild($p);
         }
     }
     $dom->saveHTMLFile(PTS_PATH . 'documentation/stubs/00_zmodule_options.html');
     // Write the external dependencies HTML
     $dom = new DOMDocument();
     $html = $dom->createElement('html');
     $dom->appendChild($html);
     $head = $dom->createElement('head');
     $title = $dom->createElement('title', 'External Dependencies');
     $head->appendChild($title);
     $html->appendChild($head);
     $body = $dom->createElement('body');
     $html->appendChild($body);
     $p = $dom->createElement('p', 'The Phoronix Test Suite has a feature known as &quot;External Dependencies&quot; where the Phoronix Test Suite can attempt to automatically install some of the test-specific dependencies on supported distributions. If running on a distribution where there is currently no External Dependencies profile, the needed package name(s) are listed for manual installation.');
     $body->appendChild($p);
     $p = $dom->createElement('p', 'Below are a list of the operating systems that currently have external dependencies support within the Phoronix Test Suite for the automatic installation of needed test files.');
     $body->appendChild($p);
     $phr = $dom->createElement('hr');
     $p->appendChild($phr);
     $exdep_generic_parser = new pts_exdep_generic_parser();
     $vendors = array_merge($exdep_generic_parser->get_vendor_aliases_formatted(), $exdep_generic_parser->get_vendors_list_formatted());
     sort($vendors);
     $ul = $dom->createElement('ul');
     $p->appendChild($ul);
     foreach ($vendors as $vendor) {
         $li = $dom->createElement('li', $vendor);
         $p->appendChild($li);
     }
     $dom->saveHTMLFile(PTS_PATH . 'documentation/stubs/02_external_dependencies.html');
     // Write the virtual suites HTML
     $dom = new DOMDocument();
     $html = $dom->createElement('html');
     $dom->appendChild($html);
     $head = $dom->createElement('head');
     $title = $dom->createElement('title', 'Virtual Test Suites');
     $head->appendChild($title);
     $html->appendChild($head);
     $body = $dom->createElement('body');
     $html->appendChild($body);
     $p = $dom->createElement('p', 'Virtual test suites are not like a traditional test suite defined by the XML suite specification. Virtual test suites are dynamically generated in real-time by the Phoronix Test Suite client based upon the specified test critera. Virtual test suites can automatically consist of all test profiles that are compatible with a particular operating system or test profiles that meet other critera. When running a virtual suite, the OpenBenchmarking.org repository of the test profiles to use for generating the dynamic suite must be prefixed. ');
     $body->appendChild($p);
     $p = $dom->createElement('p', 'Virtual test suites can be installed and run just like a normal XML test suite and shares nearly all of the same capabilities. However, when running a virtual suite, the user will be prompted to input any user-configuration options for needed test profiles just as they would need to do if running the test individually. When running a virtual suite, the user also has the ability to select individual tests within the suite to run or to run all of the contained test profiles. Virtual test suites are also only supported for an OpenBenchmarking.org repository if there is no test profile or test suite of the same name in the repository. Below is a list of common virtual test suites for the main Phoronix Test Suite repository, but the dynamic list of available virtual test suites based upon the enabled repositories is available by running ');
     $em = $dom->createElement('em', 'phoronix-test-suite list-available-virtual-suites.');
     $p->appendChild($em);
     $phr = $dom->createElement('hr');
     $p->appendChild($phr);
     $body->appendChild($p);
     foreach (pts_virtual_test_suite::available_virtual_suites() as $virtual_suite) {
         $sub_header = $dom->createElement('h3', $virtual_suite->get_title());
         $em = $dom->CreateElement('em', '  ' . $virtual_suite->get_identifier());
         $sub_header->appendChild($em);
         $body->appendChild($sub_header);
         $p = $dom->createElement('p', $virtual_suite->get_description());
         $body->appendChild($p);
     }
     $dom->saveHTMLFile(PTS_PATH . 'documentation/stubs/55_virtual_suites.html');
     // Load the HTML documentation
     foreach (pts_file_io::glob(PTS_PATH . 'documentation/stubs/*_*.html') as $html_file) {
         $pdf->html_to_pdf($html_file);
         $html_doc->html_to_html($html_file);
     }
     if (!is_writable(PTS_PATH . 'documentation/')) {
         echo PHP_EOL . 'Not writable: ' . PTS_PATH . 'documentation/';
     } else {
         $pdf_file = PTS_PATH . 'documentation/phoronix-test-suite.pdf';
         $pdf->Output($pdf_file);
         $html_doc->Output(PTS_PATH . 'documentation/phoronix-test-suite.html');
         echo PHP_EOL . 'Saved To: ' . $pdf_file . PHP_EOL . PHP_EOL;
         // Also re-generate the man page
         $man_page = '.TH phoronix-test-suite 1  "www.phoronix-test-suite.com" "' . PTS_VERSION . '"' . PHP_EOL . '.SH NAME' . PHP_EOL;
         $man_page .= 'phoronix-test-suite \\- The Phoronix Test Suite is an extensible open-source platform for performing testing and performance evaluation.' . PHP_EOL;
         $man_page .= '.SH SYNOPSIS' . PHP_EOL . '.B phoronix-test-suite [options]' . PHP_EOL . '.br' . PHP_EOL . '.B phoronix-test-suite benchmark [test | suite]' . PHP_EOL;
         $man_page .= '.SH DESCRIPTION' . PHP_EOL . pts_documentation::basic_description() . PHP_EOL;
         $man_page .= '.SH OPTIONS' . PHP_EOL . '.TP' . PHP_EOL;
         foreach ($pts_options as $section => &$contents) {
             if (empty($contents)) {
                 continue;
             }
             $man_page .= '.SH ' . strtoupper($section) . PHP_EOL;
             sort($contents);
             foreach ($contents as &$option) {
                 $man_page .= '.B ' . trim($option[0] . ' ' . (!empty($option[1]) && is_array($option[1]) ? implode(' ', $option[1]) : null)) . PHP_EOL . $option[2] . PHP_EOL . '.TP' . PHP_EOL;
             }
         }
         $man_page .= '.SH SEE ALSO' . PHP_EOL . '.B Websites:' . PHP_EOL . '.br' . PHP_EOL . 'http://www.phoronix-test-suite.com/' . PHP_EOL . '.br' . PHP_EOL . 'http://commercial.phoronix-test-suite.com/' . PHP_EOL . '.br' . PHP_EOL . 'http://www.openbenchmarking.org/' . PHP_EOL . '.br' . PHP_EOL . 'http://www.phoronix.com/' . PHP_EOL . '.br' . PHP_EOL . 'http://www.phoronix.com/forums/' . PHP_EOL;
         $man_page .= '.SH AUTHORS' . PHP_EOL . 'Copyright 2008 - ' . date('Y') . ' by Phoronix Media, Michael Larabel.' . PHP_EOL . '.TP' . PHP_EOL;
         file_put_contents(PTS_PATH . 'documentation/man-pages/phoronix-test-suite.1', $man_page);
     }
     // simple README
     $readme = '# Phoronix Test Suite ' . PTS_VERSION . PHP_EOL . 'http://www.phoronix-test-suite.com/' . PHP_EOL . PHP_EOL;
     $readme .= pts_documentation::basic_description() . PHP_EOL . PHP_EOL;
     $readme .= pts_file_io::file_get_contents(PTS_PATH . 'documentation/stubs/readme-basics.txt') . PHP_EOL . PHP_EOL;
     $readme = wordwrap($readme, 80, PHP_EOL);
     file_put_contents(PTS_PATH . 'README.md', $readme);
     // Phoromatic Documentation
     $pdf = new pts_pdf_template(pts_core::program_title(false), 'Phoromatic Documentation');
     $html_doc = new pts_html_template(pts_core::program_title(false), 'Phoromatic Documentation');
     $pdf->AddPage();
     $pdf->Image(PTS_CORE_STATIC_PATH . 'images/pts-308x160.png', 69, 85, 73, 38, 'PNG', 'http://www.phoronix-test-suite.com/');
     $pdf->Ln(120);
     $pdf->WriteStatement('www.phoronix-test-suite.com', 'C', 'http://www.phoronix-test-suite.com/');
     $pdf->Ln(15);
     $pdf->Image(PTS_CORE_STATIC_PATH . 'images/phoromatic-390x56.png', 55, 250, 0, 0, 'PNG', 'http://www.phoronix-test-suite.com/');
     //$pdf->Image(PTS_CORE_STATIC_PATH . 'images/phoromatic-390x56.png', 69, 85, 73, 38, 'PNG', 'http://www.phoromatic.com/');
     $pdf->WriteBigHeaderCenter(pts_core::program_title(true));
     $pdf->WriteHeaderCenter('Phoromatic User Manual');
     $pdf->html_to_pdf(PTS_PATH . 'documentation/phoromatic.html');
     $pdf_file = PTS_PATH . 'documentation/phoromatic.pdf';
     $pdf->Output($pdf_file);
     echo PHP_EOL . 'Saved To: ' . $pdf_file . PHP_EOL . PHP_EOL;
 }
Ejemplo n.º 20
0
 public static function program_title($show_codename = false)
 {
     return 'Phoronix Test Suite v' . PTS_VERSION . ($show_codename ? ' (' . pts_core::codename() . ')' : null);
 }
 protected static function setup_test_install_directory(&$test_install_request, $remove_old_files = false)
 {
     $identifier = $test_install_request->test_profile->get_identifier();
     pts_file_io::mkdir($test_install_request->test_profile->get_install_dir());
     if ($remove_old_files) {
         // Remove any (old) files that were installed
         $ignore_files = array('pts-install.xml', 'install-failed.log');
         foreach ($test_install_request->get_download_objects() as $download_object) {
             $ignore_files[] = $download_object->get_filename();
         }
         pts_file_io::delete($test_install_request->test_profile->get_install_dir(), $ignore_files);
     }
     pts_file_io::symlink(pts_core::user_home_directory() . '.Xauthority', $test_install_request->test_profile->get_install_dir() . '.Xauthority');
     pts_file_io::symlink(pts_core::user_home_directory() . '.drirc', $test_install_request->test_profile->get_install_dir() . '.drirc');
 }
 public function get_xml($to = null)
 {
     $xml_writer = new nye_XmlWriter();
     $xml_writer->addXmlNode('PhoronixTestSuite/Generated/Title', $this->get_title());
     $xml_writer->addXmlNode('PhoronixTestSuite/Generated/LastModified', date('Y-m-d H:i:s'));
     $xml_writer->addXmlNode('PhoronixTestSuite/Generated/TestClient', pts_core::program_title(true));
     $xml_writer->addXmlNode('PhoronixTestSuite/Generated/Description', $this->get_description());
     $xml_writer->addXmlNodeWNE('PhoronixTestSuite/Generated/Notes', $this->get_notes());
     $xml_writer->addXmlNodeWNE('PhoronixTestSuite/Generated/InternalTags', $this->get_internal_tags());
     $xml_writer->addXmlNodeWNE('PhoronixTestSuite/Generated/ReferenceID', $this->get_reference_id());
     $xml_writer->addXmlNodeWNE('PhoronixTestSuite/Generated/PreSetEnvironmentVariables', $this->get_preset_environment_variables());
     // Write the system hardware/software information
     foreach ($this->get_systems() as $s) {
         $xml_writer->addXmlNode('PhoronixTestSuite/System/Identifier', $s->get_identifier());
         $xml_writer->addXmlNode('PhoronixTestSuite/System/Hardware', $s->get_hardware());
         $xml_writer->addXmlNode('PhoronixTestSuite/System/Software', $s->get_software());
         $xml_writer->addXmlNode('PhoronixTestSuite/System/User', $s->get_username());
         $xml_writer->addXmlNode('PhoronixTestSuite/System/TimeStamp', $s->get_timestamp());
         $xml_writer->addXmlNode('PhoronixTestSuite/System/TestClientVersion', $s->get_client_version());
         $xml_writer->addXmlNode('PhoronixTestSuite/System/Notes', $s->get_notes());
         if (!defined('USER_PTS_CORE_VERSION') || USER_PTS_CORE_VERSION > 3722) {
             // Ensure that a supported result file schema is being written...
             // USER_PTS_CORE_VERSION is set by OpenBenchmarking.org so if the requested client is old, don't write this data to send back to their version
             $xml_writer->addXmlNodeWNE('PhoronixTestSuite/System/JSON', $s->get_json() ? json_encode($s->get_json()) : null);
         }
     }
     // Write the results
     foreach ($this->get_result_objects() as $result_object) {
         $buffer_items = $result_object->test_result_buffer->get_buffer_items();
         if (count($buffer_items) == 0) {
             continue;
         }
         $xml_writer->addXmlNode('PhoronixTestSuite/Result/Identifier', $result_object->test_profile->get_identifier());
         $xml_writer->addXmlNode('PhoronixTestSuite/Result/Title', $result_object->test_profile->get_title());
         $xml_writer->addXmlNode('PhoronixTestSuite/Result/AppVersion', $result_object->test_profile->get_app_version());
         $xml_writer->addXmlNode('PhoronixTestSuite/Result/Arguments', $result_object->get_arguments());
         $xml_writer->addXmlNode('PhoronixTestSuite/Result/Description', $result_object->get_arguments_description());
         $xml_writer->addXmlNode('PhoronixTestSuite/Result/Scale', $result_object->test_profile->get_result_scale());
         $xml_writer->addXmlNode('PhoronixTestSuite/Result/Proportion', $result_object->test_profile->get_result_proportion());
         $xml_writer->addXmlNode('PhoronixTestSuite/Result/DisplayFormat', $result_object->test_profile->get_display_format());
         foreach ($buffer_items as $i => &$buffer_item) {
             $xml_writer->addXmlNode('PhoronixTestSuite/Result/Data/Entry/Identifier', $buffer_item->get_result_identifier());
             $xml_writer->addXmlNode('PhoronixTestSuite/Result/Data/Entry/Value', $buffer_item->get_result_value());
             $xml_writer->addXmlNode('PhoronixTestSuite/Result/Data/Entry/RawString', $buffer_item->get_result_raw());
             if (!defined('USER_PTS_CORE_VERSION') || USER_PTS_CORE_VERSION > 3722) {
                 // Ensure that a supported result file schema is being written...
                 // USER_PTS_CORE_VERSION is set by OpenBenchmarking.org so if the requested client is old, don't write this data to send back to their version
                 $xml_writer->addXmlNodeWNE('PhoronixTestSuite/Result/Data/Entry/JSON', $buffer_item->get_result_json() ? json_encode($buffer_item->get_result_json()) : null);
             }
         }
     }
     return $to == null ? $xml_writer->getXML() : $xml_writer->saveXMLFile($to);
 }
function phoromatic_webui_footer()
{
    return '<div id="pts_phoromatic_bottom_footer">
<div style="float: right; padding: 2px 10px; overflow: hidden;"><a href="http://openbenchmarking.org/" style="margin-right: 20px;"><img src="data:image/png;base64,' . base64_encode(file_get_contents('images/ob-white-logo.png')) . '" /></a> <a href="http://www.phoronix-test-suite.com/"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" viewbox="0 0 76 41" width="76" height="41" preserveAspectRatio="xMinYMin meet">
  <path d="m74 22v9m-5-16v16m-5-28v28m-23-2h12.5c2.485281 0 4.5-2.014719 4.5-4.5s-2.014719-4.5-4.5-4.5h-8c-2.485281 0-4.5-2.014719-4.5-4.5s2.014719-4.5 4.5-4.5h12.5m-21 5h-11m11 13h-2c-4.970563 0-9-4.029437-9-9v-20m-24 40v-20c0-4.970563 4.0294373-9 9-9 4.970563 0 9 4.029437 9 9s-4.029437 9-9 9h-9" stroke="#c8d905" stroke-width="4" fill="none" />
</svg></a></div>
<p style="margin: 6px 15px;"><strong>' . date('H:i T - j F Y') . '</strong>' . (PTS_IS_DEV_BUILD ? ' &nbsp; [' . round(microtime(true) - PAGE_LOAD_START_TIME, 2) . 's Page Load Time]' : null) . '<br />Copyright &copy; 2008 - ' . date('Y') . ' by <a href="http://www.phoronix-media.com/">Phoronix Media</a>. All rights reserved.<br />
All trademarks used are properties of their respective owners.<br />' . pts_core::program_title(true) . ' - Core Version ' . PTS_CORE_VERSION . ' - PHP ' . PHP_VERSION . '</p></div> <script type="text/javascript"> phoromatic_checkbox_toggle_result_comparison(\'\'); </script>';
}
Ejemplo n.º 24
0
}
$intent = null;
//$table = new pts_ResultFileTable($result_file, $intent);
//echo '<p style="text-align: center; overflow: auto;" class="result_object">' . pts_render::render_graph_inline_embed($table, $result_file, $extra_attributes) . '</p>';
echo '<div id="pts_results_area">';
foreach ($result_file->get_result_objects(isset($_REQUEST['show_only_changed_results']) ? 'ONLY_CHANGED_RESULTS' : -1, true) as $i => $result_object) {
    if (stripos($result_object->get_arguments_description(), 'frame time') !== false) {
        continue;
    }
    echo '<h2><a name="r-' . $i . '"></a>' . $result_object->test_profile->get_title() . '</h2>';
    //echo '<h3>' . $result_object->get_arguments_description() . '</h3>';
    echo '<p class="result_object">';
    echo pts_render::render_graph_inline_embed($result_object, $result_file, $extra_attributes);
    echo '</p>';
    unset($result_object);
    flush();
}
echo '</div>';
if (isset($_REQUEST['system_table']) && $_REQUEST['system_table']) {
    $table = new pts_ResultFileSystemsTable($result_file);
    echo '<p style="text-align: center; overflow: auto;" class="result_object">' . pts_render::render_graph_inline_embed($table, $result_file, $extra_attributes) . '</p>';
}
?>

<p id="footer"><em><?php 
echo pts_core::program_title(true);
?>
</em><br />Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org are copyright &copy; 2004 - 2015 by Phoronix Media.<br />The Phoronix Test Suite / Phoromatic is open-source under the GNU GPL.<br />For more information, visit <a href="http://www.phoronix-test-suite.com/">Phoronix-Test-Suite.com</a> or contact <a href="http://www.phoronix-media.com/">Phoronix Media</a>.</p>
</body>
</html>
function phoromatic_webui_footer()
{
    return '<div id="pts_phoromatic_bottom_footer">
<div style="float: right; padding: 2px 10px; overflow: hidden;"><a href="http://openbenchmarking.org/" style="margin-right: 20px;"><img src="data:image/png;base64,' . base64_encode(file_get_contents('images/ob-white-logo.png')) . '" /></a> <a href="http://www.phoronix-test-suite.com/"><img src="data:image/png;base64,' . base64_encode(file_get_contents('images/pts-white-logo.png')) . '" /></a></div>
<p style="margin: 6px 15px;"><strong>' . date('H:i T - j F Y') . '</strong>' . (PTS_IS_DEV_BUILD ? ' &nbsp; [' . round(microtime(true) - PAGE_LOAD_START_TIME, 2) . 's Page Load Time]' : null) . '<br />Copyright &copy; 2008 - ' . date('Y') . ' by <a href="http://www.phoronix-media.com/">Phoronix Media</a>. All rights reserved.<br />
All trademarks used are properties of their respective owners.<br />' . pts_core::program_title(true) . ' - Core Version ' . PTS_CORE_VERSION . ' - PHP ' . PHP_VERSION . '</p></div> <script type="text/javascript"> phoromatic_checkbox_toggle_result_comparison(\'\'); </script>';
}
	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// INIT
define('PHOROMATIC_SERVER', true);
//ini_set('memory_limit', '64M');
define('PTS_MODE', 'WEB_CLIENT');
define('PTS_AUTO_LOAD_OBJECTS', true);
//error_reporting(E_ALL);
include '../../pts-core.php';
pts_core::init();
if (isset($_GET['index'])) {
    $requested_repo = str_replace(array('..', '/'), null, $_GET['repo']);
    $repo_index = pts_openbenchmarking::read_repository_index($requested_repo, false);
    echo $repo_index;
    pts_logger::add_to_log($_SERVER['REMOTE_ADDR'] . ' downloaded a copy of the ' . $requested_repo . ' OpenBenchmarking.org repository index');
} else {
    if (isset($_GET['repos'])) {
        $index_files = pts_file_io::glob(PTS_OPENBENCHMARKING_SCRATCH_PATH . '*.index');
        $json_repos = array();
        foreach ($index_files as $index_file) {
            $index_data = json_decode(file_get_contents($index_file), true);
            $json_repos['repos'][basename($index_file, '.index')] = array('title' => basename($index_file, '.index'), 'generated' => $index_data['main']['generated']);
        }
        echo json_encode($json_repos);
    } else {
Ejemplo n.º 27
0
 public static function run_connection($args)
 {
     if (pts_client::create_lock(PTS_USER_PATH . 'phoromatic_lock') == false) {
         trigger_error('Phoromatic is already running.', E_USER_ERROR);
         return false;
     }
     define('PHOROMATIC_PROCESS', true);
     if (pts_client::$pts_logger == false) {
         pts_client::$pts_logger = new pts_logger();
     }
     pts_client::$pts_logger->log(pts_core::program_title(true) . ' [' . PTS_CORE_VERSION . '] starting Phoromatic client');
     if (phodevi::system_uptime() < 60) {
         echo 'PHOROMATIC: Sleeping for 60 seconds as system freshly started.' . PHP_EOL;
         pts_client::$pts_logger->log('Sleeping for 60 seconds as system freshly started');
         sleep(60);
     }
     $server_setup = self::setup_server_addressing($args);
     //$http_comm = new phoromatic_client_comm_http();
     if (!$server_setup) {
         if (PTS_IS_DAEMONIZED_SERVER_PROCESS) {
             if (pts_client::executable_in_path('reboot')) {
                 shell_exec('reboot');
                 sleep(5);
             }
         }
         return false;
     }
     $times_failed = 0;
     $has_success = false;
     $do_exit = false;
     $just_started = true;
     self::setup_system_environment();
     pts_client::$pts_logger->log('SYSTEM HARDWARE: ' . phodevi::system_hardware(true));
     pts_client::$pts_logger->log('SYSTEM SOFTWARE: ' . phodevi::system_software(true));
     while ($do_exit == false) {
         $server_response = phoromatic::upload_to_remote_server(array('r' => 'start'));
         if ($server_response == false) {
             $times_failed++;
             pts_client::$pts_logger->log('Server response failed');
             if ($times_failed >= 2) {
                 trigger_error('Communication with server failed.', E_USER_ERROR);
                 if (PTS_IS_DAEMONIZED_SERVER_PROCESS == false && $times_failed > 5) {
                     return false;
                 } else {
                     if (PTS_IS_DAEMONIZED_SERVER_PROCESS && $times_failed > 10) {
                         if (pts_client::executable_in_path('reboot')) {
                             shell_exec('reboot');
                             sleep(5);
                         }
                     }
                 }
             }
         } else {
             if (substr($server_response, 0, 1) == '[') {
                 // Likely a notice/warning from server
                 echo PHP_EOL . substr($server_response, 0, strpos($server_response, PHP_EOL)) . PHP_EOL;
             } else {
                 if (substr($server_response, 0, 1) == '{') {
                     $times_failed = 0;
                     $json = json_decode($server_response, true);
                     if ($has_success == false) {
                         $has_success = true;
                         pts_module::save_file('last-phoromatic-server', self::$server_address . ':' . self::$server_http_port . '/' . self::$account_id);
                     }
                     if ($json != null) {
                         if (isset($json['phoromatic']['error']) && !empty($json['phoromatic']['error'])) {
                             trigger_error($json['phoromatic']['error'], E_USER_ERROR);
                         }
                         if (isset($json['phoromatic']['response']) && !empty($json['phoromatic']['response'])) {
                             echo PHP_EOL . $json['phoromatic']['response'] . PHP_EOL;
                         }
                     }
                     self::$limit_network_communication = isset($json['phoromatic']['settings']['LimitNetworkCommunication']) && pts_strings::string_bool($json['phoromatic']['settings']['LimitNetworkCommunication']);
                     if (self::$limit_network_communication) {
                         // Sleep to ensure network communication is somewhat random in case all systems started at same time
                         sleep(0, 20);
                     }
                     if ($just_started) {
                         if (PTS_IS_DAEMONIZED_SERVER_PROCESS && !self::$limit_network_communication) {
                             $pid = pcntl_fork();
                             if ($pid == 0) {
                                 // Start the tick thread
                                 self::tick_thread();
                             }
                         }
                         $just_started = false;
                     }
                     if (isset($json['phoromatic']['pre_set_sys_env_vars']) && !empty($json['phoromatic']['pre_set_sys_env_vars'])) {
                         // pre_set_sys_env_vars was added during PTS 5.8 development
                         // Sets environment variables on client as specified via the Phoromatic Server's systems page
                         foreach (explode(';', $json['phoromatic']['pre_set_sys_env_vars']) as $i => $v_string) {
                             $var = explode('=', $v_string);
                             if (count($var) == 2) {
                                 putenv($var[0] . '=' . $var[1]);
                             }
                         }
                     }
                     switch (isset($json['phoromatic']['task']) ? $json['phoromatic']['task'] : null) {
                         case 'install':
                             phoromatic::update_system_status('Installing Tests');
                             pts_suite_nye_XmlReader::set_temporary_suite('pre-seed', $json['phoromatic']['test_suite']);
                             pts_test_installer::standard_install('pre-seed', false, true);
                             break;
                         case 'benchmark':
                             // Make sure all latest tests are available
                             pts_openbenchmarking::refresh_repository_lists(null, true);
                             $benchmark_timer = time();
                             self::$is_running_as_phoromatic_node = true;
                             $suite_identifier = sha1(time() . rand(2, 1000));
                             pts_suite_nye_XmlReader::set_temporary_suite($suite_identifier, $json['phoromatic']['test_suite']);
                             self::$p_save_identifier = $json['phoromatic']['trigger_id'];
                             $phoromatic_results_identifier = self::$p_save_identifier;
                             $phoromatic_save_identifier = $json['phoromatic']['save_identifier'];
                             self::$p_schedule_id = isset($json['phoromatic']['schedule_id']) ? $json['phoromatic']['schedule_id'] : false;
                             self::$p_trigger_id = self::$p_save_identifier;
                             $benchmark_ticket_id = isset($json['phoromatic']['benchmark_ticket_id']) ? $json['phoromatic']['benchmark_ticket_id'] : null;
                             phoromatic::update_system_status('Running Benchmarks For: ' . $phoromatic_save_identifier);
                             if (pts_strings::string_bool($json['phoromatic']['settings']['RunInstallCommand'])) {
                                 if (isset($json['phoromatic']['pre_install_set_context'])) {
                                     phoromatic::set_user_context($json['phoromatic']['pre_install_set_context'], self::$p_trigger_id, self::$p_schedule_id, 'PRE_INSTALL');
                                 }
                                 pts_test_installer::standard_install($suite_identifier, pts_strings::string_bool($json['phoromatic']['settings']['ForceInstallTests']), true);
                                 if (isset($json['phoromatic']['post_install_set_context'])) {
                                     phoromatic::set_user_context($json['phoromatic']['post_install_set_context'], self::$p_trigger_id, self::$p_schedule_id, 'POST_INSTALL');
                                 }
                             }
                             $env_vars = isset($json['phoromatic']['environment_variables']) ? pts_strings::parse_value_string_vars($json['phoromatic']['environment_variables']) : array();
                             // Do the actual running
                             phodevi::clear_cache();
                             self::$test_run_manager = new pts_test_run_manager(array('UploadResults' => isset($json['phoromatic']['settings']['UploadResultsToOpenBenchmarking']) && pts_strings::string_bool($json['phoromatic']['settings']['UploadResultsToOpenBenchmarking']), 'SaveResults' => true, 'RunAllTestCombinations' => false, 'OpenBrowser' => false), true);
                             if (self::$test_run_manager->initial_checks($suite_identifier, 'SHORT')) {
                                 // Load the tests to run
                                 if (self::$test_run_manager->load_tests_to_run($suite_identifier)) {
                                     phoromatic::update_system_status('Tests In Run Queue: ' . implode(', ', self::$test_run_manager->get_tests_to_run_identifiers()));
                                     if (isset($json['phoromatic']['pre_run_set_context'])) {
                                         phoromatic::set_user_context($json['phoromatic']['pre_run_set_context'], self::$p_trigger_id, self::$p_schedule_id, 'PRE_RUN');
                                     }
                                     if (isset($json['phoromatic']['settings']['UploadResultsToOpenBenchmarking']) && pts_strings::string_bool($json['phoromatic']['settings']['UploadResultsToOpenBenchmarking'])) {
                                         self::$test_run_manager->auto_upload_to_openbenchmarking();
                                         pts_openbenchmarking_client::override_client_setting('UploadSystemLogsByDefault', pts_strings::string_bool($json['phoromatic']['settings']['UploadSystemLogs']));
                                     }
                                     // Save results?
                                     // Run the actual tests
                                     if (isset($env_vars['PTS_CONCURRENT_TEST_RUNS']) && $env_vars['PTS_CONCURRENT_TEST_RUNS'] > 1) {
                                         $total_loop_time = isset($env_vars['TOTAL_LOOP_TIME']) ? $env_vars['TOTAL_LOOP_TIME'] : false;
                                         pts_client::$pts_logger->log('STRESS / MULTI-TEST EXECUTION STARTED @ ' . date('Y-m-d H:i:s'));
                                         pts_client::$pts_logger->log('CONCURRENT RUNS = ' . $env_vars['PTS_CONCURRENT_TEST_RUNS'] . ' TOTAL LOOP TIME = ' . $total_loop_time);
                                         $r = self::$test_run_manager->multi_test_stress_run_execute($env_vars['PTS_CONCURRENT_TEST_RUNS'], $total_loop_time);
                                         if ($r == false) {
                                             return;
                                         }
                                         pts_client::$pts_logger->log('STRESS / MULTI-TEST EXECUTION ENDED @ ' . date('Y-m-d H:i:s'));
                                     } else {
                                         self::$test_run_manager->auto_save_results($phoromatic_save_identifier, $phoromatic_results_identifier, isset($json['phoromatic']['test_description']) ? $json['phoromatic']['test_description'] : 'A Phoromatic run.');
                                         self::$test_run_manager->pre_execution_process();
                                         self::$test_run_manager->call_test_runs();
                                     }
                                     phoromatic::update_system_status('Benchmarks Completed For: ' . $phoromatic_save_identifier);
                                     self::$test_run_manager->post_execution_process();
                                     $elapsed_benchmark_time = time() - $benchmark_timer;
                                     // Handle uploading data to server
                                     $result_file = new pts_result_file(self::$test_run_manager->get_file_name());
                                     $upload_system_logs = pts_strings::string_bool($json['phoromatic']['settings']['UploadSystemLogs']);
                                     $server_response = self::upload_test_result($result_file, $upload_system_logs, isset($json['phoromatic']['schedule_id']) ? $json['phoromatic']['schedule_id'] : null, $phoromatic_save_identifier, $json['phoromatic']['trigger_id'], $elapsed_benchmark_time, $benchmark_ticket_id);
                                     //pts_client::$pts_logger->log('DEBUG RESPONSE MESSAGE: ' . $server_response);
                                     if (!pts_strings::string_bool($json['phoromatic']['settings']['ArchiveResultsLocally'])) {
                                         pts_client::remove_saved_result_file(self::$test_run_manager->get_file_name());
                                     }
                                 }
                                 if (isset($json['phoromatic']['post_install_set_context'])) {
                                     phoromatic::set_user_context($json['phoromatic']['post_install_set_context'], self::$p_trigger_id, self::$p_schedule_id, 'POST_RUN');
                                 }
                             }
                             self::$p_schedule_id = null;
                             self::$is_running_as_phoromatic_node = false;
                             break;
                         case 'reboot':
                             echo PHP_EOL . 'Phoromatic received a remote command to reboot.' . PHP_EOL;
                             phoromatic::update_system_status('Attempting System Reboot');
                             if (pts_client::executable_in_path('reboot')) {
                                 shell_exec('reboot');
                                 sleep(5);
                             }
                             break;
                         case 'shutdown-if-supports-wake':
                             $supports_wol = false;
                             foreach (pts_network::get_network_wol() as $net_device) {
                                 if (strpos($net_device, 'g') !== false) {
                                     $supports_wol = true;
                                     break;
                                 }
                             }
                             if (!$supports_wol) {
                                 break;
                             }
                         case 'shutdown':
                             if (isset($json['phoromatic']['client_update_script']) && !empty($json['phoromatic']['client_update_script'])) {
                                 self::run_client_update_script($json['phoromatic']['client_update_script']);
                                 sleep(10);
                             }
                             echo PHP_EOL . 'Phoromatic received a remote command to shutdown.' . PHP_EOL;
                             phoromatic::update_system_status('Attempting System Shutdown');
                             if (pts_client::executable_in_path('poweroff')) {
                                 shell_exec('poweroff');
                                 sleep(5);
                             }
                             break;
                         case 'maintenance':
                             echo PHP_EOL . 'Idling, system maintenance mode set by Phoromatic Server.' . PHP_EOL;
                             phoromatic::update_system_status('Maintenance Mode');
                             sleep(60);
                             break;
                         case 'idle':
                             if (isset($json['phoromatic']['client_update_script']) && !empty($json['phoromatic']['client_update_script'])) {
                                 self::run_client_update_script($json['phoromatic']['client_update_script']);
                             }
                             //echo PHP_EOL . 'Idling, waiting for task.' . PHP_EOL;
                             phoromatic::update_system_status('Idling, Waiting For Task');
                             break;
                         case 'exit':
                             echo PHP_EOL . 'Phoromatic received a remote command to exit.' . PHP_EOL;
                             phoromatic::update_system_status('Exiting Phoromatic');
                             $do_exit = true;
                             break;
                     }
                 }
             }
         }
         if (!$do_exit) {
             if ($server_response == false) {
                 sleep(rand(10, 30));
             } else {
                 if (self::$limit_network_communication) {
                     sleep(60, 240);
                 } else {
                     sleep(60);
                 }
             }
         }
     }
     pts_client::release_lock(PTS_USER_PATH . 'phoromatic_lock');
 }
Ejemplo n.º 28
0
 public function __get($name)
 {
     // This assumes that isset() has been called on $name prior to actually trying to get it...
     if (isset($this->cache[$name])) {
         return PHP_EOL . $this->cache[$name] . PHP_EOL;
     } else {
         if (PTS_IS_CLIENT && isset($this->options[$name])) {
             if (isset($this->options[$name]['type'])) {
                 $tries = array($this->options[$name]);
             } else {
                 $tries = $this->options[$name];
             }
             $contents = null;
             foreach ($tries as &$try) {
                 if ($try['type'] == 'F' && isset($try['F'][4]) && substr($try['F'], 0, 2) == '~/') {
                     // Set the home directory
                     $try['F'] = str_replace('~/', pts_core::user_home_directory(), $try['F']);
                 }
                 if ($try['type'] == 'F' && is_file($try['F'])) {
                     $contents = file_get_contents($try['F']);
                 } else {
                     if ($try['type'] == 'C') {
                         $command = pts_client::executable_in_path(pts_strings::first_in_string($try['C']));
                         if ($command != null) {
                             $descriptor_spec = array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
                             $proc = proc_open($try['C'], $descriptor_spec, $pipes, null, null);
                             $contents = stream_get_contents($pipes[1]);
                             fclose($pipes[1]);
                             $return_value = proc_close($proc);
                         }
                     }
                 }
                 if (isset($try['remove_timestamps']) && $try['remove_timestamps']) {
                     // remove leading timestamps such as from dmesg and Xorg.0.log
                     $contents = pts_strings::remove_line_timestamps($contents);
                 }
                 if ($contents != null) {
                     if ($try['cacheable']) {
                         $this->cache[$name] = $contents;
                     }
                     return PHP_EOL . $contents . PHP_EOL;
                 }
             }
         }
     }
     return false;
 }
 public static function run($r)
 {
     $_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($r[0], $tdir);
     $result_file = new pts_result_file($r[0]);
     $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->WriteText($notes_r[$i]);
     }
     /*
     if(count($identifiers) > 1 && is_file($tdir . 'result-graphs/overview.jpg'))
     {
     	$pdf->AddPage();
     	$pdf->Ln(100);
     	$pdf->Image($tdir . 'result-graphs/overview.jpg', 15, 40, 180);
     }
     */
     $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++;
     }
     // To save:
     /*
     $pdf_file = 'SAVE_TO';
     
     if(substr($pdf_file, -4) != '.pdf')
     {
     	$pdf_file .= '.pdf';
     }
     */
     $pdf_file = pts_core::user_home_directory() . $r[0] . '.pdf';
     $pdf->Output($pdf_file);
     pts_file_io::delete($tdir, null, true);
     echo PHP_EOL . 'Saved To: ' . $pdf_file . PHP_EOL;
 }