hoaparse.test 11.9 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/sh
# -*- coding: utf-8 -*-
# Copyright (C) 2014 Laboratoire de Recherche et Développement de
# l'Epita (LRDE).
#
# 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

expecterr()
{
   cat >$1.exp
29
   ../../bin/autfilt --hoa $1 2>$1.err >$1.out && exit 1
30
31
32
33
34
   test $? = 2
   cat $1.err
   diff $1.err $1.exp
}

35
36
37
38
39
40
41
42
43
expectok()
{
   cat >$1.exp
   ../../bin/autfilt --hoa $1 >$1.out
   test $? = 0
   cat $1.out
   diff $1.out $1.exp
}

44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87

cat >input <<EOF
HOA: v1
States: 1
Start: 0
AP: 1 "a"
States: 2
Acceptance: 1 Inf(0)
--BODY--
State: 0 {0}
[0] 1
State: 1 {0}
[t] 1
--END--
EOF

expecterr input <<EOF
input:5.1-9: redefinition of the number of states...
input:2.1-9: ... previously defined here.
EOF

cat >input <<EOF
HOA: v1
States: 1
Start: 0
AP: 1 "a"
Acceptance: 1 Inf(0)
--BODY--
State: 0 {0}
[0] 1
State: 1 {0}
[t] 1
--END--
EOF

expecterr input <<EOF
input:8.5: state number is larger than state count...
input:2.1-9: ... declared here.
input:9.8: state number is larger than state count...
input:2.1-9: ... declared here.
input:10.5: state number is larger than state count...
input:2.1-9: ... declared here.
EOF

88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
cat >input <<EOF
HOA: v1
States: 1
Start: 0
AP: 1 "a"
Acceptance: 1 Inf(0)
--BODY--
State: 0 {0}
[0] 0
State: 0 {0}
[t] 0
--END--
EOF

expecterr input <<EOF
input:9.1-8: redeclaration of state 0
EOF

106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
cat >input <<EOF
HOA: v1
States: 0
AP: 1 "a" "b"
Acceptance: 0 t
--BODY--
--END--
EOF

expecterr input <<EOF
input:3.1-13: found 2 atomic propositions instead of the 1 announced
EOF

cat >input <<EOF
HOA: v1
AP: 1 "a"
States: 0
AP: 2 "a" "b"
Acceptance: 0 t
--BODY--
--END--
EOF

expecterr input <<EOF
130
131
input:4.1-3: ignoring this redeclaration of APs...
input:2.1-5: ... previously declared here.
132
133
134
135
136
137
138
139
EOF

cat >input <<EOF
HOA: v1
AP: 1 "a"
States: 0
Start: 1
--BODY--
140
141
State: 0 {0 1}
[0] 0 {0}
142
143
144
145
--END--
EOF

expecterr input <<EOF
146
input:4.1-8: initial state number is larger than state count...
147
148
input:3.1-9: ... declared here.
input:1.1-4.8: missing 'Acceptance:' header
149
150
151
152
153
input:6.8: state number is larger than state count...
input:3.1-9: ... declared here.
input:6.10-14: ignoring acceptance sets because of missing acceptance condition
input:7.5: state number is larger than state count...
input:3.1-9: ... declared here.
154
155
156
157
158
EOF

cat >input <<EOF
HOA: v1
AP: 1 "a"
159
160
Start: 1
States: 1
161
162
163
164
165
166
167
--BODY--
--END--
EOF

expecterr input <<EOF
input:3.1-8: initial state number is larger than state count...
input:4.1-9: ... declared here.
168
input:1.1-4.9: missing 'Acceptance:' header
169
170
171
172
173
174
175
176
177
178
179
180
181
EOF

cat >input <<EOF
HOA: v1
Acceptance: 1 Inf(0)
Start: 0
States: 1
Acceptance: 1 Inf(0)
--BODY--
--END--
EOF

expecterr input <<EOF
182
input:5.1-13: ignoring this redefinition of the acceptance condition...
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
input:2.1-13: ... previously defined here.
EOF

cat >input <<EOF
HOA: v1
Start: 0
AP: 1 "a"
States: 2
Acceptance: 1 Inf(0)
--BODY--
State: 0 {0}
[0] 1
State: 1 {1}
[t] 1
--END--
EOF

