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_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); } }
public static function run($r) { echo PHP_EOL . pts_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; }
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_comment = $this->dom->createComment(pts_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'); $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) { $pdf = new pts_pdf_template(pts_title(false), 'Test Client Documentation'); $html_doc = new pts_html_template(pts_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_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 "External Dependencies" 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_title(false), 'Phoromatic Documentation'); $html_doc = new pts_html_template(pts_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_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; }
public function Footer() { if ($this->PageNo() == 1) { return; } $this->SetY(-10); $this->SetFont('Arial', 'B', 7); $this->Cell(0, 0, pts_title(), 0, 0, 'L'); $this->Cell(0, 0, 'www.phoronix-test-suite.com', 0, 0, 'R', true, 'http://www.phoronix-test-suite.com/'); }
if (isset($_POST['normalize_results']) && $_POST['normalize_results']) { $extra_attributes['normalize_result_buffer'] = true; } $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($_POST['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>'; //$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_title(true); ?> </em><br />Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org are copyright © 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>
public function get_xml($to = null) { $xml_writer = new nye_XmlWriter(PTS_IS_CLIENT ? 'pts-results-viewer.xsl' : null); $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_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); }
public static function run($r) { echo PHP_EOL . pts_title(true) . PHP_EOL; }
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)); } $test_flags = pts_c::auto_mode | pts_c::defaults_mode | pts_c::batch_mode; pts_client::set_test_flags($test_flags); if ($allow_new_tests_to_be_installed) { if ($allow_new_dependencies_to_be_installed == false) { $test_flags |= pts_c::skip_tests_with_missing_dependencies; } pts_test_installer::standard_install($to_test, $test_flags); } $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); if (pts_test_run_manager::initial_checks($to_test, $test_flags) != false) { $test_run_manager = new pts_test_run_manager($test_flags); 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_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); } }
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); define('REMOTE_ACCESS', true); // XXX TODO: Is this still used with new Phoromatic? //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_client::init(); $json_info = array('http_server' => isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : null, 'pts' => pts_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_title(true) . ' Phoromatic Server [' . $_SERVER['SERVER_SOFTWARE'] . ']'; }
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_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; } } if ($just_started) { if (PTS_IS_DAEMONIZED_SERVER_PROCESS) { $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'); 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; $test_flags = pts_c::auto_mode | pts_c::batch_mode; $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'); } if (pts_strings::string_bool($json['phoromatic']['settings']['ForceInstallTests'])) { $test_flags |= pts_c::force_install; } pts_client::set_test_flags($test_flags); pts_test_installer::standard_install($suite_identifier); 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(); if (pts_test_run_manager::initial_checks($suite_identifier, 0, 'SHORT')) { self::$test_run_manager = new pts_test_run_manager($test_flags); pts_test_run_manager::set_batch_mode(array('UploadResults' => isset($json['phoromatic']['settings']['UploadResultsToOpenBenchmarking']) && pts_strings::string_bool($json['phoromatic']['settings']['UploadResultsToOpenBenchmarking']), 'SaveResults' => true, 'RunAllTestCombinations' => false, 'OpenBrowser' => false)); // 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 { sleep(60); } } } pts_client::release_lock(PTS_USER_PATH . 'phoromatic_lock'); }
public function generic_heading($string) { static $shown_pts = false; if ($shown_pts == false) { $string = pts_title() . PHP_EOL . $string; } echo self::string_header($string, '='); }
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_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>'; }
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_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; } } } }
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 ? ' [' . round(microtime(true) - PAGE_LOAD_START_TIME, 2) . 's Page Load Time]' : null) . '<br />Copyright © 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_title(true) . ' - Core Version ' . PTS_CORE_VERSION . ' - PHP ' . PHP_VERSION . '</p></div> <script type="text/javascript"> phoromatic_checkbox_toggle_result_comparison(\'\'); </script>'; }
public function generic_heading($string, $ending_line_break = true) { static $shown_pts = false; if ($shown_pts == false) { $string = pts_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; } } }
public function add_result_file_meta_data(&$object, $reference_id = null, $title = null, $description = null) { $title = !empty($title) ? $title : $object->get_title(); if ($title == null) { trigger_error('No title supplied for result file meta-data.', E_USER_WARNING); return false; } $this->xml_writer->addXmlNode('PhoronixTestSuite/Generated/Title', $title); $this->xml_writer->addXmlNode('PhoronixTestSuite/Generated/LastModified', date('Y-m-d H:i:s')); $this->xml_writer->addXmlNode('PhoronixTestSuite/Generated/TestClient', pts_title(true)); $this->xml_writer->addXmlNode('PhoronixTestSuite/Generated/Description', $description != null ? $description : $object->get_description()); $this->xml_writer->addXmlNodeWNE('PhoronixTestSuite/Generated/Notes', $object->get_notes()); $this->xml_writer->addXmlNodeWNE('PhoronixTestSuite/Generated/InternalTags', $object->get_internal_tags()); $this->xml_writer->addXmlNodeWNE('PhoronixTestSuite/Generated/ReferenceID', $reference_id != null ? $reference_id : $object->get_reference_id()); $this->xml_writer->addXmlNodeWNE('PhoronixTestSuite/Generated/PreSetEnvironmentVariables', $object->get_preset_environment_variables()); return true; }
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) { array_push($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) { array_push($json['pts']['msg']['tests'], $test); $tp = new pts_test_profile($test); array_push($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_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) { 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_title(true) . ' starting Phoromatic Server' . PHP_EOL; $pts_logger->log(pts_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); }