Ejemplo n.º 1
0
def run_cpp_demo(prefix, demo, rootdir, timing, failed):
    print(
        "----------------------------------------------------------------------"
    )
    print("Running C++ demo %s%s" % (prefix, demo))
    print("")

    cppdemo_executable = get_executable_name(demo, "cpp")
    if platform.system() == 'Windows':
        cppdemo_executable += '.exe'

    t1 = time()
    os.chdir(demo)
    status, output = get_status_output(
        "%s .%s%s" % (prefix, os.path.sep, cppdemo_executable))
    os.chdir(rootdir)
    t2 = time()
    timing += [(t2 - t1, demo)]

    if status == 0:
        print("OK")
    elif status == 10:  # Failing but exiting gracefully
        print("ok (graceful exit on fail)")
    else:
        print("*** Failed")
        print(output)
        failed += [(demo, "C++", prefix, output)]
Ejemplo n.º 2
0
def run_python_demo(prefix, demo, rootdir, timing, failed):
    print(
        "----------------------------------------------------------------------"
    )
    print("Running Python demo %s%s" % (prefix, demo))
    print("")

    demofile = get_executable_name(demo, "python") + '.py'

    t1 = time()
    os.chdir(demo)
    status, output = get_status_output("%s %s -u %s" %
                                       (prefix, sys.executable, demofile))
    os.chdir(rootdir)
    t2 = time()
    timing += [(t2 - t1, demo)]

    if status == 0:
        print("OK")
    elif status == 10:  # Failing but exiting gracefully
        print("ok (graceful exit on fail)")
    else:
        print("*** Failed")
        print(output)

        # Add contents from Instant's compile.log to output
        instant_compile_log = os.path.join(instant.get_default_error_dir(),
                                           "compile.log")
        if os.path.isfile(instant_compile_log):
            instant_error = file(instant_compile_log).read()
            output += "\n\nInstant compile.log for %s:\n\n" % demo
            output += instant_error
        failed += [(demo, "Python", prefix, output)]
Ejemplo n.º 3
0
def run_and_analyse(path, run_str, prog_type, no_reachable_check = False):
    cmd = "%s %s" % (vg_comm, run_str)

    curdir = os.getcwd()
    os.chdir(path)
    try:
        status, output = get_status_output(cmd)
    finally:
        os.chdir(curdir)

    if "No such file or directory" in "".join([str(l) for l in output]):
        print("*** FAILED: Unable to run demo")
        return [(demo, "C++", output[1])]

    if len(re.findall('All heap blocks were freed',output[1])) == 1:
        print("OK")
        return []

    if "LEAK SUMMARY:" in output[1] and "ERROR SUMMARY:" in output[1]:
        if re_def_lost.search(output[1]) and \
           re_pos_lost.search(output[1]) and \
           re_error.search(output[1]) and \
           (no_reachable_check or re_reachable.search(output[1])):
            print("OK")
            return []

    print("*** FAILED: Memory error")
    return [(path, prog_type, output[1])]
Ejemplo n.º 4
0
def run_and_analyse(path, run_str, prog_type, no_reachable_check=False):
    cmd = "%s %s" % (vg_comm, run_str)

    curdir = os.getcwd()
    os.chdir(path)
    try:
        status, output = get_status_output(cmd)
    finally:
        os.chdir(curdir)

    if "No such file or directory" in "".join([str(l) for l in output]):
        print("*** FAILED: Unable to run demo")
        return [(demo, "C++", output[1])]

    if len(re.findall('All heap blocks were freed', output[1])) == 1:
        print("OK")
        return []

    if "LEAK SUMMARY:" in output[1] and "ERROR SUMMARY:" in output[1]:
        if re_def_lost.search(output[1]) and \
           re_pos_lost.search(output[1]) and \
           re_error.search(output[1]) and \
           (no_reachable_check or re_reachable.search(output[1])):
            print("OK")
            return []

    print("*** FAILED: Memory error")
    return [(path, prog_type, output[1])]
