diff options
author | Michael Larabel <michael@phx-laptop.(none)> | 2008-06-07 23:06:08 -0400 |
---|---|---|
committer | Michael Larabel <michael@phx-laptop.(none)> | 2008-06-07 23:06:08 -0400 |
commit | fe4804789791da17d40413373d56ab71466ad4f7 (patch) | |
tree | 902d786cd3aa86166a8fd94c06ca34e498288b60 | |
parent | 8a32a92dc66680e3a8aa7929e0d44b8b4edbf909 (diff) | |
download | phoronix-test-suite-upstream-fe4804789791da17d40413373d56ab71466ad4f7.tar.gz phoronix-test-suite-upstream-fe4804789791da17d40413373d56ab71466ad4f7.tar.xz phoronix-test-suite-upstream-fe4804789791da17d40413373d56ab71466ad4f7.zip |
Start to push forward some Phoronix Test Suite modules / plug-in
framework support... Some basic bits are now in there but nothing to
keep end-users, yet.
-rw-r--r-- | pts-core/functions/pts-functions-install.php | 2 | ||||
-rw-r--r-- | pts-core/functions/pts-functions-run.php | 5 | ||||
-rw-r--r-- | pts-core/functions/pts-functions.php | 9 | ||||
-rw-r--r-- | pts-core/functions/pts-functions_modules.php | 32 | ||||
-rw-r--r-- | pts-core/objects/pts_module_interface.php | 78 | ||||
-rw-r--r-- | pts-core/pts-run-benchmark.php | 2 | ||||
-rw-r--r-- | pts-core/pts-run-cmd.php | 3 |
7 files changed, 131 insertions, 0 deletions
diff --git a/pts-core/functions/pts-functions-install.php b/pts-core/functions/pts-functions-install.php index 3961c35..c9ecc7f 100644 --- a/pts-core/functions/pts-functions-install.php +++ b/pts-core/functions/pts-functions-install.php @@ -282,6 +282,7 @@ function pts_install_benchmark($Benchmark) if(is_file(TEST_RESOURCE_DIR . "$Benchmark/install.sh") || is_file(TEST_RESOURCE_DIR . "$Benchmark/install.php")) { + pts_module_process("__pre_test_install"); $install_header = "Installing Benchmark: " . $Benchmark; if(($size = pts_test_estimated_download_size($Benchmark)) != "") @@ -305,6 +306,7 @@ function pts_install_benchmark($Benchmark) echo pts_exec("cd " . BENCHMARK_ENV_DIR . $Benchmark . "/ && " . PHP_BIN . " " . TEST_RESOURCE_DIR . $Benchmark . "/install.php " . BENCHMARK_ENV_DIR . $Benchmark) . "\n"; file_put_contents(BENCHMARK_ENV_DIR . "$Benchmark/pts-install", md5_file(TEST_RESOURCE_DIR . $Benchmark . "/install.php")); } + pts_module_process("__post_test_install"); } else { diff --git a/pts-core/functions/pts-functions-run.php b/pts-core/functions/pts-functions-run.php index 9101c40..13409aa 100644 --- a/pts-core/functions/pts-functions-run.php +++ b/pts-core/functions/pts-functions-run.php @@ -269,6 +269,8 @@ function pts_run_benchmark($benchmark_identifier, $extra_arguments = "", $argume } pts_process_register($benchmark_identifier); + pts_module_process("__pre_test_run"); + $xml_parser = new tandem_XmlReader(file_get_contents(XML_PROFILE_DIR . $benchmark_identifier . ".xml")); $execute_binary = $xml_parser->getXMLValue(P_TEST_EXECUTABLE); $benchmark_title = $xml_parser->getXMLValue(P_TEST_TITLE); @@ -376,6 +378,8 @@ function pts_run_benchmark($benchmark_identifier, $extra_arguments = "", $argume if(!empty($BENCHMARK_RESULTS)) array_push($BENCHMARK_RESULTS_ARRAY, $BENCHMARK_RESULTS); } + if($times_to_run > 1 && $i < ($times_to_run - 1)) + pts_module_process("__interim_test_run"); } pts_monitor_update(); // Update sensors, etc @@ -493,6 +497,7 @@ function pts_run_benchmark($benchmark_identifier, $extra_arguments = "", $argume //pts_beep(); pts_process_remove($benchmark_identifier); + pts_module_process("__post_test_run"); // 0 = main end result return array($END_RESULT); diff --git a/pts-core/functions/pts-functions.php b/pts-core/functions/pts-functions.php index 11e7d27..71f7a85 100644 --- a/pts-core/functions/pts-functions.php +++ b/pts-core/functions/pts-functions.php @@ -63,6 +63,7 @@ require_once("pts-core/functions/pts.php"); 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_modules.php"); require_once("pts-core/functions/pts-functions_monitor.php"); define("THIS_RUN_TIME", time()); @@ -73,6 +74,7 @@ define("XML_DISTRO_DIR", PTS_DIR . "pts/distro-xml/"); define("SCRIPT_DISTRO_DIR", PTS_DIR . "pts/distro-scripts/"); define("TEST_RESOURCE_DIR", PTS_DIR . "pts/test-resources/"); define("ETC_DIR", PTS_DIR . "pts/etc/"); +define("MODULE_DIR", PTS_DIR . "pts-core/modules/"); define("RESULTS_VIEWER_DIR", PTS_DIR . "pts-core/pts-results-viewer/"); define("PTS_USER_DIR", getenv("PTS_USER_DIR")); define("PTS_MONITOR_DIR", PTS_USER_DIR . "system-monitor" . '/'); @@ -96,6 +98,13 @@ register_shutdown_function("pts_shutdown"); $PTS_GLOBAL_ID = 1; +// PTS Modules Support + +$PTS_MODULES = array(); +pts_load_modules($PTS_MODULES); +pts_module_process("__startup"); +register_shutdown_function("pts_module_process", "__shutdown"); + if(($to_show = getenv("MONITOR"))) { $to_show = explode(',', $to_show); diff --git a/pts-core/functions/pts-functions_modules.php b/pts-core/functions/pts-functions_modules.php new file mode 100644 index 0000000..c351320 --- /dev/null +++ b/pts-core/functions/pts-functions_modules.php @@ -0,0 +1,32 @@ +<?php + +/* + Phoronix Test Suite "Trondheim" + URLs: http://www.phoronix.com, http://www.phoronix-test-suite.com/ + Copyright (C) 2008, Phoronix Media + Copyright (C) 2008, Michael Larabel + pts-functions_modules.php: Functions related to PTS module loading/management. + Modules are optional add-ons that don't fit the requirements for entrance into pts-core but provide added functionality. +*/ + +function pts_load_modules(&$modules_list) +{ + // TODO: Detect other modules to load + + // Clean-up modules list + array_unique($modules_list); + for($i = 0; $i < count($modules_list); $i++) + if(!is_file(MODULE_DIR . $modules_list[$i] . ".php")) + unset($modules_list[$i]); + + // Load the modules + foreach($modules_list as $module) + include(MODULE_DIR . $module . ".php"); +} +function pts_module_process($process) +{ + foreach($GLOBALS["PTS_MODULES"] as $module) + eval("$module::$process();"); // TODO: This can be cleaned up once PHP 5.3.0+ is out there and adopted +} + +?> diff --git a/pts-core/objects/pts_module_interface.php b/pts-core/objects/pts_module_interface.php new file mode 100644 index 0000000..56cba1d --- /dev/null +++ b/pts-core/objects/pts_module_interface.php @@ -0,0 +1,78 @@ +<?php + +/* + Phoronix Test Suite "Trondheim" + URLs: http://www.phoronix.com, http://www.phoronix-test-suite.com/ + Copyright (C) 2008, Phoronix Media + Copyright (C) 2004-2008, Michael Larabel + pts_module_interface.php: The generic Phoronix Test Suite module object that is extended by the specific modules/plug-ins +*/ + +class pts_module_interface +{ + const module_name = "Generic Module"; + const module_version = "1.0.0"; + const module_description = "A description of the module."; + const module_author = "Module Creator"; + + // + // General Functions + // + + public static function __startup($obj) + { + return; + } + public static function __shutdown($obj) + { + return; + } + + // + // Installation Functions + // + + public static function __pre_install_process($obj) + { + return; + } + public static function __pre_test_install($obj) + { + return; + } + public static function __post_test_install($obj) + { + return; + } + public static function __post_install_process($obj) + { + return; + } + + // + // Run Functions + // + + public static function __pre_run_process($obj) + { + return; + } + public static function __pre_test_run($obj) + { + return; + } + public static function __interim_test_run($obj) + { + return; + } + public static function __post_test_run($obj) + { + return; + } + public static function __post_run_process($obj) + { + return; + } +} + +?> diff --git a/pts-core/pts-run-benchmark.php b/pts-core/pts-run-benchmark.php index fd86653..53000f5 100644 --- a/pts-core/pts-run-benchmark.php +++ b/pts-core/pts-run-benchmark.php @@ -146,6 +146,7 @@ if($SAVE_RESULTS) } pts_disable_screensaver(); // Kill the screensaver +pts_module_process("__pre_run_process"); if($TO_RUN_TYPE == "BENCHMARK") { @@ -317,6 +318,7 @@ else } pts_beep(2); +pts_module_process("__post_run_process"); if($SAVE_RESULTS) { $check_processes = array( diff --git a/pts-core/pts-run-cmd.php b/pts-core/pts-run-cmd.php index f755dc1..f9c5b46 100644 --- a/pts-core/pts-run-cmd.php +++ b/pts-core/pts-run-cmd.php @@ -76,12 +76,15 @@ switch($COMMAND) $ARG_1 = strtolower($ARG_1); + pts_module_process("__pre_install_process"); + // Any external dependencies? pts_install_package_on_distribution($ARG_1); // Install benchmarks $install_objects = ""; pts_recurse_install_benchmark($ARG_1, $install_objects); + pts_module_process("__post_install_process"); break; case "FORCE_INSTALL_ALL": case "INSTALL_ALL": |