pts-core: Various minor code clean-ups and code reorganization improvements

This commit is contained in:
Michael Larabel
2021-11-27 18:25:36 -06:00
parent 6e68eb1ed7
commit 2c4503e105
38 changed files with 215 additions and 375 deletions

View File

@@ -111,7 +111,7 @@ class debug_render_test implements pts_option_interface
foreach(pts_results::saved_test_results() as $saved_result)
{
$save_to_dir = pts_client::setup_test_result_directory($saved_result);
$generated_graphs = pts_client::generate_result_file_graphs($saved_result, $save_to_dir, $extra_graph_attributes);
$generated_graphs = pts_svg_dom_gd::generate_result_file_graphs($saved_result, $save_to_dir, $extra_graph_attributes);
echo $saved_result . ': ' . count($generated_graphs) . PHP_EOL;
}
}

View File

@@ -42,8 +42,8 @@ class diagnostics implements pts_option_interface
{
echo pts_client::cli_just_bold($var) . ' = ' . $var_value . PHP_EOL;
}
echo PHP_EOL . 'Environmental Variables (accessible via test scripts):' . PHP_EOL;
foreach(pts_client::environmental_variables() as $var => $var_value)
echo PHP_EOL . 'Environment Variables (accessible via test scripts):' . PHP_EOL;
foreach(pts_client::environment_variables() as $var => $var_value)
{
echo pts_client::cli_just_bold($var) . ' = ' . $var_value . PHP_EOL;
}

View File

@@ -125,10 +125,10 @@ class dump_documentation implements pts_option_interface
}
}
$vars = pts_module_manager::module_call($module, 'module_environmental_variables');
$vars = pts_module_manager::module_call($module, 'module_environment_variables');
if(is_array($vars) && count($vars) > 0)
{
$p = $dom->createElement('p', 'This module utilizes the following environmental variables: ' . implode(', ', $vars) . '.');
$p = $dom->createElement('p', 'This module utilizes the following environment variables: ' . implode(', ', $vars) . '.');
$body->appendChild($p);
}

View File

@@ -59,7 +59,7 @@ class module_info implements pts_option_interface
echo PHP_EOL;
}
$vars = pts_module_manager::module_call($module, 'module_environmental_variables');
$vars = pts_module_manager::module_call($module, 'module_environment_variables');
if(is_array($vars))
{
echo 'Module Environment Variables:' . PHP_EOL;

View File

@@ -43,7 +43,7 @@ class remove_installed_test implements pts_option_interface
if(pts_user_io::prompt_bool_input('Are you sure you wish to remove the test ' . $test_profile, false))
{
pts_client::remove_installed_test($test_profile);
pts_tests::remove_installed_test($test_profile);
echo PHP_EOL . $test_profile . ' has been removed.' . PHP_EOL;
}
else

View File

@@ -42,7 +42,7 @@ class result_file_to_pdf implements pts_option_interface
$_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);
pts_svg_dom_gd::generate_result_file_graphs($r[0], $tdir);
$result_file = new pts_result_file($r[0]);
$result_output = pts_result_file_output::result_file_to_pdf($result_file, '', 'S');

View File

@@ -27,7 +27,7 @@ class flush_caches extends pts_module_interface
const module_description = 'Loading this module will ensure caches (page cache, swap, etc) automatically get flushed prior to running any test.';
const module_author = 'Phoronix Media';
public static function module_environmental_variables()
public static function module_environment_variables()
{
return array('PTS_FLUSH_CACHES');
}

View File

