Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
953e6166137950fc7f5cec82dd47324ff3903311
[simgrid.git] / teshsuite / smpi / MBI / MBI.py
1 #! /usr/bin/env python3
2
3 # Copyright 2021-2022. The SimGrid Team. All rights reserved. 
4 # This program is free software; you can redistribute it and/or modify it
5 # under the terms of the license (GNU LGPL) which comes with this package.
6
7 # This script runs a previously compiled MBI script and checks on the result.
8 # This file was written for the SimGrid project. Parts coming from the MBI projets are MBIutils.py and simgrid.py
9
10 import sys
11 import os
12
13 from MBIutils import *
14 import simgrid
15
16 if len(sys.argv) != 4:
17     print(f"Usage: MBI.py binary source (received: {sys.argv})")
18     sys.exit(1)
19
20 if not os.path.exists("cluster.xml"):
21     with open('cluster.xml', 'w') as outfile:
22         outfile.write("<?xml version='1.0'?>\n")
23         outfile.write("<!DOCTYPE platform SYSTEM \"https://simgrid.org/simgrid.dtd\">\n")
24         outfile.write('<platform version="4.1">\n')
25         outfile.write(' <cluster id="acme" prefix="node-" radical="0-99" suffix="" speed="1Gf" bw="125MBps" lat="50us"/>\n')
26         outfile.write('</platform>\n')
27
28
29 simgrid = simgrid.Tool()
30
31 (name, path, binary, filename) = sys.argv
32 for test in parse_one_code(filename):
33     execcmd = test['cmd'].replace("mpirun", f"{path}/smpi_script/bin/smpirun -wrapper '{path}/bin/simgrid-mc --log=mc_safety.t:info' -platform ./cluster.xml -analyze --cfg=smpi/finalization-barrier:on --cfg=smpi/list-leaks:10 --cfg=model-check/max-depth:10000 --cfg=smpi/pedantic:true")
34     execcmd = execcmd.replace('${EXE}', binary)
35     execcmd = execcmd.replace('$zero_buffer', "--cfg=smpi/buffering:zero")
36     execcmd = execcmd.replace('$infty_buffer', "--cfg=smpi/buffering:infty")
37
38     if os.path.exists(f'{filename}.txt'):
39         os.remove(f'{filename}.txt')
40     run_cmd(buildcmd="", execcmd=execcmd, cachefile=filename, filename=filename, binary=binary, timeout=300, batchinfo="", read_line_lambda=None)
41     outcome = simgrid.parse(filename)
42
43     (res_category, elapsed, diagnostic, outcome) = categorize(simgrid, "simgrid", filename, test['expect'])
44
45     if res_category != "TRUE_NEG" and res_category != "TRUE_POS":
46         print("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n")
47         print(f"SimGrid gave the wrong result ({outcome} instead of {test['expect']}).")
48         sys.exit(1)