|
1 | | -# tool |
| 1 | +# tool |
2 | 2 |
|
3 | 3 | TOOL_BINARY=./2ls-binary |
4 | 4 | TOOL_NAME=2LS |
5 | 5 |
|
6 | 6 | # function to run the tool |
7 | 7 |
|
8 | | -run() |
| 8 | +run() |
9 | 9 | { |
10 | 10 | # add property-specific options |
11 | 11 | if [[ "$PROP" == "termination" ]]; then |
12 | | - PROPERTY="$PROPERTY --termination --competition-mode" |
| 12 | + PROPERTY1="$PROPERTY --termination --competition-mode" |
13 | 13 | PROPERTY2="$PROPERTY --nontermination --competition-mode" |
14 | | - |
| 14 | + |
15 | 15 | # run the termination and nontermination analysis in parallel |
16 | | - $TOOL_BINARY --graphml-witness $LOG.witness $BIT_WIDTH $PROPERTY \ |
17 | | - --function $ENTRY $BM >> $LOG.ok 2>&1 & |
| 16 | + $TOOL_BINARY --graphml-witness $LOG.witness $BIT_WIDTH $PROPERTY1 \ |
| 17 | + --function $ENTRY $BM >> $LOG.ok1 2>&1 & |
| 18 | + PID1="$!" |
18 | 19 | $TOOL_BINARY --graphml-witness $LOG.witness $BIT_WIDTH $PROPERTY2 \ |
19 | | - --function $ENTRY $BM >> $LOG.ok 2>&1 & |
20 | | - wait -n |
21 | | - |
| 20 | + --function $ENTRY $BM >> $LOG.ok2 2>&1 & |
| 21 | + PID2="$!" |
| 22 | + # this might not work in all environments |
| 23 | + wait -n &> /dev/null |
| 24 | + |
22 | 25 | # store the exit code of the first process that is finished |
23 | 26 | EC=$? |
24 | | - |
25 | | - # if the result of termination analysis is unknown, |
26 | | - # wait for the most recently executed background process, |
27 | | - # which is nontermination analysis |
28 | | - if [$EC -eq 5]; then |
29 | | - wait $! |
| 27 | + |
| 28 | + # find out which one has finished |
| 29 | + for pid in $PID1 $PID2 |
| 30 | + do |
| 31 | + if ! ps -p $pid &> /dev/null; then |
| 32 | + EXITED=$pid |
| 33 | + break |
| 34 | + fi |
| 35 | + done |
| 36 | + |
| 37 | + # if the result of the first exiting analysis is inconclusive |
| 38 | + # then wait for the other analysis to finish |
| 39 | + if [ $EC -eq 5 ]; then |
| 40 | + wait -n &> /dev/null |
30 | 41 | EC=$? |
| 42 | + if [[ "$EXITED" == "$PID1" ]]; then |
| 43 | + mv $LOG.ok2 $LOG.ok |
| 44 | + else |
| 45 | + mv $LOG.ok1 $LOG.ok |
| 46 | + fi |
| 47 | + else # we have a conclusive result, kill the other process |
| 48 | + if [[ "$EXITED" == "$PID1" ]]; then |
| 49 | + kill -9 $PID2 &> /dev/null |
| 50 | + mv $LOG.ok1 $LOG.ok |
| 51 | + else |
| 52 | + kill -9 $PID1 &> /dev/null |
| 53 | + mv $LOG.ok2 $LOG.ok |
| 54 | + fi |
31 | 55 | fi |
32 | 56 | else |
33 | 57 | PROPERTY="$PROPERTY --k-induction --competition-mode" |
34 | | - |
| 58 | + |
35 | 59 | # run the tool |
36 | 60 | $TOOL_BINARY --graphml-witness $LOG.witness $BIT_WIDTH $PROPERTY \ |
37 | 61 | --function $ENTRY $BM >> $LOG.ok 2>&1 |
38 | | - |
| 62 | + |
39 | 63 | # store the exit code |
40 | 64 | EC=$? |
41 | 65 | fi |
|
0 commit comments