summaryrefslogtreecommitdiffstats
path: root/pts-core/functions
diff options
context:
space:
mode:
authorMichael Larabel <michael@phx-laptop.(none)>2008-09-11 20:56:15 -0400
committerMichael Larabel <michael@phx-laptop.(none)>2008-09-11 20:56:15 -0400
commit78eff48ca50cf08728e59a9ad60d6c276af95515 (patch)
tree81f0d3dd1cfffc0455fd84f032c15b1e1298ceb2 /pts-core/functions
parent2ca4be349d96e9fe442fe8de46b03d45d97dd3b6 (diff)
downloadphoronix-test-suite-upstream-78eff48ca50cf08728e59a9ad60d6c276af95515.tar.gz
phoronix-test-suite-upstream-78eff48ca50cf08728e59a9ad60d6c276af95515.tar.xz
phoronix-test-suite-upstream-78eff48ca50cf08728e59a9ad60d6c276af95515.zip
pts-core: Create the unified PTS test/suite type handler
Diffstat (limited to 'pts-core/functions')
-rw-r--r--pts-core/functions/pts-functions.php1
-rw-r--r--pts-core/functions/pts-functions_types.php89
-rw-r--r--pts-core/functions/pts-interfaces.php7
3 files changed, 90 insertions, 7 deletions
diff --git a/pts-core/functions/pts-functions.php b/pts-core/functions/pts-functions.php
index a1dfdb0..5b0695b 100644
--- a/pts-core/functions/pts-functions.php
+++ b/pts-core/functions/pts-functions.php
@@ -30,6 +30,7 @@ require_once("pts-core/functions/pts-interfaces.php");
require_once("pts-core/functions/pts-functions_config.php");
require_once("pts-core/functions/pts-functions_system.php");
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");
define("XML_PROFILE_DIR", PTS_DIR . "pts/test-profiles/");
diff --git a/pts-core/functions/pts-functions_types.php b/pts-core/functions/pts-functions_types.php
new file mode 100644
index 0000000..68dd073
--- /dev/null
+++ b/pts-core/functions/pts-functions_types.php
@@ -0,0 +1,89 @@
+<?php
+
+/*
+ Phoronix Test Suite
+ URLs: http://www.phoronix.com, http://www.phoronix-test-suite.com/
+ Copyright (C) 2008, Phoronix Media
+ Copyright (C) 2008, Michael Larabel
+ pts-functions_types.php: Functions needed for type handling of tests/suites.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+define("TYPE_TEST", "TEST"); // Type is test
+define("TYPE_TEST_SUITE", "TEST_SUITE"); // Type is a test suite
+
+function is_suite($object)
+{
+ $type = pts_test_type($object);
+
+ return $type == TYPE_TEST_SUITE;
+}
+function is_test($object)
+{
+ $type = pts_test_type($object);
+
+ return $type == TYPE_TEST;
+}
+function pts_locations_tests($object)
+{
+ // Provide an array containing the location(s) of all test(s) for the supplied object name
+ $tests = array();
+
+ if(is_suite($object)) // Object is suite
+ {
+ $xml_parser = new tandem_XmlReader(@file_get_contents(XML_SUITE_DIR . $object . ".xml"));
+ $tests_in_suite = array_unique($xml_parser->getXMLArrayValues(P_SUITE_TEST_NAME));
+
+ foreach($tests_in_suite as $test)
+ foreach(pts_locations_tests($test) as $sub_test)
+ array_push($tests, $sub_test);
+ }
+ else if(is_test($object)) // Object is a test
+ {
+ if(TYPE_TEST == $object)
+ array_push($tests, XML_TEST_DIR . $object . ".xml");
+ }
+ else if(is_file(($file_path = pts_input_correct_results_path($object)))) // Object is a local file
+ {
+ $xml_parser = new tandem_XmlReader($file_path);
+ $tests_in_file = $xml_parser->getXMLArrayValues(P_RESULTS_TEST_TESTNAME);
+
+ foreach($tests_in_file as $test)
+ foreach(pts_locations_tests($test) as $sub_test)
+ array_push($tests, $sub_test);
+ }
+ else if(is_file(SAVE_RESULTS_DIR . $object . "/composite.xml")) // Object is a saved results file
+ {
+ $xml_parser = new tandem_XmlReader(SAVE_RESULTS_DIR . $object . "/composite.xml");
+ $tests_in_save = $xml_parser->getXMLArrayValues(P_RESULTS_TEST_TESTNAME);
+
+ foreach($tests_in_save as $test)
+ foreach(pts_locations_tests($test) as $sub_test)
+ array_push($tests, $sub_test);
+ }
+ else if(pts_is_global_id($TO_INSTALL)) // Object is a Phoronix Global file
+ {
+ $xml_parser = new tandem_XmlReader(pts_global_download_xml($TO_INSTALL));
+ $tests_in_global = $xml_parser->getXMLArrayValues(P_RESULTS_TEST_TESTNAME);
+
+ foreach($tests_in_global as $test)
+ foreach(pts_locations_tests($test) as $sub_test)
+ array_push($tests, $sub_test);
+ }
+
+ return array_unique($tests);
+}
+
+?>
diff --git a/pts-core/functions/pts-interfaces.php b/pts-core/functions/pts-interfaces.php
index babc348..660fcc7 100644
--- a/pts-core/functions/pts-interfaces.php
+++ b/pts-core/functions/pts-interfaces.php
@@ -211,11 +211,4 @@ define("P_GRAPH_MARKCOUNT", "PhoronixTestSuite/Graphs/Other/NumberOfMarks"); //
define("P_GRAPH_WATERMARK", "PhoronixTestSuite/Graphs/Other/Watermark"); // Graph watermark
define("P_GRAPH_BORDER", "PhoronixTestSuite/Graphs/Other/Border"); // Graph border bool
-//
-// Define Types
-//
-
-define("TYPE_TEST", "TEST"); // Type is test
-define("TYPE_TEST_SUITE", "TEST_SUITE"); // Type is a test suite
-
?>