>
--git a/TODO b/TODO
index 0874dc4..234fd8b 100644
--- a/TODO
+++ b/TODO
@@ -1,8 +1,5 @@
- Rewrite and finish GUI component
- Clean up / make nice of text output
-- Support multiple possible paths
- - i.e. /usr/local/games/doom3/ || ~/doom3/
- - Right now stuck to benchmark-env but can be changed easily
- Verbose output of all system details, benchmark dumps, etc
- Improve / clean-up tandem_xml
- Add More Benchmarks!
diff --git a/pts-core/functions/pts-functions.php b/pts-core/functions/pts-functions.php
index afcb213..1e12dea 100644
--- a/pts-core/functions/pts-functions.php
+++ b/pts-core/functions/pts-functions.php
@@ -18,6 +18,10 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+// Load OS-specific functions
+require_once("pts-core/functions/pts-functions_config.php");
+require_once("pts-core/functions/pts-functions_linux.php");
+
define("PTS_VERSION", "0.1.0");
define("PTS_CODENAME", "TRONDHEIM");
define("PTS_TYPE", "DESKTOP");
@@ -27,11 +31,11 @@ define("THIS_RUN_TIME", time());
define("XML_PROFILE_LOCATION", "pts/benchmark-profiles/");
define("XML_SUITE_LOCATION", "pts/benchmark-suites/");
define("BENCHMARK_RESOURCE_LOCATION", "pts/benchmark-resources/");
-define("BENCHMARK_ENVIRONMENT", pts_find_home(pts_read_user_config("PhoronixTestSuite/Options/Benchmarking/EnvironmentDirectory", "~/benchmark-env/")));
-define("SAVE_RESULTS_LOCATION", pts_find_home(pts_read_user_config("PhoronixTestSuite/Options/Benchmarking/ResultsDirectory", "test-results/")));
+define("PTS_USER_DIR", pts_find_home("~/.phoronix-test-suite/"));
-// Load OS-specific functions
-require_once("pts-core/functions/pts-functions_linux.php");
+pts_user_config_init();
+define("BENCHMARK_ENVIRONMENT", pts_find_home(pts_read_user_config("PhoronixTestSuite/Options/Benchmarking/EnvironmentDirectory", "~/pts-benchmark-env/")));
+define("SAVE_RESULTS_LOCATION", pts_find_home(pts_read_user_config("PhoronixTestSuite/Options/Results/Directory", "~/pts-test-results/")));
// Etc
$PTS_GLOBAL_ID = 1;
@@ -50,30 +54,6 @@ function __autoload($to_load)
}
// Phoronix Test Suite - Functions
-function pts_find_home($path)
-{
- if(strpos($path, '~') !== FALSE)
- {
- $whoami = trim(shell_exec("whoami"));
-
- if($whoami == "root")
- $home_path = "/root";
- else
- $home_path = "/home/$whoami";
-
- $path = str_replace('~', $home_path, $path);
- }
- return $path;
-}
-function pts_current_user()
-{
- $pts_user = pts_read_user_config("PhoronixTestSuite/GlobalDatabase/UserName", "Default User");
-
- if($pts_user == "Default User")
- $pts_user = trim(shell_exec("whoami"));
-
- return $pts_user;
-}
function pts_benchmark_names_to_array()
{
$benchmark_names = array();
@@ -261,7 +241,7 @@ function pts_process_active($process)
}
function display_web_browser($URL)
{
- $view_results = pts_bool_question("Do you want to view the results in your web browser (Y/n)?");
+ $view_results = pts_bool_question("Do you want to view the results in your web browser (y/N)?", false);
if($view_results)
shell_exec("firefox $URL &");
@@ -334,21 +314,6 @@ function pts_exec($exec, $extra_vars = null)
{
return shell_exec(pts_variables_export_string($extra_vars) . "$exec");
}
-function pts_read_user_config($xml_pointer, $value = null)
-{
- if(is_file("user-config.xml"))
- if(($file = file_get_contents("user-config.xml")) != 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;
-}
function pts_request_new_id()
{
global $PTS_GLOBAL_ID;
diff --git a/pts-core/functions/pts-functions_config.php b/pts-core/functions/pts-functions_config.php
new file mode 100644
index 0000000..d6c6874
--- /dev/null
+++ b/pts-core/functions/pts-functions_config.php
@@ -0,0 +1,76 @@
+<?php
+
+// Phoronix Test Suite - User Config Functions
+
+function pts_user_config_init()
+{
+ if(!is_dir(PTS_USER_DIR))
+ mkdir(PTS_USER_DIR);
+
+ if(is_file(PTS_USER_DIR . "user-config.xml"))
+ $file = file_get_contents(PTS_USER_DIR . "user-config.xml");
+ else
+ $file = "";
+ $read_config = new tandem_XmlReader($file);
+
+ $config = new tandem_XmlWriter();
+ $config->addXmlObject("PhoronixTestSuite/GlobalDatabase/UserName", 0, pts_read_user_config("PhoronixTestSuite/GlobalDatabase/UserName", "Default User", $read_config));
+ $config->addXmlObject("PhoronixTestSuite/GlobalDatabase/UploadKey", 0, pts_read_user_config("PhoronixTestSuite/GlobalDatabase/UploadKey", "", $read_config));
+ $config->addXmlObject("PhoronixTestSuite/Options/Results/Directory", 1, pts_read_user_config("PhoronixTestSuite/Options/Results/Directory", "~/pts-test-results/", $read_config));
+ $config->addXmlObject("PhoronixTestSuite/Options/Benchmarking/EnvironmentDirectory", 2, pts_read_user_config("PhoronixTestSuite/Options/Benchmarking/EnvironmentDirectory", "~/pts-benchmark-env/", $read_config));
+ $config->addXmlObject("PhoronixTestSuite/Options/Benchmarking/SleepTimeBetweenTests", 2, pts_read_user_config("PhoronixTestSuite/Options/Benchmarking/SleepTimeBetweenTests", "5", $read_config));
+
+ file_put_contents(PTS_USER_DIR . "user-config.xml", $config->getXML());
+}
+
+function pts_read_user_config($xml_pointer, $value = null, $tandem_xml = null)
+{
+ if($tandem_xml != null)
+ {
+ $temp_value = $tandem_xml->getXmlValue($xml_pointer);
+
+ if(!empty($temp_value))
+ $value = $temp_value;
+ }
+ else
+ {
+ if(is_file(PTS_USER_DIR . "user-config.xml"))
+ if(($file = file_get_contents(PTS_USER_DIR . "user-config.xml")) != 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;
+}
+function pts_find_home($path)
+{
+ if(strpos($path, '~') !== FALSE)
+ {
+ $whoami = trim(shell_exec("whoami"));
+
+ if($whoami == "root")
+ $home_path = "/root";
+ else
+ $home_path = "/home/$whoami";
+
+ $path = str_replace('~', $home_path, $path);
+ }
+ return $path;
+}
+function pts_current_user()
+{
+ $pts_user = pts_read_user_config("PhoronixTestSuite/GlobalDatabase/UserName", "Default User");
+
+ if($pts_user == "Default User")
+ $pts_user = trim(shell_exec("whoami"));
+
+ return $pts_user;
+}
+
+?>
diff --git a/user-config.xml b/user-config.xml
deleted file mode 100644
index 0fb6e96..0000000
--- a/user-config.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
<?xml version="1.0"?>
-<PhoronixTestSuite>
- <GlobalDatabase>
- <UserName>Default User</UserName>
- <UploadKey></UploadKey>
- <AutoUploadResults>FALSE</AutoUploadResults>
- </GlobalDatabase>
- <Options>
- <Results>
- <BuildGraphsLocally>FALSE</BuildGraphsLocally>
- </Results>
- <Benchmarking>
- <EnvironmentDirectory>~/pts-benchmark-env/</EnvironmentDirectory>
- <ResultsDirectory>test-results/</ResultsDirectory>
- <SleepTimeBetweenTests>5</SleepTimeBetweenTests>
- </Benchmarking>
- </Options>
Copyright © 2010 by Phoronix Media