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

randaut=../../bin/randaut
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
26
autfilt=../../bin/autfilt
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
27

28
$randaut --spin -Q4 a b | ../ltl2tgba -H -XN - >out
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
29
30
31
32
33
grep 'States: 4' out
grep 'AP: 2' out
grep 'state-acc' out
grep 'Acceptance: 1' out

34
$randaut -n 3 --hoa -Q5..9 -A1..3 3 >out
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
test `grep -c 'States: [5-9]$' out` = 3
test `grep -c 'Acceptance: [1-3] ' out` = 3
test `grep -c 'AP: 3 ' out` = 3


$randaut --spin -A2 3 2>stderr && exit 1
grep 'spin.*incompatible' stderr

$randaut --spin -A0 3  # should work

$randaut --ba -A2 3 2>stderr && exit 1
grep 'ba.*incompatible' stderr

$randaut --ba -A0 3 2>stderr && exit 1
grep 'ba.*incompatible' stderr
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
50
51
52
53
54

$randaut --states 10..20 2 -n 100 -H > aut.hoa
a=`$autfilt --states=..14 -c <aut.hoa`
b=`$autfilt aut.hoa --states=15.. -c`
test `expr $a + $b` = 100
55
56
57
58
59
60

# The count of SCCs and edges might change if the
# algorithm or its default values are changed.  Do
# not hesitate to adjust the expected values below.
$randaut -n 5 --name='%F-%L-%s-%c-%e' -H a | grep '^name' >out
cat >expected<<EOF
61
name: "0-0-10-1-30"
62
63
64
65
name: "0-1-10-1-29"
name: "0-2-10-3-22"
name: "0-3-10-1-30"
name: "0-4-10-1-27"
66
67
68
69
70
EOF
diff out expected

$randaut -n 5 --stats='name: "%F-%L-%s-%c-%e"' a >out2
diff out2 expected
71
72
73

$randaut -n 5 --dot=@ a 2>stderr && exit 1
grep 'randaut: unknown option.*@' stderr
74

75
76
$randaut -n -1 -Q2 2 -H | $autfilt -H --is-deterministic -n 3 -o out.hoa
$randaut -n -1 -Q2 2 -H | $autfilt -H -v --is-deterministic -n 4 -o '>>out.hoa'
77
78
79
80
81
82
83
$autfilt -H out.hoa -o 'out-det%d.hoa'
$autfilt -H out.hoa -o '>>out-det%d.hoa'
test 8 = `$autfilt -c out-det0.hoa`
test 6 = `$autfilt -c out-det1.hoa`

$autfilt -H out.hoa -o foo -c 2>stderr && exit 1
grep 'autfilt: options --output and --count are incompatible' stderr
84

85
(
86
87
88
89
    $randaut -n 2 -Q5 -A4 -H 2
    $randaut -A 'random 4' -n 2 -Q5 -H 2
    $randaut -A 'parity rand rand 2..4' -n3 -Q5 -H 2
    $randaut -A 'generalized-Rabin 3 1..2 2..3 0' -n3 -Q5 -H 2
90
) | grep -E '(acc-name:|Acceptance:)' > output
91
92
cat output

93
a=Acceptance
94
cat >expected <<EOF
95
96
97
98
99
acc-name: generalized-Buchi 4
$a: 4 Inf(0)&Inf(1)&Inf(2)&Inf(3)
acc-name: generalized-Buchi 4
$a: 4 Inf(0)&Inf(1)&Inf(2)&Inf(3)
$a: 4 Fin(1) | (Fin(2) & Fin(3) & Fin(0))
100
$a: 4 (Fin(0) & Fin(3)) | (Fin(2) & Inf(1))
101
102
acc-name: parity min even 4
$a: 4 Inf(0) | (Fin(1) & (Inf(2) | Fin(3)))
103
104
105
106
107
108
109
110
acc-name: parity max even 2
$a: 2 Fin(1) & Inf(0)
acc-name: parity max odd 4
$a: 4 Inf(3) | (Fin(2) & (Inf(1) | Fin(0)))
acc-name: generalized-Rabin 3 2 3 0
$a: 8 (Fin(0) & (Inf(1)&Inf(2))) | (Fin(3) & (Inf(4)&Inf(5)&Inf(6))) | Fin(7)
acc-name: generalized-Rabin 3 2 2 0
$a: 7 (Fin(0) & (Inf(1)&Inf(2))) | (Fin(3) & (Inf(4)&Inf(5))) | Fin(6)
111
112
acc-name: generalized-Rabin 3 2 3 0
$a: 8 (Fin(0) & (Inf(1)&Inf(2))) | (Fin(3) & (Inf(4)&Inf(5)&Inf(6))) | Fin(7)
113
114
115
EOF
diff output expected

116
117
118
119
120
121
122
123
124
$randaut --spin -A 'random 2' 2 2>stderr && exit 1
grep 'randaut: --spin.*--acceptance' stderr
$randaut --ba --acceptance='random 2' 2 2>stderr && exit 1
grep 'randaut: --acceptance.*--ba' stderr

$randaut -n 10 2..4 -H | grep AP: > output
cat output
cat >expected <<EOF
AP: 3 "p0" "p1" "p2"
125
AP: 4 "p0" "p1" "p2" "p3"
126
AP: 3 "p0" "p1" "p2"
127
AP: 4 "p0" "p1" "p2" "p3"
128
129
130
131
132
AP: 3 "p0" "p1" "p2"
AP: 4 "p0" "p1" "p2" "p3"
AP: 2 "p0" "p1"
AP: 3 "p0" "p1" "p2"
AP: 2 "p0" "p1"
133
AP: 3 "p0" "p1" "p2"
134
135
EOF
diff output expected
136
137
138
139
140
141
142
143
144
145
146
147

$randaut -A3 --colored 2 -H | grep 'properties:.*colored'
$randaut -S -A'parity min even 3' --colored 2 -H | grep 'properties:.*colored'

$randaut --colored 2 2>stderr && exit 1
grep 'randaut: --colored requires' stderr
$randaut -A0..2 --colored 2 2>stderr && exit 1
grep 'randaut: --colored requires' stderr
$randaut -S -A'parity min even 0..3' -q -n10 --colored 2 2>stderr && exit 1
grep 'randaut: --colored requires' stderr

: