1 #! /usr/bin/env python3
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.
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
14 from MBIutils import *
17 if len(sys.argv) != 4:
18 print(f"Usage: MBI.py binary source (received: {sys.argv})")
21 if not os.path.exists("cluster.xml"):
22 with open('cluster.xml', 'w') as outfile:
23 outfile.write("<?xml version='1.0'?>\n")
24 outfile.write("<!DOCTYPE platform SYSTEM \"https://simgrid.org/simgrid.dtd\">\n")
25 outfile.write('<platform version="4.1">\n')
26 outfile.write(' <cluster id="acme" prefix="node-" radical="0-99" suffix="" speed="1Gf" bw="125MBps" lat="50us"/>\n')
27 outfile.write('</platform>\n')
30 simgrid = simgrid.Tool()
32 (name, path, binary, filename) = sys.argv
33 for test in parse_one_code(filename):
34 execcmd = re.sub("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", test['cmd'])
35 execcmd = re.sub('\${EXE}', binary, execcmd)
36 execcmd = re.sub('\$zero_buffer', "--cfg=smpi/buffering:zero", execcmd)
37 execcmd = re.sub('\$infty_buffer', "--cfg=smpi/buffering:infty", execcmd)
39 if os.path.exists(f'{filename}.txt'):
40 os.remove(f'{filename}.txt')
41 run_cmd(buildcmd="", execcmd=execcmd, cachefile=filename, filename=filename, binary=binary, timeout=300, batchinfo="", read_line_lambda=None)
42 outcome = simgrid.parse(filename)
44 (res_category, elapsed, diagnostic, outcome) = categorize(simgrid, "simgrid", filename, test['expect'])
46 if res_category != "TRUE_NEG" and res_category != "TRUE_POS":
47 print("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n")
48 print(f"SimGrid gave the wrong result ({outcome} instead of {test['expect']}).")