Ejemplo n.º 1
0
 public static function module_config_save($module_name, $set_options = null)
 {
     // Validate the config files, update them (or write them) if needed, and other configuration file tasks
     pts_file_io::mkdir(PTS_MODULE_DATA_PATH . $module_name);
     $settings_to_write = array();
     if (is_file(PTS_MODULE_DATA_PATH . $module_name . "/module-settings.xml")) {
         $module_config_parser = new nye_XmlReader(PTS_MODULE_DATA_PATH . $module_name . "/module-settings.xml");
         $option_identifier = $module_config_parser->getXMLArrayValues('PhoronixTestSuite/ModuleSettings/Option/Identifier');
         $option_value = $module_config_parser->getXMLArrayValues('PhoronixTestSuite/ModuleSettings/Option/Value');
         for ($i = 0; $i < count($option_identifier); $i++) {
             $settings_to_write[$option_identifier[$i]] = $option_value[$i];
         }
     }
     foreach ($set_options as $identifier => $value) {
         $settings_to_write[$identifier] = $value;
     }
     $config = new nye_XmlWriter();
     foreach ($settings_to_write as $identifier => $value) {
         $config->addXmlNode('PhoronixTestSuite/ModuleSettings/Option/Identifier', $identifier);
         $config->addXmlNode('PhoronixTestSuite/ModuleSettings/Option/Value', $value);
     }
     $config->saveXMLFile(PTS_MODULE_DATA_PATH . $module_name . "/module-settings.xml");
 }
 public static function rebuild_result_parser_file($xml_file)
 {
     $xml_writer = new nye_XmlWriter();
     $xml_parser = new pts_parse_results_nye_XmlReader($xml_file);
     $result_template = $xml_parser->getXMLArrayValues('PhoronixTestSuite/ResultsParser/OutputTemplate');
     $result_match_test_arguments = $xml_parser->getXMLArrayValues('PhoronixTestSuite/ResultsParser/MatchToTestArguments');
     $result_key = $xml_parser->getXMLArrayValues('PhoronixTestSuite/ResultsParser/ResultKey');
     $result_line_hint = $xml_parser->getXMLArrayValues('PhoronixTestSuite/ResultsParser/LineHint');
     $result_line_before_hint = $xml_parser->getXMLArrayValues('PhoronixTestSuite/ResultsParser/LineBeforeHint');
     $result_line_after_hint = $xml_parser->getXMLArrayValues('PhoronixTestSuite/ResultsParser/LineAfterHint');
     $result_before_string = $xml_parser->getXMLArrayValues('PhoronixTestSuite/ResultsParser/ResultBeforeString');
     $result_after_string = $xml_parser->getXMLArrayValues('PhoronixTestSuite/ResultsParser/ResultAfterString');
     $strip_from_result = $xml_parser->getXMLArrayValues('PhoronixTestSuite/ResultsParser/StripFromResult');
     $strip_result_postfix = $xml_parser->getXMLArrayValues('PhoronixTestSuite/ResultsParser/StripResultPostfix');
     $multi_match = $xml_parser->getXMLArrayValues('PhoronixTestSuite/ResultsParser/MultiMatch');
     $file_format = $xml_parser->getXMLArrayValues('PhoronixTestSuite/ResultsParser/FileFormat');
     $result_divide_by = $xml_parser->getXMLArrayValues('PhoronixTestSuite/ResultsParser/DivideResultBy');
     $result_multiply_by = $xml_parser->getXMLArrayValues('PhoronixTestSuite/ResultsParser/MultiplyResultBy');
     $result_scale = $xml_parser->getXMLArrayValues('PhoronixTestSuite/ResultsParser/ResultScale');
     $result_proportion = $xml_parser->getXMLArrayValues('PhoronixTestSuite/ResultsParser/ResultProportion');
     $result_precision = $xml_parser->getXMLArrayValues('PhoronixTestSuite/ResultsParser/ResultPrecision');
     foreach (array_keys($result_template) as $i) {
         $xml_writer->addXmlNode('PhoronixTestSuite/ResultsParser/OutputTemplate', $result_template[$i]);
         $xml_writer->addXmlNodeWNE('PhoronixTestSuite/ResultsParser/MatchToTestArguments', $result_match_test_arguments[$i]);
         $xml_writer->addXmlNodeWNE('PhoronixTestSuite/ResultsParser/ResultKey', $result_key[$i]);
         $xml_writer->addXmlNodeWNE('PhoronixTestSuite/ResultsParser/LineHint', $result_line_hint[$i]);
         $xml_writer->addXmlNodeWNE('PhoronixTestSuite/ResultsParser/LineBeforeHint', $result_line_before_hint[$i]);
         $xml_writer->addXmlNodeWNE('PhoronixTestSuite/ResultsParser/LineAfterHint', $result_line_after_hint[$i]);
         $xml_writer->addXmlNodeWNE('PhoronixTestSuite/ResultsParser/ResultBeforeString', $result_before_string[$i]);
         $xml_writer->addXmlNodeWNE('PhoronixTestSuite/ResultsParser/ResultAfterString', $result_after_string[$i]);
         $xml_writer->addXmlNodeWNE('PhoronixTestSuite/ResultsParser/StripFromResult', $strip_from_result[$i]);
         $xml_writer->addXmlNodeWNE('PhoronixTestSuite/ResultsParser/StripResultPostfix', $strip_result_postfix[$i]);
         $xml_writer->addXmlNodeWNE('PhoronixTestSuite/ResultsParser/MultiMatch', $multi_match[$i]);
         $xml_writer->addXmlNodeWNE('PhoronixTestSuite/ResultsParser/DivideResultBy', $result_divide_by[$i]);
         $xml_writer->addXmlNodeWNE('PhoronixTestSuite/ResultsParser/MultiplyResultBy', $result_multiply_by[$i]);
         $xml_writer->addXmlNodeWNE('PhoronixTestSuite/ResultsParser/ResultScale', $result_scale[$i]);
         $xml_writer->addXmlNodeWNE('PhoronixTestSuite/ResultsParser/ResultProportion', $result_proportion[$i]);
         $xml_writer->addXmlNodeWNE('PhoronixTestSuite/ResultsParser/ResultPrecision', $result_precision[$i]);
         $xml_writer->addXmlNodeWNE('PhoronixTestSuite/ResultsParser/FileFormat', $file_format[$i]);
     }
     $result_iqc_source_file = $xml_parser->getXMLArrayValues('PhoronixTestSuite/ImageParser/SourceImage');
     $result_match_test_arguments = $xml_parser->getXMLArrayValues('PhoronixTestSuite/ImageParser/MatchToTestArguments');
     $result_iqc_image_x = $xml_parser->getXMLArrayValues('PhoronixTestSuite/ImageParser/ImageX');
     $result_iqc_image_y = $xml_parser->getXMLArrayValues('PhoronixTestSuite/ImageParser/ImageY');
     $result_iqc_image_width = $xml_parser->getXMLArrayValues('PhoronixTestSuite/ImageParser/ImageWidth');
     $result_iqc_image_height = $xml_parser->getXMLArrayValues('PhoronixTestSuite/ImageParser/ImageHeight');
     foreach (array_keys($result_iqc_source_file) as $i) {
         $xml_writer->addXmlNode('PhoronixTestSuite/ImageParser/SourceImage', $result_iqc_source_file[$i]);
         $xml_writer->addXmlNodeWNE('PhoronixTestSuite/ImageParser/MatchToTestArguments', $result_match_test_arguments[$i]);
         $xml_writer->addXmlNodeWNE('PhoronixTestSuite/ImageParser/ImageX', $result_iqc_image_x[$i]);
         $xml_writer->addXmlNodeWNE('PhoronixTestSuite/ImageParser/ImageY', $result_iqc_image_y[$i]);
         $xml_writer->addXmlNodeWNE('PhoronixTestSuite/ImageParser/ImageWidth', $result_iqc_image_width[$i]);
         $xml_writer->addXmlNodeWNE('PhoronixTestSuite/ImageParser/ImageHeight', $result_iqc_image_height[$i]);
     }
     $monitor_sensor = $xml_parser->getXMLArrayValues('PhoronixTestSuite/SystemMonitor/Sensor');
     $monitor_frequency = $xml_parser->getXMLArrayValues('PhoronixTestSuite/SystemMonitor/PollingFrequency');
     $monitor_report_as = $xml_parser->getXMLArrayValues('PhoronixTestSuite/SystemMonitor/Report');
     foreach (array_keys($monitor_sensor) as $i) {
         $xml_writer->addXmlNode('PhoronixTestSuite/SystemMonitor/Sensor', $monitor_sensor[$i]);
         $xml_writer->addXmlNodeWNE('PhoronixTestSuite/SystemMonitor/PollingFrequency', $monitor_frequency[$i]);
         $xml_writer->addXmlNodeWNE('PhoronixTestSuite/SystemMonitor/Report', $monitor_report_as[$i]);
     }
     $extra_data_id = $xml_parser->getXMLArrayValues('PhoronixTestSuite/ExtraData/Identifier');
     foreach (array_keys($extra_data_id) as $i) {
         $xml_writer->addXmlNode('PhoronixTestSuite/ExtraData/Identifier', $extra_data_id[$i]);
     }
     return $xml_writer;
 }
 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);
 }
