summaryrefslogtreecommitdiffstats
path: root/pts-core
diff options
context:
space:
mode:
authorMichael Larabel <michael@phx-laptop.(none)>2008-12-02 22:05:51 -0500
committerMichael Larabel <michael@phx-laptop.(none)>2008-12-02 22:05:51 -0500
commit822459a4b92fda1aabbd0edbd33ab4d8445e3808 (patch)
treee54fe8bc92324f56dc26e0f9ec98892fcf69c1fd /pts-core
parent3828e81cf3832f592c03a8168d0250c9c52bfd9a (diff)
downloadphoronix-test-suite-upstream-822459a4b92fda1aabbd0edbd33ab4d8445e3808.tar.gz
phoronix-test-suite-upstream-822459a4b92fda1aabbd0edbd33ab4d8445e3808.tar.xz
phoronix-test-suite-upstream-822459a4b92fda1aabbd0edbd33ab4d8445e3808.zip
pts-core: Cut down on use of pts_exit() command due to the new option
architecture, instead use returns appropriately
Diffstat (limited to 'pts-core')
-rw-r--r--pts-core/functions/pts-functions-run.php5
-rw-r--r--pts-core/functions/pts-functions.php28
-rw-r--r--pts-core/functions/pts-init.php37
-rw-r--r--pts-core/options/install_test.php6
-rw-r--r--pts-core/options/run_test.php25
5 files changed, 59 insertions, 42 deletions
diff --git a/pts-core/functions/pts-functions-run.php b/pts-core/functions/pts-functions-run.php
index 97b06cf..d177320 100644
--- a/pts-core/functions/pts-functions-run.php
+++ b/pts-core/functions/pts-functions-run.php
@@ -539,6 +539,7 @@ function pts_verify_test_installation($identifier)
// Verify a test is installed
$tests = pts_contained_tests($identifier);
$needs_installing = array();
+ $valid_op = true;
foreach($tests as $test)
{
@@ -578,9 +579,11 @@ function pts_verify_test_installation($identifier)
if(!pts_is_assignment("TEST_INSTALL_PASS") && pts_read_assignment("COMMAND") != "benchmark")
{
- pts_exit();
+ $valid_op = false;
}
}
+
+ return $valid_op;
}
function pts_recurse_call_tests($tests_to_run, $arguments_array, $save_results = false, &$tandem_xml = "", $results_identifier = "", $arguments_description = "")
{
diff --git a/pts-core/functions/pts-functions.php b/pts-core/functions/pts-functions.php
index 5360909..9df06ab 100644
--- a/pts-core/functions/pts-functions.php
+++ b/pts-core/functions/pts-functions.php
@@ -33,34 +33,6 @@ require_once("pts-core/functions/pts-functions_tests.php");
require_once("pts-core/functions/pts-functions_types.php");
require_once("pts-core/functions/pts-functions_modules.php");
-// User's home directory for storing results, module files, test installations, etc.
-define("PTS_DIR", pts_directory());
-define("PTS_USER_DIR", pts_user_home() . ".phoronix-test-suite/");
-
-// Distribution External Dependency Locations
-define("XML_DISTRO_DIR", PTS_DIR . "pts/distro-xml/");
-define("SCRIPT_DISTRO_DIR", PTS_DIR . "pts/distro-scripts/");
-
-// Misc Locations
-define("ETC_DIR", PTS_DIR . "pts/etc/");
-define("MODULE_DIR", PTS_DIR . "pts-core/modules/");
-define("RESULTS_VIEWER_DIR", PTS_DIR . "pts-core/results-viewer/");
-define("TEST_LIBRARIES_DIR", PTS_DIR . "pts-core/test-libraries/");
-define("STATIC_DIR", PTS_DIR . "pts-core/static/");
-define("FONT_DIR", RESULTS_VIEWER_DIR . "fonts/");
-
-// Test & Suite Locations
-define("XML_PROFILE_DIR", PTS_DIR . "pts/test-profiles/");
-define("XML_PROFILE_CTP_BASE_DIR", XML_PROFILE_DIR . "base/");
-define("XML_SUITE_DIR", PTS_DIR . "pts/test-suites/");
-define("TEST_RESOURCE_DIR", PTS_DIR . "pts/test-resources/");
-define("TEST_RESOURCE_CTP_BASE_DIR", TEST_RESOURCE_DIR . "base/");
-define("XML_PROFILE_LOCAL_DIR", PTS_USER_DIR . "test-profiles/");
-define("XML_PROFILE_LOCAL_CTP_BASE_DIR", XML_PROFILE_LOCAL_DIR . "base/");
-define("XML_SUITE_LOCAL_DIR", PTS_USER_DIR . "test-suites/");
-define("TEST_RESOURCE_LOCAL_DIR", PTS_USER_DIR . "test-resources/");
-define("TEST_RESOURCE_LOCAL_CTP_BASE_DIR", TEST_RESOURCE_LOCAL_DIR . "base/");
-
// Phoronix Test Suite - Functions
function pts_run_option_command($command, $pass_args = null, $command_descriptor = "")
{
diff --git a/pts-core/functions/pts-init.php b/pts-core/functions/pts-init.php
index 30bca33..840afa4 100644
--- a/pts-core/functions/pts-init.php
+++ b/pts-core/functions/pts-init.php
@@ -23,6 +23,7 @@
function pts_init()
{
+ pts_define_directories(); // Define directories
pts_basic_init(); // Initalize common / needed PTS start-up work
if(IS_SCTP_MODE)
@@ -57,6 +58,36 @@ function pts_directory()
return $dir;
}
+function pts_define_directories()
+{
+ // User's home directory for storing results, module files, test installations, etc.
+ define("PTS_DIR", pts_directory());
+ define("PTS_USER_DIR", pts_user_home() . ".phoronix-test-suite/");
+
+ // Distribution External Dependency Locations
+ define("XML_DISTRO_DIR", PTS_DIR . "pts/distro-xml/");
+ define("SCRIPT_DISTRO_DIR", PTS_DIR . "pts/distro-scripts/");
+
+ // Misc Locations
+ define("ETC_DIR", PTS_DIR . "pts/etc/");
+ define("MODULE_DIR", PTS_DIR . "pts-core/modules/");
+ define("RESULTS_VIEWER_DIR", PTS_DIR . "pts-core/results-viewer/");
+ define("TEST_LIBRARIES_DIR", PTS_DIR . "pts-core/test-libraries/");
+ define("STATIC_DIR", PTS_DIR . "pts-core/static/");
+ define("FONT_DIR", RESULTS_VIEWER_DIR . "fonts/");
+
+ // Test & Suite Locations
+ define("XML_PROFILE_DIR", PTS_DIR . "pts/test-profiles/");
+ define("XML_PROFILE_CTP_BASE_DIR", XML_PROFILE_DIR . "base/");
+ define("XML_SUITE_DIR", PTS_DIR . "pts/test-suites/");
+ define("TEST_RESOURCE_DIR", PTS_DIR . "pts/test-resources/");
+ define("TEST_RESOURCE_CTP_BASE_DIR", TEST_RESOURCE_DIR . "base/");
+ define("XML_PROFILE_LOCAL_DIR", PTS_USER_DIR . "test-profiles/");
+ define("XML_PROFILE_LOCAL_CTP_BASE_DIR", XML_PROFILE_LOCAL_DIR . "base/");
+ define("XML_SUITE_LOCAL_DIR", PTS_USER_DIR . "test-suites/");
+ define("TEST_RESOURCE_LOCAL_DIR", PTS_USER_DIR . "test-resources/");
+ define("TEST_RESOURCE_LOCAL_CTP_BASE_DIR", TEST_RESOURCE_LOCAL_DIR . "base/");
+}
function pts_basic_init()
{
// Initialize The Phoronix Test Suite
@@ -196,12 +227,6 @@ function pts_extended_init()
// Check for batch mode
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
diff --git a/pts-core/options/install_test.php b/pts-core/options/install_test.php
index d808443..69673c6 100644
--- a/pts-core/options/install_test.php
+++ b/pts-core/options/install_test.php
@@ -52,7 +52,8 @@ class install_test implements pts_option_interface
if(strpos($agreement, "PCQS") == false)
{
- pts_exit("An error occurred while connecting to the Phoronix Test Suite Server. Please try again later.");
+ echo pts_string_header("An error occurred while connecting to the Phoronix Test Suite server. Try again later.");
+ return false;
}
echo "\n\n" . $agreement;
@@ -66,7 +67,8 @@ class install_test implements pts_option_interface
}
else
{
- pts_exit(pts_string_header("In order to run PCQS you must agree to the listed terms."));
+ pts_string_header("In order to run PCQS you must agree to the listed terms.");
+ return false;
}
}
diff --git a/pts-core/options/run_test.php b/pts-core/options/run_test.php
index fc35bc7..37457e4 100644
--- a/pts-core/options/run_test.php
+++ b/pts-core/options/run_test.php
@@ -27,6 +27,12 @@ class run_test implements pts_option_interface
require("pts-core/functions/pts-functions-run.php");
require("pts-core/functions/pts-functions-merge.php");
+ if(IS_BATCH_MODE && pts_read_user_config(P_OPTION_BATCH_CONFIGURED, "FALSE") == "FALSE")
+ {
+ echo pts_string_header("The batch mode must first be configured\nRun: phoronix-test-suite batch-setup");
+ return false;
+ }
+
$TO_RUN = strtolower($r[0]);
if(is_file($r[0]) && substr(basename($r[0]), -4) == ".svg")
@@ -54,7 +60,8 @@ class run_test implements pts_option_interface
if(empty($TO_RUN))
{
- pts_exit("\nThe test, suite name, or saved file name must be supplied.\n");
+ echo pts_string_header("The test, suite, or saved file name must be supplied.");
+ return false;
}
pts_set_assignment("TO_RUN", $TO_RUN);
@@ -65,12 +72,18 @@ class run_test implements pts_option_interface
if(empty($test_title))
{
- pts_exit($TO_RUN . " is not a test.");
+ echo pts_string_header($TO_RUN . " is not a test.");
+ return false;
}
}
// Make sure tests are installed
- pts_verify_test_installation($TO_RUN);
+ $verify_result = pts_verify_test_installation($TO_RUN);
+
+ if($verify_result == false)
+ {
+ return false;
+ }
if(!$TO_RUN_TYPE)
{
@@ -90,7 +103,8 @@ class run_test implements pts_option_interface
}
else
{
- pts_exit("\nNot Recognized: $TO_RUN \n\n");
+ echo pts_string_header("Not Recognized: " . $TO_RUN);
+ return false;
}
$SAVE_RESULTS = true;
@@ -275,7 +289,8 @@ class run_test implements pts_option_interface
}
else
{
- pts_exit("\nUnrecognized option: " . $TO_RUN_TYPE . "\n");
+ echo pts_string_header("\nUnrecognized option: " . $TO_RUN_TYPE . "\n");
+ return false;
}
if($SAVE_RESULTS && (!IS_BATCH_MODE || pts_read_user_config(P_OPTION_BATCH_PROMPTDESCRIPTION, "FALSE") == "TRUE"))