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

Alex Jia ajia at redhat.com
Thu Aug 15 06:00:51 UTC 2013


Hi hongming,
BTW, could we ignore module or function name in "Test Procedure"
section, because the module and entry function are the same name,
it's a deliberately design, but the "Test Procedure" looks like 
a duplicate naming for others. 

<slice>

network:define:define
network:network_list:network_list
network:start:start
network:network_list:network_list
network:autostart:autostart
network:update:update

</slice>


-- 
Regards,     
Alex


----- Original Message -----
From: "hongming" <honzhang at redhat.com>
To: gren at redhat.com
Cc: libvir-list at redhat.com
Sent: Thursday, August 15, 2013 1:47:05 PM
Subject: Re: [libvirt] [test-API][PATCH] Add display of cases result to	log.xml

Hi Guannan

You can see the new test report from the following url.

http://fileshare.englab.nay.redhat.com/pub/section3/libvirtauto/libvirt-test-API/log.xml

Thanks
Hongming

On 08/15/2013 11:32 AM, Hongming Zhang wrote:
> 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 """

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




More information about the libvir-list mailing list