Commit 85489236 authored by Cyril L'Orphelin's avatar Cyril L'Orphelin
Browse files

Develop

parent 3dc09b43
<?xml version='1.0'?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="CUNIT_TEST_RUN_REPORT">
<html>
<head>
<title> CUnit - Automated Test Run Summary Report </title>
</head>
<body bgcolor="#e0e0f0">
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="CUNIT_HEADER">
<div align="center">
<h3>
<b> CUnit - A Unit testing framework for C. </b> <br/>
<a href="http://cunit.sourceforge.net/"> http://cunit.sourceforge.net/ </a>
</h3>
</div>
</xsl:template>
<xsl:template match="CUNIT_RESULT_LISTING">
<p/>
<div align="center">
<h2> Automated Test Run Results </h2>
</div>
<table cols="4" width="90%" align="center">
<tr>
<td width="25%"> </td>
<td width="25%"> </td>
<td width="25%"> </td>
<td width="25%"> </td>
</tr>
<xsl:apply-templates/>
</table>
</xsl:template>
<xsl:template match="CUNIT_RUN_SUITE">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="SUITE_NAME">
</xsl:template>
<xsl:template match="CUNIT_RUN_SUITE_SUCCESS">
<tr bgcolor="#f0e0f0">
<td colspan="4">
Running Suite <xsl:value-of select="SUITE_NAME"/>
</td>
</tr>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="CUNIT_RUN_GROUP">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="CUNIT_RUN_GROUP_SUCCESS">
<tr bgcolor="#f0e0f0">
<td colspan="4">
Running Group <xsl:apply-templates/>
</td>
</tr>
</xsl:template>
<xsl:template match="CUNIT_RUN_TEST_RECORD">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="CUNIT_RUN_TEST_SUCCESS">
<tr bgcolor="#e0f0d0">
<td> </td>
<td colspan="2">
Running test <xsl:apply-templates/>...
</td>
<td bgcolor="#50ff50"> Passed </td>
</tr>
</xsl:template>
<xsl:template match="CUNIT_RUN_TEST_FAILURE">
<tr bgcolor="#e0f0d0">
<td> </td>
<td colspan="2">
Running test <xsl:value-of select="TEST_NAME"/>...
</td>
<td bgcolor="#ff5050"> Failed </td>
</tr>
<tr>
<td colspan="4" bgcolor="#ff9090">
<table width="100%">
<tr>
<th width="15%"> File Name </th>
<td width="50%" bgcolor="#e0eee0">
<xsl:value-of select="FILE_NAME"/>
</td>
<th width="20%"> Line Number </th>
<td width="10%" bgcolor="#e0eee0">
<xsl:value-of select="LINE_NUMBER"/>
</td>
</tr>
<tr>
<th width="15%"> Condition </th>
<td colspan="3" width="85%" bgcolor="#e0eee0">
<xsl:value-of select="CONDITION"/>
</td>
</tr>
</table>
</td>
</tr>
</xsl:template>
<xsl:template match="CUNIT_RUN_SUITE_FAILURE">
<tr>
<td colspan="3" bgcolor="#f0b0f0">
Running Suite <xsl:value-of select="SUITE_NAME"/>...
</td>
<td bgcolor="#ff7070">
<xsl:value-of select="FAILURE_REASON"/>
</td>
</tr>
</xsl:template>
<xsl:template match="CUNIT_RUN_GROUP_FAILURE">
<tr>
<td colspan="3" bgcolor="#f0b0f0">
Running Group <xsl:value-of select="GROUP_NAME"/>...
</td>
<td bgcolor="#ff7070">
<xsl:value-of select="FAILURE_REASON"/>
</td>
</tr>
</xsl:template>
<xsl:template match="CUNIT_RUN_SUMMARY">
<p/>
<table width="90%" rows="5" align="center">
<tr align="center" bgcolor="skyblue">
<th colspan="6"> Cumulative Summary for Run </th>
</tr>
<tr>
<th width="15%" bgcolor="#ffffc0" align="center"> Type </th>
<th width="17%" bgcolor="#ffffc0" align="center"> Total </th>
<th width="17%" bgcolor="#ffffc0" align="center"> Run </th>
<th width="17%" bgcolor="#ffffc0" align="center"> Succeeded </th>
<th width="17%" bgcolor="#ffffc0" align="center"> Failed </th>
<th width="17%" bgcolor="#ffffc0" align="center"> Inactive </th>
</tr>
<xsl:for-each select="CUNIT_RUN_SUMMARY_RECORD">
<tr align="center" bgcolor="lightgreen">
<td> <xsl:value-of select="TYPE" /> </td>
<td> <xsl:value-of select="TOTAL" /> </td>
<td> <xsl:value-of select="RUN" /> </td>
<td> <xsl:value-of select="SUCCEEDED" /> </td>
<td> <xsl:value-of select="FAILED" /> </td>
<td> <xsl:value-of select="INACTIVE" /> </td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
<xsl:template match="CUNIT_FOOTER">
<p/>
<hr align="center" width="90%" color="maroon" />
<h5 align="center"> <xsl:apply-templates/> </h5>
</xsl:template>
</xsl:stylesheet>
\ No newline at end of file
......@@ -5,7 +5,7 @@
L'intérêt du TP réside dans les échanges au sein du groupe et avec les formateurs
---
1. Ouvrez le fichier tp1.py , analyser le et essayer de comprendre ce qu'il fait **~15 min**
1. Ouvrez les fichiers du projet (<a href="TP1.py">TP1.py</a>, <a href="log1">log1</a> , <a href="log2">log2</a>, <a href="CUnit-Run.xsl">CUnit-Run.xsl</a> ) , analysez les et essayez de comprendre ce que doit faire le script principal **~15 min**
2. Les encadrants du TP vont expliquer ce que fait réellement le script **~10 min**
3. Avec les éléments des présentations précédentes, formulez une analyse critique du contenu du script **~ 15 min**
4. Discutez de ces retours avec les encadrants **~5-10 min**
......
import sys
import os
import re
import shutil
import time
os.system('cls')
verboseMode = False
ttpExtension=[]
ttpPath=[]
ttpIncrement=[]
srcAjout=[]
srcFiles = []
ttpLine =[]
folderNumber=[]
## Update input file by removing the reference to unexisting files
# @param log file
def extract(logFile):
# Check current working directory.
workingDir = os.getcwd()
#verbose
if verboseMode == True :
print "current working directory is "+workingDir
print "log in parameter is "+logFile
#Change relative path for sourcePathFile from logDirectory
logDirectory, logFileName = os.path.split(logFile)
#sourcePathFile = os.path.relpath(sourcePathFile,logDirectory)
# change the current directry for the directory of the input file
os.chdir(logDirectory)
#verbose
if verboseMode == True :
print "log directory is "+logDirectory
#create XML directory
path_XML_extract = os.path.join(logDirectory, "XML_extract")
# check if directory already exits
if os.path.isdir(path_XML_extract) :
# delete directory to remove all previous files
shutil.rmtree(path_XML_extract, ignore_errors = False)
#tempo avant de recreer le repertoire
time.sleep(1) # Sleep for 1 seconds
#create directory
os.mkdir(path_XML_extract)
#verbose
if verboseMode == True :
print path_XML_extract+" directory has been created"
# reading of the log file
countLine = 0
tmpFilePath = ""
with open(logFileName, 'r') as f:
xmlFileName =""
for line in f:
countLine += 1
# Search for xml header in log file <?xml version="1.0" ?>
matchXML = re.search('\<\?xml version\=\"1.0\" \?\>', line)
if matchXML is not None:
# create temporary file
tmpFilePath = os.path.normpath(path_XML_extract + "/tmp.xml")
with open(tmpFilePath, 'a') as tmpfile:
tmpfile.close()
if verboseMode == True :
print "<?xml version=\"1.0\" ?> found at line "+str(countLine)
# complete file
if(os.path.isfile(tmpFilePath)):
#line to be ignore
matchIgnore = re.search('\<\!DOCTYPE CUNIT_TEST_RUN_REPORT', line)
if matchIgnore is None:
with open(tmpFilePath, 'a') as tmpfile:
matchXMLName = re.search('\<SUITE_NAME\>', line)
if matchXMLName is not None:
getNext =0
a= line.split(" ")
for i in a :
if getNext == 1 :
xmlFileName = i
getNext = 0
if i == "<SUITE_NAME>":
getNext =1
tmpfile.write(line + "\n")
tmpfile.close()
# Search for xml tag </CUNIT_TEST_RUN_REPORT> (end of xml file)
matchEndXML = re.search('\<\/CUNIT_TEST_RUN_REPORT\>', line)
if matchEndXML is not None:
if verboseMode == True :
print "</CUNIT_TEST_RUN_REPORT> found at line "+str(countLine)
if tmpFilePath != "":
os.rename(tmpFilePath, path_XML_extract+"/"+xmlFileName+".xml")
tmpFilePath = ""
f.close()
if __name__ == "__main__":
# argument for debuging
#sys.argv=r"foo -v ..\log".split()
import getopt
help = '''unit_test_extract_xml.py [-v] log
extract xml unit test from jenkin build log.
-v verbose mode
-h print help'''
try:
opts, args = getopt.getopt(sys.argv[1:],"v")
except getopt.GetoptError:
print help
sys.exit(2)
# check that one parameter is defined
if len(args) != 1 :
if len(args) == 0 :
print "one argument needed"
if len(args) > 2 :
print "parameter "+str(args[1:])+" not managed"
print help
sys.exit(2)
else:
if not os.path.isfile(args[0]):
print "input "+str(args[0])+" is not an existing file"
print help
sys.exit(2)
logDirectory, logFileName = os.path.split(args[0])
if logFileName[-4:-1]!="log":
print "input file "+str(args[0:])+" is not the log file"
print help
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
print help
sys.exit(2)
elif opt == '-v':
print " *** verbose mode activated"
verboseMode = True
extract(args[0])
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -57,9 +57,8 @@ $ coverage report -m --omit=tri_test.py
<details>
<summary>Solution</summary>
<pre><code>
if __name__ == '__main__':
if __name__ == '__main__':
import sys
sys.setrecursionlimit(100000)
......@@ -75,7 +74,7 @@ $ coverage report -m --omit=tri_test.py
TAB_METHODS[idx](t0, longueurT)
stop = timeit.default_timer()
execution_time = stop - start
print("{:20} => {:.02E}".format(TAB_METHODS[idx].__name__ , execution_time))</code></pre>
print("{:20} => {:.02E}".format(TAB_METHODS[idx].__name__ , execution_time))
</details>
----
......@@ -106,7 +105,7 @@ Si vous voulez installer le client pour tester du code local à votre machine, s
-Dsonar.login=votre_token
</code>
4. Visualisez les résultats sur <a href="https://sonarqube.cc.in2p3.fr"> l'instance SonarQube @CCIN2P3 </a>
4. Visualisez les résultats sur <a href="https://sonarqube.cc.in2p3.fr"> l'instance SonarQube @CCIN2P3 </a> à l'aide des identifiants stockés dans Gitlab
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment