lbttparse.test 4 KB
Newer Older
1
2
#!/bin/sh
# -*- coding: utf-8 -*-
3
4
# Copyright (C) 2012, 2013, 2014, 2015 Laboratoire de Recherche et
# Développement de l'Epita (LRDE).
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#
# This file is part of Spot, a model checking library.
#
# Spot is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Spot is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
# License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

. ./defs

set -e

for f in 'p0 U p1 U p2' 'Gp00 | Gp13 | Gp42' '{(1;1)*}[]->p1'
do
  # Make sure Spot can read the LBTT it produces
28
  run 0 ../../bin/ltl2tgba --lbtt "$f" > out
29
  s=`wc -l < out`
30
31
32
33
34
  if ../../bin/ltl2tgba -H "$f" | grep 'properties:.*state-acc'; then
      head -n 1 out | grep t && exit 1
  else
      head -n 1 out | grep t
  fi
35
  run 0 ../../bin/autfilt --lbtt out > out2
36
37
38
39
40
  s2=`wc -l < out2`
  test "$s" -eq "$s2"

  # The LBTT output use 2 lines par state, one line per transition,
  # and one extra line for header.
41
42
  run 0 ../../bin/ltl2tgba "$f" --stats 'expr %s \* 2 + %e + 1' > size
  l=$(eval "$(cat size)")
43
  test "$s" -eq "$l"
44

45
46
47
48
49
50
  # Make sure we output the state-based format
  # for BA...
  run 0 ../../bin/ltl2tgba --ba --lbtt --low --any "$f" >out4
  head -n 1 out4 | grep t && exit 1
  s4=`wc -l < out4`
  test "$s" -eq "$s4"
51
52
  run 0 ../../bin/autfilt --lbtt out4 > out5
  run 0 ../../bin/autfilt out4 --are-isomorphic out5
53
54
55
56
57
  # ... unless --lbtt=t is used.
  run 0 ../../bin/ltl2tgba --ba --lbtt=t --low --any "$f" >out6
  head -n 1 out6 | grep t
  s6=`wc -l < out6`
  test "$s" -eq "$s6"
58
59
  run 0 ../../bin/autfilt --lbtt out6 > out7
  run 0 ../../bin/autfilt out6 --are-isomorphic out7
60
done
61

62
63
64
65
66

# multiple inputs (from different tools)

cat >input <<EOF
/* This is the output of 'lbt' on the formula 'U p0 p1'. */
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
4 1
0 1 -1
1 p0
2 p1
-1
1 0 -1
1 p0
2 p1
-1
2 0 0 -1
3 t
-1
3 0 0 -1
3 t
-1
82
83
/* This kind of output is returned by wring2lbtt, on the same formula.
   (Newer versions of LBTT reject this input with missing new lines.) */
84
85
86
87
88
89
90
4 1 0 1 -1 1 p0
2 p1
-1 1 0 -1 1 p0
2 p1
-1 2 0 0 -1 3 t
-1 3 0 0 -1 3 t
-1
91
92
93
94
95
96
/* This is an automaton without state and three acceptance sets.
   Spot is not able to deal with automata that do not have initial
   state, so it will add a dummy state. */
0 3
/* Another example from wring2lbtt (or modella), showing that the
   acceptance set of the states is not always numbered from 0. */
97
98
99
100
101
102
103
104
105
106
6 1 0 1 -1 1 | & ! p0 ! p1 & p0 ! p1
2 & ! p0 ! p1
3 | & p0 p1 & ! p0 p1
-1 1 0 -1 4 ! p1
-1 2 0 -1 2 & ! p0 ! p1
3 | & p0 p1 & ! p0 p1
-1 3 0 -1 5 t
-1 4 0 1 -1 4 ! p1
-1 5 0 1 -1 5 t
-1
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/* this one show that state numbers do not always start from 0 */
1 1t
1 1
1 -1 !p0
1 0 -1 p0
-1
/* This is the output of 'lbt' on the formula 'U p0 p1', but with
   states 1 and 2 changed to 100 and 200 */
4 1
0 1 -1
100 p0
200 p1
-1
100 0 -1
100 p0
200 p1
-1
200 0 0 -1
3 t
-1
3 0 0 -1
3 t
-1
/* This is the output of 'lbt' on the formula 'U p0 p1', but with
   states 0 and 2 changed to 100 and 200.  This make sure the renaming
   also applies to the initial state.
 */
4 1
100 1 -1
1 p0
200 p1
-1
1 0 -1
1 p0
200 p1
-1
200 0 0 -1
3 t
-1
3 0 0 -1
3 t
-1
149
150
EOF

151
152
153
154
155
156
run 0 ../../bin/autfilt --stats '%s %t %e %a' input > output
cat >expected<<EOF
4 16 6 1
4 16 6 1
1 0 0 3
6 20 9 1
157
158
159
1 2 2 1
4 16 6 1
4 16 6 1
160
161
162
EOF

diff output expected
163
164
165
166
167
168
169
170
171
172
173

cat > input <<EOF
1 2t
0 1
0 -1 & ! "a" ! "b" !
0 0 -1 & "a" ! "b" /* comments are OK */
0 1 -1 & ! "a" /* here too */ "b"
0 0 1 -1 & "a" "b"
-1
EOF
cat >expected <<EOF
174
input:3.5-20: failed to parse guard:  & ! "a" ! "b" !
175
176
177
178
179
180
input:3.20: syntax error, unexpected '!', expecting end of formula
input:3.20: ignoring trailing garbage
EOF
../../bin/autfilt -q input 2> stderr && exit 1
cat stderr
diff stderr expected