[Libreoffice-commits] dev-tools.git: test-bugzilla-files/test-bugzilla-files.py
Markus Mohrhard
markus.mohrhard at googlemail.com
Sun Feb 16 22:26:17 CET 2014
test-bugzilla-files/test-bugzilla-files.py | 151 +++++++++++++++++++++++++++--
1 file changed, 145 insertions(+), 6 deletions(-)
New commits:
commit 36caa1b3dddb7fe1e49672133ffc266b437bcdaf
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sun Feb 16 22:25:40 2014 +0100
update crash testing script
diff --git a/test-bugzilla-files/test-bugzilla-files.py b/test-bugzilla-files/test-bugzilla-files.py
index 862933d..f21ce38 100644
--- a/test-bugzilla-files/test-bugzilla-files.py
+++ b/test-bugzilla-files/test-bugzilla-files.py
@@ -317,6 +317,135 @@ def handleCrash(file, disposed):
def alarm_handler(args):
args.kill()
+def writeExportCrash(fileName):
+ exportCrash = open("exportCrash.txt", "a")
+ exportCrash.write(fileName + '\n')
+ exportCrash.close()
+
+def exportDoc(xDoc, filterName, validationCommand, filename, connection):
+ props = [ ("FilterName", filterName) ]
+ saveProps = tuple([mkPropertyValue(name, value) for (name, value) in props])
+ extensions = { "calc8": ".ods",
+ "MS Excel 97": ".xls",
+ "Calc Office Open XML": ".xlsx",
+ "writer8": ".odt",
+ "Office Open XML Text": ".docx",
+ "Rich Text Format": ".rtf",
+ "MS Word 97": ".doc",
+ "impress8": ".odp",
+ "draw8": ".odg",
+ "Impress Office Open XML": ".pptx",
+ "MS PowerPoint 97": ".ppt",
+ "math8": ".odf",
+ "StarOffice XML (Base)": ".odb"
+ }
+ base = os.path.splitext(filename)[0]
+ filename = base + extensions[filterName]
+ fileURL = "file:///srv/crashtestdata/current" + filename
+ t = None
+ try:
+ args = [connection]
+ t = threading.Timer(180, alarm_handler, args)
+ t.start()
+ xDoc.storeToURL(fileURL, saveProps)
+ except pyuno.getClass("com.sun.star.beans.UnknownPropertyException"):
+ if t.is_alive():
+ writeExportCrash(filename)
+ raise # means crashed, handle it later
+ except pyuno.getClass("com.sun.star.lang.DisposedException"):
+ if t.is_alive():
+ writeExportCrash(filename)
+ raise # means crashed, handle it later
+ except pyuno.getClass("com.sun.star.lang.IllegalArgumentException"):
+ pass # means could not open the file, ignore it
+ except pyuno.getClass("com.sun.star.task.ErrorCodeIOException"):
+ pass
+ except:
+ pass
+ finally:
+ if t.is_alive():
+ t.cancel()
+
+ print("xDoc.storeToURL " + fileURL + " " + filterName + "\n")
+ if validationCommand:
+ validationCommandWithURL = validationCommand + " " + fileURL[7:]
+ print(validationCommandWithURL)
+ try:
+ output = str(subprocess.check_output(validationCommandWithURL, shell=True), encoding='utf-8')
+ print(output)
+ if ("Error" in output) or ("error" in output):
+ print("Error validating file")
+ validLog = open(fileURL[7:]+".log", "w")
+ validLog.write(output)
+ validLog.close()
+ except subprocess.CalledProcessError:
+ pass # ignore that exception
+
+
+class ExportFileTest:
+ def __init__(self, xDoc, component, filename):
+ self.xDoc = xDoc
+ self.component = component
+ self.filename = filename
+ def run(self, connection):
+ formats = self.getExportFormats()
+ print(formats)
+ for format in formats:
+ filterName = self.getFilterName(format)
+ validation = self.getValidationCommand(filterName)
+ print(format)
+ print(filterName)
+ if filterName:
+ xExportedDoc = exportDoc(self.xDoc, filterName, validation, self.filename, connection)
+ if xExportedDoc:
+ xExportedDoc.close(True)
+
+ def getExportFormats(self):
+ formats = { "calc": ["ods", "xls", "xlsx"],
+ "writer" : ["odt", "doc", "docx", "rtf"],
+ "impress" : ["odp", "ppt", "pptx"],
+ "draw" : ["odg"],
+ "base" : ["odb"],
+ "math" : ["odf"]
+ }
+ if not self.component in formats:
+ return []
+ return formats[self.component]
+
+ def getValidationCommand(self, filterName):
+ validationCommand = { "calc8" : "java -Djavax.xml.validation.SchemaFactory:http://relaxng.org/ns/structure/1.0=org.iso_relax.verifier.jaxp.validation.RELAXNGSchemaFactoryImpl -Dorg.iso_relax.verifier.VerifierFactoryLoader=com.sun.msv.verifier.jarv.FactoryLoaderImpl -jar /home/buildslave/source/bin/odfvalidator.jar -e",
+ "writer8" : "java -Djavax.xml.validation.SchemaFactory:http://relaxng.org/ns/structure/1.0=org.iso_relax.verifier.jaxp.validation.RELAXNGSchemaFactoryImpl -Dorg.iso_relax.verifier.VerifierFactoryLoader=com.sun.msv.verifier.jarv.FactoryLoaderImpl -jar /home/buildslave/source/bin/odfvalidator.jar -e",
+ "impress8" : "java -Djavax.xml.validation.SchemaFactory:http://relaxng.org/ns/structure/1.0=org.iso_relax.verifier.jaxp.validation.RELAXNGSchemaFactoryImpl -Dorg.iso_relax.verifier.VerifierFactoryLoader=com.sun.msv.verifier.jarv.FactoryLoaderImpl -jar /home/buildslave/source/bin/odfvalidator.jar -e",
+ "draw8" : "java -Djavax.xml.validation.SchemaFactory:http://relaxng.org/ns/structure/1.0=org.iso_relax.verifier.jaxp.validation.RELAXNGSchemaFactoryImpl -Dorg.iso_relax.verifier.VerifierFactoryLoader=com.sun.msv.verifier.jarv.FactoryLoaderImpl -jar /home/buildslave/source/bin/odfvalidator.jar -e",
+ "math8" : "java -Djavax.xml.validation.SchemaFactory:http://relaxng.org/ns/structure/1.0=org.iso_relax.verifier.jaxp.validation.RELAXNGSchemaFactoryImpl -Dorg.iso_relax.verifier.VerifierFactoryLoader=com.sun.msv.verifier.jarv.FactoryLoaderImpl -jar /home/buildslave/source/bin/odfvalidator.jar -e",
+ "StarOffice XML (Base)" : "java -Djavax.xml.validation.SchemaFactory:http://relaxng.org/ns/structure/1.0=org.iso_relax.verifier.jaxp.validation.RELAXNGSchemaFactoryImpl -Dorg.iso_relax.verifier.VerifierFactoryLoader=com.sun.msv.verifier.jarv.FactoryLoaderImpl -jar /home/buildslave/source/bin/odfvalidator.jar -e",
+ "Calc Office Open XML": "java -jar /home/buildslave/source/bin/officeotron.jar",
+ "Office Open XML Text": "java -jar /home/buildslave/source/bin/officeotron.jar",
+ "Impress Office Open XML": "java -jar /home/buildslave/source/bin/officeotron.jar"
+ }
+ if not filterName in validationCommand:
+ return None
+ return validationCommand[filterName]
+
+ def getFilterName(self, format):
+ filterNames = { "ods": "calc8",
+ "xls": "MS Excel 97",
+ "xlsx": "Calc Office Open XML",
+ "odt": "writer8",
+ "doc": "MS Word 97",
+ "docx": "Office Open XML Text",
+ "rtf": "Rich Text Format",
+ "odp": "impress8",
+ "odg": "draw8",
+ "pptx": "Impress Office Open XML",
+ "ppt": "MS PowerPoint 97",
+ "odb": "StarOffice XML (Base)",
+ "odf": "math8"
+ }
+ return filterNames[format]
+
+
+
class LoadFileTest:
def __init__(self, file, state, component):
self.file = file
@@ -336,6 +465,11 @@ class LoadFileTest:
t = threading.Timer(60, alarm_handler, args)
t.start()
xDoc = loadFromURL(xContext, url, t, self.component)
+ print("doc loaded")
+ t.cancel()
+ if xDoc:
+ exportTest = ExportFileTest(xDoc, self.component, self.file)
+ exportTest.run(connection)
self.state.goodFiles.append(self.file)
except pyuno.getClass("com.sun.star.beans.UnknownPropertyException"):
print("caught UnknownPropertyException " + self.file)
@@ -348,6 +482,7 @@ class LoadFileTest:
self.state.badPropertyFiles.append(self.file)
connection.tearDown()
connection.setUp()
+ xDoc = None
except pyuno.getClass("com.sun.star.lang.DisposedException"):
print("caught DisposedException " + self.file)
if not t.is_alive():
@@ -359,6 +494,7 @@ class LoadFileTest:
self.state.badDisposedFiles.append(self.file)
connection.tearDown()
connection.setUp()
+ xDoc = None
finally:
if t.is_alive():
t.cancel()
@@ -366,6 +502,7 @@ class LoadFileTest:
if xDoc:
t = threading.Timer(10, alarm_handler, args)
t.start()
+ print("closing document")
xDoc.close(True)
t.cancel()
except pyuno.getClass("com.sun.star.beans.UnknownPropertyException"):
@@ -382,6 +519,7 @@ class LoadFileTest:
connection.tearDown()
connection.setUp()
print("...done with: " + self.file)
+ subprocess.call("rm core*", shell=True)
class State:
def __init__(self):
@@ -421,12 +559,13 @@ def writeReport(state, startTime):
timeoutFiles.write("\n")
timeoutFiles.close()
-validCalcFileExtensions = [ ".xlsx", ".xls", ".ods", ".fods" ]
-validWriterFileExtensions = [ ".docx" , ".rtf", ".odt", ".fodt", ".doc" ]
-validImpressFileExtensions = [ ".ppt", ".pptx", ".odp", ".fodp" ]
-validDrawFileExtensions = [ ".odg", ".fodg" ]
-validRevereseFileExtensions = [ ".vsd", ".vdx", ".cdr", ".pub", ".wpd" ]
-validFileExtensions = dict([("calc", validCalcFileExtensions), ("writer", validWriterFileExtensions), ("impress", validImpressFileExtensions), ("draw", validDrawFileExtensions), ("reverse", validRevereseFileExtensions) ])
+validCalcFileExtensions = [ ".xlsx", ".xltx", ".xls", ".ods", ".ots", ".sxc", ".stc", ".fods", ".xlsb", ".xlsm", ".xltm", ".csv", ".slk", ".wks", ".sdc", ".sdc5" ]
+validWriterFileExtensions = [ ".docx" , ".rtf", ".odt", ".fodt", ".doc", ".odm", ".ott", ".oth", ".sxw", ".sxg", ".stw", ".dotx", ".lwp", ".wpd", ".wps", ".abw", ".hwp", ".docm", ".dotm", ".sdw", ".sdw5", ".sgl5" ]
+validImpressFileExtensions = [ ".ppt", ".pptx", ".odp", ".fodp", ".otp", ".sxi", ".sti", ".pptm", ".sldm", ".ppsm", ".potm", ".ppotx", ".ppsx", ".sldx", ".key", ".sdd_i", ".sdd5", ".sdp5" ]
+validDrawFileExtensions = [ ".odg", ".fodg", ".otg", ".sxd", ".std", ".vsd", ".vdx", ".pub", ".cdr", ".sda5", ".sdd_d" ]
+validBaseFileExtensions = [ ".odb" ]
+validMathFileExtensions = [ ".odf", ".otf", ".sxm", ".mml", ".smf", ".smf5" ]
+validFileExtensions = dict([("calc", validCalcFileExtensions), ("writer", validWriterFileExtensions), ("impress", validImpressFileExtensions), ("draw", validDrawFileExtensions), ("base", validBaseFileExtensions), ("Math", validMathFileExtensions) ])
def runLoadFileTests(opts, dirs):
startTime = datetime.datetime.now()
More information about the Libreoffice-commits
mailing list