Summary
Description: Unnamed repository; edit this file to name it for gitweb.
Last Change: Wed 2/3/10 13:04
Recent Commits
>
--git a/CHANGE-LOG b/CHANGE-LOG
index a1e8fe0..f76dfcd 100644
--- a/CHANGE-LOG
+++ b/CHANGE-LOG
@@ -24,6 +24,7 @@ Phoronix Test Suite (Git)
- pts-core: Support using PHPs cURL library for handling downloads when available
- pts-core: Calculate download speeds for each test file download, to provide estimations on future downloads for how long it may take to download
- pts-core: Drop support for SH PTS modules, since it was rarely used and just added overhead to pts-core module architecture
+- pts-core: Only process a PTS module API call to a module if it actually hooks into that method
- phodevi: Split out phodevi_parser module into phodevi_linux_parser, phodevi_osx_parser, and phodevi_solaris_parser for OS-specific functions
- phodevi: Avoid situations of the manufacturer/vendor string being repeated in the motherboard property
- phodevi: Add device notes and special settings string functionality to API
diff --git a/documentation/writing_your_first_module.html b/documentation/writing_your_first_module.html
index 111dea1..9c38a15 100644
--- a/documentation/writing_your_first_module.html
+++ b/documentation/writing_your_first_module.html
@@ -14,34 +14,20 @@
<div style="width: 1px; height: 20px;"></div>
<p>Writing a module for the Phoronix Test Suite allows new functionality to be added
without having to extensively learn how pts-core functions. The module framework
-for the Phoronix Test Suite allows modules to be written either as a shell script
-or as a PHP object. Example PTS modules could include a module to shutdown the
+for the Phoronix Test Suite allows modules to be written either as a PHP object. Example PTS modules could include a module to shutdown the
screensaver when the Phoronix Test Suite starts up and re-enabling it when the
test is over, using sendmail to forward the results to an e-mail address when
testing is completed, or writing the current test status to a LCDproc-enabled
VFD display.</p>
-<p>Both PHP and SH modules are stored in <em>pts-core/modules/</em>. Loading a
+<p>Modules are stored in <em>pts-core/modules/</em>. Loading a
module is done by either setting the <em>PTS_MODULES</em> environmental variable
-with the name of the module (excluding the <em>.sh</em> or <em>.php</em> file
-extension) or by associating a module with a separate environmental variable.
-The list of these environmental variables for auto-loading modules is stored in <em>pts-core/static/module-variables.txt</em>.
-The name of the environmental variable starts the line followed by an equal sign
-(<em>=</em>) and then what module to load if the variable is set. For example,
-if <em>module-variables.txt</em> contained a line that read <em>EMAIL_RESULTS_TO=email_results</em>,
-and the following command was run <em>EMAIL_RESULTS_TO=my-email-address@my-domain.com
-phoronix-test-suite benchmark universe</em>, it would automatically load the <em>email_results</em>
-module and the <em>EMAIL_RESULTS_TO</em> variable could be read by this module
-using a conventional method for reading the variable.</p>
-<p>If you plan to permanently use a module, the string that normally would be
-defined in <em>PTS_MODULES</em> can be set within the <em>LoadModules</em> tag
-found in <em>~/.phoronix-test-suite/user-config.xml</em>. Multiple modules can
-be loaded simultaneously using the <em>PTS_MODULES</em> variable or <em>LoadModules</em>
-tag by delimiting each command with a comma (<em>,</em>).</p>
+with the name of the module (excluding the <em>.php</em> file
+extension) or by associating a module with a separate environmental variable. The default list of modules to be loaded is stored in <em>~/.phoronix-test-suite/user-config.xml</em>.</p>
<p>Note: To run through all of the function calls for a module without needing to run a test,
run <em>phoronix-test-suite test-module MODULE_NAME</em>. Additionally, running
<em>phoronix-test-suite debug-module MODULE_NAME</em> will yield additional debugging details while
executing the same process.</p>
-<h1>PHP Module</h1>
+<h1>Module</h1>
<p>To see all of the functions supported for modules written in PHP, look at <em>pts-core/modules/dummy_module.php</em>
and additionally the other .php modules that ship with the Phoronix Test Suite.
Additionally, there are several functions written specifically for Phoronix Test
@@ -81,47 +67,6 @@ class time_me extends pts_module_interface<br />
<p>Then by running <em>PTS_MODULES=time_me phoronix-test-suite benchmark video-extensions</em>,
at the end of the test it would print a string similar to: "The Phoronix
Test Suite Ran For 52 Seconds."</p>
-<p>Running phoronix-test-suite module-info time_me would produce the following
-text.</p>
-<blockquote>====================================<br>
-Module: Time Me!<br>
-====================================</p>
-<p>Version: 1.0.0<br>
-Author: Phoronix Media<br>
-Description: This is a module that times how long the Phoronix Test Suite runs.</blockquote>
-<h1>Shell Script Modules</h1>
-<p>Writing Phoronix Test Suite modules in PHP is the preferred method, but the
-programming model for a shell script is similar. Look at <em>dummy_script_module.sh</em>
-to see available options. Below is a .sh version of the <em>time_me.php</em> module
-showcased in the previous section. This <em>time_me.sh</em> module provides the
-same exact functionality as the PHP version.</p>
-<blockquote>#!/bin/sh<br />
-case $1 in<br />
- "module_name")<br />
- echo "Time Me!"<br />
- ;;<br />
- "module_version")<br />
- echo "1.0.0"<br />
- ;;<br />
- "module_description")<br />
- echo "This is a module that times how long the Phoronix Test Suite runs."<br />
- ;;<br />
- "module_author")<br />
- echo "Phoronix Media"<br />
- ;;<br />
- "__startup")<br />
- date +%s > /tmp/pts-start-timer<br />
- ;;<br />
- "__shutdown")<br />
- date +%s > /tmp/pts-end-timer<br />
- START_TIME=`cat /tmp/pts-start-timer`<br />
- END_TIME=`cat /tmp/pts-end-timer`<br />
- TIME_ELAPSED=`expr $END_TIME - $START_TIME`<br />
- echo "\nThe Phoronix Test Suite Ran For $TIME_ELAPSED Seconds.\n";<br />
- rm -f /tmp/pts-start-timer<br />
- rm -f /tmp/pts-end-timer<br />
- ;;<br />
-esac</blockquote>
<!-- END OF PTS AREA -->
</div></div><div class="pts_doc_fixed"><div class="pts_doc_bottom"><div style="float: left;"><a href="http://www.phoronix-test-suite.com/">Phoronix-Test-Suite.com</a></div><div style="float: right;">Copyright © 2008 by <a href="http://www.phoronix-media.com/">Phoronix Media</a>.</div></div></div>
</body>
diff --git a/pts-core/library/pts-functions_modules.php b/pts-core/library/pts-functions_modules.php
index bdb7735..2fb002b 100644
--- a/pts-core/library/pts-functions_modules.php
+++ b/pts-core/library/pts-functions_modules.php
@@ -226,7 +226,7 @@ function pts_module_call($module, $process, &$object_pass = null)
function pts_module_process($process, &$object_pass = null)
{
// Run a module process on all registered modules
- foreach(pts_module_manager::attached_modules() as $module)
+ foreach(pts_module_manager::attached_modules($process) as $module)
{
pts_module_process_task($module, $process, $object_pass);
}
diff --git a/pts-core/objects/pts_module_interface.php b/pts-core/objects/pts_module_interface.php
index 62aae74..193bc39 100644
--- a/pts-core/objects/pts_module_interface.php
+++ b/pts-core/objects/pts_module_interface.php
@@ -48,6 +48,12 @@ class pts_module_interface
}
//
+ // The below methods are optional and can be implemented by any module
+ //
+
+ /*
+
+ //
// General Functions
//
@@ -166,6 +172,8 @@ class pts_module_interface
// Passed is a read-only copy of the pts_user_error object
return;
}
+
+ */
}
?>
diff --git a/pts-core/objects/pts_module_manager.php b/pts-core/objects/pts_module_manager.php
index 26b0f9b..2e2def5 100644
--- a/pts-core/objects/pts_module_manager.php
+++ b/pts-core/objects/pts_module_manager.php
@@ -24,6 +24,7 @@ class pts_module_manager
{
private static $modules = array();
private static $var_storage = array();
+ private static $module_process = array();
private static $current_module = null;
//
@@ -33,6 +34,19 @@ class pts_module_manager
public static function attach_module($module)
{
array_push(self::$modules, $module);
+
+ if(class_exists($module))
+ {
+ foreach(get_class_methods($module) as $module_method)
+ {
+ if(!is_array(self::$module_process[$module_method]))
+ {
+ self::$module_process[$module_method] = array();
+ }
+
+ array_push(self::$module_process[$module_method], $module);
+ }
+ }
}
public static function detach_module($module)
{
@@ -41,9 +55,9 @@ class pts_module_manager
unset(self::$modules[$module]);
}
}
- public static function attached_modules()
+ public static function attached_modules($process_name = null)
{
- return self::$modules;
+ return $process_name == null ? self::$modules : (isset(self::$module_process[$process_name]) ? self::$module_process[$process_name] : array());
}
public static function is_module_attached($module)
&nb
Copyright © 2010 by Phoronix Media