Commit f70bcede authored by erwan's avatar erwan
Browse files

test: add a -seed option to gg to get reproducible GM tests

parent 9c12063b
Pipeline #73756 passed with stages
in 3 minutes and 55 seconds
# Time-stamp: <modified the 27/07/2021 (at 10:44) by Erwan Jahier>
# Time-stamp: <modified the 02/09/2021 (at 10:38) by Erwan Jahier>
# Rules to generate various dot files.
# The DECO_PATTERN variable should be defined
grid%.dot:
gg grid -w $* -he $* -o $@
gg grid -w $* -he $* -o $@ $(SEED)
gg-deco $(DECO_PATTERN) $@ -o $@
clique%.dot:
gg clique -n $* -o $@
gg clique -n $* -o $@ $(SEED)
gg-deco $(DECO_PATTERN) $@ -o $@
er%.dot:
gg ER --connected -p 0.1 -n $* -o $@
gg ER --connected -p 0.1 -n $* -o $@ $(SEED)
gg-deco $(DECO_PATTERN) $@ -o $@
ba%.dot:
gg BA -n $* -o $@
gg BA -n $* -o $@ $(SEED)
gg-deco $(DECO_PATTERN) $@ -o $@
udg%.dot:
gg UDG -n $* -w 10 -o $@
gg UDG -n $* -w 10 -o $@ $(SEED)
gg-deco $(DECO_PATTERN) $@ -o $@
qudg%.dot:
gg QUDG -n $* -w 10 -o $@
gg QUDG -n $* -w 10 -o $@ $(SEED)
gg-deco $(DECO_PATTERN) $@ -o $@
ring%.dot:
gg ring -n $* -o $@
gg ring -n $* -o $@ $(SEED)
gg-deco $(DECO_PATTERN) $@ -o $@
diring%.dot:
gg ring -dir -n $* -o $@
gg ring -dir -n $* -o $@ $(SEED)
gg-deco $(DECO_PATTERN) $@ -o $@
tree%.dot:
gg tree -n $* -o $@
gg tree -n $* -o $@ $(SEED)
gg-deco $(DECO_PATTERN) $@ -o $@
intree%.dot:
gg tree --in-tree -n $* -o $@
gg tree --in-tree -n $* -o $@ $(SEED)
gg-deco $(DECO_PATTERN) $@ -o $@
outtree%.dot:
gg tree --out-tree -n $* -o $@
gg tree --out-tree -n $* -o $@ $(SEED)
gg-deco $(DECO_PATTERN) $@ -o $@
inouttree%.dot:
gg tree --in-out-tree -n $* -o $@
gg tree --in-out-tree -n $* -o $@ $(SEED)
gg-deco $(DECO_PATTERN) $@ -o $@
......
# Time-stamp: <modified the 01/09/2021 (at 10:26) by Erwan Jahier>
# Time-stamp: <modified the 02/09/2021 (at 10:34) by Erwan Jahier>
#
# Define some default rules that ought to work most of the time
#
......@@ -72,7 +72,11 @@ $(EXPDIR):
# update the reference
%.ugm_test: %.rif $(EXPDIR)
cp $*.rif $(EXPDIR)/$*.rif.exp
cp $*.rif $(EXPDIR)/$*.rif.exp
# fix the seed (in Makefile.dot) for the non-regression tests
SEED=--seed 42
############################################################################################
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -279,7 +279,11 @@ let () = (
exit 2
| Some g -> g
in
(match t.seed with
| None -> Random.self_init ()
| Some i -> Random.init i
);
make_dot g t.outputFile (all_attr t.rooted t.diameter g);
if (t.outputFile <> "" && not t.silent)
then Printf.printf "Done.\nOutput file : '%s'\n" t.outputFile
)
)
let () = Random.self_init ();
type action = string
......@@ -32,6 +31,7 @@ type t = {
mutable ba : ba_m;
mutable qudg : qudg_arg;
mutable seed : int option;
mutable silent : bool;
mutable connected : bool;
mutable directed : bool;
......@@ -83,8 +83,8 @@ let (make_args : unit -> t) =
r1 = 2.;
p = 0.5;
};
seed = None;
silent = false;
connected = false;
directed = false;
......@@ -301,6 +301,10 @@ let (mkoptab : string array -> t -> unit) =
"Same as the option '-du', but with the two radiuses being ";
"also displayed.\n"],"QUDG")];
mkopt args ["--seed";"-seed"]
(Arg.Int(fun i -> args.seed <- Some i))
[(["Set the pseudo-random generator seed"],"void")];
mkopt args ["--silent";"-s"]
(Arg.Unit (fun () -> args.silent <- true))
[(["be quiet"],"void")];
......
......@@ -30,6 +30,7 @@ type t = {
mutable ba : ba_m;
mutable qudg : qudg_arg;
mutable seed : int option;
mutable silent : bool;
mutable connected : bool;
mutable directed : bool;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment