Quellcode durchsuchen

Fix race condition detection + fix some outdated test files.

Joeri Exelmans vor 5 Jahren
Ursprung
Commit
ee9218c8d6

+ 2 - 1
src/sccd/execution/memory.py

@@ -49,8 +49,9 @@ class MemorySnapshot:
     
     race_conditions = self.temp_dirty & self.round_dirty
     if race_conditions:
+      variables = list(self.scope[-1].all_variables())
       # some variable written to twice before refresh
-      raise Exception("Race condition for variables %s" % str(list(self.scope[-1].get_name(offset) for offset in race_conditions.items())))
+      raise Exception("Race condition for variables %s" % str(list(variables[offset].name for offset in race_conditions.items())))
 
     self.round_dirty |= self.temp_dirty
     self.temp_dirty = Bitmap() # reset

+ 4 - 4
test/test_files/features/functions/fail_parameter_type.xml

@@ -7,14 +7,14 @@
       input_event_lifeline="first_combo_step"/>
 
     <datamodel>
-      <func id="digit(i:int, pos:int)">
+      digit = func(i:int, pos:int) {
         pow = 10 ** pos;
         return i // pow % 10;
-      </func>
+      };
 
-      <func id="numdigits(i:int)">
+      numdigits = func(i:int) {
         return float_to_int(log10(i)) + 1;
-      </func>
+      };
     </datamodel>
 
     <root initial="ready">

+ 2 - 2
test/test_files/features/functions/fail_return_branches.xml

@@ -2,12 +2,12 @@
 <test>
   <statechart>
     <datamodel>
-      <func id="illegal_func(i: int)">
+      illegal_func = func(i:int) {
         if (i > 1)
           return 42
         else
           return "hey";
-      </func>
+      };
     </datamodel>
 
     <root/>

+ 2 - 2
test/test_files/features/functions/fail_return_branches2.xml

@@ -2,10 +2,10 @@
 <test>
   <statechart>
     <datamodel>
-      <func id="illegal_func(i: int)">
+      illegal_func = func(i:int) {
         if (i &gt; 10) return 1;
         return "hello";
-      </func>
+      };
     </datamodel>
 
     <root/>

+ 2 - 2
test/test_files/features/functions/fail_return_branches3.xml

@@ -2,9 +2,9 @@
 <test>
   <statechart>
     <datamodel>
-      <func id="illegal_func(i: int)">
+      illegal_func = func(i:int) {
         if (i &gt; 10) return 1;
-      </func>
+      };
     </datamodel>
 
     <root/>

+ 2 - 2
test/test_files/features/functions/fail_return_branches4.xml

@@ -2,10 +2,10 @@
 <test>
   <statechart>
     <datamodel>
-      <func id="illegal_func">
+      illegal_func = func(i:int) {
         return 1;
         return 2;
-      </func>
+      };
     </datamodel>
 
     <root/>

+ 2 - 2
test/test_files/features/functions/fail_return_branches5.xml

@@ -2,10 +2,10 @@
 <test>
   <statechart>
     <datamodel>
-      <func id="illegal_func(i: int)">
+      illegal_func = func(i:int) {
         if (i &gt; 10) return 1;
         if (i &lt; 5) return "hello";
-      </func>
+      };
     </datamodel>
 
     <root/>

+ 4 - 4
test/test_files/features/functions/fail_return_type.xml

@@ -7,14 +7,14 @@
       input_event_lifeline="first_combo_step"/>
 
     <datamodel>
-      <func id="digit(i:int, pos:int)">
+      digit = func(i:int, pos:int) {
         pow = 10 ** pos;
         return i // pow % 10;
-      </func>
+      };
 
-      <func id="numdigits(i:int)">
+      numdigits = func(i:int) {
         return float_to_int(log10(i)) + 1;
-      </func>
+      };
     </datamodel>
 
     <root initial="ready">

+ 2 - 4
test/test_files/semantics/memory_protocol/fail_race_condition.xml

@@ -6,9 +6,10 @@
       input_event_lifeline="whole"
       assignment_memory_protocol="big_step"/>
     <datamodel>
-      <var id="x" expr="0"/>
+      x = 0;
     </datamodel>
     <root>
+      <!-- both transitions execute in the same big step, both writing to 'x' (one overwriting the other's result) -->
       <parallel id="p">
         <state id="a">
           <state id="a1">
@@ -31,7 +32,4 @@
   <input>
     <event port="in" name="e" time="0 d"/>
   </input>
-  <output>
-
-  </output>
 </test>