Ejemplo n.º 4
0
 public static function update_test_install_xml(&$test_profile, $this_duration = 0, $is_install = false, $compiler_data = null, $install_footnote = null)
 {
     // Refresh/generate an install XML for pts-install.xml
     if ($test_profile->test_installation == false) {
         // XXX: Hackish way to avoid problems until this function is better written for clean installations, etc
         $test_profile->test_installation = new pts_installed_test($test_profile);
     }
     $xml_writer = new nye_XmlWriter('file://' . PTS_USER_PATH . 'xsl/' . 'pts-test-installation-viewer.xsl');
     $test_duration = $test_profile->test_installation->get_average_run_time();
     if (!is_numeric($test_duration) && !$is_install) {
         $test_duration = $this_duration;
     }
     if (!$is_install && is_numeric($this_duration) && $this_duration > 0) {
         $test_duration = ceil(($test_duration * $test_profile->test_installation->get_run_count() + $this_duration) / ($test_profile->test_installation->get_run_count() + 1));
     }
     $compiler_data = $is_install ? $compiler_data : $test_profile->test_installation->get_compiler_data();
     $install_footnote = $is_install ? $install_footnote : $test_profile->test_installation->get_install_footnote();
     $test_version = $is_install ? $test_profile->get_test_profile_version() : $test_profile->test_installation->get_installed_version();
     $test_checksum = $is_install ? $test_profile->get_installer_checksum() : $test_profile->test_installation->get_installed_checksum();
     $sys_identifier = $is_install ? phodevi::system_id_string() : $test_profile->test_installation->get_installed_system_identifier();
     $install_time = $is_install ? date('Y-m-d H:i:s') : $test_profile->test_installation->get_install_date_time();
     $install_time_length = $is_install ? $this_duration : $test_profile->test_installation->get_latest_install_time();
     $latest_run_time = $is_install || $this_duration == 0 ? $test_profile->test_installation->get_latest_run_time() : $this_duration;
     $times_run = $test_profile->test_installation->get_run_count();
     if ($is_install) {
         $last_run = $latest_run_time;
         if (empty($last_run)) {
             $last_run = '0000-00-00 00:00:00';
         }
     } else {
         $last_run = date('Y-m-d H:i:s');
         $times_run++;
     }
     $xml_writer->addXmlNode('PhoronixTestSuite/TestInstallation/Environment/Identifier', $test_profile->get_identifier());
     $xml_writer->addXmlNode('PhoronixTestSuite/TestInstallation/Environment/Version', $test_version);
     $xml_writer->addXmlNode('PhoronixTestSuite/TestInstallation/Environment/CheckSum', $test_checksum);
     $xml_writer->addXmlNode('PhoronixTestSuite/TestInstallation/Environment/CompilerData', json_encode($compiler_data));
     $xml_writer->addXmlNode('PhoronixTestSuite/TestInstallation/Environment/InstallFootnote', $install_footnote);
     $xml_writer->addXmlNode('PhoronixTestSuite/TestInstallation/Environment/SystemIdentifier', $sys_identifier);
     $xml_writer->addXmlNode('PhoronixTestSuite/TestInstallation/History/InstallTime', $install_time);
     $xml_writer->addXmlNode('PhoronixTestSuite/TestInstallation/History/InstallTimeLength', $install_time_length);
     $xml_writer->addXmlNode('PhoronixTestSuite/TestInstallation/History/LastRunTime', $last_run);
     $xml_writer->addXmlNode('PhoronixTestSuite/TestInstallation/History/TimesRun', $times_run);
     $xml_writer->addXmlNode('PhoronixTestSuite/TestInstallation/History/AverageRunTime', $test_duration);
     $xml_writer->addXmlNode('PhoronixTestSuite/TestInstallation/History/LatestRunTime', $latest_run_time);
     $xml_writer->saveXMLFile($test_profile->get_install_dir() . 'pts-install.xml');
 }
Ejemplo n.º 5
0
 public static function user_config_generate($new_config_values = null)
 {
     // Validate the config files, update them (or write them) if needed, and other configuration file tasks
     $read_config = new pts_config_nye_XmlReader($new_config_values);
     $config = new nye_XmlWriter('xsl/pts-user-config-viewer.xsl');
     $config->addXmlNodeFromReader('PhoronixTestSuite/Options/OpenBenchmarking/AnonymousUsageReporting', $read_config);
     $config->addXmlNodeFromReader('PhoronixTestSuite/Options/OpenBenchmarking/IndexCacheTTL', $read_config);
     $config->addXmlNodeFromReader('PhoronixTestSuite/Options/OpenBenchmarking/AlwaysUploadSystemLogs', $read_config);
     $config->addXmlNodeFromReader('PhoronixTestSuite/Options/General/DefaultBrowser', $read_config);
     $config->addXmlNodeFromReader('PhoronixTestSuite/Options/General/UsePhodeviCache', $read_config);
     $config->addXmlNodeFromReader('PhoronixTestSuite/Options/General/DefaultDisplayMode', $read_config);
     $config->addXmlNodeFromReader('PhoronixTestSuite/Options/General/PhoromaticServers', $read_config);
     $config->addXmlNodeFromReader('PhoronixTestSuite/Options/Modules/LoadModules', $read_config);
     $config->addXmlNodeFromReader('PhoronixTestSuite/Options/Installation/RemoveDownloadFiles', $read_config);
     $config->addXmlNodeFromReader('PhoronixTestSuite/Options/Installation/SearchMediaForCache', $read_config);
     $config->addXmlNodeFromReader('PhoronixTestSuite/Options/Installation/SymLinkFilesFromCache', $read_config);
     $config->addXmlNodeFromReader('PhoronixTestSuite/Options/Installation/PromptForDownloadMirror', $read_config);
     $config->addXmlNodeFromReader('PhoronixTestSuite/Options/Installation/EnvironmentDirectory', $read_config);
     $config->addXmlNodeFromReader('PhoronixTestSuite/Options/Installation/CacheDirectory', $read_config);
     $config->addXmlNodeFromReader('PhoronixTestSuite/Options/Testing/SaveSystemLogs', $read_config);
     $config->addXmlNodeFromReader('PhoronixTestSuite/Options/Testing/SaveInstallationLogs', $read_config);
     $config->addXmlNodeFromReader('PhoronixTestSuite/Options/Testing/SaveTestLogs', $read_config);
     $config->addXmlNodeFromReader('PhoronixTestSuite/Options/Testing/RemoveTestInstallOnCompletion', $read_config);
     $config->addXmlNodeFromReader('PhoronixTestSuite/Options/Testing/ResultsDirectory', $read_config);
     $config->addXmlNodeFromReader('PhoronixTestSuite/Options/Testing/AlwaysUploadResultsToOpenBenchmarking', $read_config);
     $config->addXmlNodeFromReader('PhoronixTestSuite/Options/Testing/AutoSortRunQueue', $read_config);
     $config->addXmlNodeFromReader('PhoronixTestSuite/Options/TestResultValidation/DynamicRunCount', $read_config);
     $config->addXmlNodeFromReader('PhoronixTestSuite/Options/TestResultValidation/LimitDynamicToTestLength', $read_config);
     $config->addXmlNodeFromReader('PhoronixTestSuite/Options/TestResultValidation/StandardDeviationThreshold', $read_config);
     $config->addXmlNodeFromReader('PhoronixTestSuite/Options/TestResultValidation/ExportResultsTo', $read_config);
     $config->addXmlNodeFromReader('PhoronixTestSuite/Options/BatchMode/SaveResults', $read_config);
     $config->addXmlNodeFromReader('PhoronixTestSuite/Options/BatchMode/OpenBrowser', $read_config);
     $config->addXmlNodeFromReader('PhoronixTestSuite/Options/BatchMode/UploadResults', $read_config);
     $config->addXmlNodeFromReader('PhoronixTestSuite/Options/BatchMode/PromptForTestIdentifier', $read_config);
     $config->addXmlNodeFromReader('PhoronixTestSuite/Options/BatchMode/PromptForTestDescription', $read_config);
     $config->addXmlNodeFromReader('PhoronixTestSuite/Options/BatchMode/PromptSaveName', $read_config);
     $config->addXmlNodeFromReader('PhoronixTestSuite/Options/BatchMode/RunAllTestCombinations', $read_config);
     $config->addXmlNodeFromReader('PhoronixTestSuite/Options/BatchMode/Configured', $read_config);
     $config->addXmlNodeFromReader('PhoronixTestSuite/Options/Networking/NoInternetCommunication', $read_config);
     $config->addXmlNodeFromReader('PhoronixTestSuite/Options/Networking/NoNetworkCommunication', $read_config);
     $config->addXmlNodeFromReader('PhoronixTestSuite/Options/Networking/Timeout', $read_config);
     $config->addXmlNodeFromReader('PhoronixTestSuite/Options/Networking/ProxyAddress', $read_config);
     $config->addXmlNodeFromReader('PhoronixTestSuite/Options/Networking/ProxyPort', $read_config);
     $config->addXmlNodeFromReader('PhoronixTestSuite/Options/Server/RemoteAccessPort', $read_config);
     $config->addXmlNodeFromReader('PhoronixTestSuite/Options/Server/Password', $read_config);
     $config->addXmlNodeFromReader('PhoronixTestSuite/Options/Server/WebSocketPort', $read_config);
     $config->addXmlNodeFromReader('PhoronixTestSuite/Options/Server/AdvertiseServiceZeroConf', $read_config);
     $config->addXmlNodeFromReader('PhoronixTestSuite/Options/Server/PhoromaticStorage', $read_config);
     $config_file = pts_config::get_config_file_location();
     if ($read_config->times_fallback() > 0 || !is_file($config_file)) {
         // Something changed, so write out file, otherwise don't bother writing file
         $config->saveXMLFile($config_file);
     }
 }