From 1fefdbaf82dc425247dca5041415bbc8c74d6a6c Mon Sep 17 00:00:00 2001
From: Erwan Jahier <jahier@imag.fr>
Date: Fri, 22 Aug 2014 15:39:13 +0200
Subject: [PATCH] socExec: Unintialised var should not raise an internal error
 (is returning nil fine?).

---
 src/socExecValue.ml         |  6 +++---
 test/lus2lic.sum            | 36 ++++++++++++++++++------------------
 test/lus2lic.time           | 14 +++++++-------
 test/should_work/PCOND1.lus |  4 +++-
 todo.org                    | 27 +++++++++++----------------
 utils/compare_exec_and_2c   |  4 +---
 6 files changed, 43 insertions(+), 48 deletions(-)

diff --git a/src/socExecValue.ml b/src/socExecValue.ml
index 9582b3aa..689ad1f4 100644
--- a/src/socExecValue.ml
+++ b/src/socExecValue.ml
@@ -1,4 +1,4 @@
-(* Time-stamp: <modified the 13/08/2014 (at 09:32) by Erwan Jahier> *)
+(* Time-stamp: <modified the 22/08/2014 (at 15:08) by Erwan Jahier> *)
 
 let dbg = (Verbose.get_flag "exec")
 
@@ -239,8 +239,8 @@ fun id ctx ->
     | B true -> "true"
     | B false -> "false"
     | U  ->
-      print_string (id ^ " undefined\n"); flush stdout;
-      assert false 
+(*       print_string (id ^ " undefined\n"); flush stdout; *)
+      raise Not_found
     | o -> 
       print_string ("get_enum '" ^ (val_to_string string_of_float o) ^"' failed\n"); flush stdout;
       assert false (* should not fail *) 
diff --git a/test/lus2lic.sum b/test/lus2lic.sum
index 757e5d91..e1dbc56e 100644
--- a/test/lus2lic.sum
+++ b/test/lus2lic.sum
@@ -1,4 +1,4 @@
-Test Run By jahier on Fri Aug 22 14:36:14 
+Test Run By jahier on Fri Aug 22 15:21:27 
 Native configuration is i686-pc-linux-gnu
 
 		=== lus2lic0 tests ===
@@ -64,7 +64,7 @@ XFAIL: Test bad programs (assert): test_lus2lic_no_node should_fail/assert/eq1.l
 
 # of expected passes		1
 # of expected failures		50
-Test Run By jahier on Fri Aug 22 14:36:20 
+Test Run By jahier on Fri Aug 22 15:21:35 
 Native configuration is i686-pc-linux-gnu
 
 		=== lus2lic1 tests ===
@@ -425,7 +425,7 @@ PASS: ./lus2lic {-2c Int.lus -n Int}
 
 # of expected passes		325
 # of unexpected failures	21
-Test Run By jahier on Fri Aug 22 14:37:16 
+Test Run By jahier on Fri Aug 22 15:23:04 
 Native configuration is i686-pc-linux-gnu
 
 		=== lus2lic2 tests ===
@@ -719,7 +719,7 @@ PASS: gcc zzz_zzz.c zzz_zzz_loop.c
 PASS: /home/jahier/lus2lic/test/../utils/compare_exec_and_2c zzz.lus 
 PASS: ./lus2lic {-2c PCOND1.lus -n PCOND1}
 PASS: gcc PCOND1_PCOND1.c PCOND1_PCOND1_loop.c 
-FAIL: Try to compare lus2lic -exec and -2c: /home/jahier/lus2lic/test/../utils/compare_exec_and_2c PCOND1.lus 
+PASS: /home/jahier/lus2lic/test/../utils/compare_exec_and_2c PCOND1.lus 
 FAIL: Generate c code  : ./lus2lic {-2c PCOND.lus -n PCOND}
 PASS: ./lus2lic {-2c SWITCH.lus -n SWITCH}
 PASS: gcc SWITCH_SWITCH.c SWITCH_SWITCH_loop.c 
@@ -751,9 +751,9 @@ PASS: /home/jahier/lus2lic/test/../utils/compare_exec_and_2c X.lus
 
 		=== lus2lic2 Summary ===
 
-# of expected passes		303
-# of unexpected failures	10
-Test Run By jahier on Fri Aug 22 14:38:53 
+# of expected passes		304
+# of unexpected failures	9
+Test Run By jahier on Fri Aug 22 15:24:56 
 Native configuration is i686-pc-linux-gnu
 
 		=== lus2lic3 tests ===
