ltldo.test 4.47 KB
Newer Older
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
1 2
#!/bin/sh
# -*- coding: utf-8 -*-
3 4
# Copyright (C) 2015-2017 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
#
# 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

24 25 26
ltldo=ltldo
ltl2tgba=ltl2tgba
genltl=genltl
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
27

28
run 0 $ltldo -f a -f 'a&b' -f 'a -> b' -t 'echo %f,%s,%[ei]w' >output
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
29
cat >expected <<EOF
30 31 32
a,a,a=1
(a) & (b),(a) && (b),(a=1) * (b=1)
(a) -> (b),(a) -> (b),(a=0) + (b=1)
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
33 34 35
EOF
diff output expected

36 37 38
# Renaming
run 0 $ltldo -f a -f 'a&_b' -t 'echo %f,%s' >output
cat >expected <<EOF
39
a,a
40 41 42 43
(p0) & (p1),(p0) && (p1)
EOF
diff output expected

Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
44

45
# Test timeouts.  Each of these runs should take 2*2 seconds.
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
46
$genltl --or-g=1..2 |
47
run 0 $ltldo -t 'sleep 10; echo %f' -T1 -t 'sleep 10; echo %f' \
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
48 49 50 51
	     >output 2>stderr
test -z "`cat output`"
test 4 = `grep -c warning: stderr`

52 53 54 55 56 57 58 59 60 61 62 63 64 65
genltl --or-g=1..2 |
run 0 ltldo -t 'sleep 10; echo %f' -T1 -t 'sleep 10; echo %f' \
	     --fail-on-timeout --error=warn >output 2>stderr
test -z "`cat output`"
test 4 = `grep -c error: stderr`
grep -q 'aborting here' stderr && exit 1

genltl --or-g=1..2 |
run 2 ltldo -t 'sleep 10; echo %f' -T1 -t 'sleep 10; echo %f' \
	     --fail-on-timeout >output 2>stderr
test -z "`cat output`"
test 1 = `grep -c error: stderr`
grep -q 'aborting here' stderr

66 67
test "`echo 1,a,3,4 | ltldo -F-/2 ltl2tgba --stats='%<,%s,%>'`" = '1,2,3,4'

Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
68 69
$genltl --and-gf=1..3 |
run 0 $ltldo "{tgba}$ltl2tgba %f -H >%H" "{ba}$ltl2tgba >%N %f -s" \
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
70
	     --stats="%T,%#,%f,%s,%t,%e" >output
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
71 72
cat output
cat >expected <<EOF
73 74 75 76 77 78
tgba,1,GFp1,1,2,2
ba,1,GFp1,2,4,4
tgba,2,GFp1 & GFp2,1,4,4
ba,2,GFp1 & GFp2,3,12,8
tgba,3,GFp1 & GFp2 & GFp3,1,8,8
ba,3,GFp1 & GFp2 & GFp3,4,32,13
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
79
EOF
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
diff output expected

# Renaming
run 0 $ltldo "$ltl2tgba -H %s>%H" -f GF_foo_ -H >output
cat output
# The HOA output uses _foo_ as atomic proposition, but the name shows
# that GFp0 was actually given to ltl2tgba.
cat >expected <<EOF
HOA: v1
name: "GFp0"
States: 1
Start: 0
AP: 1 "_foo_"
acc-name: Buchi
Acceptance: 1 Inf(0)
95
properties: trans-labels explicit-labels trans-acc complete
96
properties: deterministic stutter-invariant
97 98 99
--BODY--
State: 0
[!0] 0
100
[0] 0 {0}
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
--END--
EOF
diff output expected

# But we can force the name in the output:
run 0 $ltldo "$ltl2tgba -H %s>%H" -f GF_foo_ -H --name=%f >output
cat output
cat >expected <<EOF
HOA: v1
name: "GF_foo_"
States: 1
Start: 0
AP: 1 "_foo_"
acc-name: Buchi
Acceptance: 1 Inf(0)
116
properties: trans-labels explicit-labels trans-acc complete
117 118 119 120
properties: deterministic stutter-invariant
--BODY--
State: 0
[!0] 0
121
[0] 0 {0}
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
--END--
EOF
diff output expected

# Not trusting properties
run 0 $ltldo "$ltl2tgba -H %s>%H" -f GF_foo_ -H --trust-hoa=no >output
cat output
cat >expected <<EOF
HOA: v1
name: "GFp0"
States: 1
Start: 0
AP: 1 "_foo_"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels trans-acc complete
138
properties: deterministic
139 140 141
--BODY--
State: 0
[!0] 0
142
[0] 0 {0}
143 144 145
--END--
EOF
diff output expected
146 147 148

$ltldo ': %s; true>%O' -f GFa 2>stderr && exit 1
test $? = 2
149
grep ':.*empty input' stderr
150
grep 'ltldo: aborting' stderr
151

152 153 154 155 156 157 158 159 160
$ltldo ': %s; true>%O' --errors=ignore -f GFa 2>stderr
test $? = 0
test -z "`cat stderr`"

$ltldo ': %s; true>%O' --errors=warn -f GFa 2>stderr
test $? = 0
grep ':.*empty input' stderr


161 162
$ltldo '{name} foo/bar/ltl2baextended' -f GFa 2>stderr && exit 1
grep 'error:.*foo/bar/ltl2baextended -f .*>.*' stderr
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
163 164


165 166 167 168
test 2 = `genltl --and-gf=1..4 | ltldo ltl2tgba -n2 | autfilt -c`
test 3 = `genltl --and-gf=1..2 | ltldo ltl2tgba 'ltl2tgba -s' -n3 | autfilt -c`


Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
169 170 171 172
genltl --rv-counter=9 | ltldo ltl2tgba --stats='
print("%[up]R + %[uc]R + %[sp]R + %[sc]R - %R\n");
die if abs(%[up]R + %[uc]R + %[sp]R + %[sc]R - %R) > 0.02;' > code.pl
perl code.pl
173 174 175 176 177 178 179 180 181 182 183

# ltldo should not leave temporary files behind itself on errors
ltldo -f a 'ltl2dstar --ltl2nba=spin:ltl2tgba@-DS' && exit 2
for i in lcr-*; do
    case $i in
        'lcr-*');;
        *)
           echo $i should not be here;
           exit 2;;
    esac
done