Make regression suite scripts work on posix as well.

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@600 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
pull/1/head
aramis_acg 2010-03-13 12:13:53 +00:00
parent 9fd2245eb1
commit 2d19e7cbbe
4 changed files with 611 additions and 601 deletions

View File

@ -1,130 +1,128 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- Coding: UTF-8 -*- # -*- Coding: UTF-8 -*-
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Open Asset Import Library (ASSIMP) # Open Asset Import Library (ASSIMP)
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# #
# Copyright (c) 2006-2010, ASSIMP Development Team # Copyright (c) 2006-2010, ASSIMP Development Team
# #
# All rights reserved. # All rights reserved.
# #
# Redistribution and use of this software in source and binary forms, # Redistribution and use of this software in source and binary forms,
# with or without modification, are permitted provided that the following # with or without modification, are permitted provided that the following
# conditions are met: # conditions are met:
# #
# * Redistributions of source code must retain the above # * Redistributions of source code must retain the above
# copyright notice, this list of conditions and the # copyright notice, this list of conditions and the
# following disclaimer. # following disclaimer.
# #
# * Redistributions in binary form must reproduce the above # * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the # copyright notice, this list of conditions and the
# following disclaimer in the documentation and/or other # following disclaimer in the documentation and/or other
# materials provided with the distribution. # materials provided with the distribution.
# #
# * Neither the name of the ASSIMP team, nor the names of its # * Neither the name of the ASSIMP team, nor the names of its
# contributors may be used to endorse or promote products # contributors may be used to endorse or promote products
# derived from this software without specific prior # derived from this software without specific prior
# written permission of the ASSIMP Development Team. # written permission of the ASSIMP Development Team.
# #
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
"""Generate the regression database db.zip from the files in the <root> """Generate the regression database db.zip from the files in the <root>
/test/models directory. Older databases are overwritten with no prompt. /test/models directory. Older databases are overwritten with no prompt.
""" """
import sys import sys
import os import os
import subprocess import subprocess
import zipfile import zipfile
import settings import settings
import utils import utils
# ------------------------------------------------------------------------------- # -------------------------------------------------------------------------------
def process_dir(d, outfile, file_filter): def process_dir(d, outfile, file_filter):
""" Generate small dump records for all files in 'd' """ """ Generate small dump records for all files in 'd' """
print("Processing directory " + d) print("Processing directory " + d)
for f in os.listdir(d): for f in os.listdir(d):
fullp = os.path.join(d, f) fullp = os.path.join(d, f)
if os.path.isdir(fullp) and not f == ".svn": if os.path.isdir(fullp) and not f == ".svn":
process_dir(fullp, outfile, file_filter) process_dir(fullp, outfile, file_filter)
continue continue
if file_filter(f): if file_filter(f):
for pp in settings.pp_configs_to_test: for pp in settings.pp_configs_to_test:
print("DUMP " + fullp + "\n post-processing: " + pp) print("DUMP " + fullp + "\n post-processing: " + pp)
outf = os.path.join(os.getcwd(), settings.database_name, outf = os.path.join(os.getcwd(), settings.database_name,
utils.hashing(fullp, pp)) utils.hashing(fullp, pp))
cmd = utils.assimp_bin_path + " dump \"" + fullp + \ cmd = [utils.assimp_bin_path,"dump",fullp,outf,"-b","-s",pp]
"\" " + outf + " -b -s " + pp outfile.write("assimp dump "+"-"*80+"\n")
outfile.flush()
outfile.write("assimp dump "+"-"*80+"\n") if subprocess.call(cmd, stdout=outfile, stderr=outfile, shell=False):
outfile.flush() print("Failure processing " + fullp)
if subprocess.call(cmd, stdout=outfile, stderr=outfile, shell=False):
print("Failure processing " + fullp)
# -------------------------------------------------------------------------------
def make_zip():
# ------------------------------------------------------------------------------- """Zip the contents of ./<settings.database_name>"""
def make_zip(): zipout = zipfile.ZipFile(settings.database_name + ".zip", "w", zipfile.ZIP_DEFLATED)
"""Zip the contents of ./<settings.database_name>""" for f in os.listdir(settings.database_name):
zipout = zipfile.ZipFile(settings.database_name + ".zip", "w", zipfile.ZIP_DEFLATED) p = os.path.join(settings.database_name, f)
for f in os.listdir(settings.database_name): zipout.write(p, f)
p = os.path.join(settings.database_name, f) if settings.remove_old:
zipout.write(p, f) os.remove(p)
if settings.remove_old:
os.remove(p) if settings.remove_old:
os.rmdir(settings.database_name)
if settings.remove_old:
os.rmdir(settings.database_name) bad = zipout.testzip()
assert bad is None
bad = zipout.testzip()
assert bad is None
# -------------------------------------------------------------------------------
def gen_db():
# ------------------------------------------------------------------------------- """Generate the crash dump database in ./<settings.database_name>"""
def gen_db(): try:
"""Generate the crash dump database in ./<settings.database_name>""" os.mkdir(settings.database_name)
try: except OSError:
os.mkdir(settings.database_name) pass
except OSError:
pass outfile = open(os.path.join("..", "results", "gen_regression_db_output.txt"), "w")
(ext_list, err) = subprocess.Popen([utils.assimp_bin_path, "listext"],
outfile = open(os.path.join("..", "results", "gen_regression_db_output.txt"), "w") stdout=subprocess.PIPE).communicate()
(ext_list, err) = subprocess.Popen([utils.assimp_bin_path, "listext"],
stdout=subprocess.PIPE).communicate() ext_list = str(ext_list).lower().split(";")
ext_list = list(filter(
ext_list = str(ext_list).lower().split(";") lambda f: not f in settings.exclude_extensions, map(
ext_list = list(filter( lambda f: f.strip("b* \'"), ext_list)))
lambda f: not f in settings.exclude_extensions, map(
lambda f: f.strip("b* \'"), ext_list))) print(ext_list)
for tp in settings.model_directories:
print(ext_list) process_dir(tp, outfile,
for tp in settings.model_directories: lambda x: os.path.splitext(x)[1] in ext_list)
process_dir(tp, outfile,
lambda x: os.path.splitext(x)[1] in ext_list)
# -------------------------------------------------------------------------------
if __name__ == "__main__":
# ------------------------------------------------------------------------------- utils.find_assimp_or_die()
if __name__ == "__main__": gen_db()
utils.find_assimp_or_die() make_zip()
gen_db()
make_zip() print("="*60)
input("Press any key to continue")
print("="*60)
input("Press any key to continue") # vim: ai ts=4 sts=4 et sw=4
# vim: ai ts=4 sts=4 et sw=4

