From: Sebastien D. <sde...@us...> - 2005-06-10 12:46:10
|
Update of /cvsroot/tslogparser/tslogparser/admin/modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24369/admin/modules Added Files: tahi.mod.php Log Message: New plugin file for TAHI tests results (incomplete) --- NEW FILE: tahi.mod.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 module is for use with the TAHI Conformance Test Suite. It has been tested against the IPv6 Mobility test suite results: ct-mipv6-cn-3.1.2.tar.gz ct-mipv6-ha-3.1.2.tar.gz ct-mipv6-mn-3.1.1.tar.gz */ /* Here is a bit of design, for integration purpose. This is needed because the OPTS and TAHI do not have an exact same structure. Here is the mapping for information between TAHI and tslogparser database. -------------------- TAHI Test Suite description ----------------------- The testsuite description is extracted from the INDEX file. Also, the *.seq files are used. Here is the description of the process: The INDEX file has the following format: #, // starting lines are comments and are ignored. &print: lines are test categories, and are mapped to tslogparser routines concept. ./CN-1-1.seq: lines are test cases, and are mapped to tslogparser assertions concept. As an example here is a sample entry of a TAHI testsuite description: === Table opts_routines rou_id : 198 rou_name : Normal Operations - Registration rou_comment: NULL Note: the rou_comment could contain complete hierarchy of test categories. === Table opts_assertions assert_id : 1466 assert_routine : 198 asser_text : (here goes the full content of file CN-1-1.seq) Note: the CN-1-1.seq file contains the full description of the test, when available. === Table opts_versions ver_id : 4 ver_name : ct-mipv6-cn-3.1.2 ver_comment : IPv6 Mobility TAHI Test Suite for Correspondant Node functions + URL ver_module : tahi === Table opts_version_descriptions descr_id : 6435 descr_version : 4 descr_assert : 1466 descr_num_asser : 1 descr_num_test : 1 descr_info : CN-1-1 Note: descr_num_assert is not usefull for this module - we put dummy values. descr_num_test is obtained from the INDEX file (# of test) */ class tahi { /* 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). */ function module_info($what="") { $title = "<b>TAHI Conformance Test Suite</b> parser module for <b>TSLogParser</b>"; $text = "<p>$title</p>\n"; $text.= "<p>Release: <b>0.1</b> 2005/06/10</p>\n"; $text.= "<p>Limitations and known problems: \n"; $text.= "<ul>\n<li>Under development\n"; $text.= "<li>Tested only with :<ul>\n"; $text.= "<li>ct-mipv6-cn-3.1.2.tar.gz\n"; $text.= "<li>ct-mipv6-ha-3.1.2.tar.gz\n"; $text.= "<li>ct-mipv6-mn-3.1.1.tar.gz</ul>\n"; $text.= "</ul></p>\n"; $text.= "<p>See the <a href='http://www.tahi.org/mipv6/index.html'>test suite homepage</a> for more information.</p>\n"; if ($what == "title") return $title; /* default to all */ return $text; } /* 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. */ function TS_parse(&$parent, $TS_name, $TS_description, $path) { if ( $parent->debug ) echo "tahi->TS_parse($TS_name, $TS_description, $path)\n"; /* Check the directory contains a coherent structure */ /* Open and browse the tree */ /* We've parsed the whole tree */ if ($parent->debug > 1) print_r($opts_tree); /* The database shall be initialized here */ if (!is_db_init()) { $parent->last_error="Database was not initialized\n"; return FALSE; } /* Check no release with the same name already exist */ $releases=query_version($TS_name, 1); if ($releases) { $parent->last_error= "The release '$TS_name' is already in the database \n". "<i>".stringFromDB($releases[$TS_name]["ver_comment"])."</i>\n"; return FALSE; } /* Now, compare the $tahi_tree with the $current_tests and build up the list of tests to be added to the database.*/ /* If any routine is missing, it must be added previously to further processing */ /* browse the new release assertions */ /* If any assertion is missing, it must be added previously to further processing */ /* OK, we can now create the new release of TAHI in the database */ $sql="INSERT INTO opts_versions (ver_name, ver_comment) " . "VALUES ( ".stringToDB($TS_name).", " . stringToDB($TS_description)." )"; if ($parent->debug > 1) echo htmlentities($sql)."<br>\n"; if (!db_execute_insert($sql)) { $parent->last_error= "Failed to insert new version in the database\n"; return FALSE; } /* We retrieve the new release uniqueID */ $releases=query_version($TS_name, 1); if (!$releases) { $parent->last_error= "Internal error: the new TAHI version was not created\n"; return FALSE; } if ($parent->debug > 1) print_r($current_asserts); /* We can create the full release description */ /* We've enough information now; we can create the release */ return TRUE; } function TS_delete(&$parent, $TS_id) { if ( $parent->debug ) echo "tahi->TS_delete($TS_id)\n"; /* Check there is no run within this testsuite */ $sql = "SELECT * from opts_run_results, opts_version_descriptions" ." WHERE res_testcase=descr_id" ." AND descr_version=".$TS_id; if ($parent->debug > 1) echo htmlentities($sql)."<br>\n"; $tmp = db_execute_select($sql); if ($tmp) { $parent->last_error="The testsuite contains runs -- cannot be deleted.\n Delete the runs first.\n"; return FALSE; } /* Check the testsuite is a TAHI one */ $sql = "SELECT ver_module from opts_versions" ." WHERE ver_id=".$TS_id; if ($parent->debug > 1) echo htmlentities($sql)."<br>\n"; $tmp = db_execute_select($sql); if (!$tmp) { $parent->last_error="The testsuite cannot be found in the database.\n"; return FALSE; } if ($tmp[0]["ver_module"] != "tahi") { $parent->last_error="The testsuite is not TAHI -- cannot be deleted within the current module.\n"; return FALSE; } /* Now, delete the testsuite description */ $sql = "DELETE from opts_version_descriptions" ." WHERE descr_version=".$TS_id; if ($parent->debug > 1) echo htmlentities($sql)."<br>\n"; $tmp = db_execute_insert($sql); echo "$tmp rows deleted from opts_version_descriptions<br>\n"; /* and the testsuite name */ $sql = "DELETE from opts_versions" ." WHERE ver_id=".$TS_id; if ($parent->debug > 1) echo htmlentities($sql)."<br>\n"; $tmp = db_execute_insert($sql); if ($tmp == 0) { $parent->last_error="No row deleted in opts_version\n"; return FALSE; } if ($parent->debug > 1) echo "$tmp rows deleted from opts_version<br>\n"; return true; } function RUN_parse(&$parent, $RUN_name, $RUN_description, $TS_id, &$CONTENT) { if ( $parent->debug ) echo "tahi->RUN_parse($RUN_name, $RUN_description, $TS_id, ...".strlen($CONTENT)."c...)\n"; /* Check this TS id first */ $sql = "SELECT ver_id, ver_name, ver_comment, ver_module FROM opts_versions WHERE ver_id=$TS_id"; if ($parent->debug > 1) echo htmlentities($sql)."<br>\n"; $release = db_execute_select($sql); if (!$release) { $parent->last_error="The provided testsuite ID was not found in database\n"; return false; } if ($release[0]["ver_module"] != "tahi") { $parent->last_error="This testsuite's ID is not of type TAHI Conformance Test Suite. Aborted.\n"; return false; } /* Check that run name is free */ $sql = "SELECT run_id, run_name, run_comments FROM opts_run WHERE run_name LIKE ".stringToDB($RUN_name); if ($parent->debug > 1) echo htmlentities($sql)."<br>\n"; $res = db_execute_select($sql); if ($res) { $elem=$res[0]; $parent->last_error ="The test run '$RUN_name' is already in the database\n"; $parent->last_error.="<i>".stringFromDB($elem["run_comments"])."</i>\n"; return false; } /* Parse the results files */ /* Next step is to eliminate duplicates and match testcases with database definition */ /* We're ready to proceed: * -> walk through the log file (analyzed) * -> foreach test, find the corresponding description ID * -> save a record with the information: description ID, test status, test log. * -> this will then be used to generate the database entries. */ /* Now we've got to add the new run name in the database and get its ID */ $sql = "INSERT INTO opts_run ( run_name, run_comments )" ." VALUES ( ".stringToDB($RUN_name).", ".stringToDB($RUN_description)." )"; if ($parent->debug > 1) echo htmlentities($sql)."<br>\n"; $res = db_execute_insert($sql); if (!$res) { $parent->last_error="Failed to insert new run name"; return false; } $sql = "SELECT run_id, run_name, run_comments FROM opts_run WHERE run_name LIKE ".stringToDB($RUN_name); if ($parent->debug > 1) echo htmlentities($sql)."<br>\n"; $res = db_execute_select($sql); if (!$res) { $parent->last_error="Internal error: the run was inserted but disappeared\n"; return false; } $run_id=$res[0]["run_id"]; /* Add the records in opts_run_results */ return true; } function RUN_delete(&$parent, $RUN_id) { if ( $parent->debug ) echo "tahi->RUN_delete($RUN_id)\n"; /* Check this run belongs to an OPTS testsuite */ $sql = "SELECT ver_module FROM opts_versions, opts_version_descriptions, opts_run_results" ." WHERE res_run=$RUN_id" ." AND res_testcase=descr_id AND descr_version=ver_id" ." GROUP BY ver_module"; if ($parent->debug > 1) echo htmlentities($sql)."<br>\n"; $tmp = db_execute_select($sql); if (!$tmp) { $parent->last_error="The run ID or corresponding testsuite cannot be found in the database.\n"; return FALSE; } if ($tmp[0]["ver_module"] != "tahi") { $parent->last_error="The testsuite is not TAHI -- cannot be deleted within the current module.\n"; return FALSE; } /* We can delete everything related to this run */ $sql = "DELETE from opts_run_results " ."WHERE res_run=$RUN_id"; if ($parent->debug > 1) echo htmlentities($sql)."<br>\n"; $tmp = db_execute_insert($sql); if ($tmp == 0) { $parent->last_error="No row deleted in opts_run_results\n"; return FALSE; } if ($parent->debug > 1) echo "$tmp rows deleted from opts_run_results<br>\n"; $sql = "DELETE from opts_run " ."WHERE run_id=$RUN_id"; if ($parent->debug > 1) echo htmlentities($sql)."<br>\n"; $tmp = db_execute_insert($sql); if ($tmp == 0) { $parent->last_error="No row deleted in opts_run\n"; return FALSE; } if ($parent->debug > 1) echo "$tmp row deleted from opts_run<br>\n"; return true; } } /* Return the class name so it is added to the catalog */ return("tahi"); ?> |