Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
blind guess for coverage fix.. [ci-skip]
[simgrid.git] / tools / simgrid-monkey
index 04567c2..aca8809 100755 (executable)
@@ -1,4 +1,4 @@
-#! /usr/bin/python3
+#! /usr/bin/env python3
 
 # The goal is to introduce random failures in a simulation, to test simgrid under extreme conditions.
 # 
@@ -37,7 +37,8 @@ def get_info(cmd):
     cmd_tell.append("--log=root.t:critical")
     cmd_tell.append("--log=cmonkey.t:info")
     cmd_tell.append("--log=cmonkey.fmt:%m%n")
-    print(f"Get the initial info from the command ``{' '.join(cmd_tell)}``")
+    print(f"Get the initial info from the command.") 
+    # print(f"from ``{' '.join(cmd_tell)}``")
     first_run = subprocess.run(cmd_tell, shell=False, cwd=os.getcwd(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
 
     if first_run.returncode != 0:
@@ -70,14 +71,14 @@ parser.add_argument('command', nargs='*')
 args = parser.parse_args()
 
 (host_count,  link_count,  timestamps) = get_info(args.command)
-print(f"hosts:{host_count} links:{link_count} timestamps:{' '.join(([str(i) for i in timestamps]))}")
+print(f"Monkey informations: hosts:{host_count} links:{link_count} timestamps:{' '.join(([str(i) for i in timestamps]))}")
 
 def do_run(cmd, extra_params):
     cmd = copy.deepcopy(cmd)
     cmd.append("--cfg=plugin:cmonkey")
     for p in extra_params:
         cmd.append(p)
-    print(f"\n#################################################################################\nStart {' '.join(cmd)}")
+    print(f"Start {' '.join(cmd)}")
     run = subprocess.run(cmd, shell=False, cwd=os.getcwd(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
 
     if run.returncode != 0:
@@ -85,14 +86,16 @@ def do_run(cmd, extra_params):
         msg += str(run.stdout, errors='replace')
         print(msg)
         os.exit(1)
-    print ("Success.")
+    print ("Success.\n")
 
 def doit():
     prev = 0
     for pos in range(len(timestamps)):
         now = timestamps[pos]
         for host in range(host_count):
-            do_run(args.command, [f"--cfg=cmonkey/time:{(now-prev)/2}",f"--cfg=cmonkey/host:{host}"])
+            do_run(args.command, [f"--cfg=cmonkey/time:{(now-prev)/2}", f"--cfg=cmonkey/host:{host}"])
+            do_run(args.command, [f"--cfg=cmonkey/time:{now}", f"--cfg=cmonkey/host:{host}"])
         for link in range(link_count):
-            do_run(args.command, [f"--cfg=cmonkey/time:{(now-prev)/2}",f"--cfg=cmonkey/link:{link}"])
+            do_run(args.command, [f"--cfg=cmonkey/time:{(now-prev)/2}", f"--cfg=cmonkey/link:{link}"])
+            do_run(args.command, [f"--cfg=cmonkey/time:{now}", f"--cfg=cmonkey/link:{link}"])
 doit()