View File

@ -1,253 +1,254 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- Coding: UTF-8 -*- # -*- Coding: UTF-8 -*-
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Open Asset Import Library (ASSIMP) # Open Asset Import Library (ASSIMP)
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# #
# Copyright (c) 2006-2010, ASSIMP Development Team # Copyright (c) 2006-2010, ASSIMP Development Team
# #
# All rights reserved. # All rights reserved.
# #
# Redistribution and use of this software in source and binary forms, # Redistribution and use of this software in source and binary forms,
# with or without modification, are permitted provided that the following # with or without modification, are permitted provided that the following
# conditions are met: # conditions are met:
# #
# * Redistributions of source code must retain the above # * Redistributions of source code must retain the above
# copyright notice, this list of conditions and the # copyright notice, this list of conditions and the
# following disclaimer. # following disclaimer.
# #
# * Redistributions in binary form must reproduce the above # * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the # copyright notice, this list of conditions and the
# following disclaimer in the documentation and/or other # following disclaimer in the documentation and/or other
# materials provided with the distribution. # materials provided with the distribution.
# #
# * Neither the name of the ASSIMP team, nor the names of its # * Neither the name of the ASSIMP team, nor the names of its
# contributors may be used to endorse or promote products # contributors may be used to endorse or promote products
# derived from this software without specific prior # derived from this software without specific prior
# written permission of the ASSIMP Development Team. # written permission of the ASSIMP Development Team.
# #
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
""" """
Run the regression test suite using the settings from settings.py. Run the regression test suite using the settings from settings.py.
""" """
import sys import sys
import os import os
import subprocess import subprocess
import zipfile import zipfile
import collections import collections
import settings import settings
import utils import utils
# ------------------------------------------------------------------------------- # -------------------------------------------------------------------------------
EXPECTED_FAILURE_NOT_MET, DATABASE_LENGTH_MISMATCH, \ EXPECTED_FAILURE_NOT_MET, DATABASE_LENGTH_MISMATCH, \
DATABASE_VALUE_MISMATCH, IMPORT_FAILURE, \ DATABASE_VALUE_MISMATCH, IMPORT_FAILURE, \
FILE_NOT_READABLE, COMPARE_SUCCESS = range(6) FILE_NOT_READABLE, COMPARE_SUCCESS = range(6)
messages = collections.defaultdict(lambda: "<unknown", { messages = collections.defaultdict(lambda: "<unknown", {
EXPECTED_FAILURE_NOT_MET: EXPECTED_FAILURE_NOT_MET:
"""Unexpected success during import\n\ """Unexpected success during import\n\
\tReturn code was 0""", \tReturn code was 0""",
DATABASE_LENGTH_MISMATCH: DATABASE_LENGTH_MISMATCH:
"""Database mismatch: lengths don't match\n\ """Database mismatch: lengths don't match\n\
\tExpected: {0} Actual: {1}""", \tExpected: {0} Actual: {1}""",
DATABASE_VALUE_MISMATCH: DATABASE_VALUE_MISMATCH:
"""Database mismatch: """, """Database mismatch: """,
IMPORT_FAILURE: IMPORT_FAILURE:
"""Unexpected failure during import\n\ """Unexpected failure during import\n\
\tReturn code was {0}""", \tReturn code was {0}""",
FILE_NOT_READABLE: FILE_NOT_READABLE:
"""Unexpected failure reading file""", """Unexpected failure reading file""",
COMPARE_SUCCESS: COMPARE_SUCCESS:
"""Results match archived reference dump in database\n\ """Results match archived reference dump in database\n\
\tNumber of bytes compared: {0}""" \tNumber of bytes compared: {0}"""
}) })
outfilename_output = "run_regression_suite_output.txt" outfilename_output = "run_regression_suite_output.txt"
outfilename_failur = "run_regression_suite_failures.csv" outfilename_failur = "run_regression_suite_failures.csv"
# ------------------------------------------------------------------------------- # -------------------------------------------------------------------------------
class results: class results:
""" Handle formatting of results""" """ Handle formatting of results"""
def __init__(self, zipin): def __init__(self, zipin):
"""Init, given a ZIPed database """ """Init, given a ZIPed database """
self.failures = [] self.failures = []
self.success = [] self.success = []
self.zipin = zipin self.zipin = zipin
def fail(self, failfile, filename_expect, pp, msg, *args): def fail(self, failfile, filename_expect, pp, msg, *args):
""" """
Report failure of a sub-test Report failure of a sub-test
File f failed a test for pp config pp, failure notice is msg, File f failed a test for pp config pp, failure notice is msg,
*args is format()ting args for msg *args is format()ting args for msg
""" """
print("[FAILURE] " + messages[msg].format(*args)) print("[FAILURE] " + messages[msg].format(*args))
self.failures.append((failfile, filename_expect, pp)) self.failures.append((failfile, filename_expect, pp))
def ok(self, f, pp, msg, *args): def ok(self, f, pp, msg, *args):
""" """
Report success of a sub-test Report success of a sub-test
File f passed the test, msg is a happy success note, File f passed the test, msg is a happy success note,
*args is format()ing args for msg. *args is format()ing args for msg.
""" """
print("[SUCCESS] " + messages[msg].format(*args)) print("[SUCCESS] " + messages[msg].format(*args))
self.success.append(f) self.success.append(f)
def report_results(self): def report_results(self):
"""Write results to ../results/run_regression_suite_failures.txt""" """Write results to ../results/run_regression_suite_failures.txt"""
print("\n" + ('='*60) + "\n" + "SUCCESS: {0}\r\nFAILURE: {1}".format( print("\n" + ('='*60) + "\n" + "SUCCESS: {0}\r\nFAILURE: {1}".format(
len(self.success), len(self.failures)) + len(self.success), len(self.failures)) +
"\n" + ('='*60) + "\n") "\n" + ('='*60) + "\n")
with open(os.path.join('..', 'results',outfilename_failur), "wt") as f: with open(os.path.join('..', 'results',outfilename_failur), "wt") as f:
f.write("ORIGINAL FILE;EXPECTED DUMP\n") f.write("ORIGINAL FILE;EXPECTED DUMP\n")
f.writelines(map( f.writelines(map(
lambda x: x[0] + ' ' + x[2] + ";" + x[1] + "\n", self.failures)) lambda x: x[0] + ' ' + x[2] + ";" + x[1] + "\n", self.failures))
if self.failures: if self.failures:
print("\nSee " + settings.results + "\\" + outfilename_failur print("\nSee " + settings.results + "\\" + outfilename_failur
+ " for more details\n\n") + " for more details\n\n")
# ------------------------------------------------------------------------------- # -------------------------------------------------------------------------------
def mkoutputdir_andgetpath(fullpath, myhash, app): def mkoutputdir_andgetpath(fullpath, myhash, app):
outfile = os.path.join(settings.results, "tmp", os.path.split(fullpath)[1] + "_" + myhash) outfile = os.path.join(settings.results, "tmp", os.path.split(fullpath)[1] + "_" + myhash)
try: try:
os.mkdir(outfile) os.mkdir(outfile)
except OSError: except OSError:
pass pass
outfile = os.path.join(outfile, app) outfile = os.path.join(outfile, app)
return outfile return outfile
# ------------------------------------------------------------------------------- # -------------------------------------------------------------------------------
def process_dir(d, outfile_results, zipin, result): def process_dir(d, outfile_results, zipin, result):
shellparams = {'stdout':outfile_results, 'stderr':outfile_results, 'shell':False} shellparams = {'stdout':outfile_results, 'stderr':outfile_results, 'shell':False}
print("Processing directory " + d) print("Processing directory " + d)
for f in os.listdir(d): for f in os.listdir(d):
fullpath = os.path.join(d, f) fullpath = os.path.join(d, f)
if os.path.isdir(fullpath) and not f == ".svn": if os.path.isdir(fullpath) and not f == ".svn":
process_dir(fullpath, outfile_results, zipin, result) process_dir(fullpath, outfile_results, zipin, result)
continue continue
for pppreset in settings.pp_configs_to_test: for pppreset in settings.pp_configs_to_test:
filehash = utils.hashing(fullpath, pppreset) filehash = utils.hashing(fullpath, pppreset)
failure = False failure = False
try: try:
input_expected = zipin.open(filehash, "r").read() input_expected = zipin.open(filehash, "r").read()
# empty dump files indicate 'expected import failure' # empty dump files indicate 'expected import failure'
if not len(input_expected): if not len(input_expected):
failure = True failure = True
except KeyError: except KeyError:
#print("Didn't find "+fullpath+" (Hash is "+filehash+") in database") #print("Didn't find "+fullpath+" (Hash is "+filehash+") in database")
continue continue
print("-"*60 + "\n " + os.path.realpath(fullpath) + " pp: " + pppreset) print("-"*60 + "\n " + os.path.realpath(fullpath) + " pp: " + pppreset)
outfile_actual = mkoutputdir_andgetpath(fullpath, filehash, "ACTUAL") outfile_actual = mkoutputdir_andgetpath(fullpath, filehash, "ACTUAL")
outfile_expect = mkoutputdir_andgetpath(fullpath, filehash, "EXPECT") outfile_expect = mkoutputdir_andgetpath(fullpath, filehash, "EXPECT")
outfile_results.write("assimp dump "+"-"*80+"\n") outfile_results.write("assimp dump "+"-"*80+"\n")
outfile_results.flush() outfile_results.flush()
command = utils.assimp_bin_path + " dump \"" + fullpath + \
"\" " + outfile_actual + " -b -s " + pppreset command = [utils.assimp_bin_path,"dump",fullpath,outfile_actual,"-b","-s",pppreset]
r = subprocess.call(command, **shellparams) r = subprocess.call(command, **shellparams)
if r and not failure: if r and not failure:
result.fail(fullpath, outfile_expect, pppreset, IMPORT_FAILURE, r) result.fail(fullpath, outfile_expect, pppreset, IMPORT_FAILURE, r)
continue continue
elif failure: elif failure:
result.fail(fullpath, outfile_expect, pppreset, EXPECTED_FAILURE_NOT_MET) result.fail(fullpath, outfile_expect, pppreset, EXPECTED_FAILURE_NOT_MET)
continue continue
with open(outfile_expect, "wb") as s: with open(outfile_expect, "wb") as s:
s.write(input_expected) s.write(input_expected)
with open(outfile_actual, "rb") as s: with open(outfile_actual, "rb") as s:
input_actual = s.read() input_actual = s.read()
if len(input_expected) != len(input_actual): if len(input_expected) != len(input_actual):
result.fail(fullpath, outfile_expect, pppreset, DATABASE_LENGTH_MISMATCH, result.fail(fullpath, outfile_expect, pppreset, DATABASE_LENGTH_MISMATCH,
len(input_expected), len(input_actual)) len(input_expected), len(input_actual))
continue continue
outfile_results.write("assimp cmpdump "+"-"*80+"\n") outfile_results.write("assimp cmpdump "+"-"*80+"\n")
outfile_results.flush() outfile_results.flush()
command = utils.assimp_bin_path + ' cmpdump "' + outfile_actual + '" "' \
+ outfile_expect + '"' command = [utils.assimp_bin_path,'cmpdump',outfile_actual,outfile_expect]
if subprocess.call(command, **shellparams) != 0:
if subprocess.call(command, **shellparams) != 0: result.fail(fullpath, outfile_expect, pppreset, DATABASE_VALUE_MISMATCH)
result.fail(fullpath, outfile_expect, pppreset, DATABASE_VALUE_MISMATCH) continue
continue
result.ok(fullpath, pppreset, COMPARE_SUCCESS, len(input_expected)) result.ok(fullpath, pppreset, COMPARE_SUCCESS,
len(input_expected))
# -------------------------------------------------------------------------------
def del_folder_with_contents(folder): # -------------------------------------------------------------------------------
for root, dirs, files in os.walk(folder, topdown=False): def del_folder_with_contents(folder):
for name in files: for root, dirs, files in os.walk(folder, topdown=False):
os.remove(os.path.join(root, name)) for name in files:
for name in dirs: os.remove(os.path.join(root, name))
os.rmdir(os.path.join(root, name)) for name in dirs:
os.rmdir(os.path.join(root, name))
# -------------------------------------------------------------------------------
def run_test(): # -------------------------------------------------------------------------------
utils.find_assimp_or_die() def run_test():
tmp_target_path = os.path.join(settings.results, "tmp") utils.find_assimp_or_die()
try: tmp_target_path = os.path.join(settings.results, "tmp")
os.mkdir(tmp_target_path) try:
except OSError as oerr: os.mkdir(tmp_target_path)
# clear contents if tmp folder exists already except OSError as oerr:
del_folder_with_contents(tmp_target_path) # clear contents if tmp folder exists already
del_folder_with_contents(tmp_target_path)
try:
zipin = zipfile.ZipFile(settings.database_name + ".zip", try:
"r", zipfile.ZIP_STORED) zipin = zipfile.ZipFile(settings.database_name + ".zip",
"r", zipfile.ZIP_STORED)
except IOError:
print("Regression database ", settings.database_name, except IOError:
".zip was not found") print("Regression database ", settings.database_name,
return ".zip was not found")
return
res = results(zipin)
with open(os.path.join(settings.results, outfilename_output), "wt") as outfile: res = results(zipin)
for tp in settings.model_directories: with open(os.path.join(settings.results, outfilename_output), "wt") as outfile:
process_dir(tp, outfile, zipin, res) for tp in settings.model_directories:
process_dir(tp, outfile, zipin, res)
res.report_results()
res.report_results()
# -------------------------------------------------------------------------------
if __name__ == "__main__": # -------------------------------------------------------------------------------
run_test() if __name__ == "__main__":
input("Press any key to continue ...") run_test()
input("Press any key to continue ...")
# vim: ai ts=4 sts=4 et sw=4
# vim: ai ts=4 sts=4 et sw=4

