summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Larabel <michael@phx-laptop.(none)>2008-10-16 12:05:09 -0400
committerMichael Larabel <michael@phx-laptop.(none)>2008-10-16 12:05:09 -0400
commit0e0ff3d00bdb3f466af9b8183b2927fd9f5109f6 (patch)
tree615f18da1f66efb833b555c025e2c7816b233aa2
parentb85db9cb3decd1459c90bbc836b6b268d69de2fe (diff)
downloadphoronix-test-suite-upstream-0e0ff3d00bdb3f466af9b8183b2927fd9f5109f6.tar.gz
phoronix-test-suite-upstream-0e0ff3d00bdb3f466af9b8183b2927fd9f5109f6.tar.xz
phoronix-test-suite-upstream-0e0ff3d00bdb3f466af9b8183b2927fd9f5109f6.zip
pts-core: Clean / optimize pts-core code / run PEAR's PHP_CodeSniffer
and clean up most errors and warnings
-rw-r--r--CHANGE-LOG1
-rw-r--r--pts-core/functions/pts-functions-extra.php30
-rw-r--r--pts-core/functions/pts-functions-install.php112
-rw-r--r--pts-core/functions/pts-functions-merge.php12
-rw-r--r--pts-core/functions/pts-functions-run.php144
-rw-r--r--pts-core/functions/pts-functions-sctp.php6
-rw-r--r--pts-core/functions/pts-functions.php209
-rw-r--r--pts-core/functions/pts-functions_config.php60
-rw-r--r--pts-core/functions/pts-functions_modules.php84
-rw-r--r--pts-core/functions/pts-functions_system_cpu.php40
-rw-r--r--pts-core/functions/pts-functions_system_graphics.php128
-rw-r--r--pts-core/functions/pts-functions_system_hardware.php47
-rw-r--r--pts-core/functions/pts-functions_system_parsing.php110
-rw-r--r--pts-core/functions/pts-functions_system_software.php58
-rw-r--r--pts-core/functions/pts-functions_tests.php96
-rw-r--r--pts-core/functions/pts-functions_types.php74
-rw-r--r--pts-core/functions/pts-init.php64
-rw-r--r--pts-core/objects/pts_BarGraph.php16
-rw-r--r--pts-core/objects/pts_CustomGraph.php5
-rw-r--r--pts-core/objects/pts_Graph.php181
-rw-r--r--pts-core/objects/pts_LineGraph.php14
-rw-r--r--pts-core/objects/pts_MultiPassFailGraph.php22
-rw-r--r--pts-core/objects/pts_PassFailGraph.php12
-rw-r--r--pts-core/objects/pts_module.php55
-rw-r--r--pts-core/objects/pts_module_interface.php22
-rw-r--r--pts-core/objects/pts_module_option.php6
-rw-r--r--pts-core/objects/pts_test_tandem_XmlReader.php2
-rw-r--r--pts-core/objects/tandem_XmlReader.php62
-rw-r--r--pts-core/objects/tandem_XmlWriter.php46
-rw-r--r--pts-core/pts-run-cmd.php164
-rw-r--r--pts-core/pts-run-test.php63
31 files changed, 1672 insertions, 273 deletions
diff --git a/CHANGE-LOG b/CHANGE-LOG
index f9449e8..8f14cd8 100644
--- a/CHANGE-LOG
+++ b/CHANGE-LOG
@@ -5,6 +5,7 @@ September 13, 2008 (Hot-Fix Release)
- pts-core: Fix MD5 checksum regression
- pts-core: Add support for installing the Phoronix Certification & Qualification Suite once agreeing to the terms
+- pts-core: Clean / optimize pts-core code / run PEAR's PHP_CodeSniffer and clean up most errors and warnings
- pts: Fix a bug that caused unigine-tropics to fail with the data path
- pts: Move PCQS tests out of tree
- pts: Fix a bug that caused unigine-sanctuary to fail with the data path
diff --git a/pts-core/functions/pts-functions-extra.php b/pts-core/functions/pts-functions-extra.php
index b1fb441..aef3219 100644
--- a/pts-core/functions/pts-functions-extra.php
+++ b/pts-core/functions/pts-functions-extra.php
@@ -31,10 +31,14 @@ function pts_remove_saved_result($identifier)
@unlink(SAVE_RESULTS_DIR . $identifier . "/composite.xml");
foreach(glob(SAVE_RESULTS_DIR . $identifier . "/result-graphs/*.png") as $remove_file)
+ {
@unlink($remove_file);
+ }
foreach(glob(SAVE_RESULTS_DIR . $identifier . "/test-*.xml") as $remove_file)
+ {
@unlink($remove_file);
+ }
@unlink(SAVE_RESULTS_DIR . $identifier . "/pts-results-viewer.xsl");
@rmdir(SAVE_RESULTS_DIR . $identifier . "/result-graphs/");
@@ -54,12 +58,18 @@ function pts_print_format_tests($object, $steps = -1)
$tests_in_suite = array_unique($xml_parser->getXMLArrayValues(P_SUITE_TEST_NAME));
if($steps > 0)
+ {
asort($tests_in_suite);
+ }
if($steps == 0)
+ {
echo $object . "\n";
+ }
else
+ {
echo str_repeat(" ", $steps) . "+ " . $object . "\n";
+ }
foreach($tests_in_suite as $test)
{
@@ -67,7 +77,9 @@ function pts_print_format_tests($object, $steps = -1)
}
}
else
+ {
echo str_repeat(" ", $steps) . "* " . $object . "\n";
+ }
}
function pts_generate_download_cache()
{
@@ -79,7 +91,9 @@ function pts_generate_download_cache()
else
{
if(is_file(PTS_DOWNLOAD_CACHE_DIR . "make-cache-howto"))
+ {
unlink(PTS_DOWNLOAD_CACHE_DIR . "make-cache-howto");
+ }
}
$xml_writer = new tandem_XmlWriter();
@@ -103,7 +117,9 @@ function pts_generate_download_cache()
for($i = 0; $i < count($package_url); $i++)
{
if(empty($package_filename[$i]))
+ {
$package_filename[$i] = basename($package_url[$i]);
+ }
if(is_file(PTS_DOWNLOAD_CACHE_DIR . $package_filename[$i]) && (empty($package_md5[$i]) || md5_file(PTS_DOWNLOAD_CACHE_DIR . $package_filename[$i]) == $package_md5[$i]))
{
@@ -121,7 +137,9 @@ function pts_generate_download_cache()
echo "\tCaching: " . $package_filename[$i] . "\n";
if(copy(TEST_ENV_DIR . $test . "/" . $package_filename[$i], PTS_DOWNLOAD_CACHE_DIR . $package_filename[$i]))
+ {
$cached = true;
+ }
}
}
}
@@ -174,23 +192,35 @@ function pts_estimated_time_string($time)
$strlen_time = strlen($time);
if(strlen($time_trim = str_replace("~", "", $time)) != $strlen_time)
+ {
$formatted_string = "Approximately " . $time_trim;
+ }
else if(strlen($time_trim = str_replace(array('l'), '', $time)) != $strlen_time)
+ {
$formatted_string = "Less Than " . $time_trim;
+ }
else if(strlen($time_trim = str_replace(array('g'), '', $time)) != $strlen_time)
+ {
$formatted_string = "Greater Than " . $time_trim;
+ }
else if(strlen($time_trim = str_replace("-", ", ", $time)) != $strlen_time)
{
$time_trim = explode(",", $time_trim);
for($i = 0; $i < count($time_trim); $i++)
+ {
$time_trim[$i] = trim($time_trim[$i]);
+ }
if(count($time_trim) == 2)
+ {
$formatted_string = $time_trim[0] . " to " . $time_trim[1];
+ }
}
else
+ {
$formatted_string = $time;
+ }
$formatted_string .= " Minutes";
diff --git a/pts-core/functions/pts-functions-install.php b/pts-core/functions/pts-functions-install.php
index f4674f8..2169a68 100644
--- a/pts-core/functions/pts-functions-install.php
+++ b/pts-core/functions/pts-functions-install.php
@@ -28,31 +28,41 @@ function pts_start_install($TO_INSTALL)
}
else
{
- $tests = pts_contained_tests($TO_INSTALL, TRUE);
+ $tests = pts_contained_tests($TO_INSTALL, true);
if(count($tests) == 0)
{
$exit_message = "";
if(!getenv("SILENT_INSTALL"))
+ {
$exit_message = "\nNot recognized: $TO_INSTALL\n";
+ }
pts_exit($exit_message);
}
}
foreach($tests as $test)
+ {
pts_install_test($test);
+ }
}
function pts_start_install_dependencies($TO_INSTALL, &$PLACE_LIST)
{
if(IS_SCTP_MODE)
+ {
$tests = array($TO_INSTALL);
+ }
else
- $tests = pts_contained_tests($TO_INSTALL, TRUE);
+ {
+ $tests = pts_contained_tests($TO_INSTALL, true);
+ }
foreach($tests as $test)
+ {
pts_install_external_dependencies_list($test, $PLACE_LIST);
+ }
}
function pts_download_test_files($identifier)
{
@@ -67,7 +77,7 @@ function pts_download_test_files($identifier)
$package_architecture = $xml_parser->getXMLArrayValues(P_DOWNLOADS_PACKAGE_ARCHSPECIFIC);
$header_displayed = false;
- if(strpos(PTS_DOWNLOAD_CACHE_DIR, "://") > 0 && ($xml_dc_file = @file_get_contents(PTS_DOWNLOAD_CACHE_DIR . "pts-download-cache.xml")) != FALSE)
+ if(strpos(PTS_DOWNLOAD_CACHE_DIR, "://") > 0 && ($xml_dc_file = @file_get_contents(PTS_DOWNLOAD_CACHE_DIR . "pts-download-cache.xml")) != false)
{
$xml_dc_parser = new tandem_XmlReader($xml_dc_file);
$dc_file = $xml_dc_parser->getXMLArrayValues(P_CACHE_PACKAGE_FILENAME);
@@ -82,7 +92,9 @@ function pts_download_test_files($identifier)
for($i = 0; $i < count($package_url); $i++)
{
if(empty($package_filename[$i]))
+ {
$package_filename[$i] = basename($package_url[$i]);
+ }
$download_location = TEST_ENV_DIR . $identifier . "/";
@@ -93,25 +105,35 @@ function pts_download_test_files($identifier)
$platforms = explode(",", $package_platform[$i]);
foreach($platforms as $key => $value)
+ {
$platforms[$key] = trim($value);
+ }
if(!in_array(OPERATING_SYSTEM, $platforms))
+ {
$file_exempt = true;
+ }
}
if(!empty($package_architecture[$i]))
{
$architectures = explode(",", $package_architecture[$i]);
foreach($architectures as $key => $value)
+ {
$architectures[$key] = trim($value);
+ }
$this_arch = kernel_arch();
if(strlen($this_arch) > 3 && substr($this_arch, -2) == "86")
+ {
$this_arch = "x86";
+ }
if(!in_array($this_arch, $architectures))
+ {
$file_exempt = true;
+ }
}
if(!is_file($download_location . $package_filename[$i]) && !$file_exempt)
@@ -126,7 +148,7 @@ function pts_download_test_files($identifier)
if(ceil(disk_free_space(TEST_ENV_DIR) / 1048576) < $size)
{
echo pts_string_header("There is not enough space (at " . TEST_ENV_DIR . ") for this test.");
- return FALSE;
+ return false;
}
}
echo pts_string_header("Downloading Files For: " . $identifier . $download_append);
@@ -135,9 +157,13 @@ function pts_download_test_files($identifier)
}
if($package_url[$i] == $package_filename[$i])
+ {
$urls = array();
+ }
else
+ {
$urls = explode(",", $package_url[$i]);
+ }
if(count($dc_file) > 0 && count($dc_md5) > 0)
{
@@ -149,7 +175,9 @@ function pts_download_test_files($identifier)
echo pts_download(PTS_DOWNLOAD_CACHE_DIR . $package_filename[$i], $download_location);
if(!pts_validate_md5_download_file($download_location . $package_filename[$i] . ".temp", $package_md5[$i]))
+ {
@unlink($download_location . $package_filename[$i] . ".temp");
+ }
else
{
shell_exec("cd " . $download_location . " && mv " . $package_filename[$i] . ".temp " . $package_filename[$i]);
@@ -165,13 +193,17 @@ function pts_download_test_files($identifier)
echo "Copying Cached File: " . $package_filename[$i] . "\n";
if(copy(PTS_DOWNLOAD_CACHE_DIR . $package_filename[$i], $download_location . $package_filename[$i]))
+ {
$urls = array();
+ }
}
if(($c = count($urls)) > 0)
{
if($c > 1)
+ {
shuffle($urls);
+ }
$fail_count = 0;
$try_again = true;
@@ -195,9 +227,13 @@ function pts_download_test_files($identifier)
while(($mirror_choice < 1 || $mirror_choice > count($urls)) && !pts_is_valid_download_url($mirror_choice, $package_filename[$i]));
if(is_numeric($mirror_choice))
+ {
$url = $urls[($mirror_choice - 1)];
+ }
else
+ {
$url = $mirror_choice;
+ }
}
else
{
@@ -215,7 +251,9 @@ function pts_download_test_files($identifier)
if(!pts_validate_md5_download_file($download_location . $package_filename[$i] . ".temp", $package_md5[$i]))
{
if(is_file($download_location . $package_filename[$i] . ".temp"))
+ {
unlink($download_location . $package_filename[$i] . ".temp");
+ }
$file_downloaded = false;
$fail_count++;
@@ -236,16 +274,22 @@ function pts_download_test_files($identifier)
$try_again = pts_bool_question("Would you like to try downloading the file again (Y/n)?", true, "TRY_DOWNLOAD_AGAIN");
if($try_again)
+ {
array_push($urls, $url);
+ }
else
+ {
$try_again = false;
+ }
}
}
}
else
{
if(is_file($download_location . $package_filename[$i] . ".temp"))
+ {
shell_exec("cd " . $download_location . " && mv " . $package_filename[$i] . ".temp " . $package_filename[$i]);
+ }
$file_downloaded = true;
$fail_count = 0;
@@ -254,7 +298,7 @@ function pts_download_test_files($identifier)
if(!$try_again)
{
echo "\nDownload of Needed Test Dependencies Failed! Exiting.\n\n";
- return FALSE;
+ return false;
}
}
while(!$file_downloaded);
@@ -262,7 +306,7 @@ function pts_download_test_files($identifier)
}
}
}
- return TRUE;
+ return true;
}
function pts_local_download_test_files($identifier)
{
@@ -277,7 +321,9 @@ function pts_local_download_test_files($identifier)
for($i = 0; $i < count($package_url); $i++)
{
if(empty($package_filename[$i]))
+ {
$package_filename[$i] = basename($package_url[$i]);
+ }
array_push($downloaded_files, $package_filename[$i]);
}
@@ -317,7 +363,9 @@ function pts_validate_md5_download_file($filename, $verified_md5)
}
}
else if($real_md5 != $verified_md5)
+ {
$valid = false;
+ }
}
}
@@ -331,13 +379,17 @@ function pts_remove_local_download_test_files($identifier)
$file_location = TEST_ENV_DIR . $identifier . "/" . $test_file;
if(is_file($file_location))
+ {
@unlink($file_location);
+ }
}
}
function pts_install_test($identifier)
{
if(!is_test($identifier))
+ {
return;
+ }
// Install a test
$installed = false;
@@ -371,7 +423,9 @@ function pts_install_test($identifier)
$custom_validated_output = trim($custom_validated_output);
if(!pts_string_bool($custom_validated_output))
+ {
$installed = false;
+ }
}
else
{
@@ -384,24 +438,30 @@ function pts_install_test($identifier)
$total_download_size = pts_estimated_download_size($argv[1]);
if($total_download_size > 0 && is_suite($argv[1]))
+ {
echo pts_string_header("Total Estimated Download Size: " . $total_download_size . " MB");
+ }
}
define("PTS_TOTAL_SIZE_MSG", 1);
}
if(!is_dir(TEST_ENV_DIR))
+ {
mkdir(TEST_ENV_DIR);
+ }
if(!is_dir(TEST_ENV_DIR . $identifier))
+ {
mkdir(TEST_ENV_DIR . $identifier);
+ }
$download_test_files = pts_download_test_files($identifier);
- if($download_test_files == FALSE)
+ if($download_test_files == false)
{
echo "\nInstallation of " . $identifier . " test failed.\n";
- return FALSE;
+ return false;
}
if(is_file(pts_location_test_resources($identifier) . "install.sh") || is_file(pts_location_test_resources($identifier) . "install.php"))
@@ -410,14 +470,16 @@ function pts_install_test($identifier)
$install_header = "Installing Test: " . $identifier;
if(($size = pts_estimated_download_size($identifier)) > 0)
+ {
$install_header .= "\nEstimated Install Size: " . $size . " MB";
+ }
echo pts_string_header($install_header);
if(!empty($size) && ceil(disk_free_space(TEST_ENV_DIR) / 1048576) < $size)
{
echo "\nThere is not enough space (at " . TEST_ENV_DIR . ") for this test to be installed.\n";
- return FALSE;
+ return false;
}
$xml_parser = new pts_test_tandem_XmlReader(pts_location_test($identifier));
@@ -441,7 +503,9 @@ function pts_install_test($identifier)
pts_module_process("__post_test_install");
if(pts_string_bool(pts_read_user_config(P_OPTION_TEST_REMOVEDOWNLOADS, "FALSE")))
+ {
pts_remove_local_download_test_files($identifier); // Remove original downloaded files
+ }
}
else
{
@@ -454,7 +518,9 @@ function pts_install_test($identifier)
{
$installed = true;
if(!getenv("SILENT_INSTALL"))
+ {
echo "Already Installed: " . $identifier . "\n";
+ }
}
}
}
@@ -485,7 +551,9 @@ function pts_external_dependency_generic($Name)
if(pts_file_missing_check(explode(",", $file_check[$selection])))
{
if($PTS_MANUAL_SUPPORT == 0)
+ {
$PTS_MANUAL_SUPPORT = 1;
+ }
echo pts_string_header($title[$selection] . "\nPossible Package Names: " . $possible_packages[$selection]);
}
@@ -516,7 +584,9 @@ function pts_file_missing_check($file_arr)
$file[$i] = trim($file[$i]);
if(is_file($file[$i]) || is_dir($file[$i]) || is_link($file[$i]))
+ {
$file_is_there = true;
+ }
}
$file_missing = $file_missing || !$file_is_there;
}
@@ -526,8 +596,10 @@ function pts_file_missing_check($file_arr)
function pts_install_package_on_distribution($identifier)
{
// PTS External Dependencies install on distribution
- if(getenv("SILENT_INSTALL") == FALSE)
+ if(getenv("SILENT_INSTALL") == false)
+ {
echo "Checking For Needed External Dependencies.\n";
+ }
$identifier = strtolower($identifier);
$install_objects = array();
@@ -540,7 +612,9 @@ function pts_install_packages_on_distribution_process($install_objects)
if(!empty($install_objects))
{
if(is_array($install_objects))
+ {
$install_objects = implode(" ", $install_objects);
+ }
$distribution = pts_vendor_identifier();
@@ -549,21 +623,27 @@ function pts_install_packages_on_distribution_process($install_objects)
echo "\nThe following dependencies will be installed: \n";
foreach(explode(" ", $install_objects) as $obj)
+ {
echo "- " . $obj . "\n";
+ }
echo "\nThis process may take several minutes.\n";
echo shell_exec("cd " . SCRIPT_DISTRO_DIR . " && sh install-" . $distribution . "-packages.sh " . $install_objects);
}
else
+ {
echo "Distribution install script not found!";
+ }
}
}
function pts_install_external_dependencies_list($identifier, &$INSTALL_OBJ)
{
// Install from a list of external dependencies
if(!is_test($identifier))
+ {
return;
+ }
$xml_parser = new pts_test_tandem_XmlReader(pts_location_test($identifier));
$title = $xml_parser->getXMLValue(P_TEST_TITLE);
@@ -574,14 +654,18 @@ function pts_install_external_dependencies_list($identifier, &$INSTALL_OBJ)
$dependencies = explode(",", $dependencies);
for($i = 0; $i < count($dependencies); $i++)
+ {
$dependencies[$i] = trim($dependencies[$i]);
+ }
if(!defined("PTS_EXDEP_FIRST_RUN"))
{
array_push($dependencies, "php-extras");
if(kernel_arch() == "x86_64")
+ {
array_push($dependencies, "linux-32bit-libraries");
+ }
define("PTS_EXDEP_FIRST_RUN", 1);
}
@@ -595,7 +679,9 @@ function pts_install_external_dependencies_list($identifier, &$INSTALL_OBJ)
}
if(!empty($package_string))
+ {
echo "\nSome additional dependencies are required to run or more of these tests, and they could not be installed automatically for your distribution. Below are the software packages that must be installed for the test(s) to run properly.\n\n" . $package_string;
+ }
}
}
}
@@ -613,6 +699,7 @@ function pts_package_generic_to_distro_name(&$package_install_array, $generic_na
$file_check = $xml_parser->getXMLArrayValues(P_EXDEP_PACKAGE_FILECHECK);
for($i = 0; $i < count($generic_package); $i++)
+ {
if(!empty($generic_package[$i]) && in_array($generic_package[$i], $generic_names))
{
if(!in_array($distro_package[$i], $package_install_array))
@@ -623,12 +710,17 @@ function pts_package_generic_to_distro_name(&$package_install_array, $generic_na
$add_dependency = pts_file_missing_check($files);
}
else
+ {
$add_dependency = true;
+ }
if($add_dependency)
+ {
array_push($package_install_array, $distro_package[$i]);
+ }
}
}
+ }
$generated = true;
}
diff --git a/pts-core/functions/pts-functions-merge.php b/pts-core/functions/pts-functions-merge.php
index 3c83e12..09db138 100644
--- a/pts-core/functions/pts-functions-merge.php
+++ b/pts-core/functions/pts-functions-merge.php
@@ -141,7 +141,9 @@ function pts_merge_test_results($OLD_RESULTS, $NEW_RESULTS)
else
{
if(!pts_version_comparable($original_pts_version[0], $new_pts_version[0]))
+ {
echo pts_string_header("PTS Versions Do Not Match! For accurate results, you should only test against the same version!");
+ }
for($i = 0; $i < count($original_system_hardware); $i++)
{
@@ -299,12 +301,18 @@ function pts_merge_batch_tests_to_line_comparison($RESULT)
// Some other work
if(!empty($suite_properties))
+ {
$suite_properties = explode(";", $suite_properties);
+ }
else
+ {
$suite_properties = array();
+ }
if(!in_array("BATCH_LINE_ANALYSIS", $suite_properties)) // analysis type
+ {
array_push($suite_properties, "BATCH_LINE_ANALYSIS");
+ }
// Write the new merge
@@ -355,11 +363,13 @@ function pts_merge_batch_tests_to_line_comparison($RESULT)
$removed = false;
for($j = 0; $j < count($r_n_test_attributes) && !$removed; $j++)
+ {
if($r_o_test_attributes[$i] == $r_n_test_attributes[$j])
{
unset($r_n_test_attributes[$j]);
$removed = true;
}
+ }
unset($r_o_test_attributes[$i]);
}
@@ -378,7 +388,9 @@ function pts_merge_batch_tests_to_line_comparison($RESULT)
$similar_attributes_text = trim($r_o_test_attributes_1[0]) . " Analysis";
if(!empty($similar_attributes_text_add))
+ {
$similar_attributes_text .= " [" . $similar_attributes_text_add . "]";
+ }
}
$USE_ID = pts_request_new_id();
diff --git a/pts-core/functions/pts-functions-run.php b/pts-core/functions/pts-functions-run.php
index f0555b5..15e7a85 100644
--- a/pts-core/functions/pts-functions-run.php
+++ b/pts-core/functions/pts-functions-run.php
@@ -36,10 +36,14 @@ function pts_prompt_results_identifier($current_identifiers = null)
if(is_array($identifier))
{
foreach($identifier as $identifier_2)
+ {
array_push($show_identifiers, $identifier_2);
+ }
}
else
+ {
array_push($show_identifiers, $identifier);
+ }
}
$show_identifiers = array_unique($show_identifiers);
@@ -47,14 +51,16 @@ function pts_prompt_results_identifier($current_identifiers = null)
echo "\nCurrent Test Identifiers:\n";
foreach($show_identifiers as $identifier)
+ {
echo "- " . $identifier . "\n";
+ }
echo "\n";
}
$times_tried = 0;
do
{
- if($times_tried == 0 && ($env_identifier = getenv("TEST_RESULTS_IDENTIFIER")) != FALSE)
+ if($times_tried == 0 && ($env_identifier = getenv("TEST_RESULTS_IDENTIFIER")) != false)
{
$RESULTS_IDENTIFIER = $env_identifier;
echo "Test Identifier: " . $RESULTS_IDENTIFIER . "\n";
@@ -70,21 +76,29 @@ function pts_prompt_results_identifier($current_identifiers = null)
}
if(empty($RESULTS_IDENTIFIER))
+ {
$RESULTS_IDENTIFIER = date("Y-m-d H:i");
+ }
else
+ {
$RESULTS_IDENTIFIER = pts_swap_user_variables($RESULTS_IDENTIFIER);
+ }
if(!defined("TEST_RESULTS_IDENTIFIER"))
+ {
define("TEST_RESULTS_IDENTIFIER", $RESULTS_IDENTIFIER);
+ }
return $RESULTS_IDENTIFIER;
}
function pts_swap_user_variables($user_str)
{
- if(strpos($user_str, "$") !== FALSE)
+ if(strpos($user_str, "$") !== false)
{
foreach(pts_user_runtime_variables() as $key => $value)
+ {
$user_str = str_replace("$" . $key, $value, $user_str);
+ }
}
return $user_str;
@@ -92,7 +106,7 @@ function pts_swap_user_variables($user_str)
function pts_prompt_save_file_name($check_env = true)
{
// Prompt to save a file when running a test
- if($check_env && ($save_name = getenv("TEST_RESULTS_NAME")) != FALSE)
+ if($check_env && ($save_name = getenv("TEST_RESULTS_NAME")) != false)
{
$CUSTOM_TITLE = $save_name;
$PROPOSED_FILE_NAME = pts_input_string_to_identifier($save_name);
@@ -118,12 +132,16 @@ function pts_prompt_save_file_name($check_env = true)
$PROPOSED_FILE_NAME = pts_input_string_to_identifier($PROPOSED_FILE_NAME);
if(is_test($PROPOSED_FILE_NAME) || is_suite($PROPOSED_FILE_NAME))
+ {
$is_reserved_word = true;
+ }
}
while(empty($PROPOSED_FILE_NAME) || $is_reserved_word);
}
else
+ {
$PROPOSED_FILE_NAME = "";
+ }
}
if(!isset($PROPOSED_FILE_NAME) || empty($PROPOSED_FILE_NAME))
@@ -150,7 +168,9 @@ function pts_promt_user_tags($default_tags = "")
if(empty($tags_input))
{
if(!is_array($default_tags) && !empty($default_tags))
+ {
$default_tags = array($default_tags);
+ }
$tags_input = pts_global_auto_tags($default_tags);
}
@@ -183,7 +203,9 @@ function pts_generate_test_notes($test_type)
$virtualized = system_virtualized_mode();
if(!empty($virtualized))
+ {
$test_notes .= " \n" . $virtualized;
+ }
if($test_type == "Graphics" || $test_type == "System")
{
@@ -191,9 +213,13 @@ function pts_generate_test_notes($test_type)
$af_level = graphics_anisotropic_level();
if(!empty($aa_level))
+ {
$test_notes .= " \nAntialiasing: $aa_level.";
+ }
if(!empty($af_level))
+ {
$test_notes .= " \nAnisotropic Filtering: $af_level.";
+ }
}
return $test_notes;
@@ -216,12 +242,16 @@ function pts_verify_test_installation($TO_RUN)
if(!is_file(TEST_ENV_DIR . $test . "/pts-install.xml"))
{
if(!pts_test_architecture_supported($test) || !pts_test_platform_supported($test))
+ {
array_push($needs_installing, $test);
+ }
}
else
{
if(!defined("TEST_INSTALL_PASS"))
+ {
define("TEST_INSTALL_PASS", true);
+ }
}
}
@@ -237,15 +267,19 @@ function pts_verify_test_installation($TO_RUN)
{
$message = "Multiple tests need to be installed before proceeding:\n\n";
foreach($needs_installing as $single_package)
+ {
$message .= "- " . $single_package . "\n";
+ }
$message .= "\nTo install these tests, run: phoronix-test-suite install " . $TO_RUN;
echo pts_string_header($message);
}
- if(!defined("TEST_INSTALL_PASS") || getenv("SILENT_INSTALL") == FALSE)
+ if(!defined("TEST_INSTALL_PASS") || getenv("SILENT_INSTALL") == false)
+ {
pts_exit();
+ }
}
}
function pts_recurse_call_tests($tests_to_run, $arguments_array, $save_results = false, &$tandem_xml = "", $results_identifier = "", $arguments_description = "")
@@ -276,10 +310,14 @@ function pts_recurse_call_tests($tests_to_run, $arguments_array, $save_results =
// test_result[0] == the main result
if($save_results && count($test_result) > 0 && ((is_numeric($test_result[0]) && $test_result[0] > 0) || (!is_numeric($test_result[0]) && strlen($test_result[0]) > 2)))
+ {
pts_record_test_result($tandem_xml, $tests_to_run[$i], $arguments_array[$i], $results_identifier, $test_result, $arguments_description[$i], pts_request_new_id());
+ }
if($i != (count($tests_to_run) - 1))
+ {
sleep(pts_read_user_config(P_OPTION_TEST_SLEEPTIME, 5));
+ }
}
}
}
@@ -302,28 +340,46 @@ function pts_record_test_result(&$tandem_xml, $test, $arguments, $identifier, $r
$default_test_descriptor = $xml_parser->getXMLValue(P_TEST_SUBTITLE);
if(!empty($default_test_descriptor))
+ {
$description = $default_test_descriptor;
+ }
else if(is_file(TEST_ENV_DIR . $test . "/pts-test-description"))
+ {
$description = @file_get_contents(TEST_ENV_DIR . $test . "/pts-test-description");
+ }
else
+ {
$description = "Phoronix Test Suite v" . PTS_VERSION;
+ }
}
if(empty($test_version) && is_file(TEST_ENV_DIR . $test . "/pts-test-version"))
+ {
$test_version = @file_get_contents(TEST_ENV_DIR . $test . "/pts-test-version");
+ }
if(empty($result_scale) && is_file(TEST_ENV_DIR . $test . "/pts-results-scale"))
+ {
$result_scale = trim(@file_get_contents(TEST_ENV_DIR . $test . "/pts-results-scale"));
+ }
if(empty($result_format))
+ {
$result_format = "BAR_GRAPH";
+ }
unset($xml_parser);
$pts_vars = pts_env_variables();
foreach($pts_vars as $key => $value)
+ {
$description = str_replace("$" . $key, $value, $description);
+ }
foreach($pts_vars as $key => $value)
+ {
if($key != "VIDEO_MEMORY" && $key != "NUM_CPU_CORES" && $key != "NUM_CPU_JOBS")
+ {
$arguments = str_replace("$" . $key, $value, $arguments);
+ }
+ }
$tandem_xml->addXmlObject(P_RESULTS_TEST_TITLE, $tandem_id, $test_title);
$tandem_xml->addXmlObject(P_RESULTS_TEST_VERSION, $tandem_id, $test_version);
@@ -344,16 +400,24 @@ function pts_save_test_file($PROPOSED_FILE_NAME, &$RESULTS = null, $RAW_TEXT = n
// Save the test file
$j = 1;
while(is_file(SAVE_RESULTS_DIR . $PROPOSED_FILE_NAME . "/test-" . $j . ".xml"))
+ {
$j++;
+ }
$REAL_FILE_NAME = $PROPOSED_FILE_NAME . "/test-" . $j . ".xml";
if($RESULTS != null)
+ {
$R_FILE = $RESULTS->getXML();
+ }
else if($RAW_TEXT != null)
+ {
$R_FILE = $RAW_TEXT;
+ }
else
+ {
return false;
+ }
pts_save_result($REAL_FILE_NAME, $R_FILE);
@@ -397,30 +461,42 @@ function pts_run_test($test_identifier, $extra_arguments = "", $arguments_descri
$default_arguments = $xml_parser->getXMLValue(P_TEST_DEFAULTARGUMENTS);
$test_type = $xml_parser->getXMLValue(P_TEST_HARDWARE_TYPE);
- if(($test_type == "Graphics" && getenv("DISPLAY") == FALSE) || getenv("NO_" . strtoupper($test_type) . "_TESTS") != FALSE)
+ if(($test_type == "Graphics" && getenv("DISPLAY") == false) || getenv("NO_" . strtoupper($test_type) . "_TESTS") != false)
+ {
return array(0);
+ }
if(empty($times_to_run) || !is_int($times_to_run))
+ {
$times_to_run = 3;
+ }
if(strlen($result_format) > 6 && substr($result_format, 0, 6) == "MULTI_") // Currently tests that output multiple results in one run can only be run once
+ {
$times_to_run = 1;
+ }
if(empty($execute_binary))
+ {
$execute_binary = $test_identifier;
+ }
if(!empty($test_type))
{
$test_name = "TEST_" . strtoupper($test_type);
if(!defined($test_name))
+ {
define($test_name, 1);
+ }
}
if(empty($result_quantifier))
{
if(is_file($test_directory . "pts-result-quantifier"))
+ {
$result_quantifier = @trim(file_get_contents($test_directory . "pts-result-quantifier"));
+ }
}
if(is_file($test_directory . $execute_binary) || is_link($test_directory . $execute_binary))
@@ -433,8 +509,10 @@ function pts_run_test($test_identifier, $extra_arguments = "", $arguments_descri
{
$execute_path_check = trim($execute_path_check);
- if(is_file($execute_path_check . $execute_binary) || is_link($execute_path_check . $execute_binary))
+ if(is_file($execute_path_check . $execute_binary) || is_link($execute_path_check . $execute_binary))
+ {
$to_execute = $execute_path_check;
+ }
}
}
@@ -486,7 +564,9 @@ function pts_run_test($test_identifier, $extra_arguments = "", $arguments_descri
echo $test_results = pts_exec("cd " . $to_execute . " && ./" . $execute_binary . " " . $pts_test_arguments, $test_extra_runtime_variables);
if(is_file($benchmark_log_file) && trim($test_results) == "")
+ {
echo file_get_contents($benchmark_log_file);
+ }
if(!($i == 0 && pts_string_bool($ignore_first_run) && $times_to_run > 1))
{
@@ -497,7 +577,9 @@ function pts_run_test($test_identifier, $extra_arguments = "", $arguments_descri
unlink(TEST_ENV_DIR . $test_identifier . "/pts-timer");
if(is_numeric($run_time))
+ {
$test_extra_runtime_variables_post = array_merge($test_extra_runtime_variables_post, array("TIMER_RESULT" => $run_time));
+ }
}
if(is_file($benchmark_log_file))
{
@@ -513,7 +595,9 @@ function pts_run_test($test_identifier, $extra_arguments = "", $arguments_descri
$test_results = pts_exec("cd " . $test_directory . " && sh " . pts_location_test_resources($test_identifier) . "parse-results.sh \"" . $test_results . "\"", $test_extra_runtime_variables_post);
}
else if(isset($run_time) && is_numeric($run_time))
+ {
$test_results = $run_time;
+ }
if(!empty($test_results))
{
@@ -528,11 +612,11 @@ function pts_run_test($test_identifier, $extra_arguments = "", $arguments_descri
if(is_file($benchmark_log_file))
{
- if(defined("TEST_RESULTS_IDENTIFIER") && (pts_string_bool(pts_read_user_config(P_OPTION_LOG_BENCHMARKFILES, "FALSE")) || (defined("IS_PCQS_MODE") && IS_PCQS_MODE) || getenv("SAVE_BENCHMARK_LOGS") != FALSE))
+ if(defined("TEST_RESULTS_IDENTIFIER") && (pts_string_bool(pts_read_user_config(P_OPTION_LOG_BENCHMARKFILES, "FALSE")) || (defined("IS_PCQS_MODE") && IS_PCQS_MODE) || getenv("SAVE_BENCHMARK_LOGS") != false))
{
$backup_log_dir = SAVE_RESULTS_DIR . SAVE_FILE_NAME . "/benchmark-logs/" . TEST_RESULTS_IDENTIFIER . "/";
$backup_filename = basename($benchmark_log_file);
- @mkdir($backup_log_dir, 0777, TRUE);
+ @mkdir($backup_log_dir, 0777, true);
@copy($benchmark_log_file, $backup_log_dir . $backup_filename);
}
@@ -553,16 +637,22 @@ function pts_run_test($test_identifier, $extra_arguments = "", $arguments_descri
$time_test_end = time();
if(empty($result_scale) && is_file($test_directory . "pts-results-scale"))
+ {
$result_scale = trim(@file_get_contents($test_directory . "pts-results-scale"));
+ }
foreach(pts_env_variables() as $key => $value)
+ {
$arguments_description = str_replace("$" . $key, $value, $arguments_description);
+ }
$RETURN_STRING = $test_title . ":\n";
$RETURN_STRING .= $arguments_description . "\n";
if(!empty($arguments_description))
+ {
$RETURN_STRING .= "\n";
+ }
if($result_format == "PASS_FAIL" || $result_format == "MULTI_PASS_FAIL")
{
@@ -571,7 +661,9 @@ function pts_run_test($test_identifier, $extra_arguments = "", $arguments_descri
$i = 1;
if(count($TEST_RESULTS_ARRAY) == 1)
+ {
$END_RESULT = $TEST_RESULTS_ARRAY[0];
+ }
else
{
foreach($TEST_RESULTS_ARRAY as $result)
@@ -617,7 +709,9 @@ function pts_run_test($test_identifier, $extra_arguments = "", $arguments_descri
foreach($TEST_RESULTS_ARRAY as $result)
{
if($result > $max_value)
+ {
$max_value = $result;
+ }
$RETURN_STRING .= $result . " " . $result_scale . "\n";
}
@@ -630,7 +724,9 @@ function pts_run_test($test_identifier, $extra_arguments = "", $arguments_descri
foreach($TEST_RESULTS_ARRAY as $result)
{
if($result < $min_value)
+ {
$min_value = $result;
+ }
$RETURN_STRING .= $result . " " . $result_scale . "\n";
}
@@ -648,16 +744,22 @@ function pts_run_test($test_identifier, $extra_arguments = "", $arguments_descri
}
if(count($TEST_RESULTS_ARRAY) > 0)
+ {
$END_RESULT = pts_trim_double($TOTAL_RESULT / count($TEST_RESULTS_ARRAY), 2);
+ }
else
+ {
$END_RESULT = pts_trim_double($TOTAL_RESULT, 2);
+ }
$RETURN_STRING .= "\nAverage: " . $END_RESULT . " " . $result_scale;
}
}
if(!isset($GLOBALS["TEST_RESULTS_TEXT"]))
+ {
$GLOBALS["TEST_RESULTS_TEXT"] = "";
+ }
if(!empty($RETURN_STRING))
{
@@ -665,7 +767,9 @@ function pts_run_test($test_identifier, $extra_arguments = "", $arguments_descri
$GLOBALS["TEST_RESULTS_TEXT"] .= $this_result;
}
else
+ {
echo "\n\n";
+ }
pts_user_message($post_run_message);
@@ -676,14 +780,18 @@ function pts_run_test($test_identifier, $extra_arguments = "", $arguments_descri
// 0 = main end result
return array($END_RESULT);
}
-function pts_global_auto_tags($extra_attr = NULL)
+function pts_global_auto_tags($extra_attr = null)
{
// Generate automatic tags for the system, used for Phoronix Global
$tags_array = array();
if(!empty($extra_attr) && is_array($extra_attr))
+ {
foreach($extra_attr as $attribute)
+ {
array_push($tags_array, $attribute);
+ }
+ }
switch(cpu_core_count())
{
@@ -703,24 +811,38 @@ function pts_global_auto_tags($extra_attr = NULL)
$cpu_type = processor_string();
if(strpos($cpu_type, "Intel") !== false)
+ {
array_push($tags_array, "Intel");
+ }
else if(strpos($cpu_type, "AMD") !== false)
+ {
array_push($tags_array, "AMD");
+ }
else if(strpos($cpu_type, "VIA") !== false)
+ {
array_push($tags_array, "VIA");
+ }
$gpu_type = graphics_processor_string();
if(strpos($cpu_type, "ATI") !== false)
+ {
array_push($tags_array, "ATI");
+ }
else if(strpos($cpu_type, "NVIDIA") !== false)
+ {
array_push($tags_array, "NVIDIA");
+ }
if(kernel_arch() == "x86_64")
+ {
array_push($tags_array, "64-bit Linux");
+ }
$os = operating_system_release();
if($os != "Unknown")
+ {
array_push($tags_array, $os);
+ }
return implode(", ", $tags_array);
}
@@ -738,7 +860,9 @@ function pts_all_combos(&$return_arr, $current_string, $options, $counter, $deli
$new_current_string = $current_string;
if(strlen($new_current_string) > 0)
+ {
$new_current_string .= $delimiter;
+ }
$new_current_string .= $single_option;
@@ -798,7 +922,9 @@ function pts_test_options($identifier)
$prefix = $settings_argument_prefix[$option_count];
if(empty($prefix)) // Backwards compatibility
+ {
$prefix = $settings_argument[$option_count]; // Drop this when ArgumentName has been removed from PTS entirely
+ }
$user_option->set_option_prefix($prefix);
$user_option->set_option_postfix($settings_argument_postfix[$option_count]);
diff --git a/pts-core/functions/pts-functions-sctp.php b/pts-core/functions/pts-functions-sctp.php
index f7d7256..cdbadf3 100644
--- a/pts-core/functions/pts-functions-sctp.php
+++ b/pts-core/functions/pts-functions-sctp.php
@@ -35,12 +35,18 @@ function generate_sctp_layer()
$test_directory = sctp_test_directory();
if(!$xml_parser->isDefined(P_TEST_TITLE))
+ {
pts_exit("\n" . SCTP_FILE . " is not a valid self-contained test profile!\n");
+ }
if(!is_dir(PTS_TEMP_DIR . "sctp/"))
+ {
mkdir(PTS_TEMP_DIR . "sctp/");
+ }
if(!is_dir($test_directory))
+ {
mkdir($test_directory);
+ }
$sctp_stages = array("install" => P_TEST_SCTP_INSTALLSCRIPT, "downloads" => P_TEST_SCTP_DOWNLOADS, "parse-results" => P_TEST_SCTP_RESULTSPARSER, "pre" => P_TEST_SCTP_PRERUN, "post" => P_TEST_SCTP_POSTRUN);
foreach($sctp_stages as $stage_file => $stage_point)
diff --git a/pts-core/functions/pts-functions.php b/pts-core/functions/pts-functions.php
index 95519bb..9d31317 100644
--- a/pts-core/functions/pts-functions.php
+++ b/pts-core/functions/pts-functions.php
@@ -34,7 +34,9 @@ require_once("pts-core/functions/pts-functions_types.php");
require_once("pts-core/functions/pts-functions_modules.php");
if(IS_SCTP_MODE)
- require_once("pts-core/functions/pts-functions-sctp.php");
+{
+ include_once("pts-core/functions/pts-functions-sctp.php");
+}
// User's home directory for storing results, module files, test installations, etc.
define("PTS_USER_DIR", pts_user_home() . ".phoronix-test-suite/");
@@ -78,14 +80,18 @@ $PTS_GLOBAL_ID = 1;
// PTS Modules Support
if(function_exists("pts_module_start_process"))
+{
pts_module_start_process();
+}
// Phoronix Test Suite - Functions
function pts_copy($from, $to)
{
// Copies a file
if(!is_file($to) || md5_file($from) != md5_file($to))
+ {
copy($from, $to);
+ }
}
function pts_gd_available()
{
@@ -101,14 +107,16 @@ function pts_gd_available()
$gd_available = false;
}
else
+ {
$gd_available = true;
+ }
return $gd_available;
}
function pts_save_result($save_to = null, $save_results = null)
{
// Saves PTS result file
- if(strpos($save_to, ".xml") === FALSE)
+ if(strpos($save_to, ".xml") === false)
{
$save_to .= ".xml";
}
@@ -116,9 +124,13 @@ function pts_save_result($save_to = null, $save_results = null)
$save_to_dir = dirname(SAVE_RESULTS_DIR . $save_to);
if(!is_dir(SAVE_RESULTS_DIR))
+ {
mkdir(SAVE_RESULTS_DIR);
+ }
if($save_to_dir != '.' && !is_dir($save_to_dir))
+ {
mkdir($save_to_dir);
+ }
if(!is_dir(SAVE_RESULTS_DIR . "pts-results-viewer"))
{
@@ -131,7 +143,9 @@ function pts_save_result($save_to = null, $save_results = null)
pts_copy(RESULTS_VIEWER_DIR . "pts-logo.png", SAVE_RESULTS_DIR . "pts-results-viewer/pts-logo.png");
if($save_to == null || $save_results == null)
+ {
$bool = true;
+ }
else
{
$save_name = basename($save_to, ".xml");
@@ -167,18 +181,28 @@ function pts_save_result($save_to = null, $save_results = null)
for($i = 0; $i < count($results_name); $i++)
{
if(strlen($results_version[$i]) > 2)
+ {
$results_name[$i] .= " v" . $results_version[$i];
+ }
if($results_result_format[$i] == "LINE_GRAPH")
+ {
$t = new pts_LineGraph($results_name[$i], $results_attributes[$i], $results_scale[$i]);
+ }
else if($results_result_format[$i] == "PASS_FAIL")
+ {
$t = new pts_PassFailGraph($results_name[$i], $results_attributes[$i], $results_scale[$i]);
+ }
else if($results_result_format[$i] == "MULTI_PASS_FAIL")
+ {
$t = new pts_MultiPassFailGraph($results_name[$i], $results_attributes[$i], $results_scale[$i]);
+ }
else
+ {
$t = new pts_BarGraph($results_name[$i], $results_attributes[$i], $results_scale[$i]);
+ }
- if(pts_gd_available() && getenv("SVG_DEBUG") == FALSE)
+ if(pts_gd_available() && getenv("SVG_DEBUG") == false)
{
// Render to PNG
$t->setRenderer("PNG");
@@ -212,33 +236,43 @@ function pts_save_result($save_to = null, $save_results = null)
}
$bool = file_put_contents(SAVE_RESULTS_DIR . $save_to, $save_results);
- if(defined("TEST_RESULTS_IDENTIFIER") && (pts_string_bool(pts_read_user_config(P_OPTION_LOG_VSYSDETAILS, "TRUE")) || (defined("IS_PCQS_MODE") && IS_PCQS_MODE) || getenv("SAVE_SYSTEM_DETAILS") != FALSE))
+ if(defined("TEST_RESULTS_IDENTIFIER") && (pts_string_bool(pts_read_user_config(P_OPTION_LOG_VSYSDETAILS, "TRUE")) || (defined("IS_PCQS_MODE") && IS_PCQS_MODE) || getenv("SAVE_SYSTEM_DETAILS") != false))
{
// Save verbose system information here
if(!is_dir($save_to_dir . "/system-details/"))
+ {
mkdir($save_to_dir . "/system-details/");
+ }
if(!is_dir($save_to_dir . "/system-details/" . TEST_RESULTS_IDENTIFIER))
+ {
mkdir($save_to_dir . "/system-details/" . TEST_RESULTS_IDENTIFIER);
+ }
// lspci
$file = shell_exec("lspci 2>&1");
- if(strpos($file, "not found") == FALSE)
+ if(strpos($file, "not found") == false)
+ {
@file_put_contents($save_to_dir . "/system-details/" . TEST_RESULTS_IDENTIFIER . "/lspci", $file);
+ }
// sensors
$file = shell_exec("sensors 2>&1");
- if(strpos($file, "not found") == FALSE)
+ if(strpos($file, "not found") == false)
+ {
@file_put_contents($save_to_dir . "/system-details/" . TEST_RESULTS_IDENTIFIER . "/sensors", $file);
+ }
if(IS_MACOSX)
{
// system_profiler (Mac OS X)
$file = shell_exec("system_profiler 2>&1");
- if(strpos($file, "not found") == FALSE)
+ if(strpos($file, "not found") == false)
+ {
@file_put_contents($save_to_dir . "/system-details/" . TEST_RESULTS_IDENTIFIER . "/system_profiler", $file);
+ }
}
// cpuinfo
@@ -257,17 +291,20 @@ function pts_process_register($process)
{
// Register a process as active
if(!is_dir(TEST_ENV_DIR))
+ {
mkdir(TEST_ENV_DIR);
+ }
if(!is_dir(TEST_ENV_DIR . ".processes"))
+ {
mkdir(TEST_ENV_DIR . ".processes");
+ }
return file_put_contents(TEST_ENV_DIR . ".processes/" . $process . ".p", getmypid());
}
function pts_process_remove($process)
{
// Remove a process from being active, if present
- if(is_file(TEST_ENV_DIR . ".processes/" . $process . ".p"))
- return @unlink(TEST_ENV_DIR . ".processes/" . $process . ".p");
+ return is_file(TEST_ENV_DIR . ".processes/" . $process . ".p") && @unlink(TEST_ENV_DIR . ".processes/" . $process . ".p");
}
function pts_process_active($process)
{
@@ -279,27 +316,41 @@ function pts_process_active($process)
$ps = trim(shell_exec("ps -p $pid 2>&1"));
if(strpos($ps, "php") > 0)
+ {
$active = true;
+ }
else
+ {
pts_process_remove($process);
+ }
}
return $active;
}
-function display_web_browser($URL, $alt_text = NULL, $default_open = FALSE)
+function display_web_browser($URL, $alt_text = null, $default_open = false)
{
// Launch the web browser
- if($alt_text == NULL)
+ if($alt_text == null)
+ {
$text = "Do you want to view the results in your web browser";
+ }
else
+ {
$text = $alt_text;
+ }
if(!$default_open)
+ {
$view_results = pts_bool_question($text . " (y/N)?", false, "OPEN_BROWSER");
+ }
else
+ {
$view_results = pts_bool_question($text . " (Y/n)?", true, "OPEN_BROWSER");
+ }
if($view_results)
+ {
shell_exec("sh pts-core/scripts/launch-browser.sh \"" . $URL . "\" 2>&1");
+ }
}
function pts_env_variables()
{
@@ -368,11 +419,11 @@ function pts_user_runtime_variables()
function pts_input_correct_results_path($path)
{
// Correct an input path for an XML file
- if(strpos($path, "/") === FALSE)
+ if(strpos($path, "/") === false)
{
$path = SAVE_RESULTS_DIR . $path;
}
- if(strpos($path, ".xml") === FALSE)
+ if(strpos($path, ".xml") === false)
{
$path = $path . ".xml";
}
@@ -384,9 +435,13 @@ function pts_variables_export_string($vars = null)
$return_string = "";
if($vars == null)
+ {
$vars = pts_env_variables();
+ }
else
+ {
$vars = array_merge(pts_env_variables(), $vars);
+ }
foreach($vars as $name => $var)
{
@@ -403,14 +458,22 @@ function pts_run_additional_vars($identifier)
$ctp_extension_string = "";
$extends = pts_test_extends_below($identifier);
foreach($extends as $extended_test)
+ {
if(is_dir(TEST_ENV_DIR . $extended_test . "/"))
+ {
$ctp_extension_string .= TEST_ENV_DIR . $extended_test . ":";
+ }
+ }
if(!empty($ctp_extension_string))
+ {
$extra_vars["PATH"] = $ctp_extension_string . "\$PATH";
+ }
if(count($extends) > 0)
+ {
$extra_vars["TEST_EXTENDS"] = TEST_ENV_DIR . $extends[0];
+ }
return $extra_vars;
}
@@ -435,7 +498,9 @@ function pts_global_upload_result($result_file, $tags = "")
$switch_tags = array("Benchmark>" => "B>", "Results>" => "R>", "Group>" => "G>", "Entry>" => "E>", "Identifier>" => "I>", "Value>" => "V>", "System>" => "S>", "Attributes>" => "A>");
foreach($switch_tags as $f => $t)
+ {
$test_results = str_replace($f, $t, $test_results);
+ }
$ToUpload = base64_encode($test_results);
$GlobalUser = pts_current_user();
@@ -449,11 +514,13 @@ function pts_global_upload_result($result_file, $tags = "")
$http_parameters = array("http" => array("method" => "POST", "content" => $upload_data));
$stream_context = stream_context_create($http_parameters);
- $opened_url = @fopen("http://www.phoronix-test-suite.com/global/user-upload.php", "rb", FALSE, $stream_context);
+ $opened_url = @fopen("http://www.phoronix-test-suite.com/global/user-upload.php", "rb", false, $stream_context);
$response = @stream_get_contents($opened_url);
if($response !== false)
+ {
$return_stream = $response;
+ }
return $return_stream;
}
@@ -473,10 +540,14 @@ function pts_global_valid_id_string($global_id)
$is_valid = true;
if(count(explode("-", $global_id)) < 3) // Global IDs should have three (or more) dashes
+ {
$is_valid = false;
+ }
- if(strlen($global_id) < 13) // Shorted Possible ID would be X-000-000-000
+ if(strlen($global_id) < 13) // Shortest Possible ID would be X-000-000-000
+ {
$is_valid = false;
+ }
return $is_valid;
}
@@ -486,22 +557,32 @@ function pts_trim_double($double, $accuracy = 2)
$return = explode(".", $double);
if(count($return) == 1)
+ {
$return[1] = "00";
+ }
if(count($return) == 2 && $accuracy > 0)
{
$strlen = strlen($return[1]);
if($strlen > $accuracy)
+ {
$return[1] = substr($return[1], 0, $accuracy);
+ }
else if($strlen < $accuracy)
+ {
for($i = $strlen; $i < $accuracy; $i++)
+ {
$return[1] .= '0';
+ }
+ }
$return = $return[0] . "." . $return[1];
}
else
+ {
$return = $return[0];
+ }
return $return;
}
@@ -524,9 +605,13 @@ function pts_bool_question($question, $default = true, $question_id = "UNKNOWN")
}
if(isset($auto_answer))
+ {
$answer = $auto_answer == "TRUE" || $auto_answer == "1";
+ }
else
+ {
$answer = $default;
+ }
}
else
{
@@ -538,11 +623,17 @@ function pts_bool_question($question, $default = true, $question_id = "UNKNOWN")
while($input != "y" && $input != "n" && $input != "");
if($input == "y")
+ {
$answer = true;
+ }
else if($input == "n")
+ {
$answer = false;
+ }
else
+ {
$answer = $default;
+ }
}
return $answer;
@@ -556,7 +647,9 @@ function pts_clean_information_string($str)
$change_phrases = array("Memory Controller Hub" => "MCH", "Advanced Micro Devices" => "AMD", "MICRO-STAR INTERNATIONAL" => "MSI", "Silicon Integrated Systems" => "SiS", "Integrated Graphics Controller" => "IGP");
foreach($change_phrases as $original_phrase => $new_phrase)
+ {
$str = str_ireplace($original_phrase, $new_phrase, $str);
+ }
$str = trim(preg_replace("/\s+/", " ", $str));
@@ -568,13 +661,19 @@ function pts_string_header($heading, $char = '=')
$header_size = 36;
foreach(explode("\n", $heading) as $line)
+ {
if(($line_length = strlen($line)) > $header_size)
+ {
$header_size = $line_length;
+ }
+ }
$terminal_width = trim(shell_exec("tput cols 2>&1"));
if($header_size > $terminal_width && $terminal_width > 1)
+ {
$header_size = $terminal_width;
+ }
return "\n" . str_repeat($char, $header_size) . "\n" . $heading . "\n" . str_repeat($char, $header_size) . "\n\n";
}
@@ -593,8 +692,12 @@ function pts_version_comparable($old, $new)
$compare = true;
if(count($old) >= 2 && count($new) >= 2)
+ {
if($old[0] != $new[0] || $old[1] != $new[1])
+ {
$compare = false;
+ }
+ }
return $compare;
}
@@ -609,14 +712,20 @@ function pts_shutdown()
if(IS_DEBUG_MODE && defined("PTS_DEBUG_FILE"))
{
if(!is_dir(PTS_USER_DIR . "debug-messages/"))
+ {
mkdir(PTS_USER_DIR . "debug-messages/");
+ }
if(file_put_contents(PTS_USER_DIR . "debug-messages/" . PTS_DEBUG_FILE, $GLOBALS["DEBUG_CONTENTS"]))
+ {
echo "\nDebug Message Saved To: " . PTS_USER_DIR . "debug-messages/" . PTS_DEBUG_FILE . "\n";
+ }
}
if(IS_SCTP_MODE)
+ {
remote_sctp_test_files();
+ }
// Remove process
pts_process_remove("phoronix-test-suite");
@@ -627,16 +736,20 @@ function pts_string_bool($string)
$string = strtolower($string);
return $string == "true" || $string == "1" || $string == "on";
}
-function pts_is_valid_download_url($string, $basename = NULL)
+function pts_is_valid_download_url($string, $basename = null)
{
// Checks for valid download URL
$is_valid = true;
- if(strpos($string, "://") == FALSE)
- $is_valid = FALSE;
+ if(strpos($string, "://") == false)
+ {
+ $is_valid = false;
+ }
if(!empty($basename) && $basename != basename($string))
- $is_valid = FALSE;
+ {
+ $is_valid = false;
+ }
return $is_valid;
}
@@ -644,7 +757,9 @@ function pts_format_time_string($time, $format = "SECONDS", $standard_version =
{
// Format an elapsed time string
if($format == "MINUTES")
+ {
$time *= 60;
+ }
$formatted_time = array();
@@ -661,10 +776,14 @@ function pts_format_time_string($time, $format = "SECONDS", $standard_version =
$formatted_part = $time_hours . " Hour";
if($time_hours > 1)
+ {
$formatted_part .= "s";
+ }
}
else
+ {
$formatted_part = $time_hours . "h";
+ }
array_push($formatted_time, $formatted_part);
}
@@ -675,10 +794,14 @@ function pts_format_time_string($time, $format = "SECONDS", $standard_version =
$formatted_part = $time_minutes . " Minute";
if($time_minutes > 1)
+ {
$formatted_part .= "s";
+ }
}
else
+ {
$formatted_part = $time_minutes . "m";
+ }
array_push($formatted_time, $formatted_part);
}
@@ -689,19 +812,27 @@ function pts_format_time_string($time, $format = "SECONDS", $standard_version =
$formatted_part = $time_seconds . " Second";
if($time_seconds > 1)
+ {
$formatted_part .= "s";
+ }
}
else
+ {
$formatted_part = $time_seconds . "s";
+ }
array_push($formatted_time, $formatted_part);
}
}
if($standard_version)
+ {
$time_string = implode(", ", $formatted_time);
+ }
else
+ {
$time_string = implode("", $formatted_time);
+ }
return $time_string;
}
@@ -711,20 +842,28 @@ function pts_evaluate_script_type($script)
$script_eval = trim($script[0]);
$script_type = false;
- if(strpos($script_eval, "<?php") !== FALSE)
+ if(strpos($script_eval, "<?php") !== false)
+ {
$script_type = "PHP";
- else if(strpos($script_eval, "#!/bin/sh") !== FALSE)
+ }
+ else if(strpos($script_eval, "#!/bin/sh") !== false)
+ {
$script_type = "SH";
- else if(strpos($script_eval, "<") !== FALSE && strpos($script_eval, ">") !== FALSE)
+ }
+ else if(strpos($script_eval, "<") !== false && strpos($script_eval, ">") !== false)
+ {
$script_type = "XML";
+ }
return $script_type;
}
function pts_set_environment_variable($name, $value)
{
// Sets an environmental variable
- if(getenv($name) == FALSE)
+ if(getenv($name) == false)
+ {
putenv($name . "=" . $value);
+ }
}
function pts_proximity_match($search, $match_to)
{
@@ -733,16 +872,20 @@ function pts_proximity_match($search, $match_to)
$is_match = true;
if(count($search) == 1)
+ {
$is_match = false;
+ }
for($i = 0; $i < count($search) && $is_match && !empty($search[$i]); $i++)
{
- if(($match_point = strpos($match_to, $search[$i])) !== FALSE && ($i > 0 || $match_point == 0))
+ if(($match_point = strpos($match_to, $search[$i])) !== false && ($i > 0 || $match_point == 0))
{
$match_to = substr($match_to, ($match_point + strlen($search[$i])));
}
else
+ {
$is_match = false;
+ }
}
return $is_match;
@@ -753,13 +896,19 @@ function pts_debug_message($message)
if(IS_DEBUG_MODE)
{
if(strpos($message, "$") > 0)
+ {
foreach(pts_env_variables() as $key => $value)
+ {
$message = str_replace("$" . $key, $value, $message);
+ }
+ }
echo "DEBUG: " . ($output = $message . "\n");
if(defined("PTS_DEBUG_FILE"))
+ {
$GLOBALS["DEBUG_CONTENTS"] = $output;
+ }
}
}
function pts_user_message($message)
@@ -778,15 +927,19 @@ function pts_user_message($message)
function pts_remove($object)
{
if(!file_exists($object))
- return FALSE;
+ {
+ return false;
+ }
if(is_file($object))
+ {
return unlink($object);
+ }
if(is_dir($object))
{
$directory = dir($object);
- while(($entry = $directory->read()) !== FALSE)
+ while(($entry = $directory->read()) !== false)
{
if($entry != "." && $entry != "..")
{
@@ -805,8 +958,10 @@ function pts_download($download, $to)
$download_output = "";
$user_agent = "PhoronixTestSuite/" . PTS_CODENAME;
- if(strpos($to_file, ".") === FALSE)
+ if(strpos($to_file, ".") === false)
+ {
$to_file = basename($download);
+ }
if(is_executable("/usr/bin/curl"))
{
diff --git a/pts-core/functions/pts-functions_config.php b/pts-core/functions/pts-functions_config.php
index 98bd870..42724aa 100644
--- a/pts-core/functions/pts-functions_config.php
+++ b/pts-core/functions/pts-functions_config.php
@@ -24,23 +24,33 @@
function pts_config_init()
{
if(!is_dir(PTS_USER_DIR))
+ {
mkdir(PTS_USER_DIR);
+ }
if(!is_dir(PTS_TEMP_DIR))
+ {
mkdir(PTS_TEMP_DIR);
+ }
pts_user_config_init();
pts_graph_config_init();
}
-function pts_user_config_init($UserName = NULL, $UploadKey = NULL, $BatchOptions = NULL)
+function pts_user_config_init($UserName = null, $UploadKey = null, $BatchOptions = null)
{
// Validate the config files, update them (or write them) if needed, and other configuration file tasks
if(is_file(PTS_USER_DIR . "user-config.xml"))
+ {
$file = file_get_contents(PTS_USER_DIR . "user-config.xml");
+ }
else if(is_file(ETC_DIR . "user-config-template.xml"))
+ {
$file = file_get_contents(ETC_DIR . "user-config-template.xml");
+ }
else
+ {
$file = "";
+ }
$read_config = new tandem_XmlReader($file);
@@ -54,17 +64,25 @@ function pts_user_config_init($UserName = NULL, $UploadKey = NULL, $BatchOptions
$agree = pts_bool_question("Do you agree to these terms and wish to proceed (Y/n)?", true);
if($agree)
+ {
echo "\n";
+ }
else
+ {
pts_exit(pts_string_header("In order to run the Phoronix Test Suite, you must agree to the listed terms."));
+ }
}
- if($UserName == NULL)
+ if($UserName == null)
+ {
$UserName = pts_read_user_config(P_OPTION_GLOBAL_USERNAME, "Default User", $read_config);
- if($UploadKey == NULL)
+ }
+ if($UploadKey == null)
+ {
$UploadKey = pts_read_user_config(P_OPTION_GLOBAL_UPLOADKEY, "", $read_config);
+ }
- if($BatchOptions == NULL || !is_array($BatchOptions))
+ if($BatchOptions == null || !is_array($BatchOptions))
{
$BatchOptions = array();
$BatchOptions[0] = pts_read_user_config(P_OPTION_BATCH_SAVERESULTS, "TRUE", $read_config);
@@ -126,14 +144,18 @@ function pts_user_config_init($UserName = NULL, $UploadKey = NULL, $BatchOptions
file_put_contents(PTS_USER_DIR . "user-config.xml", $config->getXML());
}
-function pts_module_config_init($SetOptions = NULL)
+function pts_module_config_init($SetOptions = null)
{
// Validate the config files, update them (or write them) if needed, and other configuration file tasks
if(is_file(PTS_USER_DIR . "modules-config.xml"))
+ {
$file = file_get_contents(PTS_USER_DIR . "modules-config.xml");
+ }
else
+ {
$file = "";
+ }
$module_config_parser = new tandem_XmlReader($file);
$option_module = $module_config_parser->getXMLArrayValues(P_MODULE_OPTION_NAME);
@@ -185,9 +207,13 @@ function pts_config_bool_to_string($bool)
{
// Evaluate a string to boolean type
if($bool == true)
+ {
$bool_return = "TRUE";
+ }
else
+ {
$bool_return = "FALSE";
+ }
return $bool_return;
}
@@ -196,13 +222,19 @@ function pts_graph_config_init()
// Initialize the graph configuration file
if(is_file(PTS_USER_DIR . "graph-config.xml"))
+ {
$file = file_get_contents(PTS_USER_DIR . "graph-config.xml");
+ }
else if(is_file(RESULTS_VIEWER_DIR . "graph-config-template.xml"))
+ {
$file = file_get_contents(RESULTS_VIEWER_DIR . "graph-config-template.xml");
+ }
else
+ {
$file = "";
- $read_config = new tandem_XmlReader($file);
+ }
+ $read_config = new tandem_XmlReader($file);
$config = new tandem_XmlWriter();
// Size of Graph
@@ -259,20 +291,26 @@ function pts_read_config($config_file, $xml_pointer, $value, $tandem_xml)
$temp_value = $tandem_xml->getXmlValue($xml_pointer);
if(!empty($temp_value))
+ {
$value = $temp_value;
+ }
}
else
{
if(is_file(PTS_USER_DIR . $config_file))
- if(($file = file_get_contents(PTS_USER_DIR . $config_file)) != FALSE)
+ {
+ if(($file = file_get_contents(PTS_USER_DIR . $config_file)) != false)
{
$xml_parser = new tandem_XmlReader($file);
unset($file);
$temp_value = $xml_parser->getXmlValue($xml_pointer);
if(!empty($temp_value))
+ {
$value = $temp_value;
+ }
}
+ }
}
return $value;
@@ -280,7 +318,7 @@ function pts_read_config($config_file, $xml_pointer, $value, $tandem_xml)
function pts_find_home($path)
{
// Find home directory if needed
- if(strpos($path, "~/") !== FALSE)
+ if(strpos($path, "~/") !== false)
{
$home_path = pts_user_home();
$path = str_replace("~/", $home_path, $path);
@@ -308,7 +346,9 @@ function pts_current_user()
$pts_user = pts_read_user_config(P_OPTION_GLOBAL_USERNAME, "Default User");
if($pts_user == "Default User")
+ {
$pts_user = system_user_name();
+ }
return $pts_user;
}
@@ -318,10 +358,14 @@ function pts_download_cache()
$dir = getenv("PTS_DOWNLOAD_CACHE");
if(empty($dir))
+ {
$dir = pts_read_user_config(P_OPTION_CACHE_DIRECTORY, "~/.phoronix-test-suite/download-cache/");
+ }
if(substr($dir, -1) != '/')
+ {
$dir .= '/';
+ }
return $dir;
}
diff --git a/pts-core/functions/pts-functions_modules.php b/pts-core/functions/pts-functions_modules.php
index 7d7eb12..0321b99 100644
--- a/pts-core/functions/pts-functions_modules.php
+++ b/pts-core/functions/pts-functions_modules.php
@@ -30,23 +30,23 @@ function pts_module_start_process()
{
// Process initially called when PTS starts up
$GLOBALS["PTS_MODULES"] = array();
- $GLOBALS["PTS_MODULE_CURRENT"] = FALSE;
+ $GLOBALS["PTS_MODULE_CURRENT"] = false;
$GLOBALS["PTS_MODULE_VAR_STORE"] = array();
- if(getenv("PTS_IGNORE_MODULES") !== FALSE)
- return;
-
- // Enable the toggling of the system screensaver by default.
- // To disable w/o code modification, set HALT_SCREENSAVER=NO environmental variable
- array_push($GLOBALS["PTS_MODULES"], "toggle_screensaver");
+ if(getenv("PTS_IGNORE_MODULES") == false)
+ {
+ // Enable the toggling of the system screensaver by default.
+ // To disable w/o code modification, set HALT_SCREENSAVER=NO environmental variable
+ array_push($GLOBALS["PTS_MODULES"], "toggle_screensaver");
- array_push($GLOBALS["PTS_MODULES"], "update_checker"); // Check for new PTS versions
+ array_push($GLOBALS["PTS_MODULES"], "update_checker"); // Check for new PTS versions
- pts_load_modules();
- pts_module_process("__startup");
- register_shutdown_function("pts_module_process", "__shutdown");
+ pts_load_modules();
+ pts_module_process("__startup");
+ register_shutdown_function("pts_module_process", "__shutdown");
+ }
}
-function pts_auto_detect_modules($load_here = FALSE)
+function pts_auto_detect_modules($load_here = false)
{
// Auto detect modules to load
$module_variables_file = @file_get_contents(MODULE_DIR . "module-variables.txt");
@@ -61,15 +61,19 @@ function pts_auto_detect_modules($load_here = FALSE)
$env_var = trim($module_var[0]);
$module = trim($module_var[1]);
- if(!in_array($module, $GLOBALS["PTS_MODULES"]) && ($e = getenv($env_var)) != FALSE && !empty($e))
+ if(!in_array($module, $GLOBALS["PTS_MODULES"]) && ($e = getenv($env_var)) != false && !empty($e))
{
if(IS_DEBUG_MODE)
+ {
echo "Attempting To Add Module: " . $module . "\n";
+ }
pts_attach_module($module);
if($load_here)
+ {
pts_load_module($module);
+ }
}
}
}
@@ -80,25 +84,35 @@ function pts_load_modules()
// Check for modules to auto-load from the configuration file
if(strlen(($load_modules = pts_read_user_config(P_OPTION_LOAD_MODULES, ""))) > 0)
+ {
foreach(explode(",", $load_modules) as $module)
{
$module_r = explode("=", $module);
if(count($module_r) == 2)
+ {
pts_set_environment_variable(trim($module_r[0]), trim($module_r[1]));
+ }
else
+ {
pts_attach_module($module);
+ }
}
+ }
// Check for modules to load manually in PTS_MODULES
- if(($load_modules = getenv("PTS_MODULES")) !== FALSE)
+ if(($load_modules = getenv("PTS_MODULES")) !== false)
+ {
foreach(explode(",", $load_modules) as $module)
{
$module = trim($module);
if(!in_array($module, $GLOBALS["PTS_MODULES"]))
+ {
pts_attach_module($module);
+ }
}
+ }
// Detect modules to load automatically
pts_auto_detect_modules();
@@ -106,11 +120,15 @@ function pts_load_modules()
// Clean-up modules list
array_unique($GLOBALS["PTS_MODULES"]);
for($i = 0; $i < count($GLOBALS["PTS_MODULES"]); $i++)
+ {
if(!is_file(MODULE_DIR . $GLOBALS["PTS_MODULES"][$i] . ".php"))
+ {
unset($GLOBALS["PTS_MODULES"][$i]);
+ }
+ }
// Reset counter
- $GLOBALS["PTS_MODULE_CURRENT"] = FALSE;
+ $GLOBALS["PTS_MODULE_CURRENT"] = false;
// Load the modules
$module_store_list = array();
@@ -119,14 +137,24 @@ function pts_load_modules()
pts_load_module($module);
if(pts_module_type($module) == "PHP")
+ {
eval("\$module_store_vars = " . $module . "::\$module_store_vars;");
+ }
else
+ {
$module_store_vars = array();
+ }
if(is_array($module_store_vars) && count($module_store_vars) > 0)
+ {
foreach($module_store_vars as $store_var)
+ {
if(!in_array($store_var, $module_store_list))
+ {
array_push($module_store_list, $store_var);
+ }
+ }
+ }
}
// Should any of the module options be saved to the results?
@@ -134,8 +162,10 @@ function pts_load_modules()
{
$var_value = getenv($var);
- if($var_value != FALSE && !empty($var_value))
+ if($var_value != false && !empty($var_value))
+ {
array_push($GLOBALS["PTS_MODULE_VAR_STORE"], $var . "=" . $var_value);
+ }
}
}
function pts_attach_module($module)
@@ -146,8 +176,7 @@ function pts_attach_module($module)
function pts_load_module($module)
{
// Load the actual file needed that contains the module
- if(pts_module_type($module) == "PHP")
- @include(MODULE_DIR . $module . ".php");
+ return pts_module_type($module) == "PHP" && @include(MODULE_DIR . $module . ".php");
}
function pts_module_processes()
{
@@ -157,9 +186,13 @@ function pts_module_processes()
function pts_module_call($module, $process)
{
if(pts_module_type($module) == "PHP")
+ {
$module_response = pts_php_module_call($module, $process);
+ }
else
+ {
$module_response = pts_sh_module_call($module, $process);
+ }
return $module_response;
}
@@ -167,15 +200,18 @@ function pts_sh_module_call($module, $process)
{
$module_file = MODULE_DIR . $module . ".sh";
- if(is_file($module_file))
- return trim(shell_exec("sh " . $module_file . " " . $process . " 2>&1"));
+ return is_file($module_file) && trim(shell_exec("sh " . $module_file . " " . $process . " 2>&1"));
}
function pts_php_module_call($module, $process)
{
if(method_exists($module, $process))
+ {
eval("\$module_val = " . $module . "::" . $process . "();"); // TODO: This can be cleaned up once PHP 5.3.0+ is out there and adopted
+ }
else
+ {
eval("\$module_val = " . $module . "::" . $process . ";");
+ }
return $module_val;
}
@@ -204,7 +240,7 @@ function pts_module_process($process)
}
}
}
- $GLOBALS["PTS_MODULE_CURRENT"] = FALSE;
+ $GLOBALS["PTS_MODULE_CURRENT"] = false;
}
function pts_module_process_extensions($extensions)
{
@@ -234,11 +270,17 @@ function pts_module_type($name)
else
{
if(is_file(MODULE_DIR . $name . ".php"))
+ {
$type = "PHP";
+ }
else if(is_file(MODULE_DIR . $name . ".sh"))
+ {
$type = "SH";
+ }
else
+ {
$type = null;
+ }
$GLOBALS["PTS_VAR_CACHE"]["MODULE_TYPES"][$name] = $type;
}
diff --git a/pts-core/functions/pts-functions_system_cpu.php b/pts-core/functions/pts-functions_system_cpu.php
index ddc5bf3..b49f18c 100644
--- a/pts-core/functions/pts-functions_system_cpu.php
+++ b/pts-core/functions/pts-functions_system_cpu.php
@@ -136,7 +136,9 @@ function processor_string()
}
else
+ {
$info = "Unknown";
+ }
}
return $info;
@@ -147,7 +149,9 @@ function append_processor_frequency($cpu_string, $cpu_core = 0)
if(($freq = processor_frequency($cpu_core)) > 0)
{
if(($strip_point = strpos($cpu_string, '@')) > 0)
+ {
$cpu_string = trim(substr($cpu_string, 0, $strip_point)); // stripping out the reported freq, since the CPU could be overclocked, etc
+ }
$cpu_string .= " @ " . $freq . "GHz";
}
@@ -167,14 +171,20 @@ function processor_frequency($cpu_core = 0)
$cpu_speeds = read_cpuinfo("cpu MHz");
if(count($cpu_speeds) > $cpu_core)
+ {
$info = $cpu_speeds[$cpu_core];
+ }
else
+ {
$info = $cpu_speeds[0];
+ }
$info = pts_trim_double($info / 1000, 2);
}
else
+ {
$info = current_processor_frequency($cpu_core);
+ }
return $info;
}
@@ -188,11 +198,15 @@ function processor_temperature()
$temp_c = read_acpi("/thermal_zone/THM0/temperature", "temperature"); // if it is THM0 that is for the CPU, in most cases it should be
if(($end = strpos($temp_c, ' ')) > 0)
+ {
$temp_c = substr($temp_c, 0, $end);
+ }
}
if(empty($temp_c))
+ {
$temp_c = -1;
+ }
return $temp_c;
}
@@ -211,12 +225,18 @@ function pts_processor_power_savings_enabled()
{
$cpu = processor_string();
- if(strpos($cpu, "AMD") !== FALSE)
+ if(strpos($cpu, "AMD") !== false)
+ {
$return_string = "AMD Cool n Quiet was enabled.";
- else if(strpos($cpu, "Intel") !== FALSE)
+ }
+ else if(strpos($cpu, "Intel") !== false)
+ {
$return_string = "Intel SpeedStep Technology was enabled.";
+ }
else
+ {
$return_string = "The CPU was in a power-savings mode.";
+ }
}
}
return $return_string;
@@ -234,9 +254,13 @@ function current_processor_frequency($cpu_core = 0)
$cpu_speeds = read_cpuinfo("cpu MHz");
if(count($cpu_speeds) > $cpu_core)
+ {
$info = $cpu_speeds[$cpu_core];
+ }
else
+ {
$info = $cpu_speeds[0];
+ }
$info = pts_trim_double(intval($info), 2);
}
@@ -257,12 +281,16 @@ function current_processor_frequency($cpu_core = 0)
$info = read_osx_system_profiler("SPHardwareDataType", "ProcessorSpeed");
if(($cut_point = strpos($info, " ")) > 0)
+ {
$info = substr($info, 0, $cut_point);
+ }
$info = pts_trim_double($info, 2);
}
else
+ {
$info = 0;
+ }
return $info;
}
@@ -275,7 +303,9 @@ function cpu_load_array()
$load = array();
for($i = 1; $i < 6; $i++)
+ {
array_push($load, $stat_break[$i]);
+ }
return $load;
}
@@ -292,12 +322,18 @@ function current_processor_usage()
}
if(array_sum($end_load) == 0)
+ {
$percent = 0;
+ }
else
+ {
$percent = 100 - (($end_load[(count($end_load) - 1)] * 100) / array_sum($end_load));
+ }
if(!is_numeric($percent) || $percent < 0 || $percent > 100)
+ {
$percent = -1;
+ }
return pts_trim_double($percent);
}
diff --git a/pts-core/functions/pts-functions_system_graphics.php b/pts-core/functions/pts-functions_system_graphics.php
index 4c87058..cd9c195 100644
--- a/pts-core/functions/pts-functions_system_graphics.php
+++ b/pts-core/functions/pts-functions_system_graphics.php
@@ -27,9 +27,13 @@ function graphics_frequency_string()
{
// Report graphics frequency string
if(IS_ATI_GRAPHICS)
+ {
$freq = graphics_processor_stock_frequency();
+ }
else
+ {
$freq = graphics_processor_frequency();
+ }
$freq_string = $freq[0] . "/" . $freq[1];
@@ -58,11 +62,15 @@ function graphics_processor_temperature()
$temp_c = read_ati_overdrive("Temperature");
if($temp_c == -1)
+ {
$temp_c = read_ati_extension("CoreTemperature");
+ }
}
if(empty($temp_c) || !is_numeric($temp_c))
+ {
$temp_c = -1;
+ }
return $temp_c;
}
@@ -99,14 +107,22 @@ function graphics_monitor_count()
$amdpcsdb_enabled_monitors = read_amd_pcsdb("SYSTEM/BUSID-*/DDX,EnableMonitor");
if(!is_array($amdpcsdb_enabled_monitors))
+ {
$amdpcsdb_enabled_monitors = array($amdpcsdb_enabled_monitors);
+ }
foreach($amdpcsdb_enabled_monitors as $enabled_monitor)
+ {
foreach(explode(",", $enabled_monitor) as $monitor_connection)
+ {
$monitor_count++;
+ }
+ }
}
else
+ {
$monitor_count = 1;
+ }
}
return $monitor_count;
@@ -134,16 +150,24 @@ function graphics_monitor_layout()
else if($monitor_position_x > 0 && $monitor_position_y == 0)
{
if($hit_0_0 == false)
+ {
array_push($monitor_layout, "LEFT");
+ }
else
+ {
array_push($monitor_layout, "RIGHT");
+ }
}
else if($monitor_position_x == 0 && $monitor_position_y > 0)
{
if($hit_0_0 == false)
+ {
array_push($monitor_layout, "UPPER");
+ }
else
+ {
array_push($monitor_layout, "LOWER");
+ }
}
}
@@ -155,7 +179,9 @@ function graphics_monitor_layout()
$amdpcsdb_monitor_layout = read_amd_pcsdb("SYSTEM/BUSID-*/DDX,DesktopSetup");
if(!is_array($amdpcsdb_monitor_layout))
+ {
$amdpcsdb_monitor_layout = array($amdpcsdb_monitor_layout);
+ }
foreach($amdpcsdb_monitor_layout as $card_monitor_configuration)
{
@@ -367,18 +393,15 @@ function set_video_resolution($width, $height)
function set_nvidia_extension($attribute, $value)
{
// Sets an object in NVIDIA's NV Extension
- if(!IS_NVIDIA_GRAPHICS)
- return;
-
- $info = shell_exec("nvidia-settings --assign " . $attribute . "=" . $value . " 2>&1");
+ if(IS_NVIDIA_GRAPHICS)
+ {
+ shell_exec("nvidia-settings --assign " . $attribute . "=" . $value . " 2>&1");
+ }
}
function set_amd_pcsdb($attribute, $value)
{
// Sets a value for AMD's PCSDB, Persistent Configuration Store Database
- if(!IS_ATI_GRAPHICS)
- return;
-
- if(!empty($value))
+ if(!empty($value) && IS_ATI_GRAPHICS)
{
$DISPLAY = substr(getenv("DISPLAY"), 1, 1);
@@ -392,10 +415,16 @@ function sort_available_modes($modes)
$sorted_modes = array();
foreach($modes as $this_mode)
+ {
if(count($this_mode) == 2)
+ {
array_push($mode_pixel_counts, $this_mode[0] * $this_mode[1]);
+ }
else
+ {
unset($this_mode);
+ }
+ }
sort($mode_pixel_counts);
@@ -428,7 +457,9 @@ function xrandr_available_modes()
foreach($xrandr_lines as $xrandr_mode)
{
if(($cut_point = strpos($xrandr_mode, "(")) > 0)
+ {
$xrandr_mode = substr($xrandr_mode, 0, $cut_point);
+ }
$res = explode("x", $xrandr_mode);
@@ -446,7 +477,9 @@ function xrandr_available_modes()
$this_mode = array($res[0], $res[1]);
if(in_array($ratio, $supported_ratios) && !in_array($this_mode, $ignore_modes))
+ {
array_push($available_modes, $this_mode);
+ }
}
}
}
@@ -460,9 +493,12 @@ function xrandr_available_modes()
$video_height = current_screen_height();
for($i = 0; $i < count($stock_modes); $i++)
+ {
if($stock_modes[$i][0] <= $video_width && $stock_modes[$i][1] <= $video_height)
+ {
array_push($available_modes, $stock_modes[$i]);
-
+ }
+ }
}
else
{
@@ -476,7 +512,7 @@ function xrandr_screen_resolution()
// Find the current screen resolution using XRandR
$info = shell_exec("xrandr 2>&1 | grep \"*\"");
- if(strpos($info, "*") !== FALSE)
+ if(strpos($info, "*") !== false)
{
$res = explode("x", $info);
$res[0] = trim($res[0]);
@@ -491,7 +527,9 @@ function xrandr_screen_resolution()
array_push($info, trim($res[0]), trim($res[1]));
}
else
+ {
$info = "";
+ }
}
if(empty($info))
@@ -501,7 +539,9 @@ function xrandr_screen_resolution()
$info = explode(",", $nvidia);
}
else
+ {
$info = array("Unknown", "Unknown");
+ }
}
return $info;
@@ -520,9 +560,13 @@ function current_screen_resolution()
{
// Return the current screen resolution
if(($width = current_screen_width()) != "Unknown" && ($height = current_screen_height()) != "Unknown")
+ {
$resolution = $width . "x" . $height;
+ }
else
+ {
$resolution = "Unknown";
+ }
return $resolution;
}
@@ -583,9 +627,13 @@ function graphics_processor_stock_frequency()
}
if(!is_numeric($core_freq))
+ {
$core_freq = 0;
+ }
if(!is_numeric($mem_freq))
+ {
$mem_freq = 0;
+ }
return array($core_freq, $mem_freq);
}
@@ -622,9 +670,13 @@ function graphics_processor_frequency()
}
if(!is_numeric($core_freq))
+ {
$core_freq = 0;
+ }
if(!is_numeric($mem_freq))
+ {
$mem_freq = 0;
+ }
return array($core_freq, $mem_freq);
}
@@ -640,7 +692,9 @@ function graphics_processor_string()
$info = trim(substr($info, 0, strpos($info, "\n")));
}
else
+ {
$info = "";
+ }
if(IS_ATI_GRAPHICS)
{
@@ -648,20 +702,30 @@ function graphics_processor_string()
$crossfire_card_count = 0;
if(!is_array($crossfire_status))
+ {
$crossfire_status = array($crossfire_status);
+ }
for($i = 0; $i < count($crossfire_status); $i++)
+ {
if($crossfire_status[$i] == "0x00000001")
- $crossfire_card_count += 2; // For now assume each chain is 2 cards, but proper way would be NumSlaves + 1
+ {
+ $crossfire_card_count += 2; // For now assume each chain is 2 cards, but proper way would be NumSlaves + 1
+ }
+ }
$adapters = read_amd_graphics_adapters();
if(count($adapters) > 0)
{
if($video_ram > DEFAULT_VIDEO_RAM_CAPACITY)
+ {
$video_ram = " " . $video_ram . "MB";
+ }
else
+ {
$video_ram = "";
+ }
if($crossfire_card_count > 1 && $crossfire_card_count <= count($adapters))
{
@@ -670,15 +734,21 @@ function graphics_processor_string()
if(count($unique_adapters) == 1)
{
if(strpos($adapters[0], "X2") > 0 && $crossfire_card_count > 1)
+ {
$crossfire_card_count -= 1;
+ }
$info = $crossfire_card_count . " x " . $adapters[0] . $video_ram . " CrossFire";
}
else
+ {
$info = implode(", ", $unique_adapters) . " CrossFire";
+ }
}
else
+ {
$info = $adapters[0] . $video_ram;
+ }
}
}
else if(IS_NVIDIA_GRAPHICS)
@@ -686,16 +756,18 @@ function graphics_processor_string()
$sli_mode = read_nvidia_extension("SLIMode");
if(!empty($sli_mode) && $sli_mode != "Off")
+ {
$info .= " SLI";
+ }
}
- if(empty($info) || strpos($info, "Mesa ") !== FALSE || $info == "Software Rasterizer")
+ if(empty($info) || strpos($info, "Mesa ") !== false || $info == "Software Rasterizer")
{
$log_parse = shell_exec("cat /var/log/Xorg.0.log | grep Chipset");
$log_parse = substr($log_parse, strpos($log_parse, "Chipset") + 8);
$log_parse = substr($log_parse, 0, strpos($log_parse, "found"));
- if(strpos($log_parse, "ATI") !== FALSE || strpos($log_parse, "NVIDIA") !== FALSE || strpos($log_parse, "VIA") !== FALSE || strpos($log_parse, "Intel") !== FALSE)
+ if(strpos($log_parse, "ATI") !== false || strpos($log_parse, "NVIDIA") !== false || strpos($log_parse, "VIA") !== false || strpos($log_parse, "Intel") !== false)
{
$info = $log_parse;
}
@@ -704,10 +776,14 @@ function graphics_processor_string()
$info_pci = read_pci("VGA compatible controller", false);
if(!empty($info_pci) && $info_pci != "Unknown")
+ {
$info = $info_pci;
+ }
if(($start_pos = strpos($info, " DRI ")) > 0)
+ {
$info = substr($info, $start_pos + 5);
+ }
}
}
@@ -716,10 +792,12 @@ function graphics_processor_string()
$info = read_sysctl("dev.drm.0.%desc");
if($info == "Unknown")
+ {
$info = read_sysctl("dev.agp.0.%desc");
+ }
}
- if(IS_NVIDIA_GRAPHICS && $video_ram > DEFAULT_VIDEO_RAM_CAPACITY && strpos($info, $video_ram) == FALSE)
+ if(IS_NVIDIA_GRAPHICS && $video_ram > DEFAULT_VIDEO_RAM_CAPACITY && strpos($info, $video_ram) == false)
{
$info .= " " . $video_ram . "MB";
}
@@ -740,24 +818,28 @@ function graphics_subsystem_version()
{
// Find graphics subsystem version
if(IS_SOLARIS)
+ {
$info = shell_exec("X :0 -version 2>&1");
+ }
else
+ {
$info = shell_exec("X -version 2>&1");
+ }
$pos = strrpos($info, "Release Date");
- if($pos == FALSE)
+ if($pos == false)
{
$pos = strrpos($info, "Build Date");
}
$info = trim(substr($info, 0, $pos));
- if($pos === FALSE)
+ if($pos === false)
{
$info = "Unknown";
}
- else if(($pos = strrpos($info, "(")) === FALSE)
+ else if(($pos = strrpos($info, "(")) === false)
{
$info = trim(substr($info, strrpos($info, " ")));
}
@@ -773,7 +855,7 @@ function graphics_memory_capacity()
// Graphics memory capacity
$video_ram = DEFAULT_VIDEO_RAM_CAPACITY;
- if(($vram = getenv("VIDEO_MEMORY")) != FALSE && is_numeric($vram) && $vram > DEFAULT_VIDEO_RAM_CAPACITY)
+ if(($vram = getenv("VIDEO_MEMORY")) != false && is_numeric($vram) && $vram > DEFAULT_VIDEO_RAM_CAPACITY)
{
$video_ram = $vram;
}
@@ -792,7 +874,9 @@ function graphics_memory_capacity()
$info = shell_exec("cat /var/log/Xorg.0.log | grep -i VideoRAM");
if(empty($info))
+ {
$info = shell_exec("cat /var/log/Xorg.0.log | grep \"Video RAM\"");
+ }
if(($pos = strpos($info, "RAM:")) > 0 || ($pos = strpos($info, "Ram:")) > 0)
{
@@ -800,7 +884,9 @@ function graphics_memory_capacity()
$info = substr($info, 0, strpos($info, " "));
if($info > 65535)
+ {
$video_ram = intval($info) / 1024;
+ }
}
}
else if(IS_MACOSX)
@@ -810,7 +896,9 @@ function graphics_memory_capacity()
$video_ram = $info[0];
if($info[1] == "GB")
+ {
$video_ram *= 1024;
+ }
}
}
@@ -821,7 +909,7 @@ function opengl_version()
// OpenGL version
$info = shell_exec("glxinfo 2>&1 | grep version");
- if(($pos = strpos($info, "OpenGL version string:")) === FALSE)
+ if(($pos = strpos($info, "OpenGL version string:")) === false)
{
$info = "N/A";
}
@@ -854,7 +942,9 @@ function graphics_gpu_usage()
$gpu_usage = read_ati_overdrive("GPUload");
if($gpu_usage == -1) // OverDrive isn't supported on the ATI hardware or a supported driver isn't loaded
+ {
$gpu_usage = read_ati_extension("GPUActivity");
+ }
}
return $gpu_usage;
diff --git a/pts-core/functions/pts-functions_system_hardware.php b/pts-core/functions/pts-functions_system_hardware.php
index 70d6f05..33cacd7 100644
--- a/pts-core/functions/pts-functions_system_hardware.php
+++ b/pts-core/functions/pts-functions_system_hardware.php
@@ -47,11 +47,15 @@ function main_system_hardware_string()
$version = read_system_hal("system.hardware.version");
if($vendor != "Unknown")
+ {
$info = $vendor;
+ }
else
+ {
$info = "";
+ }
- if($product == "Unknown" || empty($product) || (strpos($version, ".") === FALSE && $version != "Unknown"))
+ if($product == "Unknown" || empty($product) || (strpos($version, ".") === false && $version != "Unknown"))
{
$product = $version;
}
@@ -66,7 +70,9 @@ function main_system_hardware_string()
$fw_version = explode(" ", read_system_hal("system.firmware.version"));
if(count($fw_version) > 1)
+ {
$info = $fw_version[0] . " " . $fw_version[1];
+ }
}
if(empty($info))
@@ -86,7 +92,9 @@ function motherboard_chipset_string()
$sb_product = read_osx_system_profiler("SPSerialATADataType", "Product");
if(($cut_point = strpos($sb_product, " ")) > 0)
+ {
$sb_product = substr($sb_product, 0, $cut_point);
+ }
// TODO: Can't find Northbridge
@@ -120,13 +128,13 @@ function motherboard_chipset_string()
if(!isset($bridge) || $bridge != "Unknown")
{
// Attempt to detect Southbridge (if applicable)
- $southbridge = read_pci(array("ISA bridge", "SATA controller"), FALSE);
+ $southbridge = read_pci(array("ISA bridge", "SATA controller"), false);
if(($start_cut = strpos($southbridge, "(")) > 0 && ($end_cut = strpos($southbridge, ")", $start_cut + 1)) > 0)
{
$southbridge_extract = substr($southbridge, $start_cut + 1, $end_cut - $start_cut - 1);
- if(strpos($southbridge_extract, "rev") === FALSE)
+ if(strpos($southbridge_extract, "rev") === false)
{
$southbridge_extract = explode(" ", $southbridge_extract);
$southbridge_clean = $southbridge_extract[0];
@@ -161,8 +169,12 @@ function system_hard_disks()
$start_point = -1;
for($i = 0; $i < count($search_disk_strings) && $start_point == -1; $i++)
+ {
if(($tmp_pointer = strpos($dmesg_ata, $search_disk_strings[$i])) > 0)
+ {
$start_point = $tmp_pointer + strlen($search_disk_strings[$i]) + 1;
+ }
+ }
if($start_point != -1)
{
@@ -203,7 +215,9 @@ function system_hard_disks()
$disk_size = $disk_r[0];
if($disk_r[1] == "MB")
+ {
$disk_size /= 1024;
+ }
if($disk_size > 10 && $disk_size % 10 != 0)
{
@@ -212,13 +226,16 @@ function system_hard_disks()
$disk_size += (10 - $mod);
if($disk_size % 100 == 10)
+ {
$disk_size -= 10;
+ }
if($disk_size % 100 == 90)
+ {
$disk_size += 10;
+ }
}
$disk_size = pts_trim_double($disk_size, 0);
-
array_push($disks_capacities, $disk_size);
}
}
@@ -250,18 +267,26 @@ function system_hard_disks()
}
if($times_found > 1)
+ {
$disk = $times_found . " x " . $disks_formatted[$i];
+ }
else
+ {
$disk = $disks_formatted[$i];
+ }
array_push($disks, $disk);
}
}
if(count($disks) == 0)
+ {
$disks = system_disk_total() . "GB";
+ }
else
+ {
$disks = implode(" + ", $disks);
+ }
return $disks;
}
@@ -296,12 +321,18 @@ function memory_mb_capacity()
$info = explode(" ", $info);
if(isset($info[1]) && $info[1] == "GB")
+ {
$info = $info[0] * 1024;
+ }
else
+ {
$info = $info[0];
+ }
}
else
+ {
$info = "Unknown";
+ }
return $info;
}
@@ -315,11 +346,15 @@ function system_temperature()
$temp_c = read_acpi("/thermal_zone/THM1/temperature", "temperature"); // if it is THM1 that is for the system, in most cases it should be
if(($end = strpos($temp_c, ' ')) > 0)
+ {
$temp_c = substr($temp_c, 0, $end);
+ }
}
if(empty($temp_c))
+ {
$temp_c = -1;
+ }
return $temp_c;
}
@@ -348,7 +383,9 @@ function system_line_voltage($type)
}
if(empty($voltage))
+ {
$voltage = -1;
+ }
return $voltage;
}
@@ -364,7 +401,9 @@ function system_power_mode()
$return_status = "";
if($power_state == "off-line")
+ {
$return_status = "This computer was running on battery power.";
+ }
return $return_status;
}
diff --git a/pts-core/functions/pts-functions_system_parsing.php b/pts-core/functions/pts-functions_system_parsing.php
index 6de9ccd..6f04158 100644
--- a/pts-core/functions/pts-functions_system_parsing.php
+++ b/pts-core/functions/pts-functions_system_parsing.php
@@ -36,33 +36,45 @@ function read_acpi($point, $match)
$this_attribute = trim($line[0]);
if(count($line) > 1)
+ {
$this_value = trim($line[1]);
+ }
else
+ {
$this_value = "";
+ }
if($this_attribute == $match)
+ {
$value = $this_value;
+ }
}
}
return $value;
}
-function read_hal($name, $UDI = NULL)
+function read_hal($name, $UDI = null)
{
// Read HAL - Hardware Abstraction Layer
$info = "Unknown";
if(!is_array($name))
+ {
$name = array($name);
+ }
for($i = 0; $i < count($name) && $info == "Unknown"; $i++)
{
if(empty($UDI))
+ {
$info = shell_exec("lshal 2>&1 | grep \"" . $name[$i] . "\"");
+ }
else
+ {
$info = shell_exec("lshal -u $UDI 2>&1 | grep \"" . $name[$i] . "\"");
+ }
- if(($pos = strpos($info, $name[$i] . " = '")) !== FALSE)
+ if(($pos = strpos($info, $name[$i] . " = '")) !== false)
{
$info = substr($info, $pos + strlen($name[$i] . " = '"));
$info = trim(substr($info, 0, strpos($info, "'")));
@@ -70,7 +82,9 @@ function read_hal($name, $UDI = NULL)
$remove_words = array("empty", "unknow", "system manufacturer", "system version", "system name", "system product name", "to be filled by o.e.m.", "not applicable", "oem");
if(empty($info) || in_array(strtolower($info), $remove_words))
+ {
$info = "Unknown";
+ }
}
return $info;
@@ -81,7 +95,9 @@ function read_system_hal($name)
$hal = read_hal($name, "/org/freedesktop/Hal/devices/computer");
if($hal == "Unknown")
+ {
$hal = read_hal($name);
+ }
return $hal;
}
@@ -93,7 +109,9 @@ function read_sensors($attributes)
$sensors_lines = explode("\n", $sensors);
if(!is_array($attributes))
+ {
$attributes = array($attributes);
+ }
for($j = 0; $j < count($attributes) && empty($value); $j++)
{
@@ -109,7 +127,9 @@ function read_sensors($attributes)
$this_value = substr($this_remainder, 0, strpos($this_remainder, ' '));
if(is_numeric($this_value))
+ {
$value = $this_value;
+ }
}
}
}
@@ -123,14 +143,18 @@ function read_pci($desc, $clean_string = true)
$info = "Unknown";
if(!is_array($desc))
+ {
$desc = array($desc);
+ }
for($i = 0; $i < count($desc) && $info == "Unknown"; $i++)
{
if(substr($desc[$i], -1) != ":")
+ {
$desc[$i] .= ":";
+ }
- if(($pos = strpos($pci_info, $desc[$i])) !== FALSE)
+ if(($pos = strpos($pci_info, $desc[$i])) !== false)
{
$sub_pci_info = str_replace(array("[AMD]"), "", substr($pci_info, $pos + strlen($desc[$i])));
$EOL = strpos($sub_pci_info, "\n");
@@ -138,20 +162,30 @@ function read_pci($desc, $clean_string = true)
if($clean_string)
{
if(($temp = strpos($sub_pci_info, '/')) < $EOL && $temp > 0)
+ {
if(($temp = strpos($sub_pci_info, ' ', ($temp + 2))) < $EOL && $temp > 0)
+ {
$EOL = $temp;
+ }
+ }
if(($temp = strpos($sub_pci_info, '(')) < $EOL && $temp > 0)
+ {
$EOL = $temp;
+ }
if(($temp = strpos($sub_pci_info, '[')) < $EOL && $temp > 0)
+ {
$EOL = $temp;
+ }
}
$sub_pci_info = trim(substr($sub_pci_info, 0, $EOL));
if(($strlen = strlen($sub_pci_info)) >= 6 && $strlen < 96)
+ {
$info = pts_clean_information_string($sub_pci_info);
+ }
}
}
@@ -162,7 +196,7 @@ function read_lsb($desc)
// Read LSB Release information, Linux Standards Base
$info = shell_exec("lsb_release -a 2>&1");
- if(($pos = strrpos($info, $desc . ':')) === FALSE)
+ if(($pos = strrpos($info, $desc . ':')) === false)
{
$info = "Unknown";
}
@@ -179,7 +213,7 @@ function read_sysctl($desc)
// Read sysctl, used by *BSDs
$info = shell_exec("sysctl $desc 2>&1");
- if(strpos($info, $desc . ":") !== FALSE)
+ if(strpos($info, $desc . ":") !== false)
{
$info = trim(substr($info, strlen($desc) + 2));
}
@@ -205,12 +239,18 @@ function read_cpuinfo($attribute)
$this_attribute = trim($line[0]);
if(count($line) > 1)
+ {
$this_value = trim($line[1]);
+ }
else
+ {
$this_value = "";
+ }
if($this_attribute == $attribute)
+ {
array_push($cpuinfo_matches, $this_value);
+ }
}
}
@@ -220,7 +260,7 @@ function read_nvidia_extension($attribute)
{
// Read NVIDIA's NV Extension
$info = shell_exec("nvidia-settings --query " . $attribute . " 2>&1");
- $nv_info = NULL;
+ $nv_info = null;
if(($pos = strpos($info, $attribute)) > 0)
{
@@ -238,8 +278,12 @@ function read_xdpy_monitor_info()
$monitor_info = array();
foreach(explode("\n", $info) as $xdpyinfo_line)
- if(!empty($xdpyinfo_line) && strpos($xdpyinfo_line, "0x0") == FALSE)
+ {
+ if(!empty($xdpyinfo_line) && strpos($xdpyinfo_line, "0x0") == false)
+ {
array_push($monitor_info, $xdpyinfo_line);
+ }
+ }
return $monitor_info;
}
@@ -250,8 +294,12 @@ function read_amd_graphics_adapters()
$adapters = array();
foreach(explode("\n", $info) as $line)
+ {
if(($last_point = strrpos($line, ".")) > 0)
+ {
array_push($adapters, substr($line, $last_point + 3));
+ }
+ }
return $adapters;
}
@@ -261,7 +309,7 @@ function read_amd_pcsdb($attribute)
$info = shell_exec("aticonfig --get-pcs-key=" . $attribute . " 2>&1");
$ati_info = "";
- if(($pos = strpos($info, ":")) > 0 && strpos($info, "Error") === FALSE)
+ if(($pos = strpos($info, ":")) > 0 && strpos($info, "Error") === false)
{
$ati_info = substr($info, $pos + 2);
$ati_info = substr($ati_info, 0, strpos($ati_info, " "));
@@ -291,7 +339,9 @@ function read_amd_pcsdb_direct_parser($attribute, $find_once = false)
$is_in_prefix = false;
if(is_file("/etc/ati/amdpcsdb"))
+ {
$amdpcsdb_file = explode("\n", file_get_contents("/etc/ati/amdpcsdb"));
+ }
for($l = 0; $l < count($amdpcsdb_file) && ($find_once == false || $last_found_section_count == -1); $l++)
{
@@ -317,7 +367,9 @@ function read_amd_pcsdb_direct_parser($attribute, $find_once = false)
$this_section_count++;
}
else
+ {
$is_in_prefix = false;
+ }
}
else if($is_in_prefix && $this_section_count != $last_found_section_count && count(($key_components = explode("=", $line))) == 2)
{
@@ -353,9 +405,13 @@ function read_amd_pcsdb_direct_parser($attribute, $find_once = false)
}
if(count($attribute_values) == 0)
+ {
$attribute_values = "";
+ }
else if(count($attribute_values) == 1)
+ {
$attribute_values = $attribute_values[0];
+ }
return $attribute_values;
}
@@ -425,7 +481,7 @@ function read_ati_overdrive($attribute, $adapter = 0)
{
$info = shell_exec("aticonfig --adapter=" . $adapter . " --od-gettemperature 2>&1");
- if(($start = strpos($info, "Temperature -")) !== FALSE)
+ if(($start = strpos($info, "Temperature -")) !== false)
{
$info = substr($info, $start + 14);
$value = substr($info, 0, strpos($info, " C"));
@@ -435,7 +491,7 @@ function read_ati_overdrive($attribute, $adapter = 0)
{
$info = shell_exec("aticonfig --adapter=" . $adapter . " --od-getclocks 2>&1");
- if(strpos($info, "GPU") !== FALSE)
+ if(strpos($info, "GPU") !== false)
{
foreach(explode("\n", $info) as $line)
{
@@ -454,9 +510,13 @@ function read_ati_overdrive($attribute, $adapter = 0)
$od_value_r = explode(" ", $od_value);
if(count($od_value_r) == 1)
+ {
$value = $od_value_r[0];
+ }
else
- $value = $od_value_r;
+ {
+ $value = $od_value_r;
+ }
}
}
}
@@ -481,11 +541,17 @@ function read_system_memory_usage($TYPE = "TOTAL", $READ = "USED")
$line_type = trim($line_parts[0]);
if($TYPE == "MEMORY" && $line_type == "Mem")
+ {
$grab_line = $line_parts[1];
+ }
else if($TYPE == "SWAP" && $line_type == "Swap")
+ {
$grab_line = $line_parts[1];
+ }
else if($TYPE == "TOTAL" && $line_type == "Total")
+ {
$grab_line = $line_parts[1];
+ }
}
}
@@ -497,17 +563,23 @@ function read_system_memory_usage($TYPE = "TOTAL", $READ = "USED")
if($READ == "USED")
{
if(count($mem_parts) >= 2 && is_numeric($mem_parts[1]))
+ {
$mem_usage = $mem_parts[1];
+ }
}
else if($READ == "TOTAL")
{
if(count($mem_parts) >= 1 && is_numeric($mem_parts[0]))
+ {
$mem_usage = $mem_parts[0];
+ }
}
else if($READ == "FREE")
{
if(count($mem_parts) >= 3 && is_numeric($mem_parts[2]))
+ {
$mem_usage = $mem_parts[2];
+ }
}
}
@@ -535,7 +607,9 @@ function read_hddtemp($disk = null)
{
$unit = substr($info, $end_pos + 2, 1);
if($unit == "F")
+ {
$temperature = pts_trim_double((($temperature - 32) * 5 / 9));
+ }
$hdd_temperature = $temperature;
}
@@ -547,22 +621,26 @@ function read_osx_system_profiler($data_type, $object)
{
$info = trim(shell_exec("system_profiler " . $data_type . " 2>&1"));
$lines = explode("\n", $info);
- $value = FALSE;
+ $value = false;
- for($i = 0; $i < count($lines) && $value == FALSE; $i++)
+ for($i = 0; $i < count($lines) && $value == false; $i++)
{
$line = explode(":", $lines[$i]);
$line_object = str_replace(" ", "", $line[0]);
if(($cut_point = strpos($line_object, "(")) > 0)
+ {
$line_object = substr($line_object, 0, $cut_point);
+ }
if($line_object == $object && isset($line[1]))
{
$this_value = trim($line[1]);
if(!empty($this_value))
+ {
$value = $this_value;
+ }
}
}
@@ -597,9 +675,13 @@ function read_sun_ddu_dmi_info($object)
$line_object = str_replace(" ", "", $line[0]);
if(count($line) > 1)
+ {
$this_value = trim($line[1]);
+ }
else
+ {
$this_value = "";
+ }
if(empty($this_value) && !empty($section))
{
@@ -607,7 +689,9 @@ function read_sun_ddu_dmi_info($object)
}
if($line_object == $object && $this_section == $section && !empty($this_value))
+ {
array_push($values, $this_value);
+ }
}
}
diff --git a/pts-core/functions/pts-functions_system_software.php b/pts-core/functions/pts-functions_system_software.php
index 66a3211..0ff2956 100644
--- a/pts-core/functions/pts-functions_system_software.php
+++ b/pts-core/functions/pts-functions_system_software.php
@@ -27,15 +27,23 @@ function system_virtualized_mode()
$virtualized = "";
$gpu = graphics_processor_string();
- if(strpos(processor_string(), "QEMU") !== FALSE)
+ if(strpos(processor_string(), "QEMU") !== false)
+ {
$virtualized = "QEMU";
- else if(strpos($gpu, "VMware") !== FALSE)
+ }
+ else if(strpos($gpu, "VMware") !== false)
+ {
$virtualized = "VMware";
- else if(strpos($gpu, "VirtualBox") !== FALSE || strpos(main_system_hardware_string(), "VirtualBox") !== FALSE)
+ }
+ else if(strpos($gpu, "VirtualBox") !== false || strpos(main_system_hardware_string(), "VirtualBox") !== false)
+ {
$virtualized = "VirtualBox";
+ }
if(!empty($virtualized))
+ {
$virtualized = "This system was using " . $virtualized . " virtualization.";
+ }
return $virtualized;
}
@@ -45,10 +53,14 @@ function filesystem_type()
$fs = shell_exec("stat " . TEST_ENV_DIR . " -L -f -c %T 2> /dev/null");
if(IS_MACOSX)
+ {
$fs = read_osx_system_profiler("SPSerialATADataType", "FileSystem");
+ }
if(empty($fs) || IS_BSD)
+ {
$fs = "Unknown";
+ }
return $fs;
}
@@ -69,8 +81,10 @@ function compiler_version()
$info = shell_exec("gcc -dumpversion 2>&1");
$gcc_info = "N/A";
- if(strpos($info, '.') !== FALSE)
+ if(strpos($info, '.') !== false)
+ {
$gcc_info = "GCC " . trim($info);
+ }
return $gcc_info;
}
@@ -80,9 +94,13 @@ function kernel_arch()
$kernel_arch = trim(shell_exec("uname -m 2>&1"));
if($kernel_arch == "X86-64")
+ {
$kernel_arch = "x86_64";
+ }
else if($kernel_arch == "i86pc")
+ {
$kernel_arch = "i686";
+ }
return $kernel_arch;
}
@@ -153,20 +171,28 @@ function operating_system_release()
}
if($os == "Unknown")
+ {
$os = shell_exec("uname -s 2>&1");
+ }
}
else
+ {
$os = $vendor . " " . $version;
+ }
if(($break_point = strpos($os, ":")) > 0)
+ {
$os = substr($os, $break_point + 1);
+ }
if(IS_MACOSX)
{
$os = read_osx_system_profiler("SPSoftwareDataType", "SystemVersion");
if(($cut_point = strpos($os, "(")) > 0)
+ {
$os = substr($os, 0, $cut_point);
+ }
}
$os = trim($os);
@@ -183,7 +209,9 @@ function pts_vendor_identifier()
$vendor = operating_system_release();
if(($spos = strpos($vendor, " ")) > 1)
+ {
$vendor = substr($vendor, 0, $spos);
+ }
}
return strtolower($vendor);
@@ -210,12 +238,18 @@ function pts_process_running_bool($process)
$running = trim(str_replace(array("PID", "TTY", "TIME", "CMD"), "", $running));
if(!empty($running))
+ {
$running = true;
+ }
else
+ {
$running = false;
+ }
if(IS_MACOSX || IS_SOLARIS)
+ {
$running = false;
+ }
return $running;
}
@@ -226,16 +260,24 @@ function pts_process_running_string($process_arr)
$p_string = "";
if(!is_array($process_arr))
+ {
$process_arr = array($process_arr);
+ }
foreach($process_arr as $p_name => $p_process)
{
if(!is_array($p_process))
+ {
$p_process = array($p_process);
+ }
foreach($p_process as $process)
+ {
if(pts_process_running_bool($process))
+ {
array_push($p, $p_name);
+ }
+ }
}
$p = array_keys(array_flip($p));
@@ -247,17 +289,25 @@ function pts_process_running_string($process_arr)
$p_string .= $p[$i];
if($i != ($p_count - 1) && $p_count > 2)
+ {
$p_string .= ",";
+ }
$p_string .= " ";
if($i == ($p_count - 2))
+ {
$p_string .= "and ";
+ }
}
if($p_count == 1)
+ {
$p_string .= "was";
+ }
else
+ {
$p_string .= "were";
+ }
$p_string .= " running on this system. ";
}
diff --git a/pts-core/functions/pts-functions_tests.php b/pts-core/functions/pts-functions_tests.php
index 4b0b20c..6f038d3 100644
--- a/pts-core/functions/pts-functions_tests.php
+++ b/pts-core/functions/pts-functions_tests.php
@@ -25,12 +25,7 @@
function pts_test_needs_updated_install($identifier)
{
// Checks if test needs updating
- $needs_install = FALSE;
-
- if(!is_file(TEST_ENV_DIR . $identifier . "/pts-install.xml") || !pts_version_comparable(pts_test_profile_version($identifier), pts_test_installed_profile_version($identifier)) || pts_test_checksum_installer($identifier) != pts_test_installed_checksum_installer($identifier))
- $needs_install = TRUE;
-
- return $needs_install;
+ return !is_file(TEST_ENV_DIR . $identifier . "/pts-install.xml") || !pts_version_comparable(pts_test_profile_version($identifier), pts_test_installed_profile_version($identifier)) || pts_test_checksum_installer($identifier) != pts_test_installed_checksum_installer($identifier);
}
function pts_test_checksum_installer($identifier)
{
@@ -38,9 +33,13 @@ function pts_test_checksum_installer($identifier)
$md5_checksum = "";
if(is_file(pts_location_test_resources($identifier) . "install.php"))
+ {
$md5_checksum = md5_file(pts_location_test_resources($identifier) . "install.php");
+ }
else if(is_file(pts_location_test_resources($identifier) . "install.sh"))
+ {
$md5_checksum = md5_file(pts_location_test_resources($identifier) . "install.sh");
+ }
return $md5_checksum;
}
@@ -51,7 +50,7 @@ function pts_test_installed_checksum_installer($identifier)
if(is_file(TEST_ENV_DIR . $identifier . "/pts-install.xml"))
{
- $xml_parser = new tandem_XmlReader(TEST_ENV_DIR . $identifier . "/pts-install.xml", FALSE);
+ $xml_parser = new tandem_XmlReader(TEST_ENV_DIR . $identifier . "/pts-install.xml", false);
$version = $xml_parser->getXMLValue(P_INSTALL_TEST_CHECKSUM);
}
@@ -77,7 +76,7 @@ function pts_test_installed_profile_version($identifier)
if(is_file(TEST_ENV_DIR . $identifier . "/pts-install.xml"))
{
- $xml_parser = new tandem_XmlReader(TEST_ENV_DIR . $identifier . "/pts-install.xml", FALSE);
+ $xml_parser = new tandem_XmlReader(TEST_ENV_DIR . $identifier . "/pts-install.xml", false);
$version = $xml_parser->getXMLValue(P_INSTALL_TEST_VERSION);
}
@@ -102,7 +101,7 @@ function pts_test_refresh_install_xml($identifier, $this_test_duration = 0)
// Refresh the pts-install.xml for a test
if(is_file(TEST_ENV_DIR . $identifier . "/pts-install.xml"))
{
- $xml_parser = new tandem_XmlReader(TEST_ENV_DIR . $identifier . "/pts-install.xml", FALSE);
+ $xml_parser = new tandem_XmlReader(TEST_ENV_DIR . $identifier . "/pts-install.xml", false);
$xml_writer = new tandem_XmlWriter();
$test_duration = $xml_parser->getXMLValue(P_INSTALL_TEST_AVG_RUNTIME);
@@ -124,24 +123,26 @@ function pts_test_refresh_install_xml($identifier, $this_test_duration = 0)
$xml_writer->addXmlObject(P_INSTALL_TEST_AVG_RUNTIME, 2, $test_duration, 2);
file_put_contents(TEST_ENV_DIR . $identifier . "/pts-install.xml", $xml_writer->getXML());
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
function pts_test_name_to_identifier($name)
{
// Convert test name to identifier
- if(empty($name))
- return false;
-
$identifier = false;
- foreach(glob(XML_PROFILE_DIR . "*.xml") as $test_profile_file)
+ if(!empty($name))
{
- $xml_parser = new tandem_XmlReader($test_profile_file);
+ foreach(glob(XML_PROFILE_DIR . "*.xml") as $test_profile_file)
+ {
+ $xml_parser = new tandem_XmlReader($test_profile_file);
- if($xml_parser->getXMLValue(P_TEST_TITLE) == $name)
- $identifier = basename($test_profile_file, ".xml");
+ if($xml_parser->getXMLValue(P_TEST_TITLE) == $name)
+ {
+ $identifier = basename($test_profile_file, ".xml");
+ }
+ }
}
return $identifier;
@@ -149,12 +150,9 @@ function pts_test_name_to_identifier($name)
function pts_test_identifier_to_name($identifier)
{
// Convert identifier to test name
- if(empty($identifier))
- return false;
-
$name = false;
- if(is_test($identifier))
+ if(!empty($identifier) && is_test($identifier))
{
$xml_parser = new pts_test_tandem_XmlReader(pts_location_test($identifier));
$name = $xml_parser->getXMLValue(P_TEST_TITLE);
@@ -167,7 +165,7 @@ function pts_estimated_download_size($identifier)
// Estimate the size of files to be downloaded
$estimated_size = 0;
- foreach(pts_contained_tests($identifier, TRUE) as $test)
+ foreach(pts_contained_tests($identifier, true) as $test)
{
$xml_parser = new pts_test_tandem_XmlReader(pts_location_test($test));
$this_size = $xml_parser->getXMLValue(P_TEST_DOWNLOADSIZE); // TODO: The DownloadSize tag has been deprecates as of Phoronix Test Suite 1.4.0
@@ -196,25 +194,35 @@ function pts_estimated_download_size($identifier)
$platforms = explode(",", $package_platform[$i]);
foreach($platforms as $key => $value)
+ {
$platforms[$key] = trim($value);
+ }
if(!in_array(OPERATING_SYSTEM, $platforms))
+ {
$file_exempt = true;
+ }
}
if(!empty($package_architecture[$i]))
{
$architectures = explode(",", $package_architecture[$i]);
foreach($architectures as $key => $value)
+ {
$architectures[$key] = trim($value);
+ }
$this_arch = kernel_arch();
if(strlen($this_arch) > 3 && substr($this_arch, -2) == "86")
+ {
$this_arch = "x86";
+ }
if(!in_array($this_arch, $architectures))
+ {
$file_exempt = true;
+ }
}
if(is_numeric($package_filesize_bytes[$i]) && !$file_exempt)
@@ -233,13 +241,15 @@ function pts_test_estimated_environment_size($identifier)
// Estimate the environment size of a test or suite
$estimated_size = 0;
- foreach(pts_contained_tests($identifier, TRUE) as $test)
+ foreach(pts_contained_tests($identifier, true) as $test)
{
$xml_parser = new pts_test_tandem_XmlReader(pts_location_test($identifier));
$this_size = $xml_parser->getXMLValue(P_TEST_ENVIRONMENTSIZE);
if(!empty($this_size) && is_numeric($this_size))
+ {
$estimated_size += $this_size;
+ }
}
return $estimated_size;
@@ -259,15 +269,21 @@ function pts_test_architecture_supported($identifier)
$archs = explode(",", $archs);
foreach($archs as $key => $value)
+ {
$archs[$key] = trim($value);
+ }
$this_arch = kernel_arch();
if(strlen($this_arch) > 3 && substr($this_arch, -2) == "86")
+ {
$this_arch = "x86";
+ }
if(!in_array($this_arch, $archs))
+ {
$supported = false;
+ }
}
}
@@ -291,20 +307,28 @@ function pts_test_platform_supported($identifier)
$un_platforms = explode(",", $un_platforms);
foreach($un_platforms as $key => $value)
+ {
$un_platforms[$key] = trim($value);
+ }
if(in_array(OPERATING_SYSTEM, $un_platforms))
+ {
$supported = false;
+ }
}
if(!empty($platforms))
{
$platforms = explode(",", $platforms);
foreach($platforms as $key => $value)
+ {
$platforms[$key] = trim($value);
+ }
if(!in_array(OPERATING_SYSTEM, $platforms))
+ {
$supported = false;
+ }
}
}
}
@@ -328,19 +352,29 @@ function pts_test_version_supported($identifier)
}
function pts_suite_supported($identifier)
{
- $tests = pts_contained_tests($identifier, TRUE);
+ $tests = pts_contained_tests($identifier, true);
$supported_size = $original_size = count($tests);
for($i = 0; $i < $original_size; $i++)
+ {
if(!pts_test_supported(@$tests[$i]))
+ {
$supported_size--;
+ }
+ }
if($supported_size == 0)
+ {
$return_code = 0;
+ }
else if($supported_size != $original_size)
+ {
$return_code = 1;
+ }
else
+ {
$return_code = 2;
+ }
return $return_code;
}
@@ -356,7 +390,9 @@ function pts_available_tests_array()
asort($tests);
for($i = 0; $i < count($tests); $i++)
+ {
$tests[$i] = basename($tests[$i], ".xml");
+ }
return $tests;
}
@@ -380,7 +416,9 @@ function pts_available_suites_array()
asort($suites);
for($i = 0; $i < count($suites); $i++)
+ {
$suites[$i] = basename($suites[$i], ".xml");
+ }
return $suites;
}
@@ -396,16 +434,24 @@ function pts_test_version_compatible($version_compare = "")
$support_begins = preg_replace("/[^0-9]/", "", trim($version_compare[0]));
if(count($version_compare) == 2)
+ {
$support_ends = trim($version_compare[1]);
+ }
else
+ {
$support_ends = PTS_VERSION;
+ }
$support_ends = preg_replace("/[^0-9]/", "", $support_ends);
if($current >= $support_begins && $current <= $support_ends)
+ {
$compatible = true;
+ }
else
+ {
$compatible = false;
+ }
}
return $compatible;
diff --git a/pts-core/functions/pts-functions_types.php b/pts-core/functions/pts-functions_types.php
index 85d1463..c537832 100644
--- a/pts-core/functions/pts-functions_types.php
+++ b/pts-core/functions/pts-functions_types.php
@@ -60,19 +60,33 @@ function pts_test_type($identifier)
else if(!empty($identifier))
{
if(is_file(XML_PROFILE_LOCAL_DIR . OS_PREFIX . $identifier . ".xml"))
+ {
$test_type = TYPE_OS_LOCAL_TEST;
+ }
else if(is_file(XML_PROFILE_LOCAL_DIR . $identifier . ".xml"))
+ {
$test_type = TYPE_LOCAL_TEST;
+ }
else if(is_file(XML_SUITE_LOCAL_DIR . $identifier . ".xml"))
+ {
$test_type = TYPE_LOCAL_TEST_SUITE;
+ }
else if(is_file(XML_PROFILE_DIR . OS_PREFIX . $identifier . ".xml"))
+ {
$test_type = TYPE_OS_TEST;
+ }
else if(is_file(XML_PROFILE_DIR . $identifier . ".xml"))
+ {
$test_type = TYPE_TEST;
+ }
else if(is_file(XML_SUITE_DIR . $identifier . ".xml"))
+ {
$test_type = TYPE_TEST_SUITE;
+ }
else if(is_file(XML_PROFILE_CTP_BASE_DIR . $identifier . ".xml"))
+ {
$test_type = TYPE_BASE_TEST;
+ }
$GLOBALS["PTS_VAR_CACHE"]["TEST_TYPE"][$identifier] = $test_type;
}
@@ -94,9 +108,13 @@ function pts_location_suite($identifier)
$type = pts_test_type($identifier);
if($type == TYPE_TEST_SUITE)
+ {
$location = XML_SUITE_DIR . $identifier . ".xml";
+ }
else if($type == TYPE_LOCAL_TEST_SUITE)
+ {
$location = XML_SUITE_LOCAL_DIR . $identifier . ".xml";
+ }
}
$GLOBALS["PTS_VAR_CACHE"]["SUITE_LOCATION"][$identifier] = $location;
@@ -123,15 +141,25 @@ function pts_location_test($identifier)
$type = pts_test_type($identifier);
if($type == TYPE_TEST)
+ {
$location = XML_PROFILE_DIR . $identifier . ".xml";
+ }
else if($type == TYPE_OS_TEST)
+ {
$location = XML_PROFILE_DIR . OS_PREFIX . $identifier . ".xml";
+ }
else if($type == TYPE_LOCAL_TEST)
+ {
$location = XML_PROFILE_LOCAL_DIR . $identifier . ".xml";
+ }
else if($type == TYPE_OS_LOCAL_TEST)
+ {
$location = XML_PROFILE_LOCAL_DIR . OS_PREFIX . $identifier . ".xml";
+ }
else if($type == TYPE_BASE_TEST)
+ {
$location = XML_PROFILE_CTP_BASE_DIR . $identifier . ".xml";
+ }
}
$GLOBALS["PTS_VAR_CACHE"]["TEST_LOCATION"][$identifier] = $location;
@@ -158,15 +186,25 @@ function pts_location_test_resources($identifier)
$type = pts_test_type($identifier);
if($type == TYPE_OS_TEST && is_dir(TEST_RESOURCE_DIR . OS_PREFIX . $identifier))
+ {
$location = TEST_RESOURCE_DIR . OS_PREFIX . $identifier . "/";
+ }
else if(($type == TYPE_TEST || $type == TYPE_OS_TEST) && is_dir(TEST_RESOURCE_DIR . $identifier))
+ {
$location = TEST_RESOURCE_DIR . $identifier . "/";
+ }
else if($type == TYPE_OS_LOCAL_TEST && is_dir(TEST_RESOURCE_LOCAL_DIR . OS_PREFIX . $identifier))
+ {
$location = TEST_RESOURCE_LOCAL_DIR . OS_PREFIX . $identifier . "/";
+ }
else if(($type == TYPE_LOCAL_TEST || $type == TYPE_OS_LOCAL_TEST) && is_dir(TEST_RESOURCE_LOCAL_DIR . $identifier))
+ {
$location = TEST_RESOURCE_LOCAL_DIR . $identifier . "/";
+ }
else if($type == TYPE_BASE_TEST && is_dir(TEST_RESOURCE_CTP_BASE_DIR . $identifier))
+ {
$location = TEST_RESOURCE_CTP_BASE_DIR . $identifier . "/";
+ }
}
$GLOBALS["PTS_VAR_CACHE"]["TEST_RESOURCE_LOCATION"][$identifier] = $location;
@@ -188,9 +226,13 @@ function pts_test_extends_below($object)
if(!empty($test_extends))
{
if(!in_array($test_extends, $extensions) && is_test($test_extends))
+ {
array_push($extensions, $test_extends);
+ }
else
+ {
$test_extends = null;
+ }
}
}
}
@@ -198,7 +240,7 @@ function pts_test_extends_below($object)
return $extensions;
}
-function pts_contained_tests($object, $include_extensions = FALSE)
+function pts_contained_tests($object, $include_extensions = false)
{
// Provide an array containing the location(s) of all test(s) for the supplied object name
$tests = array();
@@ -209,16 +251,24 @@ function pts_contained_tests($object, $include_extensions = FALSE)
$tests_in_suite = array_unique($xml_parser->getXMLArrayValues(P_SUITE_TEST_NAME));
foreach($tests_in_suite as $test)
+ {
foreach(pts_contained_tests($test, $include_extensions) as $sub_test)
+ {
array_push($tests, $sub_test);
+ }
+ }
}
else if(is_test($object)) // Object is a test
{
if($include_extensions)
{
foreach(pts_test_extends_below($object) as $extension)
+ {
if(!in_array($extension, $tests))
+ {
array_push($tests, $extension);
+ }
+ }
}
array_push($tests, $object);
}
@@ -228,8 +278,12 @@ function pts_contained_tests($object, $include_extensions = FALSE)
$tests_in_file = $xml_parser->getXMLArrayValues(P_RESULTS_TEST_TESTNAME);
foreach($tests_in_file as $test)
+ {
foreach(pts_contained_tests($test, $include_extensions) as $sub_test)
+ {
array_push($tests, $sub_test);
+ }
+ }
}
else if(is_file(SAVE_RESULTS_DIR . $object . "/composite.xml")) // Object is a saved results file
{
@@ -237,8 +291,12 @@ function pts_contained_tests($object, $include_extensions = FALSE)
$tests_in_save = $xml_parser->getXMLArrayValues(P_RESULTS_TEST_TESTNAME);
foreach($tests_in_save as $test)
+ {
foreach(pts_contained_tests($test, $include_extensions) as $sub_test)
+ {
array_push($tests, $sub_test);
+ }
+ }
}
else if(pts_is_global_id($object)) // Object is a Phoronix Global file
{
@@ -246,8 +304,12 @@ function pts_contained_tests($object, $include_extensions = FALSE)
$tests_in_global = $xml_parser->getXMLArrayValues(P_RESULTS_TEST_TESTNAME);
foreach($tests_in_global as $test)
+ {
foreach(pts_contained_tests($test, $include_extensions) as $sub_test)
+ {
array_push($tests, $sub_test);
+ }
+ }
}
return array_unique($tests);
@@ -256,13 +318,21 @@ function pts_find_result_file($file, $check_global = true)
{
// PTS Find A Saved File
if(is_file($file))
+ {
$USE_FILE = $file;
+ }
else if(is_file(SAVE_RESULTS_DIR . $file . "/composite.xml"))
+ {
$USE_FILE = SAVE_RESULTS_DIR . $file . "/composite.xml";
+ }
else if($check_global && pts_is_global_id($file))
+ {
$USE_FILE = "http://www.phoronix-test-suite.com/global/pts-results-viewer.php?id=" . $file;
+ }
else
- $USE_FILE = FALSE;
+ {
+ $USE_FILE = false;
+ }
return $USE_FILE;
}
diff --git a/pts-core/functions/pts-init.php b/pts-core/functions/pts-init.php
index 266d779..8cd68e7 100644
--- a/pts-core/functions/pts-init.php
+++ b/pts-core/functions/pts-init.php
@@ -30,12 +30,16 @@ function pts_directory()
$dir = getenv("PTS_DIR");
if($dir == ".")
+ {
$dir = "";
+ }
if(!empty($dir))
{
if(substr($dir, -1) != "/")
+ {
$dir .= "/";
+ }
}
return $dir;
@@ -55,12 +59,12 @@ function pts_init()
define("PTS_START_TIME", THIS_RUN_TIME);
// Run in debug mode?
- if(($debug_file = getenv("DEBUG_FILE")) != FALSE || getenv("DEBUG") == "1" || getenv("PTS_DEBUG") == "1")
+ if(($debug_file = getenv("DEBUG_FILE")) != false || getenv("DEBUG") == "1" || getenv("PTS_DEBUG") == "1")
{
define("PTS_DEBUG_MODE", 1);
define("IS_DEBUG_MODE", true);
- if($debug_file != FALSE)
+ if($debug_file != false)
{
define("PTS_DEBUG_FILE", $debug_file);
$GLOBALS["DEBUG_CONTENTS"] = "";
@@ -69,16 +73,20 @@ function pts_init()
error_reporting(E_ALL | E_STRICT); // Set error reporting to all and strict
}
else
+ {
define("IS_DEBUG_MODE", false);
+ }
// Self-Contained Test Profile
- if(($sctp_file = getenv("SCTP_FILE")) != FALSE && is_file($sctp_file))
+ if(($sctp_file = getenv("SCTP_FILE")) != false && is_file($sctp_file))
{
define("SCTP_FILE", $sctp_file);
define("IS_SCTP_MODE", true);
}
else
+ {
define("IS_SCTP_MODE", false);
+ }
// Operating System Detection
$supported_operating_systems = array("Linux", array("Solaris", "Sun"), "FreeBSD", "BSD", array("MacOSX", "Darwin"));
@@ -87,14 +95,16 @@ function pts_init()
foreach($supported_operating_systems as $os_check)
{
if(!is_array($os_check))
+ {
$os_check = array($os_check);
+ }
$is_os = false;
$os_title = $os_check[0];
for($i = 0; $i < count($os_check) && !$is_os; $i++)
{
- if(strpos($uname_s, strtolower($os_check[$i])) !== FALSE) // Check for OS
+ if(strpos($uname_s, strtolower($os_check[$i])) !== false) // Check for OS
{
define("OPERATING_SYSTEM", $os_title);
define("IS_" . strtoupper($os_title), true);
@@ -103,7 +113,9 @@ function pts_init()
}
if(!$is_os)
+ {
define("IS_" . strtoupper($os_title), false);
+ }
}
if(!defined("OPERATING_SYSTEM"))
@@ -112,7 +124,9 @@ function pts_init()
define("IS_UNKNOWN", true);
}
else
+ {
define("IS_UNKNOWN", false);
+ }
define("OS_PREFIX", strtolower(OPERATING_SYSTEM) . "_");
}
@@ -127,9 +141,13 @@ function pts_extended_init()
@file_put_contents(PTS_DOWNLOAD_CACHE_DIR . "make-cache-howto", "A download cache is used for conserving time and bandwidth by eliminating the need for the Phoronix Test Suite to download files that have already been downloaded once. A download cache can also be transferred between PCs running the Phoronix Test Suite. For more information on this feature, view the included documentation. To generate a download cache, run:\n\nphoronix-test-suite make-download-cache\n");
}
if(!is_dir(XML_SUITE_LOCAL_DIR))
+ {
@mkdir(XML_SUITE_LOCAL_DIR);
+ }
if(!is_dir(TEST_RESOURCE_LOCAL_DIR))
+ {
@mkdir(TEST_RESOURCE_LOCAL_DIR);
+ }
if(!is_dir(XML_PROFILE_LOCAL_DIR))
{
@mkdir(XML_PROFILE_LOCAL_DIR);
@@ -139,50 +157,78 @@ function pts_extended_init()
// OpenGL / graphics detection
$opengl_driver = opengl_version();
- if(strpos($opengl_driver, "NVIDIA") !== FALSE)
+ if(strpos($opengl_driver, "NVIDIA") !== false)
+ {
define("IS_NVIDIA_GRAPHICS", true);
- else if(strpos($opengl_driver, "fglrx") !== FALSE)
+ }
+ else if(strpos($opengl_driver, "fglrx") !== false)
+ {
define("IS_ATI_GRAPHICS", true);
- else if(strpos($opengl_driver, "Mesa") !== FALSE)
+ }
+ else if(strpos($opengl_driver, "Mesa") !== false)
+ {
define("IS_MESA_GRAPHICS", true);
+ }
else
+ {
define("IS_UNKNOWN_GRAPHICS", true);
+ }
if(!defined("IS_NVIDIA_GRAPHICS"))
+ {
define("IS_NVIDIA_GRAPHICS", false);
+ }
if(!defined("IS_ATI_GRAPHICS"))
+ {
define("IS_ATI_GRAPHICS", false);
+ }
if(!defined("IS_MESA_GRAPHICS"))
+ {
define("IS_MESA_GRAPHICS", false);
+ }
if(!defined("IS_UNKNOWN_GRAPHICS"))
+ {
define("IS_UNKNOWN_GRAPHICS", false);
+ }
// Check for batch mode
- if(getenv("PTS_BATCH_MODE") != FALSE)
+ if(getenv("PTS_BATCH_MODE") != false)
{
if(pts_read_user_config(P_OPTION_BATCH_CONFIGURED, "FALSE") == "FALSE")
+ {
pts_exit(pts_string_header("The batch mode must first be configured\nRun: phoronix-test-suite batch-setup"));
+ }
define("PTS_BATCH_MODE", "1");
define("IS_BATCH_MODE", true);
}
else
+ {
define("IS_BATCH_MODE", false);
+ }
// Self-Contained Test Profile Routines
if(IS_SCTP_MODE)
+ {
generate_sctp_layer();
+ }
if(substr(pts_read_user_config(P_OPTION_TESTCORE_LASTTIME, date("Y-m-d")), 0, 10) != date("Y-m-d"))
+ {
define("IS_FIRST_RUN_TODAY", true);
+ }
else
+ {
define("IS_FIRST_RUN_TODAY", false);
+ }
}
function __autoload($to_load)
{
// Autoload needed objects
if(is_file(PTS_DIR . "pts-core/objects/" . $to_load . ".php"))
- require_once(PTS_DIR . "pts-core/objects/" . $to_load . ".php");
+ {
+ include_once(PTS_DIR . "pts-core/objects/" . $to_load . ".php");
+ }
}
?>
diff --git a/pts-core/objects/pts_BarGraph.php b/pts-core/objects/pts_BarGraph.php
index a2e3b2e..15775f2 100644
--- a/pts-core/objects/pts_BarGraph.php
+++ b/pts-core/objects/pts_BarGraph.php
@@ -60,17 +60,25 @@ class pts_BarGraph extends pts_CustomGraph
$px_bound_right = $px_bound_left + $this->identifier_width;
if($i == 0)
+ {
$this->draw_line($this->graph_image, $px_bound_left, $px_from_top_start, $px_bound_left, $px_from_top_end, $this->graph_color_notches);
+ }
if($i == (count($this->graph_identifiers) - 1) && $px_bound_right != $this->graph_left_end)
+ {
$px_bound_right = $this->graph_left_end;
+ }
$this->draw_line($this->graph_image, $px_bound_right, $px_from_top_start, $px_bound_right, $px_from_top_end, $this->graph_color_notches);
if($this->graph_font_size_identifiers == $this->minimum_identifier_font)
- $this->write_text_left($this->graph_identifiers[$i], 9, $this->graph_color_headers, $px_bound_left + ceil($this->identifier_width / 2), $px_from_top_end, $px_bound_left + ceil($this->identifier_width / 2), $px_from_top_end, TRUE);
+ {
+ $this->write_text_left($this->graph_identifiers[$i], 9, $this->graph_color_headers, $px_bound_left + ceil($this->identifier_width / 2), $px_from_top_end, $px_bound_left + ceil($this->identifier_width / 2), $px_from_top_end, true);
+ }
else
- $this->write_text_center($this->graph_identifiers[$i], $this->graph_font_size_identifiers, $this->graph_color_headers, $px_bound_left, $px_from_top_end - 5, $px_bound_right, $px_from_top_end - 5, FALSE, TRUE);
+ {
+ $this->write_text_center($this->graph_identifiers[$i], $this->graph_font_size_identifiers, $this->graph_color_headers, $px_bound_left, $px_from_top_end - 5, $px_bound_right, $px_from_top_end - 5, false, true);
+ }
}
}
protected function render_graph_bars()
@@ -92,13 +100,17 @@ class pts_BarGraph extends pts_CustomGraph
$px_bound_right = $px_bound_left + $bar_width;
if($value_plot_top < 1)
+ {
$value_plot_top = 1;
+ }
$this->draw_rectangle_border($this->graph_image, $px_bound_left, $value_plot_top - 1, $px_bound_right, $this->graph_top_end - 1, $this->graph_color_body_light);
$this->draw_rectangle($this->graph_image, $px_bound_left + 1, $value_plot_top, $px_bound_right - 1, $this->graph_top_end - 1, $paint_color);
if($graph_size > 20)
+ {
$this->write_text_center($this->graph_data[$i_o][$i], $this->graph_font_size_bars, $this->graph_color_body_text, $px_bound_left, $value_plot_top + 3, $px_bound_right, $value_plot_top + 3);
+ }
}
}
}
diff --git a/pts-core/objects/pts_CustomGraph.php b/pts-core/objects/pts_CustomGraph.php
index 3e46ff4..59432f2 100644
--- a/pts-core/objects/pts_CustomGraph.php
+++ b/pts-core/objects/pts_CustomGraph.php
@@ -26,9 +26,14 @@ class pts_CustomGraph extends pts_Graph
function __construct($Title, $SubTitle, $YTitle)
{
if(is_file(PTS_USER_DIR . "graph-config.xml"))
+ {
$file = file_get_contents(PTS_USER_DIR . "graph-config.xml");
+ }
else
+ {
$file = "";
+ }
+
$read_config = new tandem_XmlReader($file);
$this->graph_attr_width = pts_read_graph_config(P_GRAPH_SIZE_WIDTH, null, $read_config); // Graph width
diff --git a/pts-core/objects/pts_Graph.php b/pts-core/objects/pts_Graph.php
index 38bc318..911dd79 100644
--- a/pts-core/objects/pts_Graph.php
+++ b/pts-core/objects/pts_Graph.php
@@ -27,7 +27,7 @@ class pts_Graph
var $graph_attr_marks = 6; // Number of marks to make on vertical axis
var $graph_attr_width = 580; // Graph width
var $graph_attr_height = 300; // Graph height
- var $graph_attr_big_border = FALSE; // Border around graph or not
+ var $graph_attr_big_border = false; // Border around graph or not
var $graph_left_start = 20; // Distance in px to start graph from left side
var $graph_left_end_opp = 10; // Distance in px to end graph from right side
@@ -63,10 +63,10 @@ class pts_Graph
// CHANGE DIRECTORY FOR TTF FONT LOCATION INSIDE __construct FUNCTION
// Not user-friendly changes below this line
- var $graph_body_image = FALSE;
- var $graph_hide_identifiers = FALSE;
- var $graph_show_key = FALSE;
- var $graph_background_lines = FALSE;
+ var $graph_body_image = false;
+ var $graph_hide_identifiers = false;
+ var $graph_show_key = false;
+ var $graph_background_lines = false;
var $graph_type = "GRAPH";
var $graph_value_type = "NUMERICAL";
var $graph_image;
@@ -81,7 +81,7 @@ class pts_Graph
var $graph_title;
var $graph_sub_title;
var $graph_y_title;
- var $graph_y_title_hide = FALSE;
+ var $graph_y_title_hide = false;
var $graph_top_end;
var $graph_left_end;
@@ -97,11 +97,17 @@ class pts_Graph
// Directory for TTF Fonts
if(defined("FONT_DIR"))
+ {
putenv("GDFONTPATH=" . FONT_DIR);
- else if(($font_env = getenv("FONT_DIR")) != FALSE)
+ }
+ else if(($font_env = getenv("FONT_DIR")) != false)
+ {
putenv("GDFONTPATH=" . $font_env);
+ }
else
+ {
putenv("GDFONTPATH=" . getcwd());
+ }
}
public function setRenderer($Renderer)
{
@@ -111,7 +117,9 @@ class pts_Graph
$this->graph_left_start += 10;
}
else
+ {
$this->graph_renderer = "PNG";
+ }
}
public function getRenderer()
{
@@ -133,12 +141,16 @@ class pts_Graph
public function loadGraphVersion($data)
{
if(!empty($data))
+ {
$this->graph_version = "Phoronix Test Suite " . $data;
+ }
}
public function loadGraphProportion($data)
{
if($data == "LIB")
+ {
$this->graph_proportion = "Less Is Better";
+ }
//else if($data == "HIB")
// $this->graph_proportion = "More Is Better";
}
@@ -146,23 +158,31 @@ class pts_Graph
{
loadGraphValues($data_array);
}
- public function loadGraphValues($data_array, $data_title = NULL)
+ public function loadGraphValues($data_array, $data_title = null)
{
for($i = 0; $i < count($data_array); $i++)
+ {
if(is_float($data_array[$i]))
+ {
$data_array[$i] = $this->trim_double($data_array[$i], 2);
+ }
+ }
array_push($this->graph_data, $data_array);
if(!empty($data_title))
+ {
array_push($this->graph_data_title, $data_title);
+ }
}
public function setGraphBackgroundPNG($File)
{
$IMG = $this->read_png_image($File);
- if($IMG != FALSE)
+ if($IMG != false)
+ {
$this->graph_body_image = $IMG;
+ }
}
//
@@ -191,12 +211,20 @@ class pts_Graph
$maximum = $this->graph_attr_marks;
foreach($this->graph_data as $graph_set)
+ {
foreach($graph_set as $set_item)
+ {
if((is_numeric($set_item) && $set_item > $maximum) || (!is_numeric($set_item) && strlen($set_item) > strlen($maximum)))
+ {
$maximum = $set_item;
+ }
+ }
+ }
if(is_numeric($maximum))
+ {
$maximum = (floor(round($maximum * 1.35) / $this->graph_attr_marks) + 1) * $this->graph_attr_marks;
+ }
return $maximum;
}
@@ -216,11 +244,14 @@ class pts_Graph
$px_length = 0;
foreach($arr_string as $one_string)
+ {
if(($new_length = strlen($one_string)) > strlen($longest_string))
{
$longest_string = $one_string;
$px_length = $new_length;
}
+ }
+
return $longest_string;
}
protected function update_graph_dimensions($width = -1, $height = -1, $recalculate_offsets = false)
@@ -268,17 +299,21 @@ class pts_Graph
$this->graph_color_body_light = $this->convert_hex_to_type($this->graph_color_body_light);
for($i = 0; $i < count($this->graph_color_paint); $i++)
+ {
$this->graph_color_paint[$i] = $this->convert_hex_to_type($this->graph_color_paint[$i]);
+ }
// Background Color
$this->draw_rectangle($this->graph_image, 0, 0, $this->graph_attr_width, $this->graph_attr_height, $this->graph_color_background);
- if($this->graph_attr_big_border == TRUE)
+ if($this->graph_attr_big_border == true)
+ {
$this->draw_rectangle_border($this->graph_image, 0, 0, $this->graph_attr_width - 1, $this->graph_attr_height - 1, $this->graph_color_border);
+ }
}
protected function render_graph_base()
{
- if(count($this->graph_data_title) > 1 || $this->graph_show_key == TRUE)
+ if(count($this->graph_data_title) > 1 || $this->graph_show_key == true)
{
$num_key_lines = ceil(count($this->graph_data_title) / 4);
$this->graph_top_start = $this->graph_top_start + 8 + ($num_key_lines * 11);
@@ -287,16 +322,15 @@ class pts_Graph
$this->draw_rectangle($this->graph_image, $this->graph_left_start, $this->graph_top_start, $this->graph_left_end, $this->graph_top_end, $this->graph_color_body);
$this->draw_rectangle_border($this->graph_image, $this->graph_left_start, $this->graph_top_start, $this->graph_left_end, $this->graph_top_end, $this->graph_color_notches);
- if($this->graph_body_image != FALSE && $this->graph_renderer == "PNG")
+ if($this->graph_body_image != false && $this->graph_renderer == "PNG")
{
imagecopymerge($this->graph_image, $this->graph_body_image, $this->graph_left_start + (($this->graph_left_end - $this->graph_left_start) / 2) - imagesx($this->graph_body_image) / 2, $this->graph_top_start + (($this->graph_top_end - $this->graph_top_start) / 2) - imagesy($this->graph_body_image) / 2, 0, 0, imagesx($this->graph_body_image), imagesy($this->graph_body_image), 95);
-
}
// Text
$this->write_text_right($this->graph_version, 7, $this->graph_color_body_light, $this->graph_left_end, $this->graph_top_start - 9, $this->graph_left_end, $this->graph_top_start - 9);
$this->write_text_center($this->graph_title, $this->graph_font_size_heading, $this->graph_color_main_headers, $this->graph_left_start, 4, $this->graph_left_end, 4);
- $this->write_text_center($this->graph_sub_title, $this->graph_font_size_sub_heading, $this->graph_color_main_headers, $this->graph_left_start, 26, $this->graph_left_end, 26, FALSE, TRUE);
+ $this->write_text_center($this->graph_sub_title, $this->graph_font_size_sub_heading, $this->graph_color_main_headers, $this->graph_left_start, 26, $this->graph_left_end, 26, false, true);
if(!empty($this->graph_y_title) && !$this->graph_y_title_hide)
{
@@ -305,13 +339,15 @@ class pts_Graph
if(!empty($this->graph_proportion))
{
if(!empty($str))
+ {
$str .= ", ";
+ }
$str .= $this->graph_proportion;
}
$this->write_text_left($str, 7, $this->graph_color_main_headers, $this->graph_left_start, $this->graph_top_start - 9, $this->graph_left_start, $this->graph_top_start - 9);
- //$this->write_text_center($this->graph_y_title, $this->graph_font_size_axis_heading, $this->graph_color_headers, 3, $this->graph_top_start, 3, $this->graph_top_end, TRUE);
+ //$this->write_text_center($this->graph_y_title, $this->graph_font_size_axis_heading, $this->graph_color_headers, 3, $this->graph_top_start, 3, $this->graph_top_end, true);
}
}
protected function render_graph_value_ticks()
@@ -330,14 +366,20 @@ class pts_Graph
$this->write_text_right($display_value, $this->graph_font_size_tick_mark, $this->graph_color_text, $px_from_left_start - 1, $px_from_top - 2, $px_from_left_start - 1, $px_from_top - 2);
- if($i != 0 && $this->graph_background_lines == TRUE)
+ if($i != 0 && $this->graph_background_lines == true)
{
$line_width = 6;
for($y = $px_from_left_end + $line_width; $y < $this->graph_left_end; $y += ($line_width * 2))
+ {
if($y + $line_width < $this->graph_left_end)
+ {
$this->draw_line($this->graph_image, $y, $px_from_top, $y += $line_width, $px_from_top, $this->graph_color_body_light);
+ }
else
+ {
$this->draw_line($this->graph_image, $y, $px_from_top, $y += ($this->graph_left_end - $y) - 1, $px_from_top, $this->graph_color_body_light);
+ }
+ }
}
$display_value += $this->trim_double($this->graph_maximum_value / $this->graph_attr_marks, 2);
@@ -349,10 +391,14 @@ class pts_Graph
// Make room for tick markings, left hand side
if($this->graph_value_type == "NUMERICAL")
+ {
$this->graph_left_start += $this->return_ttf_string_width($this->graph_maximum_value, $this->graph_font, $this->graph_font_size_tick_mark) + 2;
+ }
- if($this->graph_hide_identifiers == TRUE)
+ if($this->graph_hide_identifiers == true)
+ {
$this->graph_top_end += $this->graph_top_end_opp / 2;
+ }
// Do the actual work
$this->render_graph_pre_init();
@@ -360,10 +406,14 @@ class pts_Graph
$this->render_graph_base();
if(!$this->graph_hide_identifiers)
+ {
$this->render_graph_identifiers();
+ }
if($this->graph_value_type == "NUMERICAL")
+ {
$this->render_graph_value_ticks();
+ }
$this->render_graph_key();
$this->render_graph_result();
@@ -380,8 +430,10 @@ class pts_Graph
}
protected function render_graph_key()
{
- if(count($this->graph_data_title) < 2 && $this->graph_show_key == FALSE)
+ if(count($this->graph_data_title) < 2 && $this->graph_show_key == false)
+ {
return;
+ }
$key_counter = 0;
$component_y = $this->graph_top_start - 20;
@@ -403,18 +455,19 @@ class pts_Graph
$this->draw_rectangle_border($this->graph_image, $component_x - 13, $component_y - 5, $component_x - 3, $component_y + 5, $this->graph_color_notches);
if($key_counter % 4 == 0)
+ {
$component_y -= 12;
+ }
}
}
$this->reset_paint_index();
}
protected function render_graph_watermark()
{
- if(empty($this->graph_watermark_text))
- return;
-
- $this->write_text_right($this->graph_watermark_text, 10, $this->graph_color_text, $this->graph_left_end - 2, $this->graph_top_start + 8, $this->graph_left_end - 2, $this->graph_top_start + 8);
-
+ if(!empty($this->graph_watermark_text))
+ {
+ $this->write_text_right($this->graph_watermark_text, 10, $this->graph_color_text, $this->graph_left_end - 2, $this->graph_top_start + 8, $this->graph_left_end - 2, $this->graph_top_start + 8);
+ }
}
protected function return_graph_image()
{
@@ -431,22 +484,32 @@ class pts_Graph
$return = explode(".", $double);
if(count($return) == 1)
+ {
$return[1] = "00";
+ }
if(count($return) == 2 && $accuracy > 0)
{
$strlen = strlen($return[1]);
if($strlen > $accuracy)
+ {
$return[1] = substr($return[1], 0, $accuracy);
+ }
else if($strlen < $accuracy)
+ {
for($i = $strlen; $i < $accuracy; $i++)
+ {
$return[1] .= '0';
+ }
+ }
$return = $return[0] . "." . $return[1];
}
else
+ {
$return = $return[0];
+ }
return $return;
}
@@ -469,14 +532,18 @@ class pts_Graph
imageinterlace($img, true);
if(function_exists("imageantialias"))
+ {
imageantialias($img, true);
+ }
}
else if($this->graph_renderer == "SVG")
{
$img = "<?xml version=\"1.0\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n";
foreach($this->graph_user_identifiers as $key => $value)
+ {
$img .= "<!-- " . $key . ": " . $value . " -->\n";
+ }
$img .= "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" viewbox=\"0 0 " . $width . " " . $height . "\" width=\"" . $width . "\" height=\"" . $height . "\">\n\n";
}
@@ -486,42 +553,62 @@ class pts_Graph
protected function render_image(&$img_object, $output_file = null, $quality = 0)
{
if($this->graph_renderer == "PNG")
+ {
imagepng($img_object, $output_file, $quality);
+ }
else if($this->graph_renderer == "SVG")
{
$img_object .= "\n\n</svg>";
if($output_file != null)
+ {
@file_put_contents($output_file, $img_object);
+ }
}
}
protected function read_png_image($File)
{
if($this->graph_renderer == "PNG")
+ {
$img = @imagecreatefrompng($File);
+ }
+ else
+ {
+ $img = null;
+ }
return $img;
}
protected function deinit_image(&$img_object)
{
if($this->graph_renderer == "PNG")
+ {
imagedestroy($img_object);
+ }
else if($this->graph_renderer == "SVG")
+ {
$img_object = null;
+ }
}
protected function convert_hex_to_type($Hex)
{
if($this->graph_renderer == "PNG")
+ {
$color = imagecolorallocate($this->graph_image, hexdec(substr($Hex, 1, 2)), hexdec(substr($Hex, 3, 2)), hexdec(substr($Hex, 5, 2)));
+ }
else if($this->graph_renderer == "SVG")
+ {
$color = $Hex;
+ }
return $color;
}
- protected function write_text_left($text_string, $font_size, $font_color, $bound_x1, $bound_y1, $bound_x2, $bound_y2, $rotate = FALSE)
+ protected function write_text_left($text_string, $font_size, $font_color, $bound_x1, $bound_y1, $bound_x2, $bound_y2, $rotate = false)
{
if(empty($text_string))
+ {
return;
+ }
if($this->graph_renderer == "PNG")
{
@@ -529,7 +616,7 @@ class pts_Graph
$ttf_width = $ttf_dimensions[0];
$ttf_height = $ttf_dimensions[1];
- if($rotate == FALSE)
+ if($rotate == false)
{
$text_x = $bound_x1;
$text_y = $bound_y1 + round($ttf_height / 2);
@@ -549,7 +636,7 @@ class pts_Graph
$ttf_width = $ttf_dimensions[0];
$ttf_height = $ttf_dimensions[1];
- if($rotate == FALSE)
+ if($rotate == false)
{
$text_x = $bound_x1;
$text_y = $bound_y1 + round($ttf_height / 2);
@@ -564,10 +651,12 @@ class pts_Graph
$this->write_svg_text($this->graph_image, $font_size, $rotation, $text_x, $text_y, $font_color, $this->graph_font, $text_string, "LEFT");
}
}
- protected function write_text_right($text_string, $font_size, $font_color, $bound_x1, $bound_y1, $bound_x2, $bound_y2, $rotate_text = FALSE)
+ protected function write_text_right($text_string, $font_size, $font_color, $bound_x1, $bound_y1, $bound_x2, $bound_y2, $rotate_text = false)
{
if(empty($text_string))
+ {
return;
+ }
if($this->graph_renderer == "PNG")
{
@@ -575,10 +664,14 @@ class pts_Graph
$ttf_width = $ttf_dimensions[0];
$ttf_height = $ttf_dimensions[1];
- if($rotate_text == FALSE)
+ if($rotate_text == false)
+ {
$rotation = 0;
+ }
else
+ {
$rotation = 90;
+ }
$text_x = $bound_x2 - $ttf_width;
$text_y = $bound_y1 + round($ttf_height / 2);
@@ -594,10 +687,14 @@ class pts_Graph
$bound_x1 -= 2;
$bound_x2 -= 2;
- if($rotate_text == FALSE)
+ if($rotate_text == false)
+ {
$rotation = 0;
+ }
else
+ {
$rotation = 90;
+ }
$text_x = $bound_x2 - $ttf_width;
$text_y = $bound_y1 + round($ttf_height / 2);
@@ -605,10 +702,12 @@ class pts_Graph
$this->write_svg_text($this->graph_image, $font_size, $rotation, $text_x, $text_y, $font_color, $this->graph_font, $text_string, "RIGHT");
}
}
- protected function write_text_center($text_string, $font_size, $font_color, $bound_x1, $bound_y1, $bound_x2, $bound_y2, $rotate_text = FALSE, $big_type = FALSE)
+ protected function write_text_center($text_string, $font_size, $font_color, $bound_x1, $bound_y1, $bound_x2, $bound_y2, $rotate_text = false, $big_type = false)
{
if(empty($text_string))
+ {
return;
+ }
if($this->graph_renderer == "PNG")
{
@@ -622,7 +721,7 @@ class pts_Graph
$ttf_dimensions = $this->return_ttf_string_dimensions($text_string, $this->graph_font, $font_size, $big_type);
$ttf_width = $ttf_dimensions[0];
- if($rotate_text == FALSE)
+ if($rotate_text == false)
{
$rotation = 0;
$text_x = (($bound_x2 - $bound_x1) / 2) + $bound_x1 - round($ttf_width / 2);
@@ -649,7 +748,7 @@ class pts_Graph
$ttf_dimensions = $this->return_ttf_string_dimensions($text_string, $this->graph_font, $font_size, $big_type);
$ttf_width = $ttf_dimensions[0];
- if($rotate_text == FALSE)
+ if($rotate_text == false)
{
$rotation = 0;
$text_x = (($bound_x2 - $bound_x1) / 2) + $bound_x1 - round($ttf_width / 2);
@@ -697,16 +796,22 @@ class pts_Graph
protected function draw_rectangle(&$img_object, $x1, $y1, $width, $height, $background_color)
{
if($this->graph_renderer == "PNG")
+ {
imagefilledrectangle($img_object, $x1, $y1, $width, $height, $background_color);
+ }
else if($this->graph_renderer == "SVG")
{
$width = $width - $x1;
$height = $height - $y1;
if($width < 0)
+ {
$x1 += $width;
+ }
if($height < 0)
+ {
$y1 += $height;
+ }
$img_object .= "<rect x=\"" . $x1 . "\" y=\"" . $y1 . "\" width=\"" . abs($width) . "\" height=\"" . abs($height) . "\" fill=\"" . $background_color . "\" />\n";
}
@@ -714,18 +819,26 @@ class pts_Graph
protected function draw_rectangle_border(&$img_object, $x1, $y1, $width, $height, $color)
{
if($this->graph_renderer == "PNG")
+ {
imagerectangle($img_object, $x1, $y1, $width, $height, $color);
+ }
else if($this->graph_renderer == "SVG")
+ {
$img_object .= "<rect x=\"" . $x1 . "\" y=\"" . $y1 . "\" width=\"" . ($width - $x1) . "\" height=\"" . ($height - $y1) . "\" fill=\"transparent\" stroke=\"" . $color . "\" stroke-width=\"1px\" />\n";
+ }
}
protected function draw_line(&$img_object, $left_start, $top_start, $from_left, $from_top, $color)
{
if($this->graph_renderer == "PNG")
+ {
imageline($img_object, $left_start, $top_start, $from_left, $from_top, $color);
+ }
else if($this->graph_renderer == "SVG")
+ {
$img_object .= "<line x1=\"" . $left_start . "\" y1=\"" . $top_start . "\" x2=\"" . $from_left . "\" y2=\"" . $from_top . "\" stroke=\"" . $color . "\" stroke-width=\"1px\" />\n";
+ }
}
- protected function return_ttf_string_dimensions($String, $Font, $Size, $Big = FALSE)
+ protected function return_ttf_string_dimensions($String, $Font, $Size, $Big = false)
{
if($this->graph_renderer == "PNG" && function_exists("imagettfbbox"))
{
@@ -733,7 +846,9 @@ class pts_Graph
$box_width = $box_array[4] - $box_array[6];
if($Big)
+ {
$box_array = imagettfbbox($Size, 0, $Font, "AZ@![]()@|_");
+ }
$box_height = $box_array[1] - $box_array[7];
}
else if($this->graph_renderer == "SVG")
diff --git a/pts-core/objects/pts_LineGraph.php b/pts-core/objects/pts_LineGraph.php
index 09ce2ff..9955009 100644
--- a/pts-core/objects/pts_LineGraph.php
+++ b/pts-core/objects/pts_LineGraph.php
@@ -30,8 +30,8 @@ class pts_LineGraph extends pts_CustomGraph
{
parent::__construct($Title, $SubTitle, $YTitle);
$this->graph_type = "LINE_GRAPH";
- $this->graph_show_key = TRUE;
- $this->graph_background_lines = TRUE;
+ $this->graph_show_key = true;
+ $this->graph_background_lines = true;
}
protected function render_graph_pre_init()
{
@@ -63,9 +63,13 @@ class pts_LineGraph extends pts_CustomGraph
$this->draw_line($this->graph_image, $px_from_left, $px_from_top_start, $px_from_left, $px_from_top_end, $this->graph_color_notches);
if($this->graph_font_size_identifiers == $this->minimum_identifier_font)
- $this->write_text_left($this->graph_identifiers[$i], 9, $this->graph_color_headers, $px_from_left, $px_from_top_end + 2, $px_from_left, $px_from_top_end + 2, TRUE);
+ {
+ $this->write_text_left($this->graph_identifiers[$i], 9, $this->graph_color_headers, $px_from_left, $px_from_top_end + 2, $px_from_left, $px_from_top_end + 2, true);
+ }
else
+ {
$this->write_text_center($this->graph_identifiers[$i], $this->graph_font_size_identifiers, $this->graph_color_headers, $px_from_left, $px_from_top_end + 2, $px_from_left, $px_from_top_end + 2);
+ }
}
}
protected function renderGraphLines()
@@ -84,10 +88,14 @@ class pts_LineGraph extends pts_CustomGraph
$px_from_left = $this->graph_left_start + ($this->identifier_width * ($i + 1));
if($px_from_left > $this->graph_left_end)
+ {
$px_from_left = $this->graph_left_end - 1;
+ }
if($value_plot_top >= $this->graph_top_end)
+ {
$value_plot_top = $this->graph_top_end - 1;
+ }
if($previous_placement != -1 && $previous_offset != -1)
{
diff --git a/pts-core/objects/pts_MultiPassFailGraph.php b/pts-core/objects/pts_MultiPassFailGraph.php
index c188ee7..e123aac 100644
--- a/pts-core/objects/pts_MultiPassFailGraph.php
+++ b/pts-core/objects/pts_MultiPassFailGraph.php
@@ -25,11 +25,11 @@ class pts_MultiPassFailGraph extends pts_CustomGraph
{
public function __construct($Title, $SubTitle, $YTitle)
{
- $this->graph_y_title_hide = TRUE;
+ $this->graph_y_title_hide = true;
parent::__construct($Title, $SubTitle, $YTitle, true);
$this->graph_type = "MULTI_PASS_FAIL";
$this->graph_value_type = "ABSTRACT";
- $this->graph_hide_identifiers = TRUE;
+ $this->graph_hide_identifiers = true;
}
protected function render_graph_passfail()
{
@@ -48,10 +48,14 @@ class pts_MultiPassFailGraph extends pts_CustomGraph
$main_font_size = $this->graph_font_size_bars;
$main_greatest_length = $this->find_longest_string($this->graph_identifiers);
while(($this->return_ttf_string_width($main_greatest_length, $this->graph_font, $main_font_size) > ($main_width - 8)) || $this->return_ttf_string_height($main_greatest_length, $this->graph_font, $main_font_size) > ($line_height - 4))
+ {
$main_font_size -= 0.5;
+ }
if(($new_size = $this->return_ttf_string_width($main_greatest_length, $this->graph_font, $main_font_size)) < ($main_width - 12))
+ {
$main_width = $new_size + 10;
+ }
$identifiers_total_width = $graph_width - $main_width - 2;
@@ -59,7 +63,9 @@ class pts_MultiPassFailGraph extends pts_CustomGraph
$identifiers_width = floor($identifiers_total_width / count($headings));
$headings_font_size = $this->graph_font_size_bars;
while(($this->return_ttf_string_width($this->find_longest_string($headings), $this->graph_font, $headings_font_size) > ($identifiers_width - 2)) || $this->return_ttf_string_height($this->graph_maximum_value, $this->graph_font, $headings_font_size) > ($line_height - 4))
+ {
$headings_font_size -= 0.5;
+ }
for($j = 0; $j < count($this->graph_data[0]); $j++)
{
@@ -68,19 +74,27 @@ class pts_MultiPassFailGraph extends pts_CustomGraph
for($i = 0; $i < count($headings) && $i < count($results); $i++)
{
if($results[$i] == "PASS")
+ {
$paint_color = $pass_color;
+ }
else
+ {
$paint_color = $fail_color;
+ }
$this_bottom_end = $this->graph_top_start + $vertical_border + (($j + 1) * $line_height) + $heading_height + 1;
if($this_bottom_end >= $this->graph_top_end - $vertical_border)
+ {
$this_bottom_end = $this->graph_top_end - $vertical_border - 1;
+ }
else if($j == (count($this->graph_data[0]) - 1) && $this_bottom_end < $this->graph_top_end - $vertical_border)
+ {
$this_bottom_end = $this->graph_top_end - $vertical_border - 1;
+ }
$this->draw_rectangle($this->graph_image, $this->graph_left_end - $horizontal_border - ($i * $identifiers_width), $this->graph_top_start + $vertical_border + ($j * $line_height) + $heading_height, $this->graph_left_end - $horizontal_border - (($i + 1) * $identifiers_width), $this_bottom_end, $paint_color);
- $this->write_text_center($results[$i], $this->graph_font_size_bars, $this->graph_color_body_text, $this->graph_left_end - $horizontal_border - ($i * $identifiers_width) - $identifiers_width, $this->graph_top_start + $vertical_border + ($j * $line_height) + $heading_height + ($line_height / 2) - ($line_ttf_height / 2), $this->graph_left_end - $horizontal_border - ($i * $identifiers_width), $this->graph_top_start + $vertical_border + ($j * $line_height) + $heading_height + ($line_height / 2) - ($line_ttf_height / 2));
+ $this->write_text_center($results[$i], $this->graph_font_size_bars, $this->graph_color_body_text, $this->graph_left_end - $horizontal_border - ($i * $identifiers_width) - $identifiers_width, $this->graph_top_start + $vertical_border + ($j * $line_height) + $heading_height + ($line_height / 2) - ($line_ttf_height / 2), $this->graph_left_end - $horizontal_border - ($i * $identifiers_width), $this->graph_top_start + $vertical_border + ($j * $line_height) + $heading_height + ($line_height / 2) - ($line_ttf_height / 2));
}
}
@@ -96,7 +110,7 @@ class pts_MultiPassFailGraph extends pts_CustomGraph
for($i = 0; $i < count($this->graph_identifiers); $i++)
{
$this->draw_line($this->graph_image, $this->graph_left_start + $horizontal_border, $this->graph_top_start + $vertical_border + ($i * $line_height) + $heading_height, $this->graph_left_end - $horizontal_border, $this->graph_top_start + $vertical_border + ($i * $line_height) + $heading_height, $this->graph_color_body_light);
- $this->write_text_right($this->graph_identifiers[$i], $main_font_size, $this->graph_color_headers, $this->graph_left_start + $horizontal_border + $main_width, $this->graph_top_start + $vertical_border + ($i * $line_height) + $heading_height + ($line_height / 2) - 2, $this->graph_left_start + $horizontal_border + $main_width, $this->graph_top_start + $vertical_border + ($i * $line_height) + $heading_height + ($line_height / 2) - 2, FALSE);
+ $this->write_text_right($this->graph_identifiers[$i], $main_font_size, $this->graph_color_headers, $this->graph_left_start + $horizontal_border + $main_width, $this->graph_top_start + $vertical_border + ($i * $line_height) + $heading_height + ($line_height / 2) - 2, $this->graph_left_start + $horizontal_border + $main_width, $this->graph_top_start + $vertical_border + ($i * $line_height) + $heading_height + ($line_height / 2) - 2, false);
}
$this->draw_line($this->graph_image, $this->graph_left_start + $horizontal_border, $this->graph_top_start + $vertical_border, $this->graph_left_end - $horizontal_border, $this->graph_top_start + $vertical_border, $this->graph_color_body_light);
diff --git a/pts-core/objects/pts_PassFailGraph.php b/pts-core/objects/pts_PassFailGraph.php
index 7ddd6e2..fe2fa1a 100644
--- a/pts-core/objects/pts_PassFailGraph.php
+++ b/pts-core/objects/pts_PassFailGraph.php
@@ -28,7 +28,7 @@ class pts_PassFailGraph extends pts_CustomGraph
parent::__construct($Title, $SubTitle, $YTitle);
$this->graph_type = "PASS_FAIL";
$this->graph_value_type = "ABSTRACT";
- $this->graph_hide_identifiers = TRUE;
+ $this->graph_hide_identifiers = true;
$this->graph_data_title = array("PASSED", "FAILED");
}
protected function render_graph_passfail()
@@ -46,15 +46,21 @@ class pts_PassFailGraph extends pts_CustomGraph
$fail_color = $this->next_paint_color();
for($i = 2; $i <= sqrt($identifier_count); $i++)
+ {
if(intval($identifier_count / $i) == ($identifier_count / $i))
+ {
$columns = $i;
+ }
+ }
$identifiers_per_column = $identifier_count / $columns;
$identifier_height = floor(($graph_height - (($identifiers_per_column - 1) * $spacing)) / $identifiers_per_column);
$identifier_width = floor(($graph_width - (($columns - 1) * $spacing)) / $columns);
while($this->return_ttf_string_width($this->graph_maximum_value, $this->graph_font, $font_size) > ($identifier_width - 8) || $this->return_ttf_string_height($this->graph_maximum_value, $this->graph_font, $font_size) > ($identifier_height - 4))
+ {
$font_size -= 0.5;
+ }
for($c = 0; $c < $columns; $c++)
{
@@ -70,9 +76,13 @@ class pts_PassFailGraph extends pts_CustomGraph
$this_vertical_end = $this->graph_top_start + $vertical_border + ($i * ($identifier_height + $spacing)) + $identifier_height;
if($this_value == "PASS")
+ {
$paint_color = $pass_color;
+ }
else
+ {
$paint_color = $fail_color;
+ }
$this->draw_rectangle_border($this->graph_image, $this_horizontal_start, $this_vertical_start, $this_horizontal_end, $this_vertical_end, $this->graph_color_body_light);
$this->draw_rectangle($this->graph_image, $this_horizontal_start + 1, $this_vertical_start + 1, $this_horizontal_end - 1, $this_vertical_end - 1, $paint_color);
diff --git a/pts-core/objects/pts_module.php b/pts-core/objects/pts_module.php
index 6608a9e..4c9f20f 100644
--- a/pts-core/objects/pts_module.php
+++ b/pts-core/objects/pts_module.php
@@ -28,7 +28,9 @@ class pts_module
$prefix_dir = PTS_USER_DIR . "module-files/";
if(!is_dir($prefix_dir))
+ {
mkdir($prefix_dir);
+ }
return $prefix_dir . str_replace("_", "-", self::module_name()) . "/";
}
@@ -58,7 +60,9 @@ class pts_module
for($i = 0; $i < count($module_options) && $value == ""; $i++)
{
if($module_options[$i]->get_identifier() == $identifier)
+ {
$value = $module_options[$i]->get_default_value();
+ }
}
}
@@ -68,40 +72,54 @@ class pts_module
{
pts_module_config_init(array(self::module_name() . "__" . $identifier => $value));
}
- public static function save_file($file, $contents = NULL, $append = false)
+ public static function save_file($file, $contents = null, $append = false)
{
// Saves a file for a module
$save_base_dir = self::save_dir();
if(!is_dir($save_base_dir))
+ {
mkdir($save_base_dir);
+ }
if(($extra_dir = dirname($file)) != "." && !is_dir($save_base_dir . $extra_dir))
+ {
mkdir($save_base_dir . $extra_dir);
+ }
if($append)
{
if(is_file($save_base_dir . $file))
- if(file_put_contents($save_base_dir . $file, $contents . "\n", FILE_APPEND) != FALSE)
+ {
+ if(file_put_contents($save_base_dir . $file, $contents . "\n", FILE_APPEND) != false)
+ {
return $save_base_dir . $file;
+ }
+ }
}
else
{
- if(file_put_contents($save_base_dir . $file, $contents) != FALSE)
+ if(file_put_contents($save_base_dir . $file, $contents) != false)
+ {
return $save_base_dir . $file;
+ }
}
- return FALSE;
+ return false;
}
public static function read_file($file)
{
$file = self::save_dir() . $file;
if(is_file($file))
+ {
$file = file_get_contents($file);
+ }
else
- $file = FALSE;
+ {
+ $file = false;
+ }
return $file;
}
@@ -109,8 +127,7 @@ class pts_module
{
$file = self::save_dir() . $file;
- if(is_file($file))
- return unlink($file);
+ return is_file($file) && unlink($file);
}
public static function copy_file($from_file, $to_file)
{
@@ -119,16 +136,24 @@ class pts_module
$save_base_dir = self::save_dir();
if(!is_dir($save_base_dir))
+ {
mkdir($save_base_dir);
+ }
if(($extra_dir = dirname($to_file)) != "." && !is_dir($save_base_dir . $extra_dir))
+ {
mkdir($save_base_dir . $extra_dir);
+ }
if(is_file($from_file) && (!is_file($save_base_dir . $to_file) || md5_file($from_file) != md5_file($save_base_dir . $to_file)))
+ {
if(copy($from_file, $save_base_dir . $to_file))
+ {
return $save_base_dir . $to_file;
+ }
+ }
- return FALSE;
+ return false;
}
public static function pts_fork_function($function)
{
@@ -137,7 +162,9 @@ class pts_module
public static function pts_timed_function($time, $function)
{
if($time <= 5 || $time > 300)
+ {
return;
+ }
if(function_exists("pcntl_fork"))
{
@@ -158,22 +185,28 @@ class pts_module
eval(self::module_name() . "::" . $function . "();"); // TODO: This can be cleaned up once PHP 5.3.0+ is out there and adopted
if($time > 0)
+ {
sleep($time);
+ }
else if($time == -1)
+ {
$loop_continue = false;
+ }
}
exit(0);
}
}
}
else
+ {
echo pts_string_header("NOTICE: php-pcntl must be installed for the " . self::module_name() . " module.");
+ }
}
private static function module_name()
{
$module_name = "unknown";
- if($GLOBALS["PTS_MODULE_CURRENT"] != FALSE)
+ if($GLOBALS["PTS_MODULE_CURRENT"] != false)
{
$module_name = $GLOBALS["PTS_MODULE_CURRENT"];
}
@@ -182,8 +215,12 @@ class pts_module
$bt = debug_backtrace();
for($i = 0; $i < count($bt) && $module_name == "unknown"; $i++)
+ {
if($bt[$i]["class"] != "pts_module")
+ {
$module_name = $bt[$i]["class"];
+ }
+ }
}
return $module_name;
diff --git a/pts-core/objects/pts_module_interface.php b/pts-core/objects/pts_module_interface.php
index 2ee80b6..4b6dd83 100644
--- a/pts-core/objects/pts_module_interface.php
+++ b/pts-core/objects/pts_module_interface.php
@@ -43,11 +43,11 @@ class pts_module_interface
// General Functions
//
- public static function __startup($obj = NULL)
+ public static function __startup($obj = null)
{
return;
}
- public static function __shutdown($obj = NULL)
+ public static function __shutdown($obj = null)
{
return;
}
@@ -56,19 +56,19 @@ class pts_module_interface
// Installation Functions
//
- public static function __pre_install_process($obj = NULL)
+ public static function __pre_install_process($obj = null)
{
return;
}
- public static function __pre_test_install($obj = NULL)
+ public static function __pre_test_install($obj = null)
{
return;
}
- public static function __post_test_install($obj = NULL)
+ public static function __post_test_install($obj = null)
{
return;
}
- public static function __post_install_process($obj = NULL)
+ public static function __post_install_process($obj = null)
{
return;
}
@@ -77,23 +77,23 @@ class pts_module_interface
// Run Functions
//
- public static function __pre_run_process($obj = NULL)
+ public static function __pre_run_process($obj = null)
{
return;
}
- public static function __pre_test_run($obj = NULL)
+ public static function __pre_test_run($obj = null)
{
return;
}
- public static function __interim_test_run($obj = NULL)
+ public static function __interim_test_run($obj = null)
{
return;
}
- public static function __post_test_run($obj = NULL)
+ public static function __post_test_run($obj = null)
{
return;
}
- public static function __post_run_process($obj = NULL)
+ public static function __post_run_process($obj = null)
{
return;
}
diff --git a/pts-core/objects/pts_module_option.php b/pts-core/objects/pts_module_option.php
index aa28509..15990b0 100644
--- a/pts-core/objects/pts_module_option.php
+++ b/pts-core/objects/pts_module_option.php
@@ -54,7 +54,9 @@ class pts_module_option
$question_string = $this->get_question();
if($this->default_value != null)
+ {
$question_string .= " [" . $this->default_value . "]";
+ }
$question_string .= ": ";
@@ -66,12 +68,16 @@ class pts_module_option
if(is_array($this->option_supported_values))
{
if(in_array($input, $this->option_supported_values))
+ {
$supported = true;
+ }
}
else if($this->option_supported_values == OPTION_NUMERIC)
{
if(is_numeric($input))
+ {
$supported = true;
+ }
}
else if(empty($input) && $this->default_value != null)
{
diff --git a/pts-core/objects/pts_test_tandem_XmlReader.php b/pts-core/objects/pts_test_tandem_XmlReader.php
index 21d1542..0595bd9 100644
--- a/pts-core/objects/pts_test_tandem_XmlReader.php
+++ b/pts-core/objects/pts_test_tandem_XmlReader.php
@@ -41,7 +41,9 @@ class pts_test_tandem_XmlReader extends tandem_XmlReader
$test_below_tag = $test_below_parser->getXMLValue($XML_TAG);
if(!empty($test_below_tag))
+ {
$fallback_value = $test_below_tag;
+ }
}
}
diff --git a/pts-core/objects/tandem_XmlReader.php b/pts-core/objects/tandem_XmlReader.php
index 81071d8..dd36631 100644
--- a/pts-core/objects/tandem_XmlReader.php
+++ b/pts-core/objects/tandem_XmlReader.php
@@ -27,22 +27,22 @@
class tandem_XmlReader
{
var $XML_DATA = "";
- var $XML_FILE_TIME = NULL;
- var $XML_FILE_NAME = NULL;
+ var $XML_FILE_TIME = null;
+ var $XML_FILE_NAME = null;
- var $XML_CACHE_FILE = FALSE; // Cache the entire XML file being parsed
- var $XML_CACHE_TAGS = TRUE; // Cache the tags that are being called
+ var $XML_CACHE_FILE = false; // Cache the entire XML file being parsed
+ var $XML_CACHE_TAGS = true; // Cache the tags that are being called
- var $NO_TAG_FALLBACK_VALUE = NULL;
+ var $NO_TAG_FALLBACK_VALUE = null;
- function __construct($XML, $DO_CACHE = TRUE)
+ function __construct($XML, $DO_CACHE = true)
{
if(is_file($XML))
{
if(!$DO_CACHE)
{
- $this->XML_CACHE_FILE = FALSE;
- $this->XML_CACHE_TAGS = FALSE;
+ $this->XML_CACHE_FILE = false;
+ $this->XML_CACHE_TAGS = false;
}
// If you're going to be banging XML files hard through the course of the script, you'll want to flush the PHP file cache
@@ -51,29 +51,33 @@ class tandem_XmlReader
$this->XML_FILE_TIME = filemtime($XML);
$this->XML_FILE_NAME = $XML;
- if($this->XML_CACHE_FILE == TRUE && isset($GLOBALS["XML_CACHE"]["FILE"][$this->XML_FILE_NAME][$this->XML_FILE_TIME]))
+ if($this->XML_CACHE_FILE == true && isset($GLOBALS["XML_CACHE"]["FILE"][$this->XML_FILE_NAME][$this->XML_FILE_TIME]))
+ {
$this->XML_DATA = $GLOBALS["XML_CACHE"]["FILE"][$this->XML_FILE_NAME][$this->XML_FILE_TIME];
+ }
if(empty($this->XML_DATA))
{
$this->XML_DATA = file_get_contents($XML);
- if($this->XML_CACHE_FILE == TRUE)
+ if($this->XML_CACHE_FILE == true)
+ {
$GLOBALS["XML_CACHE"]["FILE"][$this->XML_FILE_NAME][$this->XML_FILE_TIME] = $this->XML_DATA;
+ }
}
}
else
{
- $this->XML_CACHE_FILE = FALSE;
- $this->XML_CACHE_TAGS = FALSE;
+ $this->XML_CACHE_FILE = false;
+ $this->XML_CACHE_TAGS = false;
$this->XML_DATA = $XML;
}
}
function getStatement($STATEMENT_NAME)
{
- return $this->listStatements(TRUE, $STATEMENT_NAME);
+ return $this->listStatements(true, $STATEMENT_NAME);
}
- function listStatements($SEARCH_DO = FALSE, $SEARCH_QUERY = "")
+ function listStatements($SEARCH_DO = false, $SEARCH_QUERY = "")
{
preg_match_all("'<!--(.*?) -->'si", $this->XML_DATA, $statement_maches);
$return_array = array();
@@ -108,14 +112,18 @@ class tandem_XmlReader
{
return $this->getValue($XML_TAG) != null;
}
- function getValue($FULL_XML_TAG, $XML_TAG = null, $XML_MATCH = null, $DO_CACHE = TRUE, $FALLBACK_PROCESS = FALSE)
+ function getValue($FULL_XML_TAG, $XML_TAG = null, $XML_MATCH = null, $DO_CACHE = true, $FALLBACK_PROCESS = false)
{
if($XML_TAG == null)
+ {
$XML_TAG = $FULL_XML_TAG;
+ }
if($XML_MATCH == null)
+ {
$XML_MATCH = $this->XML_DATA;
+ }
- if($this->XML_CACHE_TAGS == TRUE && $DO_CACHE && isset($GLOBALS["XML_CACHE"]["TAGS"][$this->XML_FILE_NAME][$this->XML_FILE_TIME][$XML_TAG]))
+ if($this->XML_CACHE_TAGS == true && $DO_CACHE && isset($GLOBALS["XML_CACHE"]["TAGS"][$this->XML_FILE_NAME][$this->XML_FILE_TIME][$XML_TAG]))
{
$XML_MATCH = $GLOBALS["XML_CACHE"]["TAGS"][$this->XML_FILE_NAME][$this->XML_FILE_TIME][$XML_TAG];
}
@@ -126,7 +134,9 @@ class tandem_XmlReader
preg_match("'<$xml_step>(.*?)</$xml_step>'si", $XML_MATCH, $new_match);
if(count($new_match) > 1)
+ {
$XML_MATCH = $new_match[1];
+ }
else
{
if(!$FALLBACK_PROCESS)
@@ -134,12 +144,16 @@ class tandem_XmlReader
$XML_MATCH = $this->handleXmlZeroTagFallback($FULL_XML_TAG);
}
else
+ {
$XML_MATCH = $this->NO_TAG_FALLBACK_VALUE;
+ }
}
}
- if($this->XML_CACHE_TAGS == TRUE && $DO_CACHE)
+ if($this->XML_CACHE_TAGS == true && $DO_CACHE)
+ {
$GLOBALS["XML_CACHE"]["TAGS"][$this->XML_FILE_NAME][$this->XML_FILE_TIME][$XML_TAG] = $XML_MATCH;
+ }
}
return $XML_MATCH;
@@ -162,7 +176,9 @@ class tandem_XmlReader
$this_xml = $XML_MATCH;
for($i = 0; $i < count($xml_steps) - 2; $i++)
- $this_xml = $this->getValue($XML_TAG, $xml_steps[$i], $this_xml, FALSE);
+ {
+ $this_xml = $this->getValue($XML_TAG, $xml_steps[$i], $this_xml, false);
+ }
$next_xml_step = $xml_steps[count($xml_steps) - 2];
preg_match_all("'<$next_xml_step>(.*?)</$next_xml_step>'si", $this_xml, $xml_matches);
@@ -175,7 +191,7 @@ class tandem_XmlReader
{
if($extraction_tags_count == 1)
{
- $this_item = $this->getValue($XML_TAG, $extraction_tags[0], $xml_matches[1][$i], FALSE);
+ $this_item = $this->getValue($XML_TAG, $extraction_tags[0], $xml_matches[1][$i], false);
array_push($return_array, $this_item);
}
else
@@ -183,11 +199,13 @@ class tandem_XmlReader
if($i == 0)
{
foreach($extraction_tags as $extract)
+ {
$return_array[$extract] = array();
+ }
}
foreach($extraction_tags as $extract)
{
- $this_item = $this->getValue($XML_TAG, $extract, $xml_matches[1][$i], FALSE);
+ $this_item = $this->getValue($XML_TAG, $extract, $xml_matches[1][$i], false);
array_push($return_array[$extract], $this_item);
}
}
@@ -196,11 +214,11 @@ class tandem_XmlReader
}
function setFileCaching($BOOL)
{
- $this->XML_CACHE_FILE = ($BOOL == TRUE);
+ $this->XML_CACHE_FILE = ($BOOL == true);
}
function setTagCaching($BOOL)
{
- $this->XML_CACHE_TAGS = ($BOOL == TRUE);
+ $this->XML_CACHE_TAGS = ($BOOL == true);
}
function setCaching($BOOL)
{
diff --git a/pts-core/objects/tandem_XmlWriter.php b/pts-core/objects/tandem_XmlWriter.php
index 476eaa0..49bbe24 100644
--- a/pts-core/objects/tandem_XmlWriter.php
+++ b/pts-core/objects/tandem_XmlWriter.php
@@ -34,7 +34,7 @@ class tandem_XmlWriter
var $FORMAT_XML;
var $XSL_BINDING = null;
- function __construct($READ_FROM_XML = "", $NOT_IMPLEMENTED = "", $NICE_FORMATTING = TRUE)
+ function __construct($READ_FROM_XML = "", $NOT_IMPLEMENTED = "", $NICE_FORMATTING = true)
{
$this->FORMAT_XML = $NICE_FORMATTING;
}
@@ -46,21 +46,29 @@ class tandem_XmlWriter
{
$this->XML_CHECKSUM = true;
}
- function addXmlObject($XML_LOCATION, $UNIQUE_IDENTIFIER = 0, $XML_VALUE, $STD_STEP = null, $STEP_ID = null)
+ function addXmlObject($XML_LOCATION, $UNIQUE_IDENTIFIER = 0, $XML_VALUE = "", $STD_STEP = null, $STEP_ID = null)
{
$xml_array = array();
$alt_step = -1;
$steps = 0;
if($STD_STEP == null)
+ {
$STD_STEP = 2;
+ }
if($STEP_ID == null)
+ {
$STEP_ID = $UNIQUE_IDENTIFIER;
+ }
- if(array_search("$UNIQUE_IDENTIFIER,$XML_LOCATION", $this->XML_STRING_PATHS) !== FALSE)
+ if(array_search($UNIQUE_IDENTIFIER . "," . $XML_LOCATION, $this->XML_STRING_PATHS) !== false)
+ {
$alt_step = 2;
+ }
else
- array_push($this->XML_STRING_PATHS, "$UNIQUE_IDENTIFIER,$XML_LOCATION");
+ {
+ array_push($this->XML_STRING_PATHS, $UNIQUE_IDENTIFIER . "," . $XML_LOCATION);
+ }
$xml_steps = explode('/', $XML_LOCATION);
foreach(array_reverse($xml_steps) as $current_tag)
@@ -72,12 +80,18 @@ class tandem_XmlWriter
$xml_array = $XML_VALUE;
}
if(!empty($current_tag))
+ {
$xml_array = array("$current_tag" => $xml_array);
+ }
if($steps == $STD_STEP)
- $xml_array = array("id_$UNIQUE_IDENTIFIER" => $xml_array);
+ {
+ $xml_array = array("id_" . $UNIQUE_IDENTIFIER => $xml_array);
+ }
if($steps == $alt_step)
- $xml_array = array("id_$STEP_ID" => $xml_array);
+ {
+ $xml_array = array("id_" . $STEP_ID => $xml_array);
+ }
}
$this->XML_OBJECTS = array_merge_recursive($this->XML_OBJECTS, $xml_array);
@@ -93,7 +107,7 @@ class tandem_XmlWriter
foreach($statements_to_print as $statement)
{
- $return_string .= "<!-- $statement -->" . "\n";
+ $return_string .= "<!-- " . $statement . " -->\n";
}
return $return_string;
@@ -105,7 +119,9 @@ class tandem_XmlWriter
$this->addStatement("Generated", date("Y-m-d H:i:s"));
if($this->XML_CHECKSUM)
+ {
$this->addStatement("Checksum", md5($formatted_xml));
+ }
return "<?xml version=\"1.0\"?>\n" . $this->getXSL() . $this->getXMLStatements() . $formatted_xml;
}
@@ -128,7 +144,7 @@ class tandem_XmlWriter
{
if(!is_array($value))
{
- $formatted_xml .= $this->getXMLTabs($TIMES_DEEP) . "<$key>$value</$key>" . $this->getXMLBreaks();
+ $formatted_xml .= $this->getXMLTabs($TIMES_DEEP) . "<" . $key . ">" . $value . "</" . $key . ">" . $this->getXMLBreaks();
}
else
{
@@ -138,9 +154,9 @@ class tandem_XmlWriter
}
else
{
- $formatted_xml .= $this->getXMLTabs($TIMES_DEEP) . "<$key>" . $this->getXMLBreaks();
+ $formatted_xml .= $this->getXMLTabs($TIMES_DEEP) . "<" . $key . ">" . $this->getXMLBreaks();
$formatted_xml .= $this->getXMLBelow($value, $TIMES_DEEP + 1);
- $formatted_xml .= $this->getXMLTabs($TIMES_DEEP) . "</$key>" . $this->getXMLBreaks();
+ $formatted_xml .= $this->getXMLTabs($TIMES_DEEP) . "</" . $key . ">" . $this->getXMLBreaks();
}
}
}
@@ -149,20 +165,26 @@ class tandem_XmlWriter
}
function getXMLTabs($TIMES_DEEP)
{
- if($this->FORMAT_XML !== TRUE)
+ if($this->FORMAT_XML !== true)
+ {
return;
+ }
$return_format = "";
for($i = 0; $i < $TIMES_DEEP; $i++)
+ {
$return_format .= "\t";
+ }
return $return_format;
}
function getXMLBreaks()
{
- if($this->FORMAT_XML !== TRUE)
+ if($this->FORMAT_XML !== true)
+ {
return;
+ }
return "\n";
}
diff --git a/pts-core/pts-run-cmd.php b/pts-core/pts-run-cmd.php
index c5fb683..03cbf2b 100644
--- a/pts-core/pts-run-cmd.php
+++ b/pts-core/pts-run-cmd.php
@@ -5,7 +5,7 @@
URLs: http://www.phoronix.com, http://www.phoronix-test-suite.com/
Copyright (C) 2008, Phoronix Media
Copyright (C) 2008, Michael Larabel
- pts-run-cmd.php: The main code for supporting options aside from the test execution itself.
+ pts-run-cmd.php: The main code for supporting non-run options aside from the test execution itself.
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
@@ -28,13 +28,31 @@ require("pts-core/functions/pts-functions-extra.php");
$COMMAND = $argv[1];
if(isset($argv[2]))
+{
$ARG_1 = $argv[2];
+}
+else
+{
+ $ARG_1 = "";
+}
if(isset($argv[3]))
+{
$ARG_2 = $argv[3];
+}
+else
+{
+ $ARG_2 = "";
+}
if(isset($argv[4]))
+{
$ARG_3 = $argv[4];
+}
+else
+{
+ $ARG_3 = "";
+}
switch($COMMAND)
{
@@ -56,7 +74,9 @@ switch($COMMAND)
printf("Saved Name: %-18ls Test: %-18ls \n", $saved_identifier, $suite);
foreach($identifiers as $id)
+ {
echo "\t- " . $id . "\n";
+ }
echo "\n";
}
@@ -64,7 +84,7 @@ switch($COMMAND)
break;
case "FORCE_INSTALL_TEST":
case "INSTALL_TEST":
- require_once("pts-core/functions/pts-functions-install.php");
+ include_once("pts-core/functions/pts-functions-install.php");
if(empty($ARG_1))
{
@@ -73,20 +93,26 @@ switch($COMMAND)
else
{
if(IS_SCTP_MODE)
+ {
$ARG_1 = basename($ARG_1);
+ }
if($COMMAND == "FORCE_INSTALL_TEST")
+ {
define("PTS_FORCE_INSTALL", 1);
+ }
$ARG_1 = strtolower($ARG_1);
- if(strpos($ARG_1, "pcqs") !== FALSE && !is_file(XML_SUITE_LOCAL_DIR . "pcqs-license.txt"))
+ if(strpos($ARG_1, "pcqs") !== false && !is_file(XML_SUITE_LOCAL_DIR . "pcqs-license.txt"))
{
// Install the Phoronix Certification & Qualification Suite
$agreement = wordwrap(file_get_contents("http://www.phoronix-test-suite.com/pcqs/pcqs-license.txt"), 65);
- if(strpos($agreement, "PCQS") == FALSE)
+ if(strpos($agreement, "PCQS") == false)
+ {
pts_exit("An error occurred while connecting to the Phoronix Test Suite Server. Please try again later.");
+ }
echo "\n\n" . $agreement;
$agree = pts_bool_question("Do you agree to these terms in full and wish to proceed (y/n)?", false);
@@ -98,7 +124,9 @@ switch($COMMAND)
echo pts_string_header("The Phoronix Certification & Qualification Suite is now installed.");
}
else
+ {
pts_exit(pts_string_header("In order to run PCQS you must agree to the listed terms."));
+ }
}
pts_module_process("__pre_install_process");
@@ -111,16 +139,20 @@ switch($COMMAND)
pts_start_install($ARG_1);
pts_module_process("__post_install_process");
- if(getenv("SILENT_INSTALL") !== FALSE)
+ if(getenv("SILENT_INSTALL") !== false)
+ {
define("PTS_EXIT", 1);
+ }
}
break;
case "FORCE_INSTALL_ALL":
case "INSTALL_ALL":
- require_once("pts-core/functions/pts-functions-install.php");
+ include_once("pts-core/functions/pts-functions-install.php");
if($COMMAND == "FORCE_INSTALL_ALL")
+ {
define("PTS_FORCE_INSTALL", 1);
+ }
pts_module_process("__pre_install_process");
foreach(pts_available_tests_array() as $test)
@@ -134,7 +166,7 @@ switch($COMMAND)
pts_module_process("__post_install_process");
break;
case "INSTALL_EXTERNAL_DEPENDENCIES":
- require_once("pts-core/functions/pts-functions-install.php");
+ include_once("pts-core/functions/pts-functions-install.php");
if(empty($ARG_1))
{
@@ -149,10 +181,14 @@ switch($COMMAND)
$continue_install = pts_package_generic_to_distro_name($packages_to_install, $pts_dependencies);
if($continue_install)
+ {
pts_install_packages_on_distribution_process($packages_to_install);
+ }
}
else
+ {
pts_install_package_on_distribution($ARG_1);
+ }
}
break;
case "MAKE_DOWNLOAD_CACHE":
@@ -183,8 +219,12 @@ switch($COMMAND)
else
{
if(!empty($name) && ($COMMAND == "LIST_ALL_TESTS" || !in_array($status, array("PRIVATE", "BROKEN", "EXPERIMENTAL", "UNVERIFIED", "STANDALONE", "SCTP"))))
+ {
if(pts_test_supported($identifier))
+ {
printf("%-18ls - %-36ls [%s, %10ls]\n", $identifier, $name, $status, $license);
+ }
+ }
}
}
echo "\n";
@@ -217,7 +257,9 @@ switch($COMMAND)
$identifier_prefix = "*";
if(!$has_partially_supported_suite)
+ {
$has_partially_supported_suite = true;
+ }
}
printf("%-24ls - %-32ls [Type: %s]\n", $identifier_prefix . " " . $identifier, $name, $test_type);
@@ -237,7 +279,9 @@ switch($COMMAND)
$module = basename($module_file, ".php");
if(!in_array($module, $GLOBALS["PTS_MODULES"]))
+ {
include_once($module_file);
+ }
$module_name = pts_php_module_call($module, "module_name");
$module_version = pts_php_module_call($module, "module_version");
@@ -266,7 +310,9 @@ switch($COMMAND)
$name = $xml_parser->getXMLValue(P_TEST_TITLE);
if(!empty($name))
+ {
printf("%-18ls - %-30ls\n", $identifier, $name);
+ }
}
}
echo "\n";
@@ -293,13 +339,19 @@ switch($COMMAND)
$name = $xml_parser->getXMLValue(P_TEST_TITLE);
if(empty($test_times_run))
+ {
$test_times_run = 0;
+ }
if(empty($test_avg_runtime))
+ {
$test_avg_runtime = "N/A";
+ }
if(!empty($name))
+ {
printf("%-18ls - %-8ls %-13ls %-11ls %-13ls %-10ls\n", $identifier, $test_version, $test_time_install, $test_time_lastrun, $test_avg_runtime, $test_times_run);
+ }
}
echo "\n";
break;
@@ -331,9 +383,13 @@ switch($COMMAND)
$suite_maintainer = explode("|", $suite_maintainer);
if(count($suite_maintainer) == 2)
+ {
$suite_maintainer = trim($suite_maintainer[0]) . " <" . trim($suite_maintainer[1]) . ">";
+ }
else
+ {
$suite_maintainer = $suite_maintainer[0];
+ }
echo "Suite Version: " . $suite_version . "\n";
echo "Maintainer: " . $suite_maintainer . "\n";
@@ -372,15 +428,21 @@ switch($COMMAND)
else
{
if(!empty($test_sw_version))
+ {
$test_title .= " " . $test_sw_version;
+ }
echo pts_string_header($test_title);
$test_maintainer = explode("|", $test_maintainer);
if(count($test_maintainer) == 2)
+ {
$test_maintainer = trim($test_maintainer[0]) . " <" . trim($test_maintainer[1]) . ">";
+ }
else
+ {
$test_maintainer = $test_maintainer[0];
+ }
echo "Test Version: " . $test_version . "\n";
echo "Maintainer: " . $test_maintainer . "\n";
@@ -391,40 +453,58 @@ switch($COMMAND)
echo "Project Web-Site: " . $test_projecturl . "\n";
if(!empty($test_download_size))
+ {
echo "Download Size: " . $test_download_size . " MB\n";
+ }
if(!empty($test_environment_size))
+ {
echo "Environment Size: " . $test_environment_size . " MB\n";
+ }
if(!empty($test_estimated_length))
+ {
echo "Estimated Length: " . pts_estimated_time_string($test_estimated_length) . "\n";
+ }
echo "\nDescription: " . $test_description . "\n";
if(is_file(TEST_ENV_DIR . $ARG_1 . "/pts-install.xml"))
{
- $xml_parser = new tandem_XmlReader(TEST_ENV_DIR . $ARG_1 . "/pts-install.xml", FALSE);
+ $xml_parser = new tandem_XmlReader(TEST_ENV_DIR . $ARG_1 . "/pts-install.xml", false);
$last_run = $xml_parser->getXMLValue(P_INSTALL_TEST_LASTRUNTIME);
$avg_time = $xml_parser->getXMLValue(P_INSTALL_TEST_AVG_RUNTIME);
if($last_run == "0000-00-00 00:00:00")
+ {
$last_run = "Never";
+ }
echo "\nTest Installed: Yes\n";
echo "Last Run: " . $last_run . "\n";
if($avg_time > 0)
+ {
echo "Average Run-Time: " . $avg_time . " Seconds\n";
+ }
if($last_run != "Never")
+ {
echo "Times Run: " . $xml_parser->getXMLValue(P_INSTALL_TEST_TIMESRUN) . "\n";
+ }
}
else
+ {
echo "\nTest Installed: No\n";
+ }
if(!empty($test_dependencies))
{
echo "\nSoftware Dependencies:\n";
foreach(explode(',', $test_dependencies) as $dependency)
+ {
if(($title = pts_dependency_name(trim($dependency)) )!= "")
+ {
echo "- " . $title . "\n";
+ }
+ }
}
$associated_suites = array();
@@ -432,11 +512,12 @@ switch($COMMAND)
{
$xml_parser = new tandem_XmlReader(pts_location_suite($identifier));
$name = $xml_parser->getXMLValue(P_SUITE_TITLE);
- $identifier = basename($suite_file, ".xml");
$tests = pts_contained_tests($identifier);
if(in_array($ARG_1, $tests))
+ {
array_push($associated_suites, $identifier);
+ }
}
if(count($associated_suites) > 0)
@@ -444,7 +525,9 @@ switch($COMMAND)
asort($associated_suites);
echo "\nSuites Using This Test:\n";
foreach($associated_suites as $suite)
+ {
echo "- " . $suite . "\n";
+ }
}
echo "\n";
@@ -465,11 +548,15 @@ switch($COMMAND)
if(is_file(MODULE_DIR . $module . ".php"))
{
if(!in_array($module, $GLOBALS["PTS_MODULES"]) && !class_exists($module))
+ {
include_once(MODULE_DIR . $module . ".php");
+ }
}
if(in_array($module, $GLOBALS["PTS_MODULES"]))
+ {
$pre_message = "** This module is currently loaded. **\n";
+ }
$module_name = pts_module_call($module, "module_name");
$module_version = pts_module_call($module, "module_version");
@@ -484,7 +571,9 @@ switch($COMMAND)
echo "Description: " . $module_description . "\n";
if(!empty($module_information))
+ {
echo "\n" . $module_information . "\n";
+ }
echo "\n";
}
@@ -501,7 +590,9 @@ switch($COMMAND)
$pre_message = "";
if(!in_array($module, $GLOBALS["PTS_MODULES"]) && !class_exists($module))
+ {
include(MODULE_DIR . $module . ".php");
+ }
$module_name = pts_php_module_call($module, "module_name");
$module_description = pts_php_module_call($module, "module_description");
@@ -511,7 +602,9 @@ switch($COMMAND)
echo $module_description . "\n";
if(count($module_setup) == 0)
+ {
echo "\nThere are no options available for configuring with the " . $ARG_1 . " module.";
+ }
else
{
$set_options = array();
@@ -525,7 +618,9 @@ switch($COMMAND)
while(!$module_option->is_supported_value($input));
if(empty($input))
+ {
$input = $module_option->get_default_value();
+ }
$this_input_identifier = $module_option->get_identifier();
@@ -544,10 +639,14 @@ switch($COMMAND)
case "SHOW_RESULT":
$URL = pts_find_result_file($ARG_1);
- if($URL != FALSE)
+ if($URL != false)
+ {
shell_exec("sh pts-core/scripts/launch-browser.sh $URL 2>&1");
+ }
else
+ {
echo "\n$ARG_1 was not found.\n";
+ }
break;
case "REFRESH_GRAPHS":
if(is_file(SAVE_RESULTS_DIR . $ARG_1 . "/composite.xml"))
@@ -566,11 +665,11 @@ switch($COMMAND)
}
break;
case "UPLOAD_RESULT":
- require_once("pts-core/functions/pts-functions-run.php");
+ include_once("pts-core/functions/pts-functions-run.php");
- $USE_FILE = pts_find_result_file($ARG_1, FALSE);
+ $USE_FILE = pts_find_result_file($ARG_1, false);
- if($USE_FILE == FALSE)
+ if($USE_FILE == false)
{
echo "\nThis result doesn't exist!\n";
exit(0);
@@ -582,9 +681,13 @@ switch($COMMAND)
$upload_url = pts_global_upload_result($USE_FILE, $tags_input);
if(!empty($upload_url))
+ {
echo "Results Uploaded To: " . $upload_url . "\n\n";
+ }
else
+ {
echo "\nResults Failed To Upload.\n";
+ }
break;
case "REMOVE_ALL_RESULTS":
$remove_all = pts_bool_question("Are you sure you wish to remove all saved results (Y/n)?", true);
@@ -606,7 +709,9 @@ switch($COMMAND)
pts_remove_saved_result($ARG_1);
}
else
+ {
echo "\nThis result doesn't exist!\n";
+ }
break;
case "REMOVE_INSTALLED_TEST":
if(is_file(TEST_ENV_DIR . $ARG_1 . "/pts-install.xml"))
@@ -617,10 +722,14 @@ switch($COMMAND)
echo "\nThe " . $ARG_1 . " test has been removed.\n\n";
}
else
+ {
echo "\n";
+ }
}
else
+ {
echo "\n" . $ARG_1 . " is not installed.\n\n";
+ }
break;
case "SYS_INFO":
echo pts_string_header("Phoronix Test Suite v" . PTS_VERSION . " (" . PTS_CODENAME . ")\nSystem Information");
@@ -628,7 +737,7 @@ switch($COMMAND)
echo "Software:\n" . pts_sw_string() . "\n\n";
break;
case "MERGE_RESULTS":
- require_once("pts-core/functions/pts-functions-merge.php");
+ include_once("pts-core/functions/pts-functions-merge.php");
$BASE_FILE = $ARG_1;
$MERGE_FROM_FILE = $ARG_2;
@@ -643,16 +752,20 @@ switch($COMMAND)
$BASE_FILE = pts_find_result_file($BASE_FILE);
$MERGE_FROM_FILE = pts_find_result_file($MERGE_FROM_FILE);
- if($BASE_FILE == FALSE || $MERGE_FROM_FILE == FALSE)
+ if($BASE_FILE == false || $MERGE_FROM_FILE == false)
{
echo "\n" . $BASE_FILE . " or " . $MERGE_FROM_FILE . " couldn't be found.\n";
}
else
{
if(!empty($MERGE_TO) && !is_dir(SAVE_RESULTS_DIR . $MERGE_TO))
+ {
$MERGE_TO .= "/composite.xml";
+ }
else
+ {
$MERGE_TO = null;
+ }
if(empty($MERGE_TO))
{
@@ -675,21 +788,25 @@ switch($COMMAND)
}
break;
case "ANALYZE_RESULTS":
- require_once("pts-core/functions/pts-functions-merge.php");
+ include_once("pts-core/functions/pts-functions-merge.php");
$BASE_FILE = pts_find_result_file($ARG_1);
$SAVE_TO = $ARG_2;
- if($BASE_FILE == FALSE)
+ if($BASE_FILE == false)
{
echo "\n" . $BASE_FILE . " couldn't be found.\n";
}
else
{
if(!empty($SAVE_TO) && !is_dir(SAVE_RESULTS_DIR . $SAVE_TO))
+ {
$SAVE_TO .= "/composite.xml";
+ }
else
+ {
$SAVE_TO = null;
+ }
if(empty($SAVE_TO))
{
@@ -724,7 +841,10 @@ switch($COMMAND)
foreach($module_processes as $process)
{
if(IS_DEBUG_MODE)
+ {
echo "Calling: " . $process . "()\n";
+ }
+
pts_module_process($process);
sleep(1);
}
@@ -741,15 +861,21 @@ switch($COMMAND)
foreach($pts_defined_constants["user"] as $constant => $constant_value)
{
if(substr($constant, 0, 2) != "P_" && substr($constant, 0, 3) != "IS_")
+ {
echo $constant . " = " . $constant_value . "\n";
+ }
}
echo "\nEnd-User Run-Time Variables:\n";
foreach(pts_user_runtime_variables() as $var => $var_value)
+ {
echo $var . " = " . $var_value . "\n";
+ }
echo "\nEnvironmental Variables (accessible via test scripts):\n";
foreach(pts_env_variables() as $var => $var_value)
+ {
echo $var . " = " . $var_value . "\n";
+ }
echo "\n";
break;
case "INITIAL_CONFIG":
@@ -774,7 +900,9 @@ switch($COMMAND)
echo "\nAccount: " . $uploadkey . "\nAccount information written to user-config.xml.\n\n";
}
else
+ {
echo "\nPhoronix Global Account Not Found.\n";
+ }
break;
case "BATCH_SETUP":
echo "\nThese are the default configuration options for when running the Phoronix Test Suite in a batch mode (i.e. running phoronix-test-suite batch-benchmark universe). Running in a batch mode is designed to be as autonomous as possible, except for where you'd like any end-user interaction.\n\n";
@@ -816,7 +944,9 @@ switch($COMMAND)
//display_web_browser(SAVE_RESULTS_DIR . $ARG_1 . "/composite.xml");
}
else
+ {
echo $ARG_1 . " is an unrecognized Phoronix Global ID.\n\n";
+ }
}
break;
case "VERSION":
diff --git a/pts-core/pts-run-test.php b/pts-core/pts-run-test.php
index 18a3272..7063733 100644
--- a/pts-core/pts-run-test.php
+++ b/pts-core/pts-run-test.php
@@ -36,7 +36,8 @@ if(is_file($argv[1]) && substr(basename($argv[1]), -4) == ".svg")
if(!empty($svg_test) && !empty($svg_identifier))
{
- // TODO: Implement checks and then prompt user whether they want to run the test, suite, or global ID that the SVG references
+ // TODO: Implement checks and then prompt user whether they want to
+ // run the test, suite, or global ID that the SVG references
}
}
@@ -50,10 +51,14 @@ if(IS_BATCH_MODE)
array_push($TEST_PROPERTIES, "PTS_BATCH_MODE");
}
if(IS_SCTP_MODE)
+{
$TO_RUN = basename($TO_RUN);
+}
if(empty($TO_RUN))
+{
pts_exit("\nThe test, suite name, or saved file name must be supplied.\n");
+}
if(is_test($TO_RUN))
{
@@ -61,7 +66,9 @@ if(is_test($TO_RUN))
$test_title = $xml_parser->getXMLValue(P_TEST_TITLE);
if(empty($test_title))
+ {
pts_exit($TO_RUN . " is not a test.");
+ }
}
// Make sure tests are installed
@@ -104,9 +111,13 @@ else
$RES_NULL = null;
}
else if(getenv("PTS_SAVE_RESULTS") == "NO")
- $SAVE_RESULTS = FALSE;
- else if(getenv("TEST_RESULTS_NAME") != FALSE)
- $SAVE_RESULTS = TRUE;
+ {
+ $SAVE_RESULTS = false;
+ }
+ else if(getenv("TEST_RESULTS_NAME") != false)
+ {
+ $SAVE_RESULTS = true;
+ }
else
{
$save_option = true;
@@ -117,13 +128,19 @@ else
$result_format = $xml_parser->getXMLValue(P_TEST_RESULTFORMAT);
if($result_format == "NO_RESULT")
+ {
$save_option = false;
+ }
}
if($save_option)
+ {
$SAVE_RESULTS = pts_bool_question("Would you like to save these test results (Y/n)?", true, "SAVE_RESULTS");
+ }
else
+ {
$SAVE_RESULTS = false;
+ }
}
if($SAVE_RESULTS)
@@ -142,12 +159,18 @@ else
if($TO_RUN_TYPE != "GLOBAL_COMPARISON")
{
if($test_suite != $TO_RUN)
+ {
$is_validated = false;
+ }
else
+ {
$is_validated = true;
+ }
}
else
+ {
$is_validated = true; //TODO: add type comparison check when doing a global comparison
+ }
}
else
{
@@ -157,7 +180,7 @@ else
if(!$is_validated)
{
echo pts_string_header("This saved file-name is associated with a different test ($test_suite) from $TO_RUN. Enter a new name for saving the results.");
- $FILE_NAME = pts_prompt_save_file_name(FALSE);
+ $FILE_NAME = pts_prompt_save_file_name(false);
$PROPOSED_FILE_NAME = $FILE_NAME[0];
$CUSTOM_TITLE = $FILE_NAME[1];
}
@@ -184,7 +207,9 @@ if($SAVE_RESULTS)
}
}
else
+ {
$result_identifiers = array();
+ }
$RESULTS_IDENTIFIER = pts_prompt_results_identifier($result_identifiers);
define("SAVE_FILE_NAME", $PROPOSED_FILE_NAME);
@@ -246,13 +271,15 @@ if(is_test($TO_RUN))
}
echo "\nPlease Enter Your Choice: ";
- if($first_try && ($auto_opt = getenv(strtoupper($TO_RUN) . "_" . $this_option_pos)) != FALSE)
+ if($first_try && ($auto_opt = getenv(strtoupper($TO_RUN) . "_" . $this_option_pos)) != false)
{
$bench_choice = $auto_opt;
echo $bench_choice . "\n";
}
else
+ {
$bench_choice = trim(fgets(STDIN));
+ }
$first_try = false;
}
@@ -277,15 +304,21 @@ if(is_test($TO_RUN))
$option_display_name = $o->get_option_name(($bench_choice - 1));
if(($cut_point = strpos($option_display_name, "(")) > 1 && strpos($option_display_name, ")") > $cut_point)
+ {
$option_display_name = substr($option_display_name, 0, $cut_point);
+ }
if(count($test_options) > 1)
+ {
$TEXT_ARGS .= $o->get_name() . ": ";
+ }
$TEXT_ARGS .= $option_display_name;
if($this_option_pos < (count($test_options) - 1))
+ {
$TEXT_ARGS .= " - ";
+ }
$USER_ARGS .= $o->get_option_prefix() . $o->get_option_value(($bench_choice - 1)) . $o->get_option_postfix() . " ";
}
@@ -316,14 +349,18 @@ if(is_test($TO_RUN))
$this_arg_description = $o->get_name() . ": " . $o->get_option_name($i);
if(($cut_point = strpos($this_arg_description, "(")) > 1 && strpos($this_arg_description, ")") > $cut_point)
+ {
$this_arg_description = substr($this_arg_description, 0, $cut_point);
+ }
array_push($option_args, $this_arg);
array_push($option_args_description, $this_arg_description);
}
if($i > 1)
+ {
$description_separate = " - ";
+ }
array_push($batch_all_args_real, $option_args);
array_push($batch_all_args_description, $option_args_description);
@@ -337,7 +374,9 @@ if(is_test($TO_RUN))
$TEST_RUN = array();
for($i = 0; $i < count($TEST_ARGS); $i++) // needed at this time to fill up the array same size as the number of options present
+ {
array_push($TEST_RUN, $TO_RUN);
+ }
}
if($SAVE_RESULTS)
@@ -371,7 +410,9 @@ else if(is_suite($TO_RUN))
$SUITE_RUN_MODE = $xml_parser->getXMLValue(P_SUITE_RUNMODE);
if($SUITE_RUN_MODE == "PCQS")
+ {
define("IS_PCQS_MODE", true);
+ }
unset($xml_parser);
}
@@ -392,8 +433,12 @@ else if($SAVE_RESULTS && ($TO_RUN_TYPE == "GLOBAL_COMPARISON" || $TO_RUN_TYPE ==
unset($xml_parser);
foreach(explode(";", $test_previous_properties) as $test_prop)
+ {
if(!in_array($test_prop, $TEST_PROPERTIES))
+ {
array_push($TEST_PROPERTIES, $test_prop);
+ }
+ }
pts_module_process_extensions($test_extensions);
}
@@ -405,7 +450,9 @@ else
if($SAVE_RESULTS && (!IS_BATCH_MODE || pts_read_user_config(P_OPTION_BATCH_PROMPTDESCRIPTION, "FALSE") == "TRUE"))
{
if(empty($test_description))
+ {
$test_description = "N/A";
+ }
echo pts_string_header("If you wish, enter a new description below.\nPress ENTER to proceed without changes.", "#");
echo "Current Description: " . $test_description;
@@ -413,7 +460,9 @@ if($SAVE_RESULTS && (!IS_BATCH_MODE || pts_read_user_config(P_OPTION_BATCH_PROMP
$new_test_description = trim(fgets(STDIN));
if(!empty($new_test_description))
+ {
$test_description = $new_test_description;
+ }
}
if(is_suite($TO_RUN))
@@ -475,7 +524,9 @@ if($SAVE_RESULTS)
display_web_browser($upload_url, "Do you want to launch Phoronix Global", true);
}
else
+ {
echo "\nResults Failed To Upload.\n";
+ }
}
echo "\n";
}