Ejemplo n.º 5
0
def run_python_demo(prefix, demo, rootdir, timing, failed):
    print("----------------------------------------------------------------------")
    print("Running Python demo %s%s" % (prefix, demo))
    print("")

    demodir = demo if os.path.isdir(demo) else os.path.dirname(demo)
    demofile = get_executable_name(demo, "python") + '.py'

    t1 = time()
    os.chdir(demodir)
    status, output = get_status_output("%s %s -u %s" % (prefix, sys.executable, demofile))
    os.chdir(rootdir)
    t2 = time()
    timing += [(t2 - t1, prefix+" "+demo)]

    if status == 0:
        print("OK")
    elif status == 10: # Failing but exiting gracefully
        print("ok (graceful exit on fail)")
    else:
        print("*** Failed")
        print(output)

        # Add contents from Instant's compile.log to output
        instant_compile_log = os.path.join(get_default_error_dir(), "compile.log")
        if os.path.isfile(instant_compile_log):
            instant_error = file(instant_compile_log).read()
            output += "\n\nInstant compile.log for %s:\n\n" % demo
            output += instant_error
        failed += [(demo, "Python", prefix, output)]
Ejemplo n.º 6
0
def exodus2xml(ifilename,ofilename):
    "Convert from Exodus II format to DOLFIN XML."

    print("Converting from Exodus II format to NetCDF format")

    name = ifilename.split(".")[0]
    netcdffilename = name +".ncdf"
    status, output = get_status_output('ncdump '+ifilename + ' > '+netcdffilename)
    if status != 0:
        raise IOError("Something wrong while executing ncdump. Is ncdump "\
              "installed on the system?")
    netcdf2xml(netcdffilename, ofilename)
Ejemplo n.º 7
0
def exodus2xml(ifilename,ofilename):
    "Convert from Exodus II format to DOLFIN XML."

    print "Converting from Exodus II format to NetCDF format"

    name = ifilename.split(".")[0]
    netcdffilename = name +".ncdf"
    status, output = get_status_output('ncdump '+ifilename + ' > '+netcdffilename)
    if status != 0:
        raise IOError, "Something wrong while executing ncdump. Is ncdump "\
              "installed on the system?"
    netcdf2xml(netcdffilename, ofilename)
Ejemplo n.º 8
0
def main():
    tests = ["verify_demo_code_snippets.py"]

    failed = []
    for test in tests:
        command = "%s %s" % (sys.executable, test)
        fail, output = get_status_output(command)

        if fail:
            failed.append(fail)
            print("*** %s failed" % test)
            print(output)
        else:
            print("OK")

    return len(failed)
Ejemplo n.º 9
0
def main():
    tests = ["verify_demo_code_snippets.py"]

    failed = []
    for test in tests:
        command = "%s %s" % (sys.executable, test)
        fail, output = get_status_output(command)

        if fail:
            failed.append(fail)
            print("*** %s failed" % test)
            print(output)
        else:
            print("OK")

    return len(failed)
Ejemplo n.º 10
0
def run_and_analyse(path, run_str, prog_type, no_reachable_check = False):
    output = get_status_output("cd %s && %s %s" % (path, vg_comm, run_str))
    if "No such file or directory" in "".join([str(l) for l in output]):
        print "*** FAILED: Unable to run demo"
        return [(demo, "C++", output[1])]

    if len(re.findall('All heap blocks were freed',output[1])) == 1:
        print "OK"
        return []

    if "LEAK SUMMARY:" in output[1] and "ERROR SUMMARY:" in output[1]:
        if re_def_lost.search(output[1]) and \
           re_pos_lost.search(output[1]) and \
           re_error.search(output[1]) and \
           (no_reachable_check or re_reachable.search(output[1])):
            print "OK"
            return []

    print "*** FAILED: Memory error"
    return [(path, prog_type, output[1])]
Ejemplo n.º 11
0
def run_and_analyse(path, run_str, prog_type, no_reachable_check=False):
    output = get_status_output("cd %s && %s %s" % (path, vg_comm, run_str))
    if "No such file or directory" in "".join([str(l) for l in output]):
        print "*** FAILED: Unable to run demo"
        return [(demo, "C++", output[1])]

    if len(re.findall('All heap blocks were freed', output[1])) == 1:
        print "OK"
        return []

    if "LEAK SUMMARY:" in output[1] and "ERROR SUMMARY:" in output[1]:
        if re_def_lost.search(output[1]) and \
           re_pos_lost.search(output[1]) and \
           re_error.search(output[1]) and \
           (no_reachable_check or re_reachable.search(output[1])):
            print "OK"
            return []

    print "*** FAILED: Memory error"
    return [(path, prog_type, output[1])]
