run_valgrind_tools.py 2.57 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
import os
import shutil
import subprocess


def build(executable):
    
    morefem_root_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "..")
    morefem_cmake_dir = os.path.join(morefem_root_dir, "cmake")
    build_directory = os.path.join(morefem_root_dir, "build4valgrind")
    
12
13
    os.chdir(morefem_root_dir)
    
14
15
16
17
    if os.path.exists(build_directory):
        shutil.rmtree(build_directory)
    
    os.mkdir(build_directory)
18
    os.chdir(build_directory)
19
20
    
    cmd = "python {cmake_dir}/Scripts/configure_cmake.py --cache_file={cmake_dir}/PreCache/linux.cmake --cmake_args=\"-G Ninja\"  --third_party_directory=/opt --mode=\"debug\"".format(cmake_dir = morefem_cmake_dir)
21
    print(cmd)
22
23
    subprocess.Popen(cmd, shell = True).communicate()

24
    cmd = "ninja {}".format(executable)
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
    subprocess.Popen(cmd, shell = True).communicate()


def runValgrind(executable, lua_file, output):
    
    morefem_root_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "..")
    build_directory = os.path.join(morefem_root_dir, "build4valgrind")
    
    os.chdir(build_directory)
    
    cmd = "valgrind --error-exitcode=1 --log-file={output} -suppressions=all --show-leak-kinds=all --show-reachable=yes --track-origins=yes --leak-check=full --errors-for-leak-kinds=all --suppressions=../ExternalTools/Valgrind/openmpi.suppr --suppressions=../ExternalTools/Valgrind/libgomp.suppr --suppressions=../ExternalTools/Valgrind/libc.suppr {executable} -i {lua_file} -e MOREFEM_RESULT_DIR=Results".format(output = output, lua_file = lua_file, executable = executable)
    
    subprocess.Popen(cmd, shell = True).communicate()
    
    
def buildAndRunValgrind(executable, lua_file, output):
    build(executable)
    runValgrind(executable, lua_file, output)



# runValgrind MoReFEMTestPetscMatrixOperations ../Sources/Test/ThirdParty/PETSc/MatrixOperations/demo.lua memcheck_matrix_operations.txt
#
# runValgrind MoReFEM4Elasticity ../Sources/ModelInstances/Elasticity/demo_2d_binary.lua memcheck_elasticity.txt
#
# runValgrind MoReFEM4Heat ../Sources/ModelInstances/Heat/demo_input_heat.lua memcheck_heat.txt
#
# runValgrind MoReFEM4Hyperelasticity ../Sources/ModelInstances/Hyperelasticity/demo_input_hyperelasticity.lua memcheck_hyperelasticity.txt
#
# runValgrind MoReFEM4Laplacian ../Sources/ModelInstances/Laplacian/demo_input_laplacian.lua memcheck_laplacian.txt
#
# runValgrind MoReFEM4RivlinCube ../Sources/ModelInstances/RivlinCube/demo_input_rivlin_cube_hexahedra.lua memcheck_rivlin_cube.txt
#
# runValgrind MoReFEM4Stokes ../Sources/ModelInstances/Stokes/demo.lua memcheck_stokes.txt