@@ -64,6 +64,7 @@ public void solve(Ender ender) {
6464
6565 @ Override
6666 public void run () {
67+ List <File > todel = new ArrayList <>();
6768 try {
6869 System .out .println ("Built C files in : \n " + new File (workFolder + "/" ));
6970
@@ -75,20 +76,20 @@ public void run() {
7576 final Gal2SMTFrontEnd gsf = new Gal2SMTFrontEnd (Solver .Z3 , timeout );
7677 g2p .setSmtConfig (gsf );
7778 g2p .initSolver ();
78- g2p .transform (spec , workFolder .getCanonicalPath (), doPOR , isSafe );
79+ g2p .transform (spec , workFolder .getCanonicalPath (), doPOR , isSafe , todel );
7980
8081 } else {
8182 p2p = new PetriNet2PinsTransformer ();
8283 if (tgba != null ) {
83- p2p .transform (spn , workFolder .getCanonicalPath (), doPOR , false , tgba .getAPs ());
84+ p2p .transform (spn , workFolder .getCanonicalPath (), doPOR , false , tgba .getAPs (), todel );
8485 } else {
85- p2p .transform (spn , workFolder .getCanonicalPath (), doPOR , false , null );
86+ p2p .transform (spn , workFolder .getCanonicalPath (), doPOR , false , null , todel );
8687 }
8788
8889 }
8990 try {
90- compilePINS ((int )Math .max (2 , timeout /5 ));
91- linkPINS (Math .max (1 , timeout /5 ));
91+ compilePINS ((int )Math .max (2 , timeout /5 ), todel );
92+ linkPINS (Math .max (1 , timeout /5 ), todel );
9293 } catch (TimeoutException to ) {
9394 throw new RuntimeException ("Compilation or link of executable timed out." + to );
9495 }
@@ -111,14 +112,14 @@ public void run() {
111112 todo .removeAll (doneProps .keySet ());
112113
113114 if (tgba == null ) {
114- checkProperties (g2p , p2p , timeout ,doneProps );
115+ checkProperties (g2p , p2p , timeout ,doneProps , todel );
115116 } else {
116- checkProperty (tgba .getName (), stateBasedHOA , timeout , false , PropertyType .LTL );
117+ checkProperty (tgba .getName (), stateBasedHOA , timeout , false , PropertyType .LTL , todel );
117118 }
118119 todo .removeAll (doneProps .keySet ());
119120 if (! todo .isEmpty () && shouldRetry ) {
120121 System .out .println ("Retrying LTSmin with larger timeout " +(8 *timeout )+ " s" );
121- checkProperties (g2p , p2p , 8 * timeout , doneProps );
122+ checkProperties (g2p , p2p , 8 * timeout , doneProps , todel );
122123 }
123124 todo .removeAll (doneProps .keySet ());
124125 if ( todo .isEmpty ()) {
@@ -131,10 +132,16 @@ public void run() {
131132 } catch (RuntimeException e ) {
132133 System .out .println ("WARNING : LTS min runner thread failed on error :" + e );
133134 e .printStackTrace ();
135+ } finally {
136+ if (DEBUG == 0 ) {
137+ for (File f : todel ) {
138+ if (f .exists ()) f .delete ();
139+ }
140+ }
134141 }
135142 }
136143
137- public void checkProperties (Gal2PinsTransformerNext g2p , PetriNet2PinsTransformer p2p , long time , DoneProperties doneProps )
144+ public void checkProperties (Gal2PinsTransformerNext g2p , PetriNet2PinsTransformer p2p , long time , DoneProperties doneProps , List < File > todel )
138145 throws IOException , InterruptedException {
139146 boolean negateResult ;
140147 if (spn == null ) {
@@ -155,7 +162,7 @@ public void checkProperties(Gal2PinsTransformerNext g2p, PetriNet2PinsTransforme
155162 ptype = PropertyType .INVARIANT ;
156163 }
157164
158- checkProperty (prop .getName (),pbody ,time ,negateResult , ptype );
165+ checkProperty (prop .getName (),pbody ,time ,negateResult , ptype , todel );
159166 }
160167
161168 } else {
@@ -173,7 +180,7 @@ public void checkProperties(Gal2PinsTransformerNext g2p, PetriNet2PinsTransforme
173180 negateResult = false ;
174181 }
175182
176- checkProperty (prop .getName (),pbody ,time /spn .getProperties ().size (),negateResult , prop .getType ());
183+ checkProperty (prop .getName (),pbody ,time /spn .getProperties ().size (),negateResult , prop .getType (), todel );
177184 }
178185 }
179186 }
@@ -184,7 +191,7 @@ public void checkProperties(Gal2PinsTransformerNext g2p, PetriNet2PinsTransforme
184191 runnerThread .start ();
185192 }
186193
187- private void checkProperty (String pname , String pbody , long timeout , boolean negateResult , PropertyType propertyType ) throws IOException , InterruptedException {
194+ private void checkProperty (String pname , String pbody , long timeout , boolean negateResult , PropertyType propertyType , List < File > todel ) throws IOException , InterruptedException {
188195 if (doneProps .containsKey (pname )) {
189196 return ;
190197 }
@@ -228,7 +235,7 @@ private void checkProperty(String pname, String pbody, long timeout, boolean neg
228235
229236 try {
230237 File outputff = Files .createTempFile ("ltsrun" , ".out" ).toFile ();
231- outputff . deleteOnExit ( );
238+ todel . add ( outputff );
232239 long time = System .currentTimeMillis ();
233240 System .out .println ("Running LTSmin : " + ltsmin );
234241 int status = Runner .runTool (timeout , ltsmin , outputff , true );
@@ -276,6 +283,7 @@ private void checkProperty(String pname, String pbody, long timeout, boolean neg
276283 }
277284 }
278285 }
286+ if (DEBUG >= 1 ) System .out .println ("Property " + pname + " result: " + result );
279287 String ress = (result + "" ).toUpperCase ();
280288 doneProps .put (pname ,"TRUE" .equals (ress ),(withPOR ? "PARTIAL_ORDER " :"" ) + "EXPLICIT LTSMIN SAT_SMT" );
281289 System .out .flush ();
@@ -289,7 +297,7 @@ private boolean isStutterInvariant(String pbody) {
289297 return pbody ==null || pbody .contains (".hoa" ) || ! pbody .contains ("X" );
290298 }
291299
292- private void compilePINS (int timeout ) throws IOException , TimeoutException , InterruptedException {
300+ private void compilePINS (int timeout , List < File > todel ) throws IOException , TimeoutException , InterruptedException {
293301 // compile
294302 long time = System .currentTimeMillis ();
295303 CommandLine clgcc = new CommandLine ();
@@ -309,8 +317,7 @@ private void compilePINS(int timeout) throws IOException, TimeoutException, Inte
309317
310318 System .out .println ("Running compilation step : " + clgcc );
311319 File outputff = Files .createTempFile ("gccrun" , ".out" ).toFile ();
312- outputff .deleteOnExit ();
313- new File (workFolder +"/model.o" ).deleteOnExit ();
320+ todel .add (outputff );
314321 int status = Runner .runTool (timeout , clgcc , outputff , true );
315322 if (status != 0 ) {
316323 Files .lines (outputff .toPath ()).forEach (l -> System .err .println (l ));
@@ -320,7 +327,7 @@ private void compilePINS(int timeout) throws IOException, TimeoutException, Inte
320327 System .out .flush ();
321328 }
322329
323- private void linkPINS (long timeLimit ) throws IOException , TimeoutException , InterruptedException {
330+ private void linkPINS (long timeLimit , List < File > todel ) throws IOException , TimeoutException , InterruptedException {
324331 // link
325332 long time = System .currentTimeMillis ();
326333 CommandLine clgcc = new CommandLine ();
@@ -333,8 +340,7 @@ private void linkPINS(long timeLimit) throws IOException, TimeoutException, Inte
333340 clgcc .addArg ("model.o" );
334341 System .out .println ("Running link step : " + clgcc );
335342 File outputff = Files .createTempFile ("linkrun" , ".out" ).toFile ();
336- outputff .deleteOnExit ();
337- new File (workFolder +"/gal.so" ).deleteOnExit ();
343+ todel .add (outputff );
338344 int status = Runner .runTool (timeout , clgcc , outputff , true );
339345 if (status != 0 ) {
340346 Files .lines (outputff .toPath ()).forEach (l -> System .err .println (l ));
0 commit comments