Ejemplo n.º 12
0
def cpp_tester(request):
    gc_barrier()
    filedir = os.path.dirname(os.path.abspath(request.module.__file__))

    prefixes = ["", "mpirun -np 3 "]
    curdir = os.getcwd()
    os.chdir(filedir)
    try:
        # Set non-interactive, configure and build
        os.putenv('DOLFIN_NOPLOT', '1')

        #status, out_cmake = get_status_output('cmake .')
        #assert status == 0

        #status, out_make = get_status_output('make')
        #assert status == 0

        # Find all built test binaries
        list_of_tests = []
        for file in sorted(os.listdir('.')):
            if file.startswith("test_") and not '.' in file:
                list_of_tests.append(file)
        assert list_of_tests, "C++ tests have not been built!"

        # Run test binaries
        for prefix in prefixes: # With or without mpirun
            for test in list_of_tests:
                cmd = prefix + os.path.join('.', test)
                print("Running cmd: ", cmd)
                status, output = get_status_output(cmd)
                if not (status == 0 and 'OK' in output):
                    print(output)
                assert status == 0 and 'OK' in output

    finally:
        os.chdir(curdir)

    gc_barrier()
Ejemplo n.º 13
0
def cpp_tester(request):
    gc_barrier()
    filedir = os.path.dirname(os.path.abspath(request.module.__file__))

    prefixes = ["", "mpirun -np 3 "]
    curdir = os.getcwd()
    os.chdir(filedir)
    try:
        # Set non-interactive, configure and build
        os.putenv("DOLFIN_NOPLOT", "1")

        # status, out_cmake = get_status_output('cmake .')
        # assert status == 0

        # status, out_make = get_status_output('make')
        # assert status == 0

        # Find all built test binaries
        list_of_tests = []
        for file in sorted(os.listdir(".")):
            if file.startswith("test_") and not "." in file:
                list_of_tests.append(file)
        assert list_of_tests, "C++ tests have not been built!"

        # Run test binaries
        for prefix in prefixes:  # With or without mpirun
            for test in list_of_tests:
                cmd = prefix + os.path.join(".", test)
                print("Running cmd: ", cmd)
                status, output = get_status_output(cmd)
                if not (status == 0 and "OK" in output):
                    print(output)
                assert status == 0 and "OK" in output

    finally:
        os.chdir(curdir)

    gc_barrier()
Ejemplo n.º 14
0
def run_cpp_demo(prefix, demo, rootdir, timing, failed):
    print("----------------------------------------------------------------------")
    print("Running C++ demo %s%s" % (prefix, demo))
    print("")

    cppdemo_executable = get_executable_name(demo, "cpp")
    if platform.system() == 'Windows':
        cppdemo_executable += '.exe'

    t1 = time()
    os.chdir(demo)
    status, output = get_status_output("%s .%s%s" % (prefix, os.path.sep, cppdemo_executable))
    os.chdir(rootdir)
    t2 = time()
    timing += [(t2 - t1, prefix+" "+demo)]

    if status == 0:
        print("OK")
    elif status == 10: # Failing but exiting gracefully
        print("ok (graceful exit on fail)")
    else:
        print("*** Failed")
        print(output)
        failed += [(demo, "C++", prefix, output)]
Ejemplo n.º 15
0
        pydemos_to_run  = pydemos

    # Run C++ demos
    for demo in cppdemos_to_run:
        print "----------------------------------------------------------------------"
        print "Running C++ demo %s%s" % (prefix, demo)
        print ""

        cppdemo_executable = get_executable_name(demo, "cpp")

        if platform.system() == 'Windows':
            cppdemo_executable += '.exe'
        if os.path.isfile(os.path.join(demo, cppdemo_executable)):
            t1 = time()
            os.chdir(demo)
            output = get_status_output("%s .%s%s" % \
                                       (prefix, os.path.sep, cppdemo_executable))
            os.chdir(rootdir)
            t2 = time()
            timing += [(t2 - t1, demo)]
            if output[0] == 0:
                print "OK"
            elif output[0] == 10: # Failing but exiting gracefully
                print "ok (graceful exit on fail)"
            else:
                print "*** Failed"
                print output[1]
                failed += [(demo, "C++", prefix, output[1])]
        else:
            print "*** Warning: missing demo"

    # Run Python demos
