[test-API][PATCH] Add display of cases result to log.xml

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The original log.xml only display the testrun result, the patch add
display of case result to log.xml.
modified:   src/generator.py
-Perserver case result list and pass it to log_generator class.
modified:   src/log.xsl
-Read from xml and display case result
modified:   src/log_generator.py
-Create case result xml and add it to log.xml
---
 src/generator.py     |    5 +++--
 src/log.xsl          |   23 ++++++++++++++++++++---
 src/log_generator.py |   16 ++++++++++++++--
 3 files changed, 37 insertions(+), 7 deletions(-)

diff --git a/src/generator.py b/src/generator.py
index 0cdc9de..208fa7b 100644
--- a/src/generator.py
+++ b/src/generator.py
@@ -87,7 +87,6 @@ class FuncGen(object):
         env_logger = envlog.env_log()
         casenumber = len(self.case_name_list)
         start_time = time.strftime("%Y-%m-%d %H:%M:%S")
-
         env_logger.info("Checking Testing Environment... ")
         envck = env_inspect.EnvInspect(self.env, env_logger)
 
@@ -103,6 +102,7 @@ class FuncGen(object):
 
         # retflag: [pass, fail, skip]
         retflag = [0, 0, 0]
+        case_retlist = []
         for i in range(casenumber):
 
             clean_flag = False
@@ -165,7 +165,7 @@ class FuncGen(object):
                     retflag[2] += 1
 
                 self.fmt.print_end(mod_case, ret, env_logger)
-
+                case_retlist.append(ret)
         # close hypervisor connection
         envck.close_hypervisor_connection()
         end_time = time.strftime("%Y-%m-%d %H:%M:%S")
@@ -179,6 +179,7 @@ class FuncGen(object):
         self.log_xml_parser.add_test_summary(self.testrunid,
                                              self.testid,
                                              result,
+                                             case_retlist,
                                              start_time,
                                              end_time,
                                              self.logfile)
diff --git a/src/log.xsl b/src/log.xsl
index 577a0a5..0ca6afe 100644
--- a/src/log.xsl
+++ b/src/log.xsl
@@ -119,9 +119,10 @@
             <tr>
               <th width="5%">No.</th>
               <th width="5%">Result</th>
-              <th width="12%">Start</th>
-              <th width="12%">End</th>
-              <th width="66%">Test Procedure</th>
+              <th width="10%">Start</th>
+              <th width="10%">End</th>
+              <th width="65%">Test Procedure</th>
+              <th width="5%">Case Result</th>
             </tr>
           </thead>
           <tbody>
@@ -164,6 +165,22 @@
                     </xsl:for-each>
                   </table>
                 </td>
+                <td>
+                  <table class="pro" cellspacing="1" cellspan="0" >
+                     <xsl:for-each select="caseresult/case">
+                        <tr>
+                          <td>
+                            <xsl:if test="self::node()[text()='FAIL']">
+                               <tr class="fail"><xsl:value-of select="current()"/></tr>
+                            </xsl:if>
+                            <xsl:if test="self::node()[text()='PASS']">
+                               <tr class="pass"><xsl:value-of select="current()"/></tr>
+                            </xsl:if>
+                          </td>
+                        </tr>
+                     </xsl:for-each>
+                  </table>
+                </td>
               </tr>
             </xsl:for-each>
           </tbody>
diff --git a/src/log_generator.py b/src/log_generator.py
index be483d6..de18654 100644
--- a/src/log_generator.py
+++ b/src/log_generator.py
@@ -93,7 +93,7 @@ class LogGenerator(object):
 
         self. __write_to_file(xmldoc, self.logxml)
 
-    def add_test_summary(self, testrunid, testid, result,
+    def add_test_summary(self, testrunid, testid, result, case_retlist,
                          start_time, end_time, path):
         """ add a test summary xml block into log xml file """
         xmldoc = minidom.parse(self.logxml)
@@ -101,6 +101,8 @@ class LogGenerator(object):
         resulttext = self.doc.createTextNode(result)
         testresult.appendChild(resulttext)
 
+        caseresult = self.doc.createElement('caseresult')
+
         teststarttime = self.doc.createElement('start_time')
         starttimetext = self.doc.createTextNode(start_time)
         teststarttime.appendChild(starttimetext)
@@ -126,10 +128,20 @@ class LogGenerator(object):
                         test.childNodes.insert(0, testendtime)
                         test.childNodes.insert(0, teststarttime)
                         test.childNodes.insert(0, testresult)
+                        test.childNodes.insert(0, caseresult)
+                        for ret in reversed(case_retlist):
+                            retstr = ''
+                            if ret == 0:
+                                retstr = 'PASS'
+                            else:
+                                retstr = 'FAIL'
+                            itemresult = self.doc.createElement('case')
+                            caseresulttext = self.doc.createTextNode(retstr)
+                            itemresult.appendChild(caseresulttext)
+                            caseresult.childNodes.insert(0,itemresult)
 
         self. __write_to_file(xmldoc, self.logxml)
 
-
     def add_testrun_summary(self, testrunid, passnum, failnum, totalnum,
                             start_time, end_time):
         """ add a testrun summary xml block into log xml file """
-- 
1.7.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]