From 2d19e7cbbe6945772dbfb4399850260f4fcf2310 Mon Sep 17 00:00:00 2001 From: aramis_acg Date: Sat, 13 Mar 2010 12:13:53 +0000 Subject: [PATCH] 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 --- test/regression/gen_db.py | 258 +++++++++--------- test/regression/run.py | 507 ++++++++++++++++++------------------ test/regression/settings.py | 220 ++++++++-------- test/regression/utils.py | 227 ++++++++-------- 4 files changed, 611 insertions(+), 601 deletions(-) diff --git a/test/regression/gen_db.py b/test/regression/gen_db.py index 39ab80d38..ea7b9af9d 100644 --- a/test/regression/gen_db.py +++ b/test/regression/gen_db.py @@ -1,130 +1,128 @@ -#!/usr/bin/env python3 -# -*- Coding: UTF-8 -*- - -# --------------------------------------------------------------------------- -# Open Asset Import Library (ASSIMP) -# --------------------------------------------------------------------------- -# -# Copyright (c) 2006-2010, ASSIMP Development Team -# -# All rights reserved. -# -# Redistribution and use of this software in source and binary forms, -# with or without modification, are permitted provided that the following -# conditions are met: -# -# * Redistributions of source code must retain the above -# copyright notice, this list of conditions and the -# following disclaimer. -# -# * Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the -# following disclaimer in the documentation and/or other -# materials provided with the distribution. -# -# * Neither the name of the ASSIMP team, nor the names of its -# contributors may be used to endorse or promote products -# derived from this software without specific prior -# written permission of the ASSIMP Development Team. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# --------------------------------------------------------------------------- - -"""Generate the regression database db.zip from the files in the -/test/models directory. Older databases are overwritten with no prompt. -""" - -import sys -import os -import subprocess -import zipfile - -import settings -import utils - -# ------------------------------------------------------------------------------- -def process_dir(d, outfile, file_filter): - """ Generate small dump records for all files in 'd' """ - print("Processing directory " + d) - for f in os.listdir(d): - fullp = os.path.join(d, f) - if os.path.isdir(fullp) and not f == ".svn": - process_dir(fullp, outfile, file_filter) - continue - - if file_filter(f): - for pp in settings.pp_configs_to_test: - print("DUMP " + fullp + "\n post-processing: " + pp) - outf = os.path.join(os.getcwd(), settings.database_name, - utils.hashing(fullp, pp)) - - cmd = utils.assimp_bin_path + " dump \"" + fullp + \ - "\" " + outf + " -b -s " + pp - - outfile.write("assimp dump "+"-"*80+"\n") - outfile.flush() - if subprocess.call(cmd, stdout=outfile, stderr=outfile, shell=False): - print("Failure processing " + fullp) - - -# ------------------------------------------------------------------------------- -def make_zip(): - """Zip the contents of ./""" - zipout = zipfile.ZipFile(settings.database_name + ".zip", "w", zipfile.ZIP_DEFLATED) - for f in os.listdir(settings.database_name): - p = os.path.join(settings.database_name, f) - zipout.write(p, f) - if settings.remove_old: - os.remove(p) - - if settings.remove_old: - os.rmdir(settings.database_name) - - bad = zipout.testzip() - assert bad is None - - -# ------------------------------------------------------------------------------- -def gen_db(): - """Generate the crash dump database in ./""" - try: - os.mkdir(settings.database_name) - 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"], - stdout=subprocess.PIPE).communicate() - - ext_list = str(ext_list).lower().split(";") - ext_list = list(filter( - 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: - process_dir(tp, outfile, - lambda x: os.path.splitext(x)[1] in ext_list) - - -# ------------------------------------------------------------------------------- -if __name__ == "__main__": - utils.find_assimp_or_die() - gen_db() - make_zip() - - print("="*60) - input("Press any key to continue") - -# vim: ai ts=4 sts=4 et sw=4 - +#!/usr/bin/env python3 +# -*- Coding: UTF-8 -*- + +# --------------------------------------------------------------------------- +# Open Asset Import Library (ASSIMP) +# --------------------------------------------------------------------------- +# +# Copyright (c) 2006-2010, ASSIMP Development Team +# +# All rights reserved. +# +# Redistribution and use of this software in source and binary forms, +# with or without modification, are permitted provided that the following +# conditions are met: +# +# * Redistributions of source code must retain the above +# copyright notice, this list of conditions and the +# following disclaimer. +# +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the +# following disclaimer in the documentation and/or other +# materials provided with the distribution. +# +# * Neither the name of the ASSIMP team, nor the names of its +# contributors may be used to endorse or promote products +# derived from this software without specific prior +# written permission of the ASSIMP Development Team. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# --------------------------------------------------------------------------- + +"""Generate the regression database db.zip from the files in the +/test/models directory. Older databases are overwritten with no prompt. +""" + +import sys +import os +import subprocess +import zipfile + +import settings +import utils + +# ------------------------------------------------------------------------------- +def process_dir(d, outfile, file_filter): + """ Generate small dump records for all files in 'd' """ + print("Processing directory " + d) + for f in os.listdir(d): + fullp = os.path.join(d, f) + if os.path.isdir(fullp) and not f == ".svn": + process_dir(fullp, outfile, file_filter) + continue + + if file_filter(f): + for pp in settings.pp_configs_to_test: + print("DUMP " + fullp + "\n post-processing: " + pp) + outf = os.path.join(os.getcwd(), settings.database_name, + utils.hashing(fullp, pp)) + + cmd = [utils.assimp_bin_path,"dump",fullp,outf,"-b","-s",pp] + outfile.write("assimp dump "+"-"*80+"\n") + outfile.flush() + if subprocess.call(cmd, stdout=outfile, stderr=outfile, shell=False): + print("Failure processing " + fullp) + + +# ------------------------------------------------------------------------------- +def make_zip(): + """Zip the contents of ./""" + zipout = zipfile.ZipFile(settings.database_name + ".zip", "w", zipfile.ZIP_DEFLATED) + for f in os.listdir(settings.database_name): + p = os.path.join(settings.database_name, f) + zipout.write(p, f) + if settings.remove_old: + os.remove(p) + + if settings.remove_old: + os.rmdir(settings.database_name) + + bad = zipout.testzip() + assert bad is None + + +# ------------------------------------------------------------------------------- +def gen_db(): + """Generate the crash dump database in ./""" + try: + os.mkdir(settings.database_name) + 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"], + stdout=subprocess.PIPE).communicate() + + ext_list = str(ext_list).lower().split(";") + ext_list = list(filter( + 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: + process_dir(tp, outfile, + lambda x: os.path.splitext(x)[1] in ext_list) + + +# ------------------------------------------------------------------------------- +if __name__ == "__main__": + utils.find_assimp_or_die() + gen_db() + make_zip() + + print("="*60) + input("Press any key to continue") + +# vim: ai ts=4 sts=4 et sw=4 + diff --git a/test/regression/run.py b/test/regression/run.py index 1be82e954..9f3bf6f9d 100644 --- a/test/regression/run.py +++ b/test/regression/run.py @@ -1,253 +1,254 @@ -#!/usr/bin/env python3 -# -*- Coding: UTF-8 -*- - -# --------------------------------------------------------------------------- -# Open Asset Import Library (ASSIMP) -# --------------------------------------------------------------------------- -# -# Copyright (c) 2006-2010, ASSIMP Development Team -# -# All rights reserved. -# -# Redistribution and use of this software in source and binary forms, -# with or without modification, are permitted provided that the following -# conditions are met: -# -# * Redistributions of source code must retain the above -# copyright notice, this list of conditions and the -# following disclaimer. -# -# * Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the -# following disclaimer in the documentation and/or other -# materials provided with the distribution. -# -# * Neither the name of the ASSIMP team, nor the names of its -# contributors may be used to endorse or promote products -# derived from this software without specific prior -# written permission of the ASSIMP Development Team. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# --------------------------------------------------------------------------- - -""" -Run the regression test suite using the settings from settings.py. - -""" - -import sys -import os -import subprocess -import zipfile -import collections - -import settings -import utils - -# ------------------------------------------------------------------------------- -EXPECTED_FAILURE_NOT_MET, DATABASE_LENGTH_MISMATCH, \ -DATABASE_VALUE_MISMATCH, IMPORT_FAILURE, \ -FILE_NOT_READABLE, COMPARE_SUCCESS = range(6) - -messages = collections.defaultdict(lambda: "