Ejemplo n.º 16
0
# Last changed: 2011-03-09

import os, sys
from instant import get_status_output

pwd = os.path.dirname(os.path.abspath(__file__))

# Tests to run
tests = ["parallel-assembly-solve", "ufl-jit-assemble-chain"]

failed = []

# Command to run
command = "python test.py" + " " + " ".join(sys.argv[1:])

# Run tests
for test in tests:
    print "Running system test: %s" % test
    print "----------------------------------------------------------------------"
    os.chdir(os.path.join(pwd, test))
    fail, output = get_status_output(command)
    if fail:
        failed.append(fail)
        print "*** Failed"
        print output
    else:
        print "OK"
    print

sys.exit(len(failed))
Ejemplo n.º 17
0
#
# Modified by Johan Hake
# Modified by Johannes Ring 2011
#
# First added:  2009-08-17
# Last changed: 2011-03-12

import sys
from instant import get_status_output
from dolfin import has_mpi, has_parmetis

if not (has_mpi() and has_parmetis()):
    print "DOLFIN has not been compiled with mpi and Parmetis. Test is not run."
    sys.exit(0)

# Number of processes
num_processes = 3

# Run solver.py
failure, output = get_status_output("mpirun -n %d python solver.py" % num_processes)
if len(sys.argv) > 1 and sys.argv[1] == "--debug":
    print output

# Return exit status
if "ERROR" in output:
    print output
    sys.exit(1)
else:
    print "OK"
    sys.exit(0)
Ejemplo n.º 18
0
    for test, subtests in tests.items():
        for subtest in subtests:
            print "Running unit tests for %s (%s) with prefix '%s'" % (test,  subtest, prefix)
            print "----------------------------------------------------------------------"

            cpptest_executable = "test_" + subtest
            if platform.system() == 'Windows':
                cpptest_executable += '.exe'
            print "C++:   ",
            if only_python:
                print "Skipping tests as requested (--only-python)"
            elif not os.path.isfile(os.path.join(test, "cpp", cpptest_executable)):
                print "This test set does not have a C++ version"
            else:
                os.chdir(os.path.join(test, "cpp"))
                status, output = get_status_output("%s.%s%s" % \
                                   (prefix, os.path.sep, cpptest_executable))
                os.chdir(os.path.join(os.pardir, os.pardir))
                if status == 0 and "OK" in output:
                    print "OK",
                    match = re.search("OK \((\d+)\)", output)
                    if match:
                        num_tests = int(match.groups()[0])
                        print "(%d tests)" % num_tests,
                    print
                else:
                    print "*** Failed"
                    failed += [(test, subtest, "C++", output)]

            print "Python:",
            if os.path.isfile(os.path.join(test, "python", subtest + ".py")):
                os.chdir(os.path.join(test,"python"))
Ejemplo n.º 19
0
    for test, subtests in tests.items():
        for subtest in subtests:
            print "Running unit tests for %s (%s) with prefix '%s'" % (test,  subtest, prefix)
            print "----------------------------------------------------------------------"

            cpptest_executable = "test_" + subtest
            if platform.system() == 'Windows':
                cpptest_executable += '.exe'
            print "C++:   ",
            if only_python:
                print "Skipping tests as requested (--only-python)"
            elif not  os.path.isfile(os.path.join(test, "cpp", cpptest_executable)):
                print "This test set does not have a C++ version"
            else:
                os.chdir(os.path.join(test, "cpp"))
                status, output = get_status_output("%s.%s%s" % \
                                   (prefix, os.path.sep, cpptest_executable))
                os.chdir(os.path.join(os.pardir, os.pardir))
                if status == 0 and "OK" in output:
                    print "OK",
                    match = re.search("OK \((\d+)\)", output)
                    if match:
                        num_tests = int(match.groups()[0])
                        print "(%d tests)" % num_tests,
                    print
                else:
                    print "*** Failed"
                    failed += [(test, subtest, "C++", output)]

            print "Python:",
            if os.path.isfile(os.path.join(test, "python", subtest + ".py")):
                os.chdir(os.path.join(test,"python"))