From: Sebastien D. <sde...@us...> - 2004-12-31 15:13:24
|
Update of /cvsroot/tslogparser/tslogparser/admin/modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16198/admin/modules Added Files: ltp.mod.php opts.mod.php readme.txt Log Message: Started new modular implementation for different testsuites support --- NEW FILE: opts.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 Open POSIX Test Suite. Based on code from earlier TSLogParser releases. */ /* The following class contains the routines for the XML parser used later */ class opts_xml_routines { var $assertion; var $xml_parser; function opts_xml_routines() { $this->assertion = array("cur"=>-1); $this->xml_parser = xml_parser_create(); xml_parser_set_option($this->xml_parser, XML_OPTION_CASE_FOLDING, true); xml_set_element_handler($this->xml_parser, array($this, "startElement"), array($this, "endElement")); xml_set_character_data_handler($this->xml_parser, array($this, "characterData")); } /* The functions below are used within the XML parser -- see PHP doc for more info */ function startElement($parser, $name, $attrs) { if ($name == "ASSERTION") { echo "startElement($name, ".$attrs["ID"].")\n"; $this->assertion["cur"]=$attrs["ID"]; $this->assertion[$attrs["ID"]]=""; } } function endElement($name) { echo "endElement($name)\n"; if ($name == "ASSERTION") $this->assertion["cur"]=-1; } function characterData($data) { var_dump($data); if (($this->assertion["cur"] != -1) && (trim($data))) $this->assertion[$this->assertion["cur"]] .= $data."\n"; } /* This function is called for each assertions.xml file */ function parse_assertions($file) { if (!($fp = fopen($file, "r"))) { die("could not open XML input"); } while ($data = fread($fp, 4096)) { if (!xml_parse($this->xml_parser, $data, feof($fp))) { die(sprintf("XML error: %s at line %d<br>\nin ".$file, xml_error_string(xml_get_error_code($this->xml_parser)), xml_get_current_line_number($this->xml_parser))); } } return $this->assertion; } } class opts { /* 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() { echo "<p><b>Open POSIX Test Suite</b> parser module for <b>TSLogParser</b></p>\n"; echo "<p>Release: <b>0.1</b> 2004/12/31</p>\n"; echo "<p>Limitations and known problems: \n"; echo "<ul>\n<li>In case an assertion.xml file is malformed, the XML parser will fail\n"; echo " For this reason, you need a recent Open POSIX Test Suite release (1.5.0 is OK)\n"; echo "</li></ul></p>\n"; echo "<p>See the <a href='http://posixtest.sourceforge.net/'>test suite homepage</a> for more information.</p>\n"; return; } /* 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) { echo "opts->TS_parse($TS_name, $TS_description, $path)\n"; $releases=query_version(); $xmlparser = new opts_xml_routines(); $opts_tree=array(); $regexp_testcase="^([0-9]*)-([0-9]*|.*buildonly)\.(c|sh)$"; /* Check the directory contains a coherent structure */ if ((!is_dir($path)) || (!is_dir($path."/conformance"))) { $parent->last_error="Directory '$path' does not contain a valid source tree.\n"; return FALSE; } /* Open and browse the tree */ $dh = opendir($path."/conformance/"); if (!$dh) { $parent->last_error="Failed to open directory $path/conformance/ for reading.\n"; return FALSE; } while (($file = readdir($dh)) !== false) { if (($file == ".") || ($file == "..") || ($file == "CVS")) continue; if (is_dir($path."/conformance/".$file)) { $dh2 = opendir($path."/conformance/".$file); if (!$dh2) { $parent->last_error= "Failed to open directory $path/conformance/$file for reading.\n"; return FALSE; } while (($file2 = readdir($dh2)) !== false) { if (($file2 == ".") || ($file2 == "..") || ($file2 == "CVS")) continue; $file2array=array($file2); /* Special case: headers sys/mman.h etc... */ if (($file == "definitions") && ($file2 == "sys")) { $dh2b = opendir($path."/conformance/definitions/sys"); if (!$dh2b) { $parent->last_error= "Failed to open dir $path/conformance/definitions/sys for reading.\n"; return FALSE; } $file2array=array(); while (($file2b = readdir($dh2b)) !== false) { if (($file2b == ".") || ($file2b == "..") || ($file2b == "CVS")) continue; $file2array[]="sys/".$file2b; } closedir($dh2b); } foreach ($file2array as $file2) { if (is_dir($path."/conformance/".$file."/".$file2)) { $dh3 = opendir($path."/conformance/".$file."/".$file2); if (!$dh3) { $parent->last_error= "Failed to open directory $path/conformance/$file/$file2 for reading.\n"; return FALSE; } $assertion_file = 0; while (($file3 = readdir($dh3)) !== false) { if (($file3 == ".") || ($file3 == "..") || ($file3 == "CVS")) continue; /* We're looking for "assertions.xml" files */ if ($file3 == "assertions.xml") { $assertion_file = 1; continue; } /* We also keep track of every testcase file */ if (ereg($regexp_testcase, $file3, $regs)) $opts_tree[$file][$file2]["testcase"][$regs[1]][(int)$regs[2]]=$regs[1]."-".$regs[2].".".$regs[3]; /* Last but not least, we want the speculative tests in the database */ if ($file3 == "speculative") { $dh4 = opendir($path."/conformance/".$file."/".$file2."/".$file3); if (!$dh4) { $parent->last_error= "Failed to open directory $path/conformance/$file/$file2/speculative for reading.\n"; return FALSE; } while (($file4 = readdir($dh4)) !== false) { if (($file4 == ".") || ($file4 == "..") || ($file4 == "CVS")) continue; if (ereg($regexp_testcase, $file4, $regs)) $opts_tree[$file][$file2]["testcase"][$regs[1]][(int)$regs[2]]="speculative/".$regs[1]."-".$regs[2].".".$regs[3]; } closedir($dh4); } } closedir($dh3); /* We now parse the assertions */ if ($assertion_file) { $opts_tree[$file][$file2]["assertions"]=$xmlparser->parse_assertions($path."/conformance/".$file."/".$file2."/assertions.xml"); } } } } closedir ($dh2); } } closedir($dh); /* We've parsed the whole tree */ echo "<pre>\n"; print_r($opts_tree); echo "</pre>\n"; return TRUE; } function TS_delete($TS_id) { return false; } function RUN_parse($RUN_name, $RUN_description, $TS_id, $CONTENT) { return false; } function RUN_delete($RUN_id) { return false; } } /* Return the class name so it is added to the catalog */ return("opts"); ?> --- NEW FILE: ltp.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 Open POSIX Test Suite. Based on code from earlier TSLogParser releases. */ class ltp { function module_info() { echo "<p><b>Linux Test Project</b> parser module for <b>TSLogParser</b></p>\n"; echo "<p>Release: <b>0.0</b> 2004/12/31</p>\n"; echo "<p>Limitations and known problems: \n"; echo "<ul>\n<li>This module is just for test purpose; no function is working yet\n"; echo "</li></ul></p>\n"; echo "<p>See the <a href='http://ltp.sourceforge.net/'>test suite homepage</a> for more information.</p>\n"; return; } function TS_parse($TS_name, $TS_description, $path) { return $false; } function TS_delete($TS_id) { return $false; } function RUN_parse($RUN_name, $RUN_description, $TS_id, $CONTENT) { return $false; } function RUN_delete($RUN_id) { return $false; } } /* Return the class name so it is added to the catalog */ return("ltp"); ?> --- NEW FILE: readme.txt --- Modules decription: see file modules.inc.php for details |