@@ -1258,7 +1258,7 @@ PASS: ./myec2c {-o Int.c Int.ec}
 
 # of expected passes		475
 # of unexpected failures	15
-Test Run By jahier on Fri Aug 22 14:39:54 
+Test Run By jahier on Fri Aug 22 15:26:31 
 Native configuration is i686-pc-linux-gnu
 
 		=== lus2lic4 tests ===
@@ -1661,7 +1661,7 @@ PASS: /home/jahier/lus2lic/test/../utils/test_lus2lic_no_node zzz.lus
 PASS: ./lus2lic {-o PCOND1.lic PCOND1.lus}
 PASS: ./lus2lic {-ec -o PCOND1.ec PCOND1.lus}
 PASS: ./myec2c {-o PCOND1.c PCOND1.ec}
-FAIL: Try to compare lus2lic -exec and ecexe: /home/jahier/lus2lic/test/../utils/test_lus2lic_no_node PCOND1.lus 
+PASS: /home/jahier/lus2lic/test/../utils/test_lus2lic_no_node PCOND1.lus 
 FAIL: without any option: ./lus2lic {-o PCOND.lic PCOND.lus}
 PASS: ./lus2lic {-o SWITCH.lic SWITCH.lus}
 PASS: ./lus2lic {-ec -o SWITCH.ec SWITCH.lus}
@@ -1702,14 +1702,14 @@ PASS: /home/jahier/lus2lic/test/../utils/test_lus2lic_no_node X.lus
 
 		=== lus2lic4 Summary ===
 
-# of expected passes		421
-# of unexpected failures	10
-lus2lic0.log:testcase ./lus2lic.tests/test0.exp completed in 5 seconds
-lus2lic1.log:testcase ./lus2lic.tests/test1.exp completed in 56 seconds
-lus2lic2.log:testcase ./lus2lic.tests/test2.exp completed in 95 seconds
-lus2lic3.log:testcase ./lus2lic.tests/test3.exp completed in 60 seconds
-lus2lic4.log:testcase ./lus2lic.tests/test4.exp completed in 116 seconds
+# of expected passes		422
+# of unexpected failures	9
+lus2lic0.log:testcase ./lus2lic.tests/test0.exp completed in 7 seconds
+lus2lic1.log:testcase ./lus2lic.tests/test1.exp completed in 87 seconds
+lus2lic2.log:testcase ./lus2lic.tests/test2.exp completed in 111 seconds
+lus2lic3.log:testcase ./lus2lic.tests/test3.exp completed in 94 seconds
+lus2lic4.log:testcase ./lus2lic.tests/test4.exp completed in 156 seconds
 * Ref time: 
-0.12user 0.06system 5:36.96elapsed 0%CPU (0avgtext+0avgdata 2464maxresident)k
-0inputs+0outputs (0major+12518minor)pagefaults 0swaps
+0.11user 0.07system 7:41.15elapsed 0%CPU (0avgtext+0avgdata 2460maxresident)k
+0inputs+0outputs (0major+12507minor)pagefaults 0swaps
 * Quick time (-j 4):
diff --git a/test/lus2lic.time b/test/lus2lic.time
index 2be98903..6644657f 100644
--- a/test/lus2lic.time
+++ b/test/lus2lic.time
@@ -1,9 +1,9 @@
-lus2lic0.log:testcase ./lus2lic.tests/test0.exp completed in 5 seconds
-lus2lic1.log:testcase ./lus2lic.tests/test1.exp completed in 56 seconds
-lus2lic2.log:testcase ./lus2lic.tests/test2.exp completed in 95 seconds
-lus2lic3.log:testcase ./lus2lic.tests/test3.exp completed in 60 seconds
-lus2lic4.log:testcase ./lus2lic.tests/test4.exp completed in 116 seconds
+lus2lic0.log:testcase ./lus2lic.tests/test0.exp completed in 7 seconds
+lus2lic1.log:testcase ./lus2lic.tests/test1.exp completed in 87 seconds
+lus2lic2.log:testcase ./lus2lic.tests/test2.exp completed in 111 seconds
+lus2lic3.log:testcase ./lus2lic.tests/test3.exp completed in 94 seconds
+lus2lic4.log:testcase ./lus2lic.tests/test4.exp completed in 156 seconds
 * Ref time: 