@@ -1,146 +0,0 @@
<?php
/*
Phoronix Test Suite
URLs: http://www.phoronix.com, http://www.phoronix-test-suite.com/
Copyright (C) 2008 - 2011, Phoronix Media
Copyright (C) 2008 - 2011, Michael Larabel
graphics_override.php: Graphics AA/AF image quality setting override module
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/>.
*/
class graphics_override extends pts_module_interface
{
const module_name = "Graphics Override";
const module_version = "1.0.5";
const module_description = "This module allows you to override some graphics rendering settings for the ATI and NVIDIA drivers while running the Phoronix Test Suite.";
const module_author = "Michael Larabel";
public static $module_store_vars = array("FORCE_AA", "FORCE_AF");
static $preset_aa = FALSE;
static $preset_af = FALSE;
static $preset_aa_control = FALSE;
static $preset_af_control = FALSE;
static $supported_aa_levels = array(0, 2, 4, 8, 16);
static $supported_af_levels = array(0, 2, 4, 8, 16);
public static function module_environmental_variables()
{
return array('FORCE_AA', 'FORCE_AF');
}
public static function set_nvidia_extension($attribute, $value)
{
// Sets an object in NVIDIA's NV Extension
if(phodevi::is_nvidia_graphics())
{
shell_exec("nvidia-settings --assign " . $attribute . "=" . $value . " 2>&1");
}
}
public static function __pre_run_process()
{
if(!phodevi::is_nvidia_graphics())
{
echo "\nNo supported driver found for graphics_override module!\n";
return pts_module::MODULE_UNLOAD; // Not using a supported driver, quit the module
}
$force_aa = pts_env::read("FORCE_AA");
$force_af = pts_env::read("FORCE_AF");
if($force_aa !== FALSE && in_array($force_aa, self::$supported_aa_levels))
{
// First backup any existing override, then set the new value
if(phodevi::is_nvidia_graphics())
{
self::$preset_aa = phodevi_parser::read_nvidia_extension("FSAA");
self::$preset_aa_control = phodevi_parser::read_nvidia_extension("FSAAAppControlled");
switch($force_aa)
{
case 2:
$nvidia_aa = 2;
break;
case 4:
$nvidia_aa = 5;
break;
case 8:
$nvidia_aa = 7;
break;
case 16:
$nvidia_aa = 8;
break;
}
if(isset($nvidia_aa))
{
self::set_nvidia_extension("FSAA", $nvidia_aa);
self::set_nvidia_extension("FSAAAppControlled", 0);
}
}
}
if($force_af !== FALSE && in_array($force_af, self::$supported_af_levels))
{
// First backup any existing override, then set the new value
if(phodevi::is_nvidia_graphics())
{
self::$preset_af = phodevi_parser::read_nvidia_extension("LogAniso");
self::$preset_af_control = phodevi_parser::read_nvidia_extension("LogAnisoAppControlled");
switch($force_af)
{
case 2:
$nvidia_af = 1;
break;
case 4:
$nvidia_af = 2;
break;
case 8:
$nvidia_af = 3;
break;
case 16:
$nvidia_af = 4;
break;
}
if(isset($nvidia_af))
{
self::set_nvidia_extension("LogAniso", $nvidia_af);
self::set_nvidia_extension("LogAnisoAppControlled", 0);
}
}
}
}
public static function __post_option_process()
{
if(phodevi::is_nvidia_graphics())
{
if(self::$preset_aa !== FALSE)
{
self::set_nvidia_extension("FSAA", self::$preset_aa);
self::set_nvidia_extension("FSAAAppControlled", self::$preset_aa_control);
}
if(self::$preset_af !== FALSE)
{
self::set_nvidia_extension("LogAniso", self::$preset_af);
self::set_nvidia_extension("LogAnisoAppControlled", self::$preset_af_control);
}
}
}
}
?>

View File

@@ -27,7 +27,7 @@ class html_results_export extends pts_module_interface
const module_description = 'This module allows basic exporting of results to HTML for saving either to a file locally (specified using the EXPORT_RESULTS_HTML_FILE_TO environment variable) or to a mail account (specified using the EXPORT_RESULTS_HTML_EMAIL_TO environment variable). EXPORT_RESULTS_HTML_EMAIL_TO supports multiple email addresses delimited by a comma.';
const module_author = 'Michael Larabel';
public static function module_environmental_variables()
public static function module_environment_variables()
{
return array('EXPORT_RESULTS_HTML_EMAIL_TO', 'EXPORT_RESULTS_HTML_FILE_TO');
}

View File

@@ -32,7 +32,7 @@ class linux_perf extends pts_module_interface
private static $std_output;
private static $tmp_file;
public static function module_environmental_variables()
public static function module_environment_variables()
{
return array('LINUX_PERF');
}

View File

@@ -27,7 +27,7 @@ class log_exporter extends pts_module_interface
const module_description = 'This module allows for easily exporting test run logs and system logs to external locations via specifying the directory paths via the COPY_TEST_RUN_LOGS_TO and COPY_SYSTEM_LOGS_TO environment variables.';
const module_author = 'Michael Larabel';
public static function module_environmental_variables()
public static function module_environment_variables()
{
return array('COPY_TEST_RUN_LOGS_TO', 'COPY_SYSTEM_LOGS_TO');
}

View File

