From: Sebastien D. <sde...@us...> - 2004-12-31 15:13:23
|
Update of /cvsroot/tslogparser/tslogparser/admin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16198/admin Added Files: index.php modules.inc.php Log Message: Started new modular implementation for different testsuites support --- NEW FILE: modules.inc.php --- <?php /* * Copyright (c) 2005, Bull S.A.. All rights reserved. * Created by: Sebastien Decugis * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * This program is distributed in the hope that it would be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * You should have received a copy of the GNU General Public License along * with this program; if not, write the Free Software Foundation, Inc., 59 * Temple Place - Suite 330, Boston MA 02111-1307, USA. */ /* This file defines the base module class which will be used. A module consists in four functions closely related to a testsuite model ("type"). These functions are: int TS_parse(string TS_name, string TS_description, string TS_path); int TS_delete(int TS_id); int RUN_parse(string RUN_name, string RUN_description, int TS_id, string CONTENT); int RUN_delete(int RUN_id); An additionnal function is added for informational purpose (no functionnal need) string module_info(void) TS_parse will check for the directory TS_path and analyse its content. In case a correct testsuite structure is found, the testsuite is parsed and put into the database with name and description as provided. The return value is $true if success and $false otherwise. TS_delete will search the database for a testsuite TS_id, then delete it. In case the testsuite contains runs, TS_delete will fail. In case TS_id is not of the correct type, TS_delete will fail. Otherwise, the testsuite is deleted from the database. The return value is $true if success and $false otherwise. RUN_parse will add a new run in the database. It starts with checking that TS_id exists and is of the correct testsuite type. Then it analyzes CONTENT and if a correct run format is found, the results are added into the database with RUN_name and RUN_description information. The return value is $true if success and $false otherwise. RUN_delete will delete RUN_id run from database. It starts with checking that RUN_id belongs to a testsuite of the correct type. Then it removes it from the database. The return value is $true if success and $false otherwise. module_info will return an HTML-formated text (enclosed in <p> and </p> tags) describing the module and the testsuite it supports. All information related to the module (version, known bugs, ...) are suitable for this function (think of it as the only documentation for the module). */ /* This particular file mechanism is as follow: -> Include each .php file from the modules subdirectory. Each inclusion returns its module name, which is added into the base catalog. -> The function list_modules returns the catalog. -> The function select_module selects one of the modules as the working module. (provider of the modules functions as described earlier) -> The function selected_module returns the currently selected module. -> The function deselect_module changes the selection back to default. -> The TS_parse, TS_delete, RUN_parse, RUN_delete and module_info functions are wrappers to the selected module functions, or return an error when no module is selected. The selected module information is persistent through a session. */ class testsuite { var $modules_catalog; var $selected_module; var $last_error=""; /* Class constructor: initializes the modules catalog and the default selected */ function testsuite($default_catalog="") { $this->modules_catalog=array(); $this->selected_module=""; /* If the default catalog is not specified, get it from session */ /* @@@ Session is not implemented yet */ // $default_catalog=$_SESSION["active_module"]; /* Enumerate the modules files and include them */ foreach (glob("modules/*.mod.php") as $filename) { $tmp = require($filename); if (is_string($tmp) && class_exists($tmp)) { $this->modules_catalog[]=$tmp; if ($tmp == $default_catalog) $this->selected_module=$tmp; } else { die("File $filename has an incorrect format\n"); } } if ($this->selected_module !== $default_catalog) { /* Remove this information from the session */ /* @@@ session not implemented yet */ /* Stop here */ die("The required module <i>$default_catalog</i> is unavailable."); } } /* Functions for manipulating the selected module */ function list_modules() { return $this->modules_catalog; } function selected_module() { return $this->selected_module; } function select_module($newmod) { if (in_array($newmod, $this->modules_catalog)) { /* Set the module for this execution and for the whole session */ $this->selected_module=$newmod; /* @@@ session information is not available yet */ } } function deselect_module() { $this->selected_module=""; /* We also have to remove it from session */ /* @@@ session information is not available yet */ } /* Wrapper functions to the selected module */ function module_info() { /* Check the environment is correct */ if ($this->selected_module == "") { die("No selected module"); } if (!is_callable(array($this->selected_module,'module_info'))) { die("Module ".$this->selected_module." is malformed.\n"); } /* Call actually the module method */ return call_user_func(array($this->selected_module, 'module_info')); } function TS_parse($TS_name, $TS_description, $path) { /* Check the environment is correct */ if ($this->selected_module == "") { die("No selected module"); } if (!is_callable(array($this->selected_module,'TS_parse'))) { die("Module ".$this->selected_module." is malformed.\n"); } /* Call actually the module method */ return call_user_func_array( array($this->selected_module, 'TS_parse'), array(&$this, $TS_name, $TS_description, $path)); } } ?> --- NEW FILE: index.php --- <?php /* * Copyright (c) 2005, Bull S.A.. All rights reserved. * Created by: Sebastien Decugis * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * This program is distributed in the hope that it would be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * You should have received a copy of the GNU General Public License along * with this program; if not, write the Free Software Foundation, Inc., 59 * Temple Place - Suite 330, Boston MA 02111-1307, USA. */ $root="../"; $_PAGE["title"]="TSLP Administration Interface"; /* Output header page */ require($root."header.inc.php"); /* We'll need functions defined in other files */ require($root."database.inc.php"); require($root."functions.inc.php"); /* We'll need the database connexion */ db_init(); /* Initialize the plugins modules */ require($root."admin/modules.inc.php"); $tslp = new testsuite("opts"); /* This file allows an admin to list the current releases and runs, to delete some entries or to add new ones. It also shows the supported modules, the currently selected one and can provide additional information on any module */ echo "<pre>\n"; $tmp = $tslp->TS_parse("pts1.5.0", "Release officielle 1.5.0", "/home/thedoc/travail/CVS-sf.net/posixtestsuite"); if ($tmp == false) { echo "Erreur: <b>".$tslp->last_error."</b>\n"; } echo "</pre>\n"; ?> |