lbttparse.test 3.88 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
  head -n 1 out | grep t
  run 0 ../../bin/autfilt --lbtt out > out2
32
33
34
35
36
  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.
37
38
  run 0 ../../bin/ltl2tgba "$f" --stats 'expr %s \* 2 + %e + 1' > size
  l=$(eval "$(cat size)")
39
  test "$s" -eq "$l"
40

41
42
43
44
45
46
  # 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"
47
48
  run 0 ../../bin/autfilt --lbtt out4 > out5
  run 0 ../../bin/autfilt out4 --are-isomorphic out5
49
50
51
52
53
  # ... 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"
54
55
  run 0 ../../bin/autfilt --lbtt out6 > out7
  run 0 ../../bin/autfilt out6 --are-isomorphic out7
56
done
57

58
59
60
61
62

# multiple inputs (from different tools)

cat >input <<EOF
/* This is the output of 'lbt' on the formula 'U p0 p1'. */
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
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
78
79
/* This kind of output is returned by wring2lbtt, on the same formula.
   (Newer versions of LBTT reject this input with missing new lines.) */
80
81
82
83
84
85
86
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
87
88
89
90
91
92
/* 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. */
93
94
95
96
97
98
99
100
101
102
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
103
104
105
106
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
/* 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
145
146
EOF

147
148
149
150
151
152
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
153
154
155
1 2 2 1
4 16 6 1
4 16 6 1
156
157
158
EOF

diff output expected
159
160
161
162
163
164
165
166
167
168
169

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
170
input:3.5-20: failed to parse guard:  & ! "a" ! "b" !
171
172
173
174
175
176
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