From 1772454572ffe25b66c91ec6bd9366c0914bc8a0 Mon Sep 17 00:00:00 2001 From: Erwan Jahier <jahier@imag.fr> Date: Wed, 24 Apr 2013 15:13:04 +0200 Subject: [PATCH] Fix a bug in the -lv4 mode where constant coming from enum types were printed twice. --- src/data.ml | 3 +- src/ident.ml | 4 +- src/licPrg.ml | 2 +- src/main.ml | 8 ++-- src/socExec.ml | 6 +-- src/socExec.mli | 4 +- test/lus2lic.sum | 41 +++++++++---------- test/should_work/enum0.lus | 2 +- test/should_work/{fby.lus => followed_by.lus} | 0 test/should_work/nodeparam.lus | 2 +- todo.org | 33 ++++++++++++++- utils/test_lus2lic_no_node | 5 ++- 12 files changed, 73 insertions(+), 37 deletions(-) rename test/should_work/{fby.lus => followed_by.lus} (100%) diff --git a/src/data.ml b/src/data.ml index 72df5353..48e31fa0 100644 --- a/src/data.ml +++ b/src/data.ml @@ -48,7 +48,8 @@ let rec (type_to_string : t -> string) = | Int -> "int" | Real-> "real" | Extern s -> s ^ "(*extern*)" - | Enum (s, sl) -> "enum " ^ s ^ " {" ^ (String.concat ", " sl) ^ "}" +(* | Enum (s, sl) -> "enum " ^ s ^ " {" ^ (String.concat ", " sl) ^ "}" *) + | Enum (s, sl) -> s | Struct (sid,_) -> sid ^ "(*struct*)" | Array (ty, sz) -> Printf.sprintf "%s^%d" (type_to_string ty) sz | Alpha nb -> diff --git a/src/ident.ml b/src/ident.ml index 915bb44b..58946140 100644 --- a/src/ident.ml +++ b/src/ident.ml @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 12/04/2013 (at 08:46) by Erwan Jahier> *) +(* Time-stamp: <modified the 24/04/2013 (at 10:43) by Erwan Jahier> *) (* J'ai appele ca symbol (mais ca remplace le ident) : c'est juste une couche qui garantit l'unicite en memoire @@ -135,9 +135,9 @@ let (long_of_string : string -> long) = let string_of_idref i = ( match i.id_pack with Some p -> - if Lv6MainArgs.global_opt.Lv6MainArgs.no_prefix then i.id_id else if Lv6MainArgs.global_opt.Lv6MainArgs.ec then p^"__"^i.id_id else if Lv6MainArgs.global_opt.Lv6MainArgs.lv4 then (p^"__"^i.id_id) else + if Lv6MainArgs.global_opt.Lv6MainArgs.no_prefix then i.id_id else (p^"::"^i.id_id) | None -> i.id_id ) diff --git a/src/licPrg.ml b/src/licPrg.ml index 38edbe50..8cf885a5 100644 --- a/src/licPrg.ml +++ b/src/licPrg.ml @@ -121,7 +121,7 @@ let to_file (opt: Lv6MainArgs.t) (this:t) (main_node: Ident.idref option) = *) ItemKeyMap.iter (fun tn te -> - if (not Lv6MainArgs.global_opt.Lv6MainArgs.ec || Lic.is_extern_type te) then + if (not Lv6MainArgs.global_opt.Lv6MainArgs.lv4 || Lic.is_extern_type te) then output_string opt.Lv6MainArgs.oc (LicDump.type_decl tn te) ) this.types; diff --git a/src/main.ml b/src/main.ml index 47b9fbd8..4889b1cc 100644 --- a/src/main.ml +++ b/src/main.ml @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 23/04/2013 (at 16:41) by Erwan Jahier> *) +(* Time-stamp: <modified the 24/04/2013 (at 12:02) by Erwan Jahier> *) open Verbose open AstV6 @@ -73,6 +73,7 @@ let (gen_autotest_files : LicPrg.t -> Ident.idref option -> Lv6MainArgs.t -> uni let oracle_file_name = ("_"^name^"_oracle.lus") in let oc = open_out oracle_file_name in + let invars,outvars=soc.Soc.profile in let locals = List.map (fun (n,t) -> n^"_bis",t) outvars in let invars_str = List.map (fun (n,t) -> n^":"^(Data.type_to_string t)) invars in let outvars_str = List.map (fun (n,t) -> n^":"^(Data.type_to_string t)) outvars in @@ -89,8 +90,9 @@ let (gen_autotest_files : LicPrg.t -> Ident.idref option -> Lv6MainArgs.t -> uni let outvars_name = List.map fst outvars in let prg = prg^" ("^(String.concat "," locals_name)^") = "^name in let prg = prg^"("^(String.concat "," invars_name)^");\n "^ok^" = (" in - let prg = prg^(String.concat " and\n \t\t " (List.map2 (fun x y -> x^"="^y) - outvars_name locals_name)) ^ ");\ntel;\n" + let prg = try prg^(String.concat " and\n \t\t " (List.map2 (fun x y -> x^"="^y) + outvars_name locals_name)) ^ ");\ntel;\n" + with _ -> assert false in Lv6util.dump_entete oc; output_string oc prg; diff --git a/src/socExec.ml b/src/socExec.ml index ac3cd35b..f57b3d70 100644 --- a/src/socExec.ml +++ b/src/socExec.ml @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 15/04/2013 (at 15:54) by Erwan Jahier> *) +(* Time-stamp: <modified the 24/04/2013 (at 11:31) by Erwan Jahier> *) open Soc open Data @@ -230,7 +230,7 @@ let rec (expand_subst: Data.subst -> Data.subst list) = type sl = Data.subst list (* Reconstruct the flattenned data *) -let (unexpand : sl -> Soc.var list -> sl) = +let (unexpand_profile : sl -> Soc.var list -> sl) = fun sl vl -> let rec (aux : sl -> sl -> Soc.var list -> sl * sl)= fun sl_done sl_todo vl -> @@ -280,7 +280,7 @@ let (unexpand : sl -> Soc.var list -> sl) = (* [add_data_subst vtnl data_s s] add the data_s to s; *) let (add_data_subst : var list -> Data.subst list -> SocExecValue.substs -> SocExecValue.substs) = fun vntl_i s ctx_s -> - let s = unexpand s vntl_i in + let s = unexpand_profile s vntl_i in List.fold_left (fun acc (id,v) -> sadd acc [id] v) ctx_s s let (read_soc_input : var list -> Data.vntl -> out_channel -> substs -> substs) = diff --git a/src/socExec.mli b/src/socExec.mli index 55b3567a..cf53f580 100644 --- a/src/socExec.mli +++ b/src/socExec.mli @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 12/04/2013 (at 08:50) by Erwan Jahier> *) +(* Time-stamp: <modified the 24/04/2013 (at 14:19) by Erwan Jahier> *) (* The entry point for lus2lic -exec *) val f : Lv6MainArgs.t -> Soc.tbl -> Soc.key -> unit @@ -11,3 +11,5 @@ val do_step_dbg : Soc.tbl -> Soc.t -> Event.ctx -> SocExecValue.ctx -> (* Expand struct and arrays when communicating with the outside world *) val expand_profile : Soc.var list -> Soc.var list +val unexpand_profile : Data.subst list -> Soc.var list -> Data.subst list +val expand_subst: Data.subst -> Data.subst list diff --git a/test/lus2lic.sum b/test/lus2lic.sum index 3367a590..45b8d56b 100644 --- a/test/lus2lic.sum +++ b/test/lus2lic.sum @@ -1,4 +1,4 @@ -Test Run By jahier on Tue Apr 23 16:03:56 2013 +Test Run By jahier on Wed Apr 24 15:04:13 2013 Native configuration is i686-pc-linux-gnu === lus2lic tests === @@ -21,26 +21,22 @@ PASS: ./lus2lic {-o /tmp/ck5.lic should_work/ck5.lus} PASS: ./lus2lic {-ec -o /tmp/ck5.ec should_work/ck5.lus} PASS: ./ec2c {-o /tmp/ck5.c /tmp/ck5.ec} PASS: ../utils/test_lus2lic_no_node should_work/ck5.lus -PASS: ./lus2lic {-o /tmp/fby.lic should_work/fby.lus} -PASS: ./lus2lic {-ec -o /tmp/fby.ec should_work/fby.lus} -PASS: ./ec2c {-o /tmp/fby.c /tmp/fby.ec} -FAIL: Try to compare lus2lic -exec and ecexe: ../utils/test_lus2lic_no_node should_work/fby.lus PASS: ./lus2lic {-o /tmp/assertion.lic should_work/assertion.lus} PASS: ./lus2lic {-ec -o /tmp/assertion.ec should_work/assertion.lus} PASS: ./ec2c {-o /tmp/assertion.c /tmp/assertion.ec} -FAIL: Try to compare lus2lic -exec and ecexe: ../utils/test_lus2lic_no_node should_work/assertion.lus +PASS: ../utils/test_lus2lic_no_node should_work/assertion.lus PASS: ./lus2lic {-o /tmp/normal.lic should_work/normal.lus} PASS: ./lus2lic {-ec -o /tmp/normal.ec should_work/normal.lus} PASS: ./ec2c {-o /tmp/normal.c /tmp/normal.ec} -UNRESOLVED: Time out: ../utils/test_lus2lic_no_node should_work/normal.lus +PASS: ../utils/test_lus2lic_no_node should_work/normal.lus PASS: ./lus2lic {-o /tmp/nodeparam.lic should_work/nodeparam.lus} PASS: ./lus2lic {-ec -o /tmp/nodeparam.ec should_work/nodeparam.lus} PASS: ./ec2c {-o /tmp/nodeparam.c /tmp/nodeparam.ec} -FAIL: Try to compare lus2lic -exec and ecexe: ../utils/test_lus2lic_no_node should_work/nodeparam.lus +PASS: ../utils/test_lus2lic_no_node should_work/nodeparam.lus PASS: ./lus2lic {-o /tmp/enum0.lic should_work/enum0.lus} PASS: ./lus2lic {-ec -o /tmp/enum0.ec should_work/enum0.lus} PASS: ./ec2c {-o /tmp/enum0.c /tmp/enum0.ec} -FAIL: Try to compare lus2lic -exec and ecexe: ../utils/test_lus2lic_no_node should_work/enum0.lus +PASS: ../utils/test_lus2lic_no_node should_work/enum0.lus PASS: ./lus2lic {-o /tmp/ck6.lic should_work/ck6.lus} PASS: ./lus2lic {-ec -o /tmp/ck6.ec should_work/ck6.lus} PASS: ./ec2c {-o /tmp/ck6.c /tmp/ck6.ec} @@ -48,7 +44,7 @@ FAIL: Try to compare lus2lic -exec and ecexe: ../utils/test_lus2lic_no_node shou PASS: ./lus2lic {-o /tmp/Gyroscope2.lic should_work/Gyroscope2.lus} PASS: ./lus2lic {-ec -o /tmp/Gyroscope2.ec should_work/Gyroscope2.lus} PASS: ./ec2c {-o /tmp/Gyroscope2.c /tmp/Gyroscope2.ec} -UNRESOLVED: Time out: ../utils/test_lus2lic_no_node should_work/Gyroscope2.lus +PASS: ../utils/test_lus2lic_no_node should_work/Gyroscope2.lus PASS: ./lus2lic {-o /tmp/mouse2.lic should_work/mouse2.lus} PASS: ./lus2lic {-ec -o /tmp/mouse2.ec should_work/mouse2.lus} PASS: ./ec2c {-o /tmp/mouse2.c /tmp/mouse2.ec} @@ -278,7 +274,7 @@ PASS: ../utils/test_lus2lic_no_node should_work/model2.lus PASS: ./lus2lic {-o /tmp/alarme.lic should_work/alarme.lus} PASS: ./lus2lic {-ec -o /tmp/alarme.ec should_work/alarme.lus} PASS: ./ec2c {-o /tmp/alarme.c /tmp/alarme.ec} -FAIL: Try to compare lus2lic -exec and ecexe: ../utils/test_lus2lic_no_node should_work/alarme.lus +PASS: ../utils/test_lus2lic_no_node should_work/alarme.lus PASS: ./lus2lic {-o /tmp/onlyroll2.lic should_work/onlyroll2.lus} PASS: ./lus2lic {-ec -o /tmp/onlyroll2.ec should_work/onlyroll2.lus} PASS: ./ec2c {-o /tmp/onlyroll2.c /tmp/onlyroll2.ec} @@ -346,7 +342,7 @@ FAIL: Try to compare lus2lic -exec and ecexe: ../utils/test_lus2lic_no_node shou PASS: ./lus2lic {-o /tmp/call07.lic should_work/call07.lus} PASS: ./lus2lic {-ec -o /tmp/call07.ec should_work/call07.lus} PASS: ./ec2c {-o /tmp/call07.c /tmp/call07.ec} -FAIL: Try to compare lus2lic -exec and ecexe: ../utils/test_lus2lic_no_node should_work/call07.lus +PASS: ../utils/test_lus2lic_no_node should_work/call07.lus PASS: ./lus2lic {-o /tmp/shift_ludic.lic should_work/shift_ludic.lus} PASS: ./lus2lic {-ec -o /tmp/shift_ludic.ec should_work/shift_ludic.lus} PASS: ./ec2c {-o /tmp/shift_ludic.c /tmp/shift_ludic.ec} @@ -378,7 +374,7 @@ PASS: ../utils/test_lus2lic_no_node should_work/morel5.lus PASS: ./lus2lic {-o /tmp/bred.lic should_work/bred.lus} PASS: ./lus2lic {-ec -o /tmp/bred.ec should_work/bred.lus} PASS: ./ec2c {-o /tmp/bred.c /tmp/bred.ec} -FAIL: Try to compare lus2lic -exec and ecexe: ../utils/test_lus2lic_no_node should_work/bred.lus +PASS: ../utils/test_lus2lic_no_node should_work/bred.lus PASS: ./lus2lic {-o /tmp/tri.lic should_work/tri.lus} PASS: ./lus2lic {-ec -o /tmp/tri.ec should_work/tri.lus} PASS: ./ec2c {-o /tmp/tri.c /tmp/tri.ec} @@ -576,7 +572,7 @@ FAIL: Try to compare lus2lic -exec and ecexe: ../utils/test_lus2lic_no_node shou PASS: ./lus2lic {-o /tmp/o2l_feux_compl.lic should_work/o2l_feux_compl.lus} PASS: ./lus2lic {-ec -o /tmp/o2l_feux_compl.ec should_work/o2l_feux_compl.lus} PASS: ./ec2c {-o /tmp/o2l_feux_compl.c /tmp/o2l_feux_compl.ec} -FAIL: Try to compare lus2lic -exec and ecexe: ../utils/test_lus2lic_no_node should_work/o2l_feux_compl.lus +PASS: ../utils/test_lus2lic_no_node should_work/o2l_feux_compl.lus PASS: ./lus2lic {-o /tmp/model.lic should_work/model.lus} PASS: ./lus2lic {-ec -o /tmp/model.ec should_work/model.lus} PASS: ./ec2c {-o /tmp/model.c /tmp/model.ec} @@ -608,7 +604,7 @@ FAIL: Try to compare lus2lic -exec and ecexe: ../utils/test_lus2lic_no_node shou PASS: ./lus2lic {-o /tmp/exclusion.lic should_work/exclusion.lus} PASS: ./lus2lic {-ec -o /tmp/exclusion.ec should_work/exclusion.lus} PASS: ./ec2c {-o /tmp/exclusion.c /tmp/exclusion.ec} -FAIL: Try to compare lus2lic -exec and ecexe: ../utils/test_lus2lic_no_node should_work/exclusion.lus +PASS: ../utils/test_lus2lic_no_node should_work/exclusion.lus PASS: ./lus2lic {-o /tmp/ply01.lic should_work/ply01.lus} PASS: ./lus2lic {-ec -o /tmp/ply01.ec should_work/ply01.lus} PASS: ./ec2c {-o /tmp/ply01.c /tmp/ply01.ec} @@ -737,6 +733,10 @@ PASS: ./lus2lic {-o /tmp/Gyroscope.lic should_work/Gyroscope.lus} PASS: ./lus2lic {-ec -o /tmp/Gyroscope.ec should_work/Gyroscope.lus} PASS: ./ec2c {-o /tmp/Gyroscope.c /tmp/Gyroscope.ec} PASS: ../utils/test_lus2lic_no_node should_work/Gyroscope.lus +PASS: ./lus2lic {-o /tmp/followed_by.lic should_work/followed_by.lus} +PASS: ./lus2lic {-ec -o /tmp/followed_by.ec should_work/followed_by.lus} +PASS: ./ec2c {-o /tmp/followed_by.c /tmp/followed_by.ec} +PASS: ../utils/test_lus2lic_no_node should_work/followed_by.lus PASS: ./lus2lic {-o /tmp/asservi.lic should_work/asservi.lus} PASS: ./lus2lic {-ec -o /tmp/asservi.ec should_work/asservi.lus} PASS: ./ec2c {-o /tmp/asservi.c /tmp/asservi.ec} @@ -776,7 +776,7 @@ FAIL: Try to compare lus2lic -exec and ecexe: ../utils/test_lus2lic_no_node shou PASS: ./lus2lic {-o /tmp/drapfab.lic should_work/drapfab.lus} PASS: ./lus2lic {-ec -o /tmp/drapfab.ec should_work/drapfab.lus} PASS: ./ec2c {-o /tmp/drapfab.c /tmp/drapfab.ec} -FAIL: Try to compare lus2lic -exec and ecexe: ../utils/test_lus2lic_no_node should_work/drapfab.lus +PASS: ../utils/test_lus2lic_no_node should_work/drapfab.lus PASS: ./lus2lic {-o /tmp/pre_x.lic should_work/pre_x.lus} PASS: ./lus2lic {-ec -o /tmp/pre_x.ec should_work/pre_x.lus} PASS: ./ec2c {-o /tmp/pre_x.c /tmp/pre_x.ec} @@ -800,7 +800,7 @@ FAIL: Try to compare lus2lic -exec and ecexe: ../utils/test_lus2lic_no_node shou PASS: ./lus2lic {-o /tmp/hanane.lic should_work/hanane.lus} PASS: ./lus2lic {-ec -o /tmp/hanane.ec should_work/hanane.lus} PASS: ./ec2c {-o /tmp/hanane.c /tmp/hanane.ec} -FAIL: Try to compare lus2lic -exec and ecexe: ../utils/test_lus2lic_no_node should_work/hanane.lus +PASS: ../utils/test_lus2lic_no_node should_work/hanane.lus PASS: ./lus2lic {-o /tmp/lustre.lic should_work/lustre.lus} PASS: ./lus2lic {-ec -o /tmp/lustre.ec should_work/lustre.lus} PASS: ./ec2c {-o /tmp/lustre.c /tmp/lustre.ec} @@ -892,7 +892,7 @@ PASS: ../utils/test_lus2lic_no_node should_work/arrays.lus PASS: ./lus2lic {-o /tmp/eq1.lic should_work/eq1.lus} PASS: ./lus2lic {-ec -o /tmp/eq1.ec should_work/eq1.lus} PASS: ./ec2c {-o /tmp/eq1.c /tmp/eq1.ec} -FAIL: Try to compare lus2lic -exec and ecexe: ../utils/test_lus2lic_no_node should_work/eq1.lus +PASS: ../utils/test_lus2lic_no_node should_work/eq1.lus PASS: ./lus2lic {-o /tmp/nc3.lic should_work/nc3.lus} PASS: ./lus2lic {-ec -o /tmp/nc3.ec should_work/nc3.lus} PASS: ./ec2c {-o /tmp/nc3.c /tmp/nc3.ec} @@ -1045,8 +1045,7 @@ XPASS: Test bad programs (semantics): lus2lic {-o /tmp/bug.lic should_fail/seman === lus2lic Summary === -# of expected passes 871 -# of unexpected failures 112 +# of expected passes 885 +# of unexpected failures 100 # of unexpected successes 11 # of expected failures 37 -# of unresolved testcases 2 diff --git a/test/should_work/enum0.lus b/test/should_work/enum0.lus index 71a842d3..f3cd8d7a 100644 --- a/test/should_work/enum0.lus +++ b/test/should_work/enum0.lus @@ -2,7 +2,7 @@ type color1 = enum { blue, white, black }; type color2 = enum { green, orange, yellow }; -node t(x: color1) returns (y: color2); +node enum0(x: color1) returns (y: color2); let y = if x = blue then green else if x = white then orange else yellow; tel \ No newline at end of file diff --git a/test/should_work/fby.lus b/test/should_work/followed_by.lus similarity index 100% rename from test/should_work/fby.lus rename to test/should_work/followed_by.lus diff --git a/test/should_work/nodeparam.lus b/test/should_work/nodeparam.lus index 4c4e6b8d..9380d4eb 100644 --- a/test/should_work/nodeparam.lus +++ b/test/should_work/nodeparam.lus @@ -11,4 +11,4 @@ let tel -node h = f<< g<<42>> >>; +node nodeparam = f<< g<<42>> >>; diff --git a/todo.org b/todo.org index ba0ed477..2ad3afa5 100644 --- a/todo.org +++ b/todo.org @@ -89,15 +89,44 @@ in particular, are nodes using extern nodes generated properly? - State "TODO" from "" [2013-01-11 Fri 11:15] -* Aesthetes issues +** TODO Fix a bug occurring using -en and -esa together. + - State "TODO" from "" [2013-04-24 Wed 09:22] + +#+begin_src sh +./lus2lic _assertion_oracle.lus -n assertion_oracle -en -esa + +*** Error in file "/home/jahier/lus2lic/test/_assertion_oracle.lus", line 38, col 3 to 7, token 'v02_1': +*** +*** Variable _0v02_1_1 is already defined. +#+end_src + +-> on verra ca quand les autres test passeront ; je ferai alors une passe +complete qur le nommage des variables fraiches. + ** TODO Nommage des variables fraiches : Reprendre LicVarName.ml - State "TODO" from "" [2013-01-16 Wed 18:03] car c'est completement n'importe quoi (j'ai réussit a faire des clashs -entre les var inventées dans split et dans expandnodes !!) +entre les var inventées dans split et dans ExpandNodes !!) Pascal a introduit un mecanisme qui shunte LicName -> en discuter avec lui. +** TODO au sujet des tests de non-regression + - State "TODO" from "" [2013-04-23 Tue 17:31] + +Actuellement, test_lus2lic_no_node, je compare lus2lic -ec + ecexe et lus2lic -exec. + +Ca serait bien de faire la meme chose en passant par lus2lic -lv4 + +lus2ec voir. + +** TODO Le test de noeuds qui ont des types enum ne fonctionne pas + - State "TODO" from "" [2013-04-24 Wed 10:12] + +../utils/test_lus2lic_no_node should_work/enum0.lus + +en fait, l'option --gen-auto-test traduit les types enums en entier ; du coup +l'appel depuis l'oracle au noeud à tester est mal typé... + * Divers ** TODO lic2c : le jour ou on genere du code C, y'a peut-etre des trucs a recuperer diff --git a/utils/test_lus2lic_no_node b/utils/test_lus2lic_no_node index df73aa7e..9f54ddde 100755 --- a/utils/test_lus2lic_no_node +++ b/utils/test_lus2lic_no_node @@ -10,7 +10,10 @@ env=_"$node"_env.lut set -x verbose #echo on ./lus2lic $lustre_file -n $node --gen-autotest || exit 2 -./lus2lic $lustre_file -n $node -lv4 -en --no-prefix >> $_oracle || exit 2 +cat $lustre_file >> $_oracle + +#./lus2lic $lustre_file -n $node -lv4 -en --no-prefix >> $_oracle || exit 2 + ./lus2lic $_oracle -n $oracle -ec -o $oracle.ec || exit 2 ./lurettetop -rp "sut:v6:$lustre_file:$node" -rp "env:lutin:$env" -rp "oracle:ec:$oracle.ec:$oracle" -go -l 10 -ns2c --stop-on-oracle-error || exit 2 -- GitLab