View File

@ -1,110 +1,110 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- Coding: UTF-8 -*- # -*- Coding: UTF-8 -*-
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Open Asset Import Library (ASSIMP) # Open Asset Import Library (ASSIMP)
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# #
# Copyright (c) 2006-2010, ASSIMP Development Team # Copyright (c) 2006-2010, ASSIMP Development Team
# #
# All rights reserved. # All rights reserved.
# #
# Redistribution and use of this software in source and binary forms, # Redistribution and use of this software in source and binary forms,
# with or without modification, are permitted provided that the following # with or without modification, are permitted provided that the following
# conditions are met: # conditions are met:
# #
# * Redistributions of source code must retain the above # * Redistributions of source code must retain the above
# copyright notice, this list of conditions and the # copyright notice, this list of conditions and the
# following disclaimer. # following disclaimer.
# #
# * Redistributions in binary form must reproduce the above # * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the # copyright notice, this list of conditions and the
# following disclaimer in the documentation and/or other # following disclaimer in the documentation and/or other
# materials provided with the distribution. # materials provided with the distribution.
# #
# * Neither the name of the ASSIMP team, nor the names of its # * Neither the name of the ASSIMP team, nor the names of its
# contributors may be used to endorse or promote products # contributors may be used to endorse or promote products
# derived from this software without specific prior # derived from this software without specific prior
# written permission of the ASSIMP Development Team. # written permission of the ASSIMP Development Team.
# #
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
"""Shared settings for the regression suite (bold builder and """Shared settings for the regression suite (bold builder and
test scripts rely on this) test scripts rely on this)
""" """
import os import os
# ------------------------------------------------------------------------------- # -------------------------------------------------------------------------------
# List of file extensions to be excluded from the regression suite # List of file extensions to be excluded from the regression suite
# File extensions are case insensitive # File extensions are case insensitive
# ------------------------------------------------------------------------------- # -------------------------------------------------------------------------------
exclude_extensions = [".lws",".assbin",".assxml"] exclude_extensions = [".lws",".assbin",".assxml"]
# ------------------------------------------------------------------------------- # -------------------------------------------------------------------------------
# Post processing configurations to be included in the test. The # Post processing configurations to be included in the test. The
# strings are parameters for assimp_cmd, see assimp_cmd's doxydoc # strings are parameters for assimp_cmd, see assimp_cmd's doxydoc
# for more details. # for more details.
# The defaults are (validate-data-structure is always enabled, for # The defaults are (validate-data-structure is always enabled, for
# self-explanatory reasons :-): # self-explanatory reasons :-):
# #
# '-cfull' :apply all post processing except 'og' (optimize-scenegraph) # '-cfull' :apply all post processing except 'og' (optimize-scenegraph)
# '-og -om' :run optimize-scenegraph in combination with optimize-meshes. # '-og -om' :run optimize-scenegraph in combination with optimize-meshes.
# '-vds -jiv' :join-identical-vertices alone. This is a hotspot where # '-vds -jiv' :join-identical-vertices alone. This is a hotspot where
# floating-point inaccuracies can cause severe damage. # floating-point inaccuracies can cause severe damage.
# As you can see, not all possible combinations of pp steps are covered - # As you can see, not all possible combinations of pp steps are covered -
# but at least each step is executed at least once on each model. # but at least each step is executed at least once on each model.
# ------------------------------------------------------------------------------- # -------------------------------------------------------------------------------
pp_configs_to_test = [ pp_configs_to_test = [
"-cfull", "-cfull",
"-og -om -vds", "-og -om -vds",
"-vds -jiv" "-vds -jiv"
] ]
# ------------------------------------------------------------------------------- # -------------------------------------------------------------------------------
# Name of the regression database file to be used # Name of the regression database file to be used
# gen_db.py writes to this directory, run.py checks against this directory. # gen_db.py writes to this directory, run.py checks against this directory.
# If a zip file with the same name exists, its contents are favoured to a # If a zip file with the same name exists, its contents are favoured to a
# normal directory, so in order to test against unzipped files the ZIP needs # normal directory, so in order to test against unzipped files the ZIP needs
# to be deleted. # to be deleted.
# ------------------------------------------------------------------------------- # -------------------------------------------------------------------------------
database_name = "db" database_name = "db"
# ------------------------------------------------------------------------------- # -------------------------------------------------------------------------------
# List of directories to be processed. Paths are processed recursively. # List of directories to be processed. Paths are processed recursively.
# ------------------------------------------------------------------------------- # -------------------------------------------------------------------------------
model_directories = [ model_directories = [
os.path.join("..","models") os.path.join("..","models")
] ]
# ------------------------------------------------------------------------------- # -------------------------------------------------------------------------------
# Remove the original database files after the ZIP has been built? # Remove the original database files after the ZIP has been built?
# ------------------------------------------------------------------------------- # -------------------------------------------------------------------------------
remove_old = True remove_old = True
# ------------------------------------------------------------------------------- # -------------------------------------------------------------------------------
# Bytes to skip at the beginning of a dump. This skips the file header, which # Bytes to skip at the beginning of a dump. This skips the file header, which
# is currently the same 500 bytes header for both assbin, assxml and minidumps. # is currently the same 500 bytes header for both assbin, assxml and minidumps.
# ------------------------------------------------------------------------------- # -------------------------------------------------------------------------------
dump_header_skip = 500 dump_header_skip = 500
# ------------------------------------------------------------------------------- # -------------------------------------------------------------------------------
# Directory to write all results and logs to. The dumps pertaining to failed # Directory to write all results and logs to. The dumps pertaining to failed
# tests are written to a subfolder of this directory ('tmp'). # tests are written to a subfolder of this directory ('tmp').
# ------------------------------------------------------------------------------- # -------------------------------------------------------------------------------
results = os.path.join("..","results") results = os.path.join("..","results")
# vim: ai ts=4 sts=4 et sw=4 # vim: ai ts=4 sts=4 et sw=4

View File

@ -1,108 +1,119 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- Coding: UTF-8 -*- # -*- Coding: UTF-8 -*-
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Open Asset Import Library (ASSIMP) # Open Asset Import Library (ASSIMP)
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# #
# Copyright (c) 2006-2010, ASSIMP Development Team # Copyright (c) 2006-2010, ASSIMP Development Team
# #
# All rights reserved. # All rights reserved.
# #
# Redistribution and use of this software in source and binary forms, # Redistribution and use of this software in source and binary forms,
# with or without modification, are permitted provided that the following # with or without modification, are permitted provided that the following
# conditions are met: # conditions are met:
# #
# * Redistributions of source code must retain the above # * Redistributions of source code must retain the above
# copyright notice, this list of conditions and the # copyright notice, this list of conditions and the
# following disclaimer. # following disclaimer.
# #
# * Redistributions in binary form must reproduce the above # * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the # copyright notice, this list of conditions and the
# following disclaimer in the documentation and/or other # following disclaimer in the documentation and/or other
# materials provided with the distribution. # materials provided with the distribution.
# #
# * Neither the name of the ASSIMP team, nor the names of its # * Neither the name of the ASSIMP team, nor the names of its
# contributors may be used to endorse or promote products # contributors may be used to endorse or promote products
# derived from this software without specific prior # derived from this software without specific prior
# written permission of the ASSIMP Development Team. # written permission of the ASSIMP Development Team.
# #
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
"""Shared stuff for the gen_db and run scripts """ """Shared stuff for the gen_db and run scripts """
# ------------------------------------------------------------------------------- # -------------------------------------------------------------------------------
def hashing(file,pp): def hashing(file,pp):
""" Map an input file and a postprocessing config to an unique hash. """ Map an input file and a postprocessing config to an unique hash.
The hash is used to store the item in the database. The buildin The hash is used to store the item in the database. It
hash() function is used. The hash is a string. needs to be persistent across different python implementations
and platforms, so we implement the hashing manually.
""" """
return hex(hash(file+":"+pp))
def myhash(instring):
# sdbm hash
assimp_bin_path = None res = 0
# ------------------------------------------------------------------------------- for t in instring:
def find_assimp_or_die(): res = (ord(t) + (res<<6) + (res<<16) - res) % 2**32
"""Find assimp_cmd's binary for the current platform. os
return res
The path to the binary is stored in assimp_bin_path, the process
is aborted if it can't be found. return hex(myhash(file.replace('\\','/')+":"+pp))
"""
assimp_bin_path = None
import os # -------------------------------------------------------------------------------
import platform def find_assimp_or_die():
import sys """Find assimp_cmd's binary for the current platform.
def locate_file(f_list): The path to the binary is stored in assimp_bin_path, the process
for f in f_list: is aborted if it can't be found.
try:
fl = open(f,"rb") """
except IOError:
continue import os
fl.close() import platform
return f import sys
return None
def locate_file(f_list):
global assimp_bin_path for f in f_list:
if os.name == "nt": try:
if platform.machine() == "x86": fl = open(f,"rb")
search = [os.path.join("..","..","bin","assimpcmd_release-dll_Win32","assimp.exe"), except IOError:
os.path.join("..","..","bin","x86","assimp")] continue
fl.close()
else: # amd64, hopefully return f
search = [os.path.join("..","..","bin","assimpcmd_release-dll_x64","assimp.exe"), return None
os.path.join("..","..","bin","x64","assimp")]
global assimp_bin_path
elif os.name == "posix": if os.name == "nt":
search = [os.path.join("..","..","bin","gcc","assimp"), if platform.machine() == "x86":
os.path.join("/usr","local","bin")] search = [os.path.join("..","..","bin","assimpcmd_release-dll_Win32","assimp.exe"),
else: os.path.join("..","..","bin","x86","assimp")]
print("Unsupported operating system")
sys.exit(-5) else: # amd64, hopefully
search = [os.path.join("..","..","bin","assimpcmd_release-dll_x64","assimp.exe"),
assimp_bin_path = locate_file(search) os.path.join("..","..","bin","x64","assimp")]
if assimp_bin_path is None:
print("Can't locate assimp_cmd binary") assimp_bin_path = locate_file(search)
sys.exit(-5) if assimp_bin_path is None:
print("Can't locate assimp_cmd binary")
print("Located assimp/assimp_cmd binary at ",assimp_bin_path) sys.exit(-5)
print("Located assimp/assimp_cmd binary at ",assimp_bin_path)
if __name__ == '__main__': elif os.name == "posix":
find_assimp_or_die() #search = [os.path.join("..","..","bin","gcc","assimp"),
# os.path.join("/usr","local","bin",'assimp')]
# vim: ai ts=4 sts=4 et sw=4 assimp_bin_path = "assimp"
print("Taking system-wide assimp binary")
else:
print("Unsupported operating system")
sys.exit(-5)
if __name__ == '__main__':
find_assimp_or_die()
# vim: ai ts=4 sts=4 et sw=4