-0.12user 0.06system 5:36.96elapsed 0%CPU (0avgtext+0avgdata 2464maxresident)k
-0inputs+0outputs (0major+12518minor)pagefaults 0swaps
+0.11user 0.07system 7:41.15elapsed 0%CPU (0avgtext+0avgdata 2460maxresident)k
+0inputs+0outputs (0major+12507minor)pagefaults 0swaps
 * Quick time (-j 4):
diff --git a/test/should_work/PCOND1.lus b/test/should_work/PCOND1.lus
index a7509c5c..6059292e 100644
--- a/test/should_work/PCOND1.lus
+++ b/test/should_work/PCOND1.lus
@@ -8,8 +8,10 @@ var
   hB_on_h0: bool when h0;
   hC_on_h0: bool when h0; 
   hD_on_hC_on_h0: bool when hC_on_h0; 
+ hX_init:bool;
 let
-  hX = current(hX_on_h0);
+  hX_init = h0 or (false fby h0);
+  hX = if hX_init then current(hX_on_h0) else false;
   hA_on_h0 = hA when h0;
   hB_on_h0 = hB when h0;
   hC_on_h0 = hC when h0;
diff --git a/todo.org b/todo.org
index 88944e0d..24cc91be 100644
--- a/todo.org
+++ b/todo.org
@@ -12,15 +12,15 @@
 3. ../utils/test_lus2lic_no_node should_work/test_node_expand.lus
 4. ../utils/test_lus2lic_no_node should_work/modes3x2_v2.lus
 5. ../utils/test_lus2lic_no_node should_work/filter.lus
-6. ../utils/test_lus2lic_no_node should_work/PCOND1.lus
-7. ../utils/test_lus2lic_no_node should_work/multipar.lus
-8. ../utils/test_lus2lic_no_node should_work/activation2.lus
-9. ../utils/test_lus2lic_no_node should_work/bob.lus
-10. ../utils/test_lus2lic_no_node should_work/test_condact.lus
-11. ../utils/test_lus2lic_no_node should_work/activation1.lus
-12. ../utils/test_lus2lic_no_node should_work/Gyroscope.lus
-13. ../utils/test_lus2lic_no_node should_work/cond01.lus
-14. ../utils/test_lus2lic_no_node should_work/speedcontrol.lus
+6. ../utils/test_lus2lic_no_node should_work/multipar.lus
+7. ../utils/test_lus2lic_no_node should_work/activation2.lus
+8. ../utils/test_lus2lic_no_node should_work/bob.lus
+9. ../utils/test_lus2lic_no_node should_work/test_condact.lus
+10. ../utils/test_lus2lic_no_node should_work/activation1.lus
+11. ../utils/test_lus2lic_no_node should_work/Gyroscope.lus
+12. ../utils/test_lus2lic_no_node should_work/cond01.lus
+13. ../utils/test_lus2lic_no_node should_work/speedcontrol.lus
+
 
 
 ** TODO Extern and ec
@@ -41,13 +41,8 @@ grep "FAIL:" lus2lic*.log | grep "exec" | grep "\-2c" | sed s/'FAIL: Try to comp
 2. ../utils/compare_exec_and_2c should_work/test_node_expand.lus 2000
   -> idem
 
-3. ../utils/compare_exec_and_2c should_work/PCOND1.lus 2000
-   -> File "../obj-linux/socExecValue.ml", line 243, characters 6-12: Assertion failed
-
-4. ../utils/compare_exec_and_2c should_work/multipar.lus 2000
-  -> pb  32bits
-5. ../utils/compare_exec_and_2c should_work/array_concat.lus 2000
-  -> le a.out fait un segmentation fault
+3. ../utils/compare_exec_and_2c should_work/multipar.lus 2000
+  -> idem
 
 ** TODO lic2c : le jour ou on genere du code C, y'a peut-etre des trucs a recuperer
    - State "TODO"       from ""           [2012-12-10 Mon 14:32]
diff --git a/utils/compare_exec_and_2c b/utils/compare_exec_and_2c
index 07723baf..5de35859 100755
--- a/utils/compare_exec_and_2c
+++ b/utils/compare_exec_and_2c
@@ -55,9 +55,7 @@ then
 echo "Comparison of lus2lic -2c and lus2lic -exec with lurette on $lustre_file: ok"
 echo "lurettetop ok"
 else
-    touch a.out-via-sockets-stderr.log
-     cp a.out-via-sockets-stderr.log $node-out-via-sockets-stderr.log
-     echo "error"
+    echo "error"
      exit 2
 fi
 exit 0
-- 
GitLab