From: Sebastien D. <sde...@us...> - 2005-01-12 15:49:20
|
Update of /cvsroot/tslogparser/web In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23666 Modified Files: downloads.php features.php footer.inc.php header.inc.php index.php internals.php run-browse.php support.php Added Files: database.inc.php detailed.php foot.inc.php functions.inc.php head.inc.php report.php session.inc.php Log Message: Include the tool on the website Index: support.php =================================================================== RCS file: /cvsroot/tslogparser/web/support.php,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- support.php 12 Jan 2005 14:22:37 -0000 1.3 +++ support.php 12 Jan 2005 15:49:02 -0000 1.4 @@ -1,6 +1,6 @@ <?php $_PAGE["title"] = "SUPPORT"; -require("header.inc.php"); +require("head.inc.php"); ?> <table border='0' width='100%'> <tr> @@ -58,6 +58,6 @@ <tr><td> </td></tr> </table> <?php -require("footer.inc.php"); +require("foot.inc.php"); ?> Index: run-browse.php =================================================================== RCS file: /cvsroot/tslogparser/web/run-browse.php,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- run-browse.php 11 Jan 2005 11:10:25 -0000 1.2 +++ run-browse.php 12 Jan 2005 15:49:02 -0000 1.3 @@ -1,29 +1,240 @@ <?php -$_PAGE["title"] = "DEMONSTRATION"; -require("header.inc.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 allows the user to find which runs are in the database, + and to select for details or comparison. + +It also provides an interface to enter new results or new testsuite release. + +*/ + +/* We need to find all runs inside the database */ +$root=""; +require($root."database.inc.php"); +require($root."functions.inc.php"); +db_init(); + +$_PAGE["title"]="Results browser"; + +require($root."header.inc.php"); + +echo "<p>Go to <a href=\"".$root."admin/\">Administration Interface</a></p>\n"; + +if (isset($_GET["deselect_module"])) + unset($_SESSION["module"]); + +/* Count runs by modules in the database */ +$sql = " SELECT DISTINCT ver_module, ver_id, res_run" + ." FROM opts_versions, opts_version_descriptions, opts_run_results" + ." WHERE ver_id=descr_version" + ." AND res_testcase=descr_id"; +$runs = db_execute_select($sql); + +$infos=array(); +foreach ($runs as $row) + if (isset($infos[$row["ver_module"]])) + $infos[$row["ver_module"]]++; + else + $infos[$row["ver_module"]]=1; + +if (isset($_GET["module"])) + if (isset($infos[$_GET["module"]])) + $_SESSION["module"]=$_GET["module"]; + +/* If we found no showable results */ +if (count($infos)==0) +{ + echo "<p>There is no displayable result in the database yet.\n"; + echo "You may add some from the Administration Interface.</p>"; + db_fini(); + require($root."footer.inc.php"); + die(); +} + +/* If we have only 1 module, we don't need to ask the user */ +if (count($infos)==1) + $_SESSION["module"]=$runs[0]["ver_module"]; + +/* Otherwise, the user need to choose a module */ +if (count($infos)>1) +{ + if (!isset($_SESSION["module"])) + { + /* Show modules list and let the user choose one */ + echo "<p>Please choose a module from the list:</p>\n"; + echo "<ul>\n"; + foreach ($infos as $module => $cnt) + { + echo "<li><a href=\"".$_SERVER["PHP_SELF"]."?module=$module\">"; + echo "<b>$module</b></a> ($cnt logfiles)</li>\n"; + } + echo "</ul>\n"; + db_fini(); + require($root."footer.inc.php"); + die(); + } + else + { + /* Show selected module and let the user cancel its selection */ + echo "<p>You're viewing the <i>".$_SESSION["module"]."</i> results currently.\n"; + echo "<a href=\"".$_SERVER["PHP_SELF"]."?deselect_module=1\">"; + echo "Click here</a> to change.</p>\n"; + } +} + + +/* Now, proceed to the display */ + +/* + +We could achieve the same goal with an "outer join" sql request, +but it takes more time than 2 separate requests. + +$sql= " SELECT DISTINCT ver_name,run_name " + ." FROM " + ." ((opts_run_results INNER JOIN opts_run ON run_id=res_run)" + ." RIGHT OUTER JOIN opts_version_descriptions " + ." ON descr_id=res_testcase), opts_versions" + ." WHERE " + ." ver_id=descr_version"; +*/ +$sql= " SELECT DISTINCT ver_name, ver_comment, ver_id " + ." FROM opts_versions, opts_version_descriptions" + ." WHERE ver_id = descr_version " + ." AND ver_module = ".stringToDB($_SESSION["module"]) + ." ORDER BY ver_id DESC"; +$release_table = db_execute_select($sql); + + +$sql= " SELECT DISTINCT run_name, run_comments, ver_name, run_id " + ." FROM opts_run, opts_run_results, opts_version_descriptions, opts_versions " + ." WHERE run_id=res_run" + ." AND res_testcase=descr_id" + ." AND descr_version=ver_id" + ." AND ver_module = ".stringToDB($_SESSION["module"]) + ." ORDER BY ver_name"; +$run_table = db_execute_select($sql); + +/* Merge the data from both table */ +$infos=array(); + +foreach ($release_table as $release) + $infos[$release["ver_name"]]=array( + "id"=>$release["ver_id"], + "comment"=>$release["ver_comment"], + "runs"=>array()); + +foreach ($run_table as $run) + $infos[$run["ver_name"]]["runs"][$run["run_id"]]=array( + "name"=>$run["run_name"], + "comment"=>$run["run_comments"]); + +unset($release_table); +unset($run_table); + +/* Ok, now we'll display the result on the html page */ ?> - <table border='0' width='100%'> - <tr> - <td bgcolor="#90ACC8"> - <h2><font color="#fffffe"> - Experience <code>tslogparser</code></font></h2> - </td> - </tr> - <tr><td> </td></tr> - <tr> - <td> - <p>The tool can be experienced at:<br> - <a href="http://nptl.bullopensource.org/Tests/results/"> - http://nptl.bullopensource.org - </a> (read only access to the database).</p> - <p>If you're hosting this tool on a public place, - please let us know (though the mailing list) to - publish the link here. Thanks!</p> - </td> - </tr> - <tr><td> </td></tr> - </table> + + <h3>Available results for the <?php echo $_SESSION["module"]; ?> module</h3> + + <table border="1"> + <tr> + <td valign='top' align='center'><b>TestSuite Release</b></td> + <td valign='top' align='center' colspan="2"><b>Run Designation</b></td> + <td valign='top' align='center'><b>Action</b></td> + <td valign='top'><b>Comments</b></td> + </tr> <?php -require("footer.inc.php"); + if (!$infos) + { + /* This should never happen */ ?> + <tr> + <td colspan=5><i>Sorry, no data was found.</i></td> + </tr> +<?php + } + else + { + foreach($infos as $release => $data) + { + echo " <tr>\n"; + echo " <td valign=\"top\""; + if (count($data["runs"])>1) + echo " rowspan=\"".(count($data["runs"])+2)."\""; + elseif (count($data["runs"])==1) + echo " rowspan=\"2\""; + echo ">\n"; + echo " <font color='orange'>".stringFromDB($release)."</font>\n"; + echo " </td>\n"; + echo " <td colspan='4' align=left>\n"; + echo " <i><font color='orange'>".stringFromDB($data["comment"])."</font></i>\n"; + echo " </td>\n"; + echo " </tr>\n"; + + if ($data["runs"]) + { + echo " <form method='POST' action='report.php'>\n"; + echo " <input type='hidden' name='opts_rel' value=\"".$data["id"]."\">\n"; + /* default to masking PASS and SKIP status */ + echo " <input type='hidden' name='build_PASS' value='hidden'>\n"; + echo " <input type='hidden' name='link_SKIP' value='hidden'>\n"; + echo " <input type='hidden' name='execution_PASS' value='hidden'>\n"; + + foreach ($data["runs"] as $run_id => $run_data) + { + echo " <tr>\n"; + echo " <td align=center>\n"; + if (count($data["runs"])>1) + echo " <input type='checkbox' name='chkd_runs[]' value='".$run_id."'>\n"; + else + echo " \n"; + echo " </td>\n"; + echo " <td>\n"; + echo " ".stringFromDB($run_data["name"])."\n"; + echo " </td>\n"; + echo " <td align=center>\n"; + echo " <input type='submit' name='browse[$run_id]' value='Browse'>\n"; + echo " </td>\n"; + echo " <td>\n"; + echo " <i>".stringFromDB($run_data["comment"])."</i>\n"; + echo " </td>\n"; + echo " </tr>\n"; + } + if (count($data["runs"])>1) + { + echo " <tr>\n"; + echo " <td colspan='3' align=center>\n"; + echo " <input type='submit' name='compare' value='Compare selected'>\n"; + echo " </td>\n"; + echo " <td>\n"; + echo " \n"; + echo " </td>\n"; + echo " </tr>\n"; + } + echo " </form>\n"; + } + } + } +?> + </table> +<?php +db_fini(); +require($root."footer.inc.php"); +?> --- NEW FILE: detailed.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 gives the full information for a testcase Inputs: -> database identification of the testcase (run_id + testcase_id) Inputs are passed through GET variables, i.e.: detailed.php?run_id=2&testcase_id=17 Outputs: -> html text only */ $root=""; require($root."database.inc.php"); require($root."functions.inc.php"); $_PAGE["title"]="Testcase Detail"; require($root."header.inc.php"); if (!isset($_GET["run_id"]) || (!isset($_GET["testcase_id"]))) die("<p><b>Wrong parameter format.</b></p>\n</body></html>\n"); db_init(); /* We need to find this record in the database -- and get some more infos */ $sql = " SELECT res_log, res_status, run_name, run_comments, ver_name, ver_comment, " ." descr_info, assert_text, rou_name, rou_comment " ." FROM opts_run, opts_run_results, opts_version_descriptions, " ." opts_versions, opts_assertions, opts_routines " ." WHERE " ." opts_run.run_id = opts_run_results.res_run" ." AND opts_run_results.res_testcase = opts_version_descriptions.descr_id" ." AND opts_version_descriptions.descr_version = opts_versions.ver_id" ." AND opts_version_descriptions.descr_assert = opts_assertions.assert_id" ." AND opts_assertions.assert_routine = opts_routines.rou_id" ." AND res_run=".$_GET["run_id"]." AND res_testcase=".$_GET["testcase_id"]; $restotal = db_execute_select($sql); if (!$restotal) die("<p><b>No corresponding testcase found.</b></p>\n</body></html>\n"); $res=$restotal[0]; ?> <table border="1" width="100%"> <tr> <td valign="top" align="center"><b>Testsuite</b></td> <td valign="top" align="center"><?php echo stringFromDB($res["ver_name"]); ?></td> <td valign="top"><i><?php echo stringFromDB($res["ver_comment"]); ?></i> </td> </tr> <tr> <td valign="top" align="center"><b>Run</b></td> <td valign="top" align="center"><?php echo stringFromDB($res["run_name"]); ?></td> <td valign="top"><i><?php echo stringFromDB($res["run_comments"]); ?></i> </td> </tr> <tr> <td valign="top" align="center"><b>Routine</b></td> <td valign="top" align="center"><?php echo stringFromDB($res["rou_name"]); ?></td> <td valign="top"><i><?php echo stringFromDB($res["rou_comment"]); ?></i> </td> </tr> <tr> <td valign="top" align="center"><b>Testcase</b></td> <td valign="top" align="center"><?php echo stringFromDB($res["descr_info"]); ?></td> <td valign="top"><?php echo stringFromDB($res["assert_text"]); ?> </td> </tr> <tr> <td valign="top" align="center"><b>Status</b></td> <td valign="top" align="center"><?php $font=0; if (ereg("PASS", $res["res_status"])) { echo "<font color='green'>"; $font=1; } if (ereg("FAIL", $res["res_status"])) { echo "<font color='red'>"; $font=1; } echo stringFromDB($res["res_status"]); if ($font) echo "</font>"; ?></td> <td valign="top"><pre><?php echo strip_tags(stringFromDB($res["res_log"])); ?> </pre></td> </tr> </table> <?php db_fini(); require($root."footer.inc.php"); ?> --- NEW FILE: head.inc.php --- <?php if (!isset($_PAGE["title"])) die("Incorrect page inclusion.\n"); if (!isset($root)) $root=""; ?> <!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>TsLogParser Project</title> <?php echo " <link rel=\"stylesheet\" type=\"text/css\" href=\"".$root."my.css\">\n"; ?> </head> <body link="#1c3388" vlink="#1c3388" alink="#1c3388"> <table align="center" bgcolor="#fefefe" border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td height="30" bgcolor="#A2C0DF" colspan="2"> <center> <h1><font color="#fffffe">TestSuite Log Parser and Browser</font></h1> </center> </td> </tr> <tr> <td colspan="2" align="center"> <table border='0' cellspacing='0' cellpadding='0' width='100%'> <tr> <?php echo " <td width=300 align=left><img src=\"".$root."bos.jpg\" height=112></td>\n"; echo " <td align=\"center\"><h2>".$_PAGE["title"]."</h2></td>\n"; echo " <td width=300 align=right><img src=\"".$root."bos-rev.jpg\" height=112></td>\n"; ?> </tr> </table> </td> </tr> <tr> <td width="91" bgcolor="#A2C0DF" valign="top"> <?php require($root."menu.inc.php"); ?> </td> <td valign="top"> <table border="0" width="100%"> <tr> <td colspan=3> </td> </tr> <tr> <td> </td> <td width='100%'> Index: index.php =================================================================== RCS file: /cvsroot/tslogparser/web/index.php,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- index.php 25 Nov 2004 14:26:06 -0000 1.1.1.1 +++ index.php 12 Jan 2005 15:49:02 -0000 1.2 @@ -1,6 +1,6 @@ <?php $_PAGE["title"] = "PROJECT HOME"; -require("header.inc.php"); +require("head.inc.php"); ?> <table border='0' width='100%'> <tr> @@ -65,6 +65,6 @@ <tr><td> </td></tr> </table> <?php -require("footer.inc.php"); +require("foot.inc.php"); ?> Index: features.php =================================================================== RCS file: /cvsroot/tslogparser/web/features.php,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- features.php 11 Jan 2005 11:10:25 -0000 1.2 +++ features.php 12 Jan 2005 15:49:02 -0000 1.3 @@ -1,6 +1,6 @@ <?php $_PAGE["title"] = "FEATURES"; -require("header.inc.php"); +require("head.inc.php"); ?> <table border='0' width='100%'> <tr> @@ -99,6 +99,6 @@ <tr><td> </td></tr> </table> <?php -require("footer.inc.php"); +require("foot.inc.php"); ?> --- NEW FILE: session.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. */ /* We don't really care about security yet, so the default session handler is suitable for us. If one want to add better security, a good start is the php manual. */ session_start(); /* Below is a definition of authorized session variables for each user page. If a session variable is found out of this definition, it is unset. The format is $authorized_session_vars["variable"]=array("page1","page2"...); where variable is the session variable name (key in $_SESSION) and page1, page2 the pages where this variable is allowed. */ $authorized_session_vars=array( "module"=>array("run-browse.php"), ); /* Below is the mechanism which will delete unauthorized sessions vars */ foreach ($_SESSION as $var => $authorization) { if (!isset($authorized_session_vars[$var])) { unset($_SESSION[$var]); continue; } if (!in_array(basename($_SERVER["PHP_SELF"]),$authorized_session_vars[$var])) { unset($_SESSION[$var]); } } ?> Index: internals.php =================================================================== RCS file: /cvsroot/tslogparser/web/internals.php,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- internals.php 11 Jan 2005 10:48:20 -0000 1.2 +++ internals.php 12 Jan 2005 15:49:02 -0000 1.3 @@ -1,6 +1,6 @@ <?php $_PAGE["title"] = "INTERNALS"; -require("header.inc.php"); +require("head.inc.php"); ?> <table border='0' width='100%'> <tr> @@ -82,6 +82,6 @@ <tr><td> </td></tr> </table> <?php -require("footer.inc.php"); +require("foot.inc.php"); ?> --- NEW FILE: database.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 contains the functions to connect to the database and to execute queries */ /* database settings * * (These are separated for security reasons) * * The included file must define * $db_server * $db_user * $db_pw * $db */ if (!isset($root)) die ("Hack attempt detected\n"); require($root."../db/db_inc.php"); /* Define the latest version name */ require($root."db/update_db.inc.php"); /* Database connection handler */ $db_link=0; /* Configuration data */ $CONFIG=array(); /* Initialize link to the db and grep configuration */ function db_init() { global $db_server,$db_user,$db_pw, $db, $db_link, $CONFIG, $root; $db_link = mysql_connect($db_server,$db_user,$db_pw) or die("Failed to connect to MySQL: ".mysql_error()."\n"); mysql_select_db($db) or die("Failed selecting the database\n"); $tmp = @mysql_query("SELECT * FROM opts_config"); if ($tmp) { while ($row = mysql_fetch_assoc($tmp)) $CONFIG[$row["cfg_key"]]=$row["cfg_val"]; } if ((!isset($CONFIG["version"])) || ($CONFIG["version"] < LATEST_VERSION)) { die("<b>You need to update your database schema.</b>\n <a href='$root/admin/upgrade.php'>Click here</a>.\n"); } } /* Close link to the db */ function db_fini() { global $db_link; if ($db_link) mysql_close($db_link); } /* Check DB link */ function is_db_init() { global $db_link; return ($db_link != false); } function db_execute_select($sql) { $rows=array(); $res = mysql_query($sql) or die("Database access error: ".mysql_error()); while ($row = mysql_fetch_assoc($res)) $rows[]=$row; mysql_free_result($res); return ($rows); } function db_query($sql, &$res) { $res = mysql_query($sql) or die("Database access error: ".mysql_error()); } function db_getline($rs) { return mysql_fetch_assoc($rs); } function db_execute_insert($sql) { mysql_query($sql) or die("Database access error: ".mysql_error()); return mysql_affected_rows(); } ?> Index: downloads.php =================================================================== RCS file: /cvsroot/tslogparser/web/downloads.php,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- downloads.php 11 Jan 2005 11:10:25 -0000 1.2 +++ downloads.php 12 Jan 2005 15:49:02 -0000 1.3 @@ -1,6 +1,6 @@ <?php $_PAGE["title"] = "DOWNLOADS"; -require("header.inc.php"); +require("head.inc.php"); ?> <table border='0' width='100%'> <tr> @@ -43,6 +43,6 @@ </tr> </table> <?php -require("footer.inc.php"); +require("foot.inc.php"); ?> --- NEW FILE: functions.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 provides several functions used in other files. -> interface to database -> pre-built queries */ /* The next function will seek for a particular routine into the database. * * Input: * $routine_name: Name of the routine being searched. If $exact_match is false, this name can be partial. * $exact_match: if true, only routines with exact name are returned. * * Output: * An array of found routines is returned: * Array( * <routine_name> = Array( * "routine_id" => <routine_id> * "routine_comment" => <routine_comment> * ) * ) */ function query_routines($routine_name="", $exact_match=0) { $sql = "SELECT rou_id, rou_name, rou_comment FROM opts_routines"; if ($routine_name != "") { $sql .= " WHERE rou_name LIKE "; if ($exact_match) $sql .= "'$routine_name'"; else $sql .= "'%$routine_name%'"; } $res = db_execute_select($sql); $result=array(); foreach ($res as $data) { $result[$data["rou_name"]]=array( "routine_id"=>$data["rou_id"], "routine_comment"=>$data["rou_comment"]); } return $result; } /* The next function will retrieve assertions from the database (not bound to a particular OPTS release). * * Input: * $routine_name: Name of the routine being searched. If $exact_match is false, this name can be partial. * $exact_match: if true, only routines with exact name are returned. * * Output: * An array of found assertions is returned: * Array( * <routine_name> = Array( * <assert_id> => <assert_text> * ) * ) */ function query_all_asserts($routine_name="", $exact_match=0) { $sql = "SELECT rou_name, assert_id, assert_text FROM opts_routines, opts_assertions WHERE rou_id=assert_routine"; if ($routine_name != "") { $sql .= " AND rou_name LIKE "; if ($exact_match) $sql .= "'$routine_name'"; else $sql .= "'%$routine_name%'"; } $res = db_execute_select($sql); $result=array(); foreach ($res as $data) { if (!isset($result[$data["rou_name"]])) $result[$data["rou_name"]]=array(); $result[$data["rou_name"]][$data["assert_id"]]=$data["assert_text"]; } return $result; } /* The next function will retrieve OPTS release names from the database * * Input: * $release_name: Name of the release being searched. If $exact_match is false, this name can be partial. * $exact_match: if true, only releases with exact name are returned. * * Output: * An array of found releases is returned: * Array( * <version_name> = Array( * "ver_id" => <version_id>, * "ver_comment" => <version_comment> * ) * ) */ function query_version($release_name="", $exact_match=0) { $sql = "SELECT ver_id, ver_name, ver_comment, ver_module FROM opts_versions"; if ($release_name != "") { $sql .= " WHERE ver_name LIKE "; if ($exact_match) $sql .= "'".addslashes($release_name)."'"; else $sql .= "'%".addslashes($release_name)."%'"; } $res = db_execute_select($sql); $result=array(); foreach ($res as $data) { $result[$data["ver_name"]]= array( "ver_id"=>$data["ver_id"], "ver_comment"=>$data["ver_comment"], "ver_module" =>$data["ver_module"]); } return $result; } /* The next 2 functions are used to protect text data inserted and extracted from database. It prevents user from putting malicious HTML code, for example. A basic version will forbid all tags. Later a refined support can be developped. */ function stringToDB($string) { return "'".addslashes($string)."'"; } function stringFromDB($string) { return nl2br(htmlentities($string)); } ?> Index: footer.inc.php =================================================================== RCS file: /cvsroot/tslogparser/web/footer.inc.php,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- footer.inc.php 11 Jan 2005 10:34:40 -0000 1.2 +++ footer.inc.php 12 Jan 2005 15:49:02 -0000 1.3 @@ -1,6 +1,6 @@ <?php /* - * Copyright (c) 2004, Bull S.A.. All rights reserved. + * 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 @@ -15,30 +15,20 @@ * with this program; if not, write the Free Software Foundation, Inc., 59 * Temple Place - Suite 330, Boston MA 02111-1307, USA. */ - - -if (!isset($_PAGE["title"])) - die("Incorrect page inclusion.\n"); +/* Check there is no hack attempt */ +if (!isset($root)) + die ("Hack attempt detected\n"); ?> - </td> - <td> </td> - </tr> - </table> - </td> - </tr> - <tr> - <td colspan="2"> </td> - </tr> - </table> - <hr width="100%"> - <p>Page hosted by : <br> - <a href="http://sourceforge.net"> - <img src="http://sourceforge.net/sflogo.php?group_id=124567&type=5" - width="210" height="62" border="0" alt="SourceForge.net Logo"> - </a> + <p> + <font size='-2' color='grey'> + Generated with <a href="index.php">TsLogParser</a>. + </font> </p> - </body> -</html> +<?php + +require("foot.inc.php"); + +?> Index: header.inc.php =================================================================== RCS file: /cvsroot/tslogparser/web/header.inc.php,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- header.inc.php 25 Nov 2004 14:26:05 -0000 1.1.1.1 +++ header.inc.php 12 Jan 2005 15:49:02 -0000 1.2 @@ -1,47 +1,28 @@ <?php -if (!isset($_PAGE["title"])) - die("Incorrect page inclusion.\n"); -?> -<!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en"> -<html> - <head> - <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> - <title>TsLogParser Project</title> - <link rel="stylesheet" type="text/css" href="my.css"> - </head> - <body link="#1c3388" vlink="#1c3388" alink="#1c3388"> - <table align="center" bgcolor="#fefefe" border="0" width="100%" cellspacing="0" cellpadding="0"> - <tr> - <td height="30" bgcolor="#A2C0DF" colspan="2"> - <center> - <h1><font color="#fffffe">TestSuite Log Parser and Browser</font></h1> - </center> - </td> - </tr> - <tr> - <td colspan="2" align="center"> - <table border='0' cellspacing='0' cellpadding='0' width='100%'> - <tr> - <td width=300 align=left><img src="bos.jpg" height=112></td> - <td align="center"><h2><?php echo $_PAGE["title"]; ?></h2></td> - <td width=300 align=right><img src="bos-rev.jpg" height=112></td> - </tr> - </table> - </td> - </tr> - <tr> - <td width="91" bgcolor="#A2C0DF" valign="top"> -<?php -require("menu.inc.php"); -?> - </td> - <td valign="top"> +/* + * Copyright (c) 2005, Bull S.A.. All rights reserved. + * Created by: Sebastien Decugis - <table border="0" width="100%"> - <tr> - <td colspan=3> </td> - </tr> - <tr> - <td> </td> - <td width='100%'> + * 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. + */ + +/* We load the session module here */ +require_once($root."session.inc.php"); + +/* The L&F is grabbed from the website's */ +$_PAGE["title"] = "DEMO: ".$_PAGE["title"]; + +require("head.inc.php"); + +?> --- NEW FILE: foot.inc.php --- <?php /* * Copyright (c) 2004, 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. */ if (!isset($_PAGE["title"])) die("Incorrect page inclusion.\n"); ?> </td> <td> </td> </tr> </table> </td> </tr> <tr> <td colspan="2"> </td> </tr> </table> <hr width="100%"> <p>Page hosted by : <br> <a href="http://sourceforge.net"> <img src="http://sourceforge.net/sflogo.php?group_id=124567&type=5" width="210" height="62" border="0" alt="SourceForge.net Logo"> </a> </p> </body> </html> --- NEW FILE: report.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. */ /* The goal of this file is to give detailed content of OPTS runs. Inputs: -> run ID(s). If one run ID is given, the full detail of the run is given. If 2 or more run IDs are given, a comparison is made. Output: -> html report of the differences between all the runs. Future extensions: -> ability to select a subset of the routines only (with domains in the database) -> Summary of the results (X tests passed, Y test FAILED, ...) -> Ability to show only the summary -> Extend the "hide passed" function to something like "show only PASSED, show only HUNG" ... with the possibility to select what status to display (select from the summary, for example) */ //echo "<pre>\n"; //print_r($_POST); //echo "</pre>\n"; $root=""; require($root."database.inc.php"); require($root."functions.inc.php"); $_PAGE["title"]="Reporting Tool"; require($root."header.inc.php"); /* Verify that the page was not opened directly */ if (!isset($_POST["opts_rel"])) die("<p>No valid parameter found. Please use <a href='run-browse.php'>this page</a>.</p>\n</body></html>\n"); /* We check for correct parameters */ $mode=""; if (isset($_POST["compare"]) && isset($_POST["chkd_runs"])) { if (count($_POST["chkd_runs"]) <= 1) die("<p>Multiple releases comparison not implemented yet. <a href='run-browse.php'>Back</a></p>\n</body></html>\n"); $mode="COMPARE"; } $run_id = 0; if (isset($_POST["browse"])) { if (count($_POST["browse"]) != 1) die("<p>Invalid parameter supplied. <a href='run-browse.php'>Back</a></p>\n</body></html>\n"); $mode="BROWSE"; foreach ($_POST["browse"] as $key => $trash) $run_id = $key; } if ($mode =="") die("<p>No valid parameter found. Please use <a href='run-browse.php'>this page</a>.</p>\n</body></html>\n"); /* Remove unusefull POST variables */ if (isset($_POST["noasserts"])) { unset($_POST["asserts"]); unset($_POST["noasserts"]); } if (isset($_POST["nodetails"])) { unset($_POST["details"]); unset($_POST["nodetails"]); } if (isset($_POST["filter"]) && ($_POST["filter"]=="Show")) { unset($_POST[$_POST["filtered"]]); } if (isset($_POST["filter"])) unset($_POST["filter"]); if (isset($_POST["filtered"])) unset($_POST["filtered"]); if (isset($_POST["nologs"]) || ($mode!="BROWSE")) { unset($_POST["logs"]); unset($_POST["nologs"]); } /* Save the useful variables to allow page re-generation */ $POST_context=""; foreach ($_POST as $key => $val) if (is_array($_POST[$key])) foreach ($val as $subkey => $subval) $POST_context .=" <input type='hidden' name='".$key."[".$subkey."]' value='$subval'>\n"; else $POST_context.=" <input type='hidden' name='$key' value='$val'>\n"; /* We have a correct set of parameters, so we show the control panel */ echo " <form method=POST>\n"; echo $POST_context; // simplified session management echo " <table border=0 width=\"100%\">\n"; echo " <tr>\n"; echo " <td>Commands:</td>\n"; echo " <td><input type='submit' name='reload' value='Reload'></td>\n"; /* Displayed only for mode COMPARE */ if ($mode == "COMPARE") { if (isset($_POST["details"])) echo " <td><input type='submit' name='nodetails' value='Hide common results'></td>\n"; else echo " <td><input type='submit' name='details' value='Show common results'></td>\n"; } /* Displayed only for mode BROWSE */ if ($mode == "BROWSE") { if (isset($_POST["logs"])) echo " <td><input type='submit' name='nologs' value='Hide logs'></td>\n"; else echo " <td><input type='submit' name='logs' value='Show logs'></td>\n"; } /* Displayed in both modes */ if (isset($_POST["asserts"])) echo " <td><input type='submit' name='noasserts' value='Hide assertions'></td>\n"; else echo " <td><input type='submit' name='asserts' value='Show assertions'></td>\n"; echo " </tr>\n"; echo " </table>\n"; echo " </form>\n"; /* Whatever the mode is, we need to query the database with the same informations */ db_init(); $cond = ""; if ($mode == "BROWSE") $cond .= "res_run=$run_id"; if ($mode == "COMPARE") { $cond .= " ( (0) "; foreach ($_POST["chkd_runs"] as $run_id) $cond .= " OR (res_run=$run_id) "; $cond .= " ) "; } $sql = " SELECT run_name, res_status, count(res_status) as cnt_status" ." FROM opts_run, opts_run_results " ." WHERE opts_run.run_id = opts_run_results.res_run" ." AND ". $cond ." GROUP BY run_name, res_status"; db_query($sql, $stats_rs); $stats=array(); while ($row = db_getline($stats_rs)) $stats[$row["res_status"]][$row["run_name"]] = $row["cnt_status"]; $sql = " SELECT ver_name, run_name, res_run, assert_id, descr_id, rou_name, descr_info, res_status, " .(isset($_POST["logs"])?"res_log ":"res_log<>\"\" as is_res_log ") .(isset($_POST["asserts"])?", assert_text":"") ." FROM opts_versions, opts_run, opts_routines, opts_run_results, opts_version_descriptions, " ." opts_assertions " ." WHERE " ." opts_run.run_id = opts_run_results.res_run" ." AND opts_run_results.res_testcase = opts_version_descriptions.descr_id" ." AND opts_version_descriptions.descr_version = opts_versions.ver_id" ." AND opts_version_descriptions.descr_assert = opts_assertions.assert_id" ." AND opts_assertions.assert_routine = opts_routines.rou_id " ." AND ". $cond; //$res = db_execute_select($sql); db_query($sql, $res); /* Hash the results */ $data=array(); $asserts=array(); $runs=array(); //foreach ($res as $key => $row) $displayed=0; while ($row = db_getline($res)) { if ($mode != "BROWSE" || !isset($_POST[str_replace (' ','_',$row["res_status"])])) { $data[$row["rou_name"]][$row["assert_id"]][$row["descr_info"]][$row["descr_id"]][$row["run_name"]]=array( "status" => $row["res_status"], "log" => isset($_POST["logs"])?trim($row["res_log"]):$row["is_res_log"]); $displayed++; } $runs[$row["run_name"]]=array("id"=>$row["res_run"],"testsuite"=>$row["ver_name"]); if (isset($_POST["asserts"])) $asserts[$row["rou_name"]][$row["assert_id"]]=$row["assert_text"]; } db_fini(); /* In case we are comparing several runs, we filter out the results which are the same for all runs */ if (($mode == "COMPARE") && !(isset($_POST["details"]))) { foreach ($data as $routine => $assertsdata) foreach ($assertsdata as $assert_id => $testdata) foreach ($testdata as $testname => $desc_data) foreach ($desc_data as $desc_id => $run_data) { $tmpres=""; $diff=0; foreach ($run_data as $run_name => $detail) { if (!$tmpres) $tmpres=$detail["status"]; // save the status of the 1st test elseif ($tmpres != $detail["status"]) $diff=1; // we found a difference, we must not delete this one } if (!$diff) { unset ($data[$routine][$assert_id][$testname][$desc_id]); // No difference in this testcase $displayed--; } // we cascade-delete the empty tree branchs if (!$data[$routine][$assert_id][$testname]) unset($data[$routine][$assert_id][$testname]); if (!$data[$routine][$assert_id]) unset($data[$routine][$assert_id]); if (!$data[$routine]) unset($data[$routine]); if (!$data) die("The runs are identical -- aborted"); } } ksort($runs); ksort($data); //echo "<pre>\n"; //print_r($data); //echo "</pre>\n"; /* Print the statistics and filter command panel */ echo " <table border='1'>\n"; echo " <tr>\n"; echo " <td align='center'><b><i>Statistics / status</i></b></td>\n"; foreach ($runs as $run => $dummy) echo " <td align='center'><b>".stringFromDB($run)."</b></td>\n"; if ($mode == "BROWSE") echo " <td align='center'><b>Filtering</b></td>\n"; echo " </tr>\n"; foreach ($stats as $status => $stats_data) { echo " <tr>\n"; echo " <td align='center'>"; $font=0; if (ereg("(PASS|SKIP)", $status)) { echo "<font color='green'>"; $font=1; } if (ereg("(FAIL|INTERRUPTED|HUNG)", $status)) { echo "<font color='red'>"; $font=1; } if (ereg("(UNRESOLVED)", $status)) { echo "<font color='orange'>"; $font=1; } if (ereg("(UNSUPPORTED|UNTESTED)", $status)) { echo "<font color='black'>"; $font=1; } echo stringFromDB($status); if ($font) echo "</font>"; echo "</td>\n"; foreach ($runs as $run => $dummy) { echo " <td align='center'>"; if (isset($stats_data[$run])) echo $stats_data[$run]; else echo "0"; echo "</td>\n"; } if ($mode == "BROWSE") { echo " <td align='center'>\n"; echo " <form method='POST'>\n"; echo $POST_context; echo " <input type='hidden' name='".str_replace (' ','_',$status)."' value='hidden'>\n"; echo " <input type='hidden' name='filtered' value='".str_replace (' ','_',$status)."'>\n"; echo " <input type='submit' name='filter' value='"; if (isset($_POST[str_replace (' ','_',$status)])) echo "Show"; else echo "Hide"; echo "'>\n"; echo " </form>\n"; echo " </td>\n"; } echo " </tr>\n"; } echo " <tr>\n"; echo " <td colspan='".(count($runs)+(($mode=="BROWSE")?2:1))."'>"; echo " <i>Currently displayed: <b>$displayed</b></td>\n"; echo " </tr>\n"; echo " </table>\n"; echo " </form>\n"; echo " <hr width='30%'>\n"; /* Print the run details */ echo " <table border='1'>\n"; echo " <tr>\n"; echo " <td><b>Routine</b></td>\n"; echo " <td><b>File</b></td>\n"; foreach ($runs as $run => $trash) echo " <td><b>".stringFromDB($run)."</b></td>\n"; if (isset($_POST["logs"])) echo " <td><b>Log</b></td>\n"; if (isset($_POST["asserts"])) echo " <td><b>Assertion detail</b></td>\n"; echo " </tr>\n"; /* Display results */ $anomalies=0; foreach ($data as $routine => $rou_data) { echo " <tr>\n"; echo " <td"; $count=0; foreach($rou_data as $assert_data) $count += count($assert_data); if ($count > 1) echo " rowspan='".$count."'"; echo ">".stringFromDB($routine)."</td>\n"; $first=1; $anomalie=0; foreach ($rou_data as $assert_id => $assert_data) { $assert_first=1; $countTC = count($assert_data); foreach ($assert_data as $testcase => $test_data) { if (count($test_data) > 1) { $anomalie=1; $anomalies++; } foreach ($test_data as $testid => $run_data) { if (!$first) echo " <tr>\n"; echo " <td>".stringFromDB($testcase).($anomalie?" (*)":"")."</td>\n"; foreach ($runs as $run => $run_data_bis) { echo " <td>"; if (!isset($run_data[$run])) echo " "; else { $font=0; echo "<a href=\"detailed.php?run_id=".$run_data_bis["id"]."&testcase_id=".$testid."\">"; if (ereg("(PASS|SKIP)", $run_data[$run]["status"])) { echo "<font color='green'>"; $font=1; } if (ereg("(FAIL|INTERRUPTED|HUNG)", $run_data[$run]["status"])) { echo "<font color='red'>"; $font=1; } if (ereg("(UNRESOLVED)", $run_data[$run]["status"])) { echo "<font color='orange'>"; $font=1; } if (ereg("(UNSUPPORTED|UNTESTED)", $run_data[$run]["status"])) { echo "<font color='black'>"; $font=1; } echo stringFromDB($run_data[$run]["status"]); if ((!isset($_POST["logs"])) && $run_data[$run]["log"]) echo " (log)"; if ($font) echo "</font>"; echo "</a>"; } echo "</td>\n"; if (isset($_POST["logs"])) { echo " <td><pre>"; echo strip_tags(stringFromDB($run_data[$run]["log"])); echo " </pre></td>\n"; } } if (isset($_POST["asserts"]) && $assert_first) echo " <td".($countTC>1?" rowspan=$countTC":"")."><pre>".strip_tags(stringFromDB(wordwrap($asserts[$routine][$assert_id])))."</pre></td>\n"; echo " </tr>\n"; $first=0; $assert_first=0; } } } } echo " </table>\n"; unset($data); unset($runs); require($root."footer.inc.php"); ?> |