From 60dd15a969fa8d86e926490b640dbf45211b4501 Mon Sep 17 00:00:00 2001
From: Erwan Jahier <erwan.jahier@univ-grenoble-alpes.fr>
Date: Wed, 18 Nov 2020 13:31:16 +0100
Subject: [PATCH] simca: fix the script that were broken since
 2bf88c0d7344d91507e51014eb15df930eccd8dd

add a  test sin the CI  to make sure I  don't miss simca break  in the
future ! (I was only testing simca using the docker version of sasa).
---
 .gitlab-ci.yml                       |  6 ++++--
 tools/simca/coloring_campaign_10.ml  | 31 ++++++++++++++++++++++++++++
 tools/simca/genExpeMakefilesUtils.ml |  2 +-
 tools/simca/runSimus.ml              | 11 ++++++++--
 4 files changed, 45 insertions(+), 5 deletions(-)
 create mode 100644 tools/simca/coloring_campaign_10.ml

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index c062bca1..a6d51e83 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -16,8 +16,10 @@ build:
     - make
     - make install
     - make test
+    - cd tools/simca
+    - make && make cmxs && make log -j 15 && make pdf
 
-simca:
+simca-docker:
   image: jahierwan/verimag-sync-tools
   stage: release
   script:
@@ -27,7 +29,7 @@ simca:
     paths:
       - tools/simca
 
-  
+ 
 test_opam_test:
   stage: release
   script:
diff --git a/tools/simca/coloring_campaign_10.ml b/tools/simca/coloring_campaign_10.ml
new file mode 100644
index 00000000..bfd008dd
--- /dev/null
+++ b/tools/simca/coloring_campaign_10.ml
@@ -0,0 +1,31 @@
+#use "genExpeMakefiles.ml";;
+precision := 0.1;;
+    (* 0.01 means that we simulate until the Confidence Interval
+       size of  the 3 complexity  numbers under estimation  is smaller
+       than 1% of their current estimation.
+    *)
+let algos = ["../../test/alea-coloring-alt";
+             "../../test/alea-coloring-unif";
+             "../../test/alea-coloring"]
+let daemons = ["-sd";"-lcd";"-dd"]  
+(* let cliques = List.init 25 (fun n -> Clique (20*(n+1))) (* [20; 40; ...; 500] *) *)
+(* let rings = List.init 25 (fun n -> Ring (400*(n+1)))  (* [400; 800; ...; 10000] *) *)
+(* let er = List.init 25 (fun n -> ER (10*(n+1), 0.4)) (* [10; 20; ...; 250] *) *)
+let rings = List.init 10 (fun n -> Ring (500*(n+1)))    (* [500; 1000; ...; 5000] *)
+let cliques = List.init 10 (fun n -> Clique (30*(n+1))) (* [30; 60; ...; 300] *)
+let er = List.init 10 (fun n -> ER (30*(n+1), 0.4))     (* [30; 60; ...; 300] *)
+let networks = (cliques@rings@er)
+
+let gen_make_rules () = gen_makefile "Makefile.expe-rules" daemons algos networks;;
+
+#use "parseLog.ml";;
+let gen_pdf () =
+  let gl = ["clique"; "ring"; "er"] in 
+  List.iter (fun n -> sh ("rm -f "^n^".data")) gl; 
+  parse_log ["Col-a1","alea-coloring-unif"] gl daemons;
+  parse_log ["Col-a2","alea-coloring"] gl daemons;
+  parse_log ["Col-a3","alea-coloring-alt"] gl daemons;    
+  List.iter (fun n -> sh ("./gen_pdf_paper.r "^n^".data coloring4zpaper")) gl;
+  List.iter (fun n -> sh ("./gen_pdf.r "^n^".data coloring")) gl
+
+
diff --git a/tools/simca/genExpeMakefilesUtils.ml b/tools/simca/genExpeMakefilesUtils.ml
index 7451088a..8a265ebb 100644
--- a/tools/simca/genExpeMakefilesUtils.ml
+++ b/tools/simca/genExpeMakefilesUtils.ml
@@ -72,7 +72,7 @@ let (gen_dot_rule : out_channel -> graph -> daemon list -> dir list ->
               let log = Printf.sprintf "%s%s-%s.log" name d bdir in
               Printf.fprintf oc
                 "\t && echo \"#use \\\"%s/runSimus.ml\\\";;\\n \\
-         run_simus %b %f %d %d.0 \\\"sasa -l 20000 %s %s -nd > /dev/null\\\";;\\n\" \\
+         run_simus %b %f %d %d.0 \\\"sasa -l 20000 %s %s -nd \\\";;\\n\" \\
          | ocaml  > %s/%s \\
 "
                 cwd regen_dot !precision !max_simu_nb !timeout_in_sec dot d cwd log 
diff --git a/tools/simca/runSimus.ml b/tools/simca/runSimus.ml
index 63a7f69b..199c771a 100644
--- a/tools/simca/runSimus.ml
+++ b/tools/simca/runSimus.ml
@@ -114,10 +114,17 @@ let run_simus regen_dot threshold max_simu_nb timeout cmd =
       assert (0 = Sys.command gen_dot_cmd)
     );
     let l = run cmd in
-    List.iter
+    if (l=[]) then (
+      Printf.printf "The cmd '%s' returned nothing! \n%!" cmd;
+      exit 2
+     );
+   let l = List.filter
+       (fun str -> String.length str > 11 && String.sub str 0 10 = "This algo ") l
+   in
+   List.iter
       (fun x  ->
          match get_step x with
-         | None -> ()
+         | None -> Printf.printf "get_step fail. Maybe the graph is not connected? start again..=\n"
          (* can occur if the generated graph is not connected on some algos *)
          | Some (m,s,r) ->
            incr i;
-- 
GitLab