expecterr input <<EOF
input:9.11: number is larger than the count of acceptance sets...
input:5.1-13: ... declared here.
EOF

205
# Let's have two broken automata in a row...
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
cat >input <<EOF
HOA: v1
Start: 0
AP: 1 "a"
States: 2
Acceptance: 1 Inf(2)
--BODY--
State: 0 {0}
[0] 1
State: 1 {0}
[t] 1
--END--
HOA: v2
--BODY--
--END--
EOF

expecterr input <<EOF
224
225
input:5.19: number is larger than the count of acceptance sets...
input:5.1-13: ... declared here.
226
input:12.6-7: unsupported version of the HOA format
227
input:12.1-7: missing 'Acceptance:' header
228
EOF
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302

cat >input<<EOF
    HOA: v1
    States: 3
    Start: 0
    acc-name: generalized-Buchi 2
    Acceptance: 2 (Inf(0) & Inf(1))
    AP: 2 "a" "b"
    --BODY--
    State: 0 "foo" { 0 }
      2  /* !a  & !b */
      0  /*  a  & !b */
      1  /* !a  &  b */
      1  /*  a  &  b */
    State: 1 { 1 }
      1 1 1 1       /* four transitions on one line */
    State: 2 "sink state" { 0 }
      2 2 2 2
    --END--
EOF

expectok input <<EOF
HOA: v1
States: 3
Start: 0
AP: 2 "a" "b"
acc-name: generalized-Buchi 2
Acceptance: 2 Inf(0)&Inf(1)
properties: trans-labels explicit-labels state-acc complete deterministic
--BODY--
State: 0 {0}
[!0&!1] 1
[0&!1] 0
[!0&1] 2
[0&1] 2
State: 1 {0}
[!0&!1] 1
[0&!1] 1
[!0&1] 1
[0&1] 1
State: 2 {1}
[!0&!1] 2
[0&!1] 2
[!0&1] 2
[0&1] 2
--END--
EOF

cat >input<<EOF
    HOA: v1
    States: 3
    Start: 0
    acc-name: generalized-Buchi 2
    Acceptance: 2 (Inf(0) & Inf(1))
    AP: 2 "a" "b"
    --BODY--
    State: 0 "foo" { 0 }
      2  /* !a  & !b */
      0  /*  a  & !b */
      1  /* !a  &  b */
      /* missing transition */
    State: 1 { 1 }
      1 1 1 1       /* four transitions on one line */
    State: 2 "sink state" { 0 }
      2 2 2 2
    --END--
EOF

expecterr input <<EOF
input:8.5-11.7: not enough transitions for this state
EOF

cat >input<<EOF
    HOA: v1
303
    tool: "test"
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
    States: 3
    Start: 0
    acc-name: generalized-Buchi 2
    Acceptance: 2 (Inf(0) & Inf(1))
    AP: 2 "a" "b"
    --BODY--
    State: 0 "foo" { 0 }
      2  /* !a  & !b */
      0  /*  a  & !b */
      1  /* !a  &  b */
      1  /*  a  &  b */
      2  /*  extra transition ! */
    State: 1 { 1 }
      1 1 1 1       /* four transitions on one line */
    State: 2 "sink state" { 0 }
      2 2 2 2
    --END--
EOF

expecterr input <<EOF
324
input:14.7: too many transition for this state, ignoring this one
325
EOF
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359


cat >input <<EOF
    HOA: v1
    name: "GFa & GF(b & c)"
    States: 1
    Start: 0
    acc-name: generalized-Buchi 2
    Acceptance: 2 (Inf(0) & Inf(1))
    AP: 3 "a" "b" "c"
    Alias: @a 0
    Alias: @a 1 & 2 /* should be @bc */
    --BODY--
    State: 0
    [!@a & !@bc] 0
    [@a & !@bc]  0 {0}
    [!@a & @bc]  0 {1}
    [@a & @bc]   0 {0 1}
    --END--
EOF

expecterr input <<EOF
input:9.5-19: ignoring redefinition of alias @a
input:12.13-15: unknown alias @bc
input:13.12-14: unknown alias @bc
input:14.12-14: unknown alias @bc
input:15.11-13: unknown alias @bc
EOF