@@ -48,9 +48,9 @@ class matisk extends pts_module_interface
'upload_to_openbenchmarking' => array(false, 'A boolean value whether to automatically upload the test result to OpenBenchmarking.org'), // Automatic upload to OpenBenchmarking?
// 'open_browser' => false, // Automatically launch web browser to show the results?
),
'environmental_variables' =>
'environment_variables' =>
array(
'EXAMPLE_VAR' => array('EXAMPLE', 'The environmental_variables section allows key = value pairs of environmental variables to be set by default.')
'EXAMPLE_VAR' => array('EXAMPLE', 'The environment_variables section allows key = value pairs of environment variables to be set by default.')
),
'set_context' =>
array(
@@ -281,9 +281,9 @@ class matisk extends pts_module_interface
*/
}
if(!empty($ini['environmental_variables']) && is_array($ini['environmental_variables']))
if(!empty($ini['environment_variables']) && is_array($ini['environment_variables']))
{
foreach($ini['environmental_variables'] as $key => $value)
foreach($ini['environment_variables'] as $key => $value)
{
putenv(trim($key) . '=' . trim($value));
}

View File

@@ -38,7 +38,7 @@ class perf_per_dollar extends pts_module_interface
private static $TEST_RUN_TIME_ELAPSED = 0;
private static $TOTAL_TEST_RUN_TIME_PROCESS_START = 0;
public static function module_environmental_variables()
public static function module_environment_variables()
{
return array('COST_PERF_PER_DOLLAR', 'COST_PERF_PER_UNIT', 'COST_PERF_PER_HOUR');
}

View File

@@ -61,7 +61,7 @@ class perf_tips extends pts_module_interface
{
return 'This module alerts the user if the system configuration may not be the right one for achieving the best performance with the target benchmark(s). This initial version of the module actually cares only about the BFQ I/O scheduler: it gives a warning if BFQ is being used with an incorrect configuration in a disk benchmark, and suggests the right configuration to use. For the moment it only works for existing, throughput-based tests. It will need to be extended for responsiveness and soft real-time-latency tests.';
}
public static function module_environmental_variables()
public static function module_environment_variables()
{
return array('SUPPRESS_PERF_TIPS');
}

View File

@@ -29,7 +29,7 @@ class pushover_net extends pts_module_interface
private static $pushover_net_user_key = null;
private static $result_identifier = null;
public static function module_environmental_variables()
public static function module_environment_variables()
{
return array('PUSHOVER_NET_USER');
}

View File

@@ -30,7 +30,7 @@ class report_test_run_times extends pts_module_interface
private static $successful_test_run_request = null;
private static $result_identifier;
public static function module_environmental_variables()
public static function module_environment_variables()
{
return array('RUN_TIMES_ARE_A_BENCHMARK', 'INSTALL_TIMES_ARE_A_BENCHMARK', 'INSTALL_SIZES_ARE_A_BENCHMARK');
}

View File

@@ -51,7 +51,7 @@ class system_monitor extends pts_module_interface
private static $perf_per_sensor_collection;
private static $perf_per_sensor = false;
public static function module_environmental_variables()
public static function module_environment_variables()
{
return array('MONITOR', 'PERFORMANCE_PER_WATT', 'PERFORMANCE_PER_SENSOR', 'MONITOR_INTERVAL', 'MONITOR_PER_RUN' );
}
@@ -333,7 +333,7 @@ class system_monitor extends pts_module_interface
return $args;
}
// Parse environmental variable containing parameters of monitored sensors.
// Parse environment variable containing parameters of monitored sensors.
private static function prepare_sensor_parameters()
{
$sensor_list = pts_strings::comma_explode(pts_env::read('MONITOR'));
@@ -421,7 +421,7 @@ class system_monitor extends pts_module_interface
// instantiate sensor class if:
// a) we want to monitor all the available sensors,
// b) we want to monitor all the available sensors of the specified type,
// c) sensor type and name was passed in an environmental variable
// c) sensor type and name was passed in an environment variable
// ($sensor[0] is the type, $sensor[1] is the name, $sensor[2] is the class name)

View File

@@ -30,7 +30,7 @@ class test_timeout extends pts_module_interface
protected static $timeout_after_mins = 'auto';
protected static $time_to_allow_for_current_test = 0;
public static function module_environmental_variables()
public static function module_environment_variables()
{
return array('TEST_TIMEOUT_AFTER');
}

View File

@@ -32,7 +32,7 @@ class timed_screenshot extends pts_module_interface
protected static $screenshot_interval = 10;
protected static $existing_screenshots = array();
public static function module_environmental_variables()
public static function module_environment_variables()
{
return array('SCREENSHOT_INTERVAL');
}

View File

@@ -40,7 +40,7 @@ class toggle_screensaver extends pts_module_interface
static $xfce_screensaver_halted = false;
static $sleep_display_ac = false;
public static function module_environmental_variables()
public static function module_environment_variables()
{
return array('HALT_SCREENSAVER');
}

View File

@@ -30,7 +30,7 @@ class turbostat extends pts_module_interface
private static $turbostat_log_dir;
private static $append_to_run_log_files = false;
public static function module_environmental_variables()
public static function module_environment_variables()
{
return array('TURBOSTAT_LOG');
}

View File

@@ -29,7 +29,7 @@ class use_wine extends pts_module_interface
protected static $wine_bin = false;
protected static $original_os_under_test = null;
public static function module_environmental_variables()
public static function module_environment_variables()
{
return array('USE_WINE');
}

View File

@@ -31,7 +31,7 @@ class watchdog extends pts_module_interface
private static $monitor_threshold = 0;
private static $maximum_wait = 4;
public static function module_environmental_variables()
public static function module_environment_variables()
{
return array('WATCHDOG_SENSOR', 'WATCHDOG_SENSOR_THRESHOLD', 'WATCHDOG_MAXIMUM_WAIT');
}

View File

@@ -332,7 +332,7 @@ class pts_concise_display_mode implements pts_display_mode_interface
if(($test_description = $test_result->get_arguments_description()) != false)
{
$test_title_string .= ' [' . pts_client::swap_variables($test_description, array('pts_client', 'environmental_variables')) . ']';
$test_title_string .= ' [' . pts_client::swap_variables($test_description, array('pts_client', 'environment_variables')) . ']';
}
echo PHP_EOL . pts_client::cli_colored_text($test_title_string, 'cyan', true) . PHP_EOL;

View File

@@ -50,7 +50,7 @@ class pts_short_display_mode extends pts_concise_display_mode
$after_print = pts_client::cli_colored_text('Test Started', 'green', true);
if(($test_description = $test_result->get_arguments_description()) != false)
{
$after_print .= ' - ' . pts_client::swap_variables($test_description, array('pts_client', 'environmental_variables'));
$after_print .= ' - ' . pts_client::swap_variables($test_description, array('pts_client', 'environment_variables'));
}
echo $after_print .= PHP_EOL;

View File

@@ -302,7 +302,7 @@ class pts_web_display_mode implements pts_display_mode_interface
if(($test_description = $test_result->get_arguments_description()) != false)
{
echo ' [' . pts_client::swap_variables($test_description, array('pts_client', 'environmental_variables')) . ']';
echo ' [' . pts_client::swap_variables($test_description, array('pts_client', 'environment_variables')) . ']';
}
echo PHP_EOL;

View File

@@ -113,7 +113,7 @@ class pts_websocket_display_mode implements pts_display_mode_interface
$j['pts']['msg']['name'] = 'benchmark_state';
$j['pts']['msg']['current_state'] = 'install';
$j['pts']['msg']['current_test'] = $test_install_request ? base64_encode($test_install_request->test_profile->to_json()) : null;
//$j['pts']['msg']['arguments_description'] = pts_client::swap_variables($test_result->get_arguments_description(), array('pts_client', 'environmental_variables'));
//$j['pts']['msg']['arguments_description'] = pts_client::swap_variables($test_result->get_arguments_description(), array('pts_client', 'environment_variables'));
// CURRENT RUN QUEUE
//$j['pts']['msg']['test_run_pos'] = $this->trial_run_count_current;
@@ -335,7 +335,7 @@ class pts_websocket_display_mode implements pts_display_mode_interface
$j['pts']['msg']['name'] = 'benchmark_state';
$j['pts']['msg']['current_state'] = 'benchmark';
$j['pts']['msg']['current_test'] = base64_encode($test_result->test_profile->to_json());
$j['pts']['msg']['arguments_description'] = pts_client::swap_variables($test_result->get_arguments_description(), array('pts_client', 'environmental_variables'));
$j['pts']['msg']['arguments_description'] = pts_client::swap_variables($test_result->get_arguments_description(), array('pts_client', 'environment_variables'));
// CURRENT RUN QUEUE
$j['pts']['msg']['test_run_pos'] = $this->trial_run_count_current;

View File

@@ -250,8 +250,6 @@ class pts_client
}
}
// pts_compatibility ops here
pts_client::init_display_mode();
}
public static function module_framework_init()
@@ -333,9 +331,9 @@ class pts_client
pts_define('PTS_STARTUP_TASK_PERFORMED', true);
register_shutdown_function(array('pts_module_manager', 'module_process'), '__shutdown');
}
public static function environmental_variables()
public static function environment_variables()
{
// The PTS environmental variables passed during the testing process, etc
// The PTS environment variables passed during the testing process, etc
static $env_variables = null;
if($env_variables == null)
@@ -682,7 +680,7 @@ class pts_client
}
}
// Dump some common / important environmental variables
// Dump some common / important environment variables
$environment_variables = array(
'PATH' => null,
'CFLAGS' => null,
@@ -906,7 +904,7 @@ class pts_client
pts_openbenchmarking_client::update_gsid();
}
$pso->add_object('environmental_variables_for_modules', pts_module_manager::modules_environmental_variables());
$pso->add_object('environment_variables_for_modules', pts_module_manager::modules_environment_variables());
$pso->add_object('command_alias_list', pts_documentation::client_commands_aliases());
}
$pso->add_object('last_core_version', PTS_CORE_VERSION); // PTS version last run
@@ -1019,6 +1017,7 @@ class pts_client
continue;
}
// TODO XXX: add HTTPS check here similar to previous HTTPS code added to Phoromatic client module
$server_response = pts_network::http_get_contents('http://' . $possible_server[0] . ':' . $possible_server[1] . '/server.php', false, false, 3);
if(stripos($server_response, 'Phoromatic') !== false)
{
@@ -1092,173 +1091,11 @@ class pts_client
return $save_to_dir;
}
public static function remove_installed_test(&$test_profile)
{
pts_file_io::delete($test_profile->get_install_dir(), null, true);
}
public static function exit_client($string = null, $exit_status = 0)
{
// Exit the Phoronix Test Suite client
pts_define('PTS_EXIT', 1);
if($string != null)
{
echo PHP_EOL . $string . PHP_EOL;
}
exit($exit_status);
}
public static function current_user()
{
// Current system user
return ($pts_user = pts_openbenchmarking_client::user_name()) != null ? $pts_user : phodevi::read_property('system', 'username');
}
public static function generate_result_file_graphs($test_results_identifier, $save_to_dir = false, $extra_attributes = null)
{
// Since dropping the old result viewer, this function is no longer used except for niche cases (debug render, PDF generation)
if($save_to_dir)
{
if(pts_file_io::mkdir($save_to_dir . '/result-graphs') == false)
{
// Don't delete old files now, in case any modules (e.g. FlameGrapher) output something in there ahead of time
/*// Directory must exist, so remove any old graph files first
foreach(pts_file_io::glob($save_to_dir . '/result-graphs/*') as $old_file)
{
unlink($old_file);
}*/
}
}
if($test_results_identifier instanceof pts_result_file)
{
$result_file = &$test_results_identifier;
}
else
{
$result_file = new pts_result_file($test_results_identifier);
}
$result_file->avoid_duplicate_identifiers();
$generated_graphs = array();
$generated_graph_tables = false;
// Render overview chart
if($save_to_dir)
{
$chart = new pts_ResultFileTable($result_file);
$chart->renderChart($save_to_dir . '/result-graphs/overview.BILDE_EXTENSION');
$intent = -1;
if(($intent = pts_result_file_analyzer::analyze_result_file_intent($result_file, $intent, true)) || $result_file->get_system_count() == 1)
{
$chart = new pts_ResultFileCompactSystemsTable($result_file, $intent);
}
else
{
$chart = new pts_ResultFileSystemsTable($result_file);
}
$chart->renderChart($save_to_dir . '/result-graphs/systems.BILDE_EXTENSION');
unset($chart);
if($intent && is_dir($result_file->get_system_log_dir()))
{
$chart = new pts_DetailedSystemComponentTable($result_file, $result_file->get_system_log_dir(), $intent);
if($chart)
{
$chart->renderChart($save_to_dir . '/result-graphs/detailed_component.BILDE_EXTENSION');
}
}
}
$result_objects = $result_file->get_result_objects();
$test_titles = array();
foreach($result_objects as &$result_object)
{
$test_titles[] = $result_object->test_profile->get_title();
}
$offset = 0;
foreach($result_objects as $key => &$result_object)
{
$save_to = $save_to_dir;
$offset++;
if($save_to_dir && is_dir($save_to_dir))
{
$save_to .= '/result-graphs/' . $offset . '.BILDE_EXTENSION';
if(PTS_IS_CLIENT)
{
if($result_file->is_multi_way_comparison(null, $extra_attributes))
{
$table_keys = array();
foreach($test_titles as $this_title_index => $this_title)
{
if(isset($test_titles[$key]) && $this_title == $test_titles[$key])
{
$table_keys[] = $this_title_index;
}
}
}
else
{
$table_keys = $key;
}
$chart = new pts_ResultFileTable($result_file, null, $table_keys);
$chart->renderChart($save_to_dir . '/result-graphs/' . $offset . '_table.BILDE_EXTENSION');
unset($chart);
$generated_graph_tables = true;
}
}
$graph = pts_render::render_graph($result_object, $result_file, $save_to, $extra_attributes);
if($graph == false)
{
continue;
}
$generated_graphs[] = $graph;
}
// Generate mini / overview graphs
if($save_to_dir)
{
$graph = new pts_OverviewGraph($result_file);
$rendered = $graph->renderGraph();
// Check to see if skip_graph was realized during the rendering process
if($rendered)
{
$graph->svg_dom->output($save_to_dir . '/result-graphs/visualize.BILDE_EXTENSION');
}
unset($graph);
if($result_file->get_system_count() == 2)
{
$graph = new pts_graph_run_vs_run($result_file);
}
else
{
$graph = new pts_graph_radar_chart($result_file);
}
$rendered = $graph->renderGraph();
// Check to see if skip_graph was realized during the rendering process
if($rendered)
{
$graph->svg_dom->output($save_to_dir . '/result-graphs/radar.BILDE_EXTENSION');
}
unset($graph);
}
return $generated_graphs;
}
public static function process_shutdown_tasks()
{
@@ -1850,10 +1687,10 @@ class pts_client
public static function shell_exec($exec, $extra_vars = null)
{
// Same as shell_exec() but with the PTS env variables added in
// Convert pts_client::environmental_variables() into shell export variable syntax
// Convert pts_client::environment_variables() into shell export variable syntax
$var_string = '';
$extra_vars = ($extra_vars == null ? pts_client::environmental_variables() : array_merge(pts_client::environmental_variables(), $extra_vars));
$extra_vars = ($extra_vars == null ? pts_client::environment_variables() : array_merge(pts_client::environment_variables(), $extra_vars));
foreach(array_keys($extra_vars) as $key)
{

View File

@@ -42,7 +42,7 @@ class pts_module_interface
{
return $module_options_array;
}
public static function module_environmental_variables()
public static function module_environment_variables()
{
return array();
}

View File

@@ -48,13 +48,13 @@ class pts_module_manager
return $modules;
}
public static function modules_environmental_variables()
public static function modules_environment_variables()
{
$module_env_vars = array();
foreach(pts_module_manager::available_modules() as $module)
{
pts_module_manager::load_module($module);
$vars = pts_module_manager::module_call($module, 'module_environmental_variables');
$vars = pts_module_manager::module_call($module, 'module_environment_variables');
if(is_array($vars))
{
@@ -119,8 +119,7 @@ class pts_module_manager
break;
case pts_module::QUIT_PTS_CLIENT:
// Stop the Phoronix Test Suite immediately
pts_client::exit_client();
break;
exit(0);
}
}
pts_module_manager::set_current_module(null);
@@ -308,11 +307,11 @@ class pts_module_manager
public static function detect_modules_to_load()
{
// Auto detect modules to load
$env_vars = pts_storage_object::read_from_file(PTS_CORE_STORAGE, 'environmental_variables_for_modules');
$env_vars = pts_storage_object::read_from_file(PTS_CORE_STORAGE, 'environment_variables_for_modules');
if($env_vars == false)
{
$env_vars = pts_module_manager::modules_environmental_variables();
$env_vars = pts_module_manager::modules_environment_variables();
}
foreach($env_vars as $env_var => $modules)

View File

@@ -25,7 +25,7 @@
class pts_phoroscript_interpreter
{
private $script_file;
private $environmental_variables;
private $environment_variables;
private $var_current_directory;
public function __construct($script, $env_vars = null, $set_current_path = null)
@@ -35,7 +35,7 @@ class pts_phoroscript_interpreter
$env_vars['HOME'] = $set_current_path;
}
$this->environmental_variables = ($env_vars == null ? pts_client::environmental_variables() : array_merge(pts_client::environmental_variables(), $env_vars));
$this->environment_variables = ($env_vars == null ? pts_client::environment_variables() : array_merge(pts_client::environment_variables(), $env_vars));
$this->script_file = is_file($script) ? $script : null;
$this->var_current_directory = $set_current_path;
}
@@ -43,13 +43,13 @@ class pts_phoroscript_interpreter
{
if($path == "\$LOG_FILE")
{
return $this->environmental_variables["LOG_FILE"];
return $this->environment_variables["LOG_FILE"];
}
$this->parse_variables_in_string($path, $pass_arguments);
if(substr($path, 0, 1) == '~')
{
$path = $this->environmental_variables["HOME"] . substr($path, 2);
$path = $this->environment_variables["HOME"] . substr($path, 2);
}
if(strpos($path, '*') !== false)
@@ -129,9 +129,9 @@ class pts_phoroscript_interpreter
{
$var_value = $pass_arguments;
}
if(isset($this->environmental_variables[$var]))
if(isset($this->environment_variables[$var]))
{
$var_value = $this->environmental_variables[$var];
$var_value = $this->environment_variables[$var];
}
else if(is_numeric($var) && isset($pass_arguments_r[($var - 1)]))
{
@@ -227,7 +227,7 @@ class pts_phoroscript_interpreter
}
else if($line_r[1] == '~')
{
$this->var_current_directory = $this->environmental_variables["HOME"];
$this->var_current_directory = $this->environment_variables["HOME"];
}
else if(substr($line_r[1], 0, 1) == '"')
{

View File

@@ -87,7 +87,7 @@ class pts_test_execution
$to_execute = $test_run_request->test_profile->get_test_executable_dir();
$pts_test_arguments = trim($test_run_request->test_profile->get_default_arguments() . ' ' . ($test_run_request->test_profile->get_default_arguments() != null ? str_replace($test_run_request->test_profile->get_default_arguments(), '', $extra_arguments) : $extra_arguments) . ' ' . $test_run_request->test_profile->get_default_post_arguments());
$extra_runtime_variables = pts_tests::extra_environmental_variables($test_run_request->test_profile);
$extra_runtime_variables = pts_tests::extra_environment_variables($test_run_request->test_profile);
pts_triggered_system_events::pre_run_reboot_triggered_check($test_run_request->test_profile, $extra_runtime_variables);
@@ -298,7 +298,7 @@ class pts_test_execution
}
}
$test_process = proc_open($test_prepend . $to_exec . ' ' . $execute_binary_prepend . $execute_binary_prepend_final . $execute_binary . ' ' . $pts_test_arguments . $post_test_args, $descriptorspec, $pipes, $to_execute, array_merge($host_env, pts_client::environmental_variables(), $terv));
$test_process = proc_open($test_prepend . $to_exec . ' ' . $execute_binary_prepend . $execute_binary_prepend_final . $execute_binary . ' ' . $pts_test_arguments . $post_test_args, $descriptorspec, $pipes, $to_execute, array_merge($host_env, pts_client::environment_variables(), $terv));
if(is_resource($test_process))
{
@@ -658,7 +658,7 @@ class pts_test_execution
}
}
foreach(pts_client::environmental_variables() as $key => $value)
foreach(pts_client::environment_variables() as $key => $value)
{
if($value === null)
{

View File

@@ -681,7 +681,7 @@ class pts_test_run_manager
if($still_in_queue == false)
{
pts_client::remove_installed_test($this->get_test_to_run($this->test_run_pos)->test_profile);
pts_tests::remove_installed_test($this->get_test_to_run($this->test_run_pos)->test_profile);
}
}

View File

@@ -33,6 +33,10 @@ class pts_tests
{
self::$extra_env_vars = array();
}
public static function remove_installed_test(&$test_profile)
{
pts_file_io::delete($test_profile->get_install_dir(), null, true);
}
public static function installed_tests()
{
$cleaned_tests = array();
@@ -232,7 +236,7 @@ class pts_tests
return $reverse_dep_look_for_files;
}
public static function extra_environmental_variables(&$test_profile)
public static function extra_environment_variables(&$test_profile)
{
$extra_vars = array();
@@ -278,7 +282,7 @@ class pts_tests
}
public static function call_test_script($test_profile, $script_name, $print_string = null, $pass_argument = null, $extra_vars_append = null, $use_ctp = true, $no_prompts = false)
{
$extra_vars = pts_tests::extra_environmental_variables($test_profile);
$extra_vars = pts_tests::extra_environment_variables($test_profile);
if(isset($extra_vars_append['PATH']))
{
@@ -350,7 +354,7 @@ class pts_tests
$host_env = $_SERVER;
unset($host_env['argv']);
$descriptorspec = array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
$test_process = proc_open($sh . ' "' . $run_file . '" ' . $pass_argument . (phodevi::is_windows() && false ? '' : ' 2>&1'), $descriptorspec, $pipes, $test_directory, array_merge($host_env, pts_client::environmental_variables(), $extra_vars));
$test_process = proc_open($sh . ' "' . $run_file . '" ' . $pass_argument . (phodevi::is_windows() && false ? '' : ' 2>&1'), $descriptorspec, $pipes, $test_directory, array_merge($host_env, pts_client::environment_variables(), $extra_vars));
if(is_resource($test_process))
{

View File

@@ -79,7 +79,7 @@ abstract class phodevi_sensor
}
// Return array containing all the device name strings supported by the sensor.
// They can be passed in MONITOR environmental variable to create object
// They can be passed in MONITOR environment variable to create object
// responsible for monitoring specific device. You probably want to
// override this function if your sensor supports parametrization.
// It should return NULL on platforms where parameters are unsupported.

View File

@@ -441,6 +441,152 @@ class pts_svg_dom_gd
return $values;
}
public static function generate_result_file_graphs($test_results_identifier, $save_to_dir = false, $extra_attributes = null)
{
// Since dropping the old result viewer, this function is no longer used except for niche cases (debug render, PDF generation)
if($save_to_dir)
{
if(pts_file_io::mkdir($save_to_dir . '/result-graphs') == false)
{
// Don't delete old files now, in case any modules (e.g. FlameGrapher) output something in there ahead of time
/*// Directory must exist, so remove any old graph files first
foreach(pts_file_io::glob($save_to_dir . '/result-graphs/*') as $old_file)
{
unlink($old_file);
}*/
}
}
if($test_results_identifier instanceof pts_result_file)
{
$result_file = &$test_results_identifier;
}
else
{
$result_file = new pts_result_file($test_results_identifier);
}
$result_file->avoid_duplicate_identifiers();
$generated_graphs = array();
$generated_graph_tables = false;
// Render overview chart
if($save_to_dir)
{
$chart = new pts_ResultFileTable($result_file);
$chart->renderChart($save_to_dir . '/result-graphs/overview.BILDE_EXTENSION');
$intent = -1;
if(($intent = pts_result_file_analyzer::analyze_result_file_intent($result_file, $intent, true)) || $result_file->get_system_count() == 1)
{
$chart = new pts_ResultFileCompactSystemsTable($result_file, $intent);
}
else
{
$chart = new pts_ResultFileSystemsTable($result_file);
}
$chart->renderChart($save_to_dir . '/result-graphs/systems.BILDE_EXTENSION');
unset($chart);
if($intent && is_dir($result_file->get_system_log_dir()))
{
$chart = new pts_DetailedSystemComponentTable($result_file, $result_file->get_system_log_dir(), $intent);
if($chart)
{
$chart->renderChart($save_to_dir . '/result-graphs/detailed_component.BILDE_EXTENSION');
}
}
}
$result_objects = $result_file->get_result_objects();
$test_titles = array();
foreach($result_objects as &$result_object)
{
$test_titles[] = $result_object->test_profile->get_title();
}
$offset = 0;
foreach($result_objects as $key => &$result_object)
{
$save_to = $save_to_dir;
$offset++;
if($save_to_dir && is_dir($save_to_dir))
{
$save_to .= '/result-graphs/' . $offset . '.BILDE_EXTENSION';
if(PTS_IS_CLIENT)
{
if($result_file->is_multi_way_comparison(null, $extra_attributes))
{
$table_keys = array();
foreach($test_titles as $this_title_index => $this_title)
{
if(isset($test_titles[$key]) && $this_title == $test_titles[$key])
{
$table_keys[] = $this_title_index;
}
}
}
else
{
$table_keys = $key;
}
$chart = new pts_ResultFileTable($result_file, null, $table_keys);
$chart->renderChart($save_to_dir . '/result-graphs/' . $offset . '_table.BILDE_EXTENSION');
unset($chart);
$generated_graph_tables = true;
}
}
$graph = pts_render::render_graph($result_object, $result_file, $save_to, $extra_attributes);
if($graph == false)
{
continue;
}
$generated_graphs[] = $graph;
}
// Generate mini / overview graphs
if($save_to_dir)
{
$graph = new pts_OverviewGraph($result_file);
$rendered = $graph->renderGraph();
// Check to see if skip_graph was realized during the rendering process
if($rendered)
{
$graph->svg_dom->output($save_to_dir . '/result-graphs/visualize.BILDE_EXTENSION');
}
unset($graph);
if($result_file->get_system_count() == 2)
{
$graph = new pts_graph_run_vs_run($result_file);
}
else
{
$graph = new pts_graph_radar_chart($result_file);
}
$rendered = $graph->renderGraph();
// Check to see if skip_graph was realized during the rendering process
if($rendered)
{
$graph->svg_dom->output($save_to_dir . '/result-graphs/radar.BILDE_EXTENSION');
}
unset($graph);
}
return $generated_graphs;
}
}
?>

View File

@@ -30,7 +30,7 @@ error_reporting(E_ALL);
include('../../pts-core.php');
pts_core::init();
$environmental_variables = array(
$environment_variables = array(
'aid' => 'ACCOUNT_ID',
'sid' => 'SYSTEM_ID',
'bid' => 'BENCHMARK_TICKET_ID',
@@ -69,7 +69,7 @@ $environmental_variables = array(
'et' => 'ELAPSED_TIME',
);
foreach($environmental_variables as $get_var => $to_var)
foreach($environment_variables as $get_var => $to_var)
{
if(isset($_REQUEST[$get_var]) && !empty($_REQUEST[$get_var]))
{

View File

@@ -119,7 +119,7 @@ if(QUICK_START == false)
}
register_shutdown_function(array('pts_client', 'process_shutdown_tasks'));
//pcntl_signal(SIGTERM, array('pts_client', 'exit_client'));
//pcntl_signal(SIGTERM, ...
if(pts_env::read('PTS_IGNORE_MODULES') == false)
{