cat >input <<EOF
    HOA: v1
    name: "GFa & GF(b & c)"
    States: 1
    Start: 0
360
    acc-name: who cares
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
    Acceptance: 2 (Inf(0) & Inf(1))
    AP: 3 "a" "b" "c"
    Alias: @a 0
    Alias: @bc 1 & 2
    --BODY--
    State: 0
    [!@a & !@bc] 0
    [@a & !@bc]  0 {0}
    [!@a & @bc]  0 {1}
    [@a & @bc]   0 {0 1}
    --END--
EOF

expectok input <<EOF
HOA: v1
States: 1
Start: 0
AP: 3 "a" "b" "c"
acc-name: generalized-Buchi 2
Acceptance: 2 Inf(0)&Inf(1)
properties: trans-labels explicit-labels trans-acc complete deterministic
--BODY--
State: 0
[!0&!1 | !0&!2] 0
[0&!1 | 0&!2] 0 {0}
[!0&1&2] 0 {1}
[0&1&2] 0 {0 1}
--END--
EOF
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
390
391
392
393


cat >input <<EOF
HOA: v1
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
--ABORT--
HOA: v1
States: 2
Start: 0
Acceptance: 2 (Inf(0) & Inf(!0)) &
     --ABORT----ABORT--
HOA: v1
States: 2
Start: 0
Acceptance: 2 (Inf(0) & Inf(!0)) & Inf(!1)
AP: 1 "a"
     --BODY-- State: 0 {0
}
[0] 1
[!0--ABORT--
HOA: v1
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
410
411
412
413
414
415
416
417
418
419
420
States: 2
Start: 0
Acceptance: 2 (Inf(0) & Inf(!0)) & Inf(!1)
AP: 1 "a"
--BODY--
State: 0 {0}
[0] 1
[!0] 0 {1}
State: 1
[!0] 1
[0] 0
421
[f] 0
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
422
423
424
--END--
EOF

425
426
427
428
429
430
431
432
expecterr input <<EOF
input:1.1-2.9: aborted input automaton
input:3.1-7.14: aborted input automaton
input:7.15-23: aborted input automaton
input:8.1-16.12: aborted input automaton
EOF

cat >expected <<EOF
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
HOA: v1
States: 2
Start: 0
AP: 1 "a"
acc-name: generalized-Buchi 3
Acceptance: 3 Inf(0)&Inf(1)&Inf(2)
properties: trans-labels explicit-labels trans-acc complete deterministic
--BODY--
State: 0
[0] 1 {0 1}
[!0] 0 {0}
State: 1
[!0] 1 {1 2}
[0] 0 {1 2}
--END--
EOF
449
450

diff expected input.out
451
452
453
454
455
456
457
458


cat >input <<EOF
HOA: v1
States: 2
Start: 0
Start: 1
Start: 0 /* duplicate */
459
AP: 2 "a" "\"b\""
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
Acceptance: 1 Inf(0)
--BODY--
State: 0 {0}
[1] 1
[!1] 0
State: 1
[!0] 1
[0] 0
--END--
EOF

expectok input <<EOF
HOA: v1
States: 3
Start: 0
475
AP: 2 "a" "\"b\""
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels state-acc complete
--BODY--
State: 0
[1] 1
[!1] 2
[!0] 1
[0] 2
State: 1
[!0] 1
[0] 2
State: 2 {0}
[1] 1
[!1] 2
--END--
EOF

cat >input <<EOF
HOA: v1
States: 2
Start: 0
Start: 0  /* duplicate */
AP: 2 "a" "b"
Acceptance: 1 Inf(0)
--BODY--
State: 0 {0}
[1] 1
504
[!1] 0  /* nested /* comment */ */
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
State: 1
[!0] 1
[0] 0
--END--
EOF

expectok input <<EOF
HOA: v1
States: 2
Start: 0
AP: 2 "a" "b"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels state-acc complete deterministic
--BODY--
State: 0 {0}
[1] 1
[!1] 0
State: 1
[!0] 1
[0] 0
--END--
EOF
528

529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
cat >input <<EOF
HOA: v1
States: 3
Start: 0
AP: 2 "a" "b"
Acceptance: 1 Inf(0)
--BODY--
State: [1] 0 {0}
[!1] 0
 1
State: 1
[!0] 1
     2
State: 2
     1
[t] 2
   1 2
--END--
EOF

expecterr input <<EOF
input:8.1-4: cannot label this edge because...
input:7.8-10: ... the state is already labeled.
input:12.6: missing label for this edge (previous edge is labeled)
input:15.1-3: ignoring this label, because previous edge has no label
EOF

556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591

cat >input <<EOF
HOA: v1
States: 2
Start: 0
Important: 4 very important "!"
AP: 0
Acceptance: 1 Inf(0)
--BODY--
State: 0 {0} 1
State: 1 0
--END--
EOF

expecterr input <<EOF
input:4.1-31: ignoring unsupported header "Important:"
	(but the capital indicates information that should not be ignored)
EOF

cat >expected <<EOF
HOA: v1
States: 2
Start: 0
AP: 0
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels state-acc complete deterministic
--BODY--
State: 0 {0}
[t] 1
State: 1
[t] 0
--END--
EOF

diff expected input.out
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649


# Error recovery

cat >input <<EOF
HOA: v1
States: 2
Start: 0
AP: 0
acc-name: Buchi
Acceptance: 1 Inf(0)
--BODY--
State: 0 {a}  /* not a digit */
[t] 1
State: 1
[a] 0         /* not a digit */
--END--
HOA: v1
Acceptance: 1 Inf(0)
States: 2
Start: 0
AP: 0
acc-name: Buchi
--BODY--
State: 0 {0}
[t] "f" 1     /* WTF? */
State: 1
[t] 0
--END--
some garbage HOA: v1
Acceptance: 1 Inf(0)
States: 2
Start: 0
AP: 0
acc-name: Buchi
--BODY--
Stat: 0 {0}  /* not State: */
[t] 1
State: 1
[t] 0
--END--
this is complete garbage!
--END--
and even more garbage
EOF

expecterr input <<EOF
input:8.11: syntax error, unexpected identifier, expecting integer or '}'
input:8.10-12: ignoring this invalid acceptance set
input:11.2: syntax error, unexpected identifier
input:11.1-3: ignoring this invalid label
input:21.5-7: syntax error, unexpected string, expecting integer
input:25.1-4: syntax error, unexpected identifier, expecting end of file or HOA:
input:25.1-12: ignoring leading garbage
input:32.1-5: syntax error, unexpected header name, expecting --END-- or State:
input:37.1-4: syntax error, unexpected identifier, expecting end of file or HOA:
input:39.1-3: syntax error, unexpected identifier, expecting end of file or HOA:
EOF
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719

# A comment can contain --BODY-- or --END--, so we do not want to be
# smart about it.
cat >input <<EOF
HOA: v1
States: 2
Start: 0
AP: 0
acc-name: Buchi /* unclosed comment
Acceptance: 1 Inf(0)
--BODY--
State: 0 {0}
[t] 1
State: 1
[t] 0
--END--
HOA: v1
States: 2
Start: 0
AP: 0
acc-name: Buchi
Acceptance: 1 Inf(0)
--BODY--
State: 0 {0}
[t] 1
State: 1
[t] 0
--END--
EOF

expecterr input <<EOF
input:5.17-25.1: unclosed comment
input:5.17-25.1: syntax error, unexpected end of file
autfilt: failed to read automaton from input
EOF

# Likewise for strings
cat >input <<EOF
HOA: v1
States: 2
Start: 0
tool: "unterminated string
AP: 0
acc-name: Buchi
Acceptance: 1 Inf(0)
--BODY--
State: 0 {0}
[t] 1
State: 1
[t] 0
--END--
HOA: v1
States: 2
Start: 0
AP: 0
acc-name: Buchi
Acceptance: 1 Inf(0)
--BODY--
State: 0 {0}
[t] 1
State: 1
[t] 0
--END--
EOF

expecterr input <<EOF
input:4.7-242: unclosed string
input:4.7-242: syntax error, unexpected end of file, expecting string
autfilt: failed to read automaton from input
EOF
720
721
722
723

expecterr non-existant<<EOF
autfilt: Cannot